Algorithmic Trading
Algorithmic Trading
Backtesting a strategy in
python
Karthik Ram
·
Follow
Published in
Dev Genius
·
4 min read
·
Jan 3, 2022
169
2
Photo by Maxim Hopman on Unsplash
Intro
The goal of this article is to describe how to back-test a
technical indicator-based strategy on python. I will
specifically use a Bollinger band-based strategy to create
signals and positions.
Description of strategy
Create 20-day (+/- 2 standard deviations) Bollinger bands
on the adjusted close price. Buy, when the price crosses
the lower band from the top and hold until the price
crosses the upper band from below the next time. Sell
when the price crosses the upper band from below and
hold until the price crosses the lower band from the top
the next time.
7. Analyze results
<AxesSubplot:xlabel='Date'>
Step 7: Analyze results