Aan de slagGa gratis aan de slag

Construct an RSI based signal

It's time to implement your first mean-reversion strategy. Mean reversion trading uses signals to detect market imbalance, and takes long positions in an oversold market and short positions in an overbought market.

First, you will use the RSI indicator to gauge market conditions and construct the signal. If the RSI value drops below 30, you will enter long positions. If the RSI value rises above 70, you will enter short positions. If the RSI value is in between 30 and 70, you will take no positions.

The RSI indicator has been pre-calculated and saved in stock_rsi. The historical price data of the Google stock has been preloaded in price_data. In addition, the bt package has been imported for you.

Deze oefening maakt deel uit van de cursus

Financial Trading in Python

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Construct the signal
signal[____ > ____] = -1
signal[____ < ____] = 1
signal[(____ <= ____) & (____ >= ____)] = 0
Code bewerken en uitvoeren