Bringing data driven investments to the mainstream
Project description
fastquant :nerd_face:
Bringing backtesting to the mainstream
fastquant allows you to easily backtest investment strategies with as few as 3 lines of python code. Its goal is to promote data driven investments by making quantitative analysis in finance accessible to everyone.
Features
- Easily access historical stock data
- Backtest trading strategies with only 3 lines of code
*
- Both Yahoo Finance and Philippine stock data data are accessible straight from fastquant
Installation
pip install fastquant
Get stock data
All symbols from Yahoo Finance and Philippine Stock Exchange (PSE) are accessible via get_stock_data
.
from fastquant import get_stock_data
df = get_stock_data("JFC", "2018-01-01", "2019-01-01")
print(df.head())
# dt close volume
# 2019-01-01 293.0 181410
# 2019-01-02 292.0 1665440
# 2019-01-03 309.0 1622480
# 2019-01-06 323.0 1004160
# 2019-01-07 321.0 623090
Note: Symbols from Yahoo Finance will return closing prices in USD, while symbols from PSE will return closing prices in PHP
Backtest trading strategies
Simple Moving Average Crossover (15 day MA vs 40 day MA)
Daily Jollibee prices from 2018-01-01 to 2019-01-01
from fastquant import backtest
backtest('smac', df, fast_period=15, slow_period=40)
# Starting Portfolio Value: 100000.00
# Final Portfolio Value: 102272.90
Library of trading strategies
Strategy | Alias | Parameters |
---|---|---|
Relative Strength Index (RSI) | rsi | rsi_period , rsi_upper , rsi_lower |
Simple moving average crossover (SMAC) | smac | fast_period , slow_period |
Exponential moving average crossover (EMAC) | macd | fast_period , slow_period |
Moving Average Convergence Divergence (MACD) | emac | fast_perod , slow_upper , signal_period , sma_period , sma_dir_period |
Bollinger Bands | bbands | period , devfactor |
Relative Strength Index (RSI) Strategy
backtest('rsi', df, rsi_period=14, rsi_upper=70, rsi_lower=30)
# Starting Portfolio Value: 100000.00
# Final Portfolio Value: 132967.87
Simple moving average crossover (SMAC) Strategy
backtest('smac', df, fast_period=10, slow_period=30)
# Starting Portfolio Value: 100000.00
# Final Portfolio Value: 95902.74
Exponential moving average crossover (EMAC) Strategy
backtest('emac', df, fast_period=10, slow_period=30)
# Starting Portfolio Value: 100000.00
# Final Portfolio Value: 90976.00
Moving Average Convergence Divergence (MACD) Strategy
backtest('macd', df, fast_period=12, slow_period=26, signal_period=9, sma_period=30, dir_period=10)
# Starting Portfolio Value: 100000.00
# Final Portfolio Value: 96229.58
Bollinger Bands Strategy
backtest('bbands', df, period=20, devfactor=2.0)
# Starting Portfolio Value: 100000.00
# Final Portfolio Value: 97060.30
See more examples here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for fastquant-0.1.3.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c44fcf716cb59e0a284ceb8832a89bd4fa0c341bce683853543764014118438 |
|
MD5 | 50f1173b4a3a60cafdce3dda4888ddfe |
|
BLAKE2b-256 | 458a5e60b2f7f18fc4f54cf052cbad49a3ae4225f820d1dad5c70cd90399a7aa |