Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -786,38 +786,7 @@ def update_price_chart(selected_stock, period, chart_type):
|
|
| 786 |
|
| 787 |
return fig
|
| 788 |
|
| 789 |
-
# 更新RSI圖表(保持兼容性)
|
| 790 |
-
@app.callback(
|
| 791 |
-
dash.dependencies.Output('rsi-chart', 'figure'),
|
| 792 |
-
[dash.dependencies.Input('stock-dropdown', 'value'),
|
| 793 |
-
dash.dependencies.Input('period-dropdown', 'value')]
|
| 794 |
-
)
|
| 795 |
-
def update_rsi_chart(selected_stock, period):
|
| 796 |
-
data = get_stock_data(selected_stock, period)
|
| 797 |
-
if data.empty:
|
| 798 |
-
return {}
|
| 799 |
-
|
| 800 |
-
data = calculate_technical_indicators(data)
|
| 801 |
|
| 802 |
-
fig = go.Figure()
|
| 803 |
-
fig.add_trace(go.Scatter(x=data.index, y=data['RSI'], mode='lines', name='RSI', line=dict(color='purple', width=2)))
|
| 804 |
-
fig.add_hline(y=70, line_dash="dash", line_color="red", annotation_text="超買線(70)")
|
| 805 |
-
fig.add_hline(y=30, line_dash="dash", line_color="green", annotation_text="超賣線(30)")
|
| 806 |
-
fig.add_hline(y=50, line_dash="dot", line_color="gray", annotation_text="中線(50)")
|
| 807 |
-
|
| 808 |
-
# 添加超買超賣區域背景
|
| 809 |
-
fig.add_hrect(y0=70, y1=100, fillcolor="red", opacity=0.1, annotation_text="超買區")
|
| 810 |
-
fig.add_hrect(y0=0, y1=30, fillcolor="green", opacity=0.1, annotation_text="超賣區")
|
| 811 |
-
|
| 812 |
-
fig.update_layout(
|
| 813 |
-
title='RSI 相對強弱指標',
|
| 814 |
-
xaxis_title='日期',
|
| 815 |
-
yaxis_title='RSI',
|
| 816 |
-
height=400,
|
| 817 |
-
yaxis=dict(range=[0, 100])
|
| 818 |
-
)
|
| 819 |
-
|
| 820 |
-
return fig
|
| 821 |
|
| 822 |
# 新增:進階技術指標圖表
|
| 823 |
@app.callback(
|
|
|
|
| 786 |
|
| 787 |
return fig
|
| 788 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 789 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 790 |
|
| 791 |
# 新增:進階技術指標圖表
|
| 792 |
@app.callback(
|