This project implements a trading simulator using a Bollinger Band strategy in intraday trading.
The strategy is a simple implementation.
Given a customizable time window, the trader compute six bollinger bands.
- Upper bollinger bands:
- +3 times rolling standard deviations
- +2 times rolling standard deviations
- +1 times rolling standard deviations
- Lower bollinger bands:
- -1 times rolling standard deviations
- -2 times rolling standard deviations
- -3 times rolling standard deviations
Then we can have three scenarios:
- The current price is between +2 and -2 rolling std dev:
- The trader do nothing
- The current price is more than +2 rolling std dev:
- The trader buys stocks equivalent to a 90% of the money in the wallet
- The trader set two threshold to leave position when the future current price is
- less than +1 rolling std dev
- more than +3 rolling std dev
- The current price is less than -2 rolling std dev:
- The trader short stocks equivalent to a 90% of the money in the wallet
- The trader set two threshold to leave position when the future current price is
- more than -1 rolling std dev
- less than -3 rolling std dev
- Clone the repository in a local folder
- Run the file
run.py
- Open the
datamanager.py
- Go to
self.file_name = 'data/eni.csv'
- Change the csv filename
The output is stored in the log folder in two files trader.py
and wallet.py
.
trader.py
contains the log of the trader choices, position and dataswallet.py
contains the log of the bank account where the money is stored
For the ENI one year intraday dataset we started with 10,000 EUR and we finished with 21,622 EUR, equivalent to a + 116%, not bad at all!
I invite everybody to download the repo and try with his preferred stocks.