A backtester and spreadsheet library for security analysis.
Why another python backtesting library? How is pinkfish different? Simple, I couldn't find a python backtesting library that I allowed me to backtest intraday strategies with daily data. Even simple strategies like 'buying on the close' on the SAME day a 'new 20 day high is set' were not allowed. Additionally, I was put off by the complexity of some of the libraries available, and wanted something simple, that doesn't get in the way, and just allows me to test my trading ideas. One user commented that Pinkfish is "very lightweight and to the point". I didn't set out to write a new backtesting library, but I had to. Daily data is free; minute and tick data are typically not. Using minute and tick data can require hours to run vs seconds for daily data.
Some of the key features of pinkfish:
- leverages pandas for dataframe, spreadsheet like features
- leverages matplotlib for making financial graphs
- uses ta-lib to easily implement technical indicators
- uses daily data (vs minute or tick data) for intraday trading
- uses free daily data from yahoo finance
- simple to use python API
- backtest single stock/ETF strategy or a portolio (basket of stocks/ETFs)
- backtest short selling strategies and simulate trading with margin
- write optimizers to select the best parameters
- create spreadsheets within Jupyter Notebook by utilizing pandas dataframes and itable formatting
This is how I got pinkfish working on xubuntu 20.04:
sudo apt update sudo apt upgrade sudo apt install python-is-python3 sudo apt install build-essential sudo apt install git sudo apt install python3-pip sudo ln -s /usr/bin/pip3 /usr/bin/pip sudo apt install libfreetype6-dev sudo pip install numpy sudo pip install matplotlib sudo pip install pandas sudo pip install pandas-datareader sudo pip install empyrical sudo pip install git+https://github.com/quantopian/pyfolio (http://mrjbq7.github.io/ta-lib/install.html) cd ~/Downloads sudo wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz tar -xzvf ta-lib-0.4.0-src.tar.gz cd ta-lib ./configure --prefix=/usr make sudo make install sudo pip install TA-Lib #install jupyter notebook sudo pip install jupyter #if you want to run unit tests (optional) sudo apt install python-tk #install itable from github mkdir ~/src cd ~/src git clone https://github.com/mgymrek/itable.git cd itable sudo python setup.py install #install pinkfish from github cd ~/src git clone https://github.com/fja05680/pinkfish.git cd pinkfish sudo python setup.py install #create/specify shared data cache directory (optional) mkdir $HOME/data echo [global] > $HOME/.pinkfish echo base_dir = $HOME >> $HOME/.pinkfish