The dual-moving average trading strategy places a buy order when the short moving average crosses the long moving average in an upward direction and will place a sell order when the cross happens on the other side. This section will present the backtesting implementation of the dual-moving average strategy. We will present the implementation of a for-loop backtester and an event-based backtester.
Backtesting the dual-moving average trading strategy
For-loop backtester
- As regards the implementation of this backtester, we will use the GOOG data by retrieving it with the same function we used previously, load_financial_data. We will follow the pseudo code that we proposed during the previous section:
for each price update:
...