繪製 K 線圖(Candlestick)
K 線圖是一種將多種價格資訊整合到同一張圖表的圖表樣式。它能幫助你快速掌握價格走勢,並作為技術分析的視覺輔助。
你將使用與上一個練習相同的資料來繪製 K 線圖,這些資料已預先載入為 bitcoin_data。此外,plotly.graph_objects 已匯入為 go。
本練習屬於課程
Financial Trading in Python
練習說明
- 使用
bitcoin_data的欄位來定義一個candlestick物件。 - 使用上一步定義的
candlestick物件建立圖表。 - 顯示 K 線圖。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Define the candlestick data
candlestick = ____(
x=bitcoin_data.index,
open=bitcoin_data['____'],
high=bitcoin_data['____'],
low=bitcoin_data['____'],
close=bitcoin_data['____'])
# Create a candlestick figure
fig = ____(data=[____])
fig.update_layout(title='Bitcoin prices')
# Show the plot
fig.____()