LoslegenKostenlos starten

Build and backtest a mean reversion strategy

Previously, you constructed a signal using the RSI indicator. When the RSI value drops below 30, the signal is 1 for entering long positions in the market. When the RSI value rises above 70, the signal is -1 for entering short positions. Now you will implement a mean reversion strategy with the signal and perform a backtest on trading the Google stock.

The historical price data of the Google stock has been preloaded in price_data. In addition, the bt package has been imported for you.

Diese Übung ist Teil des Kurses

<Kurs>Financial Trading in Python</Kurs>
Kurs ansehen

Interaktive praktische Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Define the strategy
bt_strategy = bt.Strategy('RSI_MeanReversion', 
                          [____,
                           bt.algos.Rebalance()])
Code bearbeiten und ausführen