Visualize the RSI
The RSI is a momentum indicator that oscillates between 0 and 100. Typically an RSI over 70 indicates an overbought market condition, which means the asset is overvalued and the price may reverse. An RSI below 30 suggests an oversold market condition, which means the asset is undervalued and the price may rally. To better understand it, you will calculate the RSI and plot it along with the price data.
As you did in the previous exercise, you will use historical daily price data of the Google stock, which has been loaded as stock_data
. Also, talib
has been imported for you and matplotlib.pyplot
has been imported as plt
.
This exercise is part of the course
Financial Trading in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Calculate RSI
stock_data['RSI'] = ____(stock_data['____'])
# Create subplots
fig, (ax1, ax2) = plt.____(2)
# Plot RSI with the price
ax1.set_ylabel('Price')
____(stock_data['____'])
ax2.set_ylabel('RSI')
____(stock_data['____'], color='orangered')
ax1.set_title('Price and RSI')
plt.show()