開始使用免費開始

視覺化 RSI

RSI 是一種動能指標,會在 0 到 100 之間震盪。一般而言,RSI 高於 70 代表超買狀態,表示資產可能被高估,價格可能反轉。RSI 低於 30 則代表超賣狀態,表示資產可能被低估,價格可能反彈。為了更好理解,你會計算 RSI,並把它與價格資料一起繪圖。

和上一題一樣,你會使用 Google 股票的歷史日價資料,已載入為 stock_data。另外,talib 已經為你匯入,matplotlib.pyplot 也已匯入為 plt

本練習屬於課程

Financial Trading in Python

檢視課程

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# 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()
編輯並執行程式碼