https://github.com/olemorud/trading-strategies
Visualizing returns of different trading strategies using historical S&P 500 data
https://github.com/olemorud/trading-strategies
financial-analysis matplotlib plots python3 trading-strategies
Last synced: about 2 months ago
JSON representation
Visualizing returns of different trading strategies using historical S&P 500 data
- Host: GitHub
- URL: https://github.com/olemorud/trading-strategies
- Owner: olemorud
- Created: 2023-05-23T09:32:11.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-05-25T19:03:52.000Z (almost 2 years ago)
- Last Synced: 2025-02-09T02:41:12.041Z (3 months ago)
- Topics: financial-analysis, matplotlib, plots, python3, trading-strategies
- Language: Python
- Homepage:
- Size: 225 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Trading strategies plot
Plots how different trading strategies would have performed
on historical data.
## Assumptions
The main purpose of these plots is to see if stupidly
simple strategies will (roughly) outperform professionally
managed funds. Therefore some assumptions and
simplifications are made:- Assumes no trading fees on transactions.
- Assumes that you're buying and selling the entire index. (subject to change)## Currently implemented strategies:
### Buy and hold
Buy at start, never sell
### Dice roll buy/sell
Buy everything, sell everything or do nothing at random.
Performs worse than the buy and hold strategy, because the dice roll approach
ends up having fewer days invested in the stock market### Moving average crossover
Buy when a short term average (e.g. 50 days) surpasses a long term average (e.g
200 days), buy. Conversely, sell when the long term average surpasses the short
term average.Although it mitigates the losses of some market crashes, it also takes longer
to capitalize on bull runs, resulting in a worse performance. Briefly outperformed
buy and hold in the years after the
[2007-2008 financial crisis](https://en.wikipedia.org/wiki/2007%E2%80%932008_financial_crisis)## Run
### Linux / MacOS
#### bash/zsh/sh
```sh
# Setup venv
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt# Run
./plot.py# deactivate venv
deactivate
```### Windows
#### PowerShell
```ps1
# Setup venv
python -m venv venv
. .\venv\Scripts\activate.ps1
python -m pip install -r requirements.txt# Run
python .\plot.ps1# Deactivate venv
deactivate
```#### cmd.exe
```cmd
: Setup venv
python -m venv venv
venv\Scripts\activate.bat
pip install -r requirements.txt: Run
python plot.py: deactivate venv
deactivate
```