In this project, I've provided some examples of what I learned about the backtrader python package by following along with Part Time Larry's "Algorithmic Trading with Python and Backtrader" videos on youtube. The current project has two datasets (Oracle stock and S&P 500) and two trading strategies (Golden Cross and Buy & Hold for 5 days).
An example of how to run this is: python trader.py golden_cross SPY 5000 20
. This runs the backtest using the golden_cross strategy using S&P500 data starting with $5k and order sizes of 20 stocks.
The five arguments:
The type of strategy you want to backtest. Currently only golden_cross
and buy_hold5days
are accepted.
The stock ticker used to test your strategy on. Currently only ORCL
and SPY
are accepted.
The amount of cash you want to start your backtest with.
The number of stocks you wish to execute an order with.
- Python
- Matplotlib
- Backtrader
- Get ticker and historical price data programmatically
- Allow for input of date range arguments
- Create more sophisticated buy options for placed orders
Paden Roder
Contributions, issues, and feature requests are welcome!
Give a ⭐️ if you like this project!