In this example, we are implementing a mean-reverting trading strategy on the AAPL stock price. Write the MeanRevertingStrategy child class that inherits the Strategy class from the previous section:
import pandas as pdclass MeanRevertingStrategy(Strategy): def __init__(self, symbol, trade_qty, send_order_event_handler=None, lookback_intervals=20, buy_threshold=-1.5, sell_threshold=1.5 ): super(MeanRevertingStrategy, self).__init__( send_order_event_handler) self.symbol = symbol self.trade_qty = trade_qty self.lookback_intervals = lookback_intervals self.buy_threshold = buy_threshold self.sell_threshold = sell_threshold self.prices = pd.DataFrame() self.is_long = self.is_short = False
In the constructor, ...