Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -720,38 +720,7 @@ def update_price_chart(selected_stock, period, chart_type):
|
|
| 720 |
|
| 721 |
return fig
|
| 722 |
|
| 723 |
-
# 更新RSI圖表(保持兼容性)
|
| 724 |
-
@app.callback(
|
| 725 |
-
dash.dependencies.Output('rsi-chart', 'figure'),
|
| 726 |
-
[dash.dependencies.Input('stock-dropdown', 'value'),
|
| 727 |
-
dash.dependencies.Input('period-dropdown', 'value')]
|
| 728 |
-
)
|
| 729 |
-
def update_rsi_chart(selected_stock, period):
|
| 730 |
-
data = get_stock_data(selected_stock, period)
|
| 731 |
-
if data.empty:
|
| 732 |
-
return {}
|
| 733 |
-
|
| 734 |
-
data = calculate_technical_indicators(data)
|
| 735 |
|
| 736 |
-
fig = go.Figure()
|
| 737 |
-
fig.add_trace(go.Scatter(x=data.index, y=data['RSI'], mode='lines', name='RSI', line=dict(color='purple', width=2)))
|
| 738 |
-
fig.add_hline(y=70, line_dash="dash", line_color="red", annotation_text="超買線(70)")
|
| 739 |
-
fig.add_hline(y=30, line_dash="dash", line_color="green", annotation_text="超賣線(30)")
|
| 740 |
-
fig.add_hline(y=50, line_dash="dot", line_color="gray", annotation_text="中線(50)")
|
| 741 |
-
|
| 742 |
-
# 添加超買超賣區域背景
|
| 743 |
-
fig.add_hrect(y0=70, y1=100, fillcolor="red", opacity=0.1, annotation_text="超買區")
|
| 744 |
-
fig.add_hrect(y0=0, y1=30, fillcolor="green", opacity=0.1, annotation_text="超賣區")
|
| 745 |
-
|
| 746 |
-
fig.update_layout(
|
| 747 |
-
title='RSI 相對強弱指標',
|
| 748 |
-
xaxis_title='日期',
|
| 749 |
-
yaxis_title='RSI',
|
| 750 |
-
height=400,
|
| 751 |
-
yaxis=dict(range=[0, 100])
|
| 752 |
-
)
|
| 753 |
-
|
| 754 |
-
return fig
|
| 755 |
|
| 756 |
# 新增:進階技術指標圖表
|
| 757 |
@app.callback(
|
|
|
|
| 720 |
|
| 721 |
return fig
|
| 722 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 723 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 724 |
|
| 725 |
# 新增:進階技術指標圖表
|
| 726 |
@app.callback(
|