tbdavid2019 commited on
Commit
f0803c6
·
1 Parent(s): 7d4cdfc
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -194,7 +194,7 @@ def update_stock(category, stock):
194
  status_output: gr.update(value="")
195
  }
196
 
197
- def predict_stock(category, stock, stock_item, selected_features):
198
  if not all([category, stock, stock_item]):
199
  return gr.update(value=None), "請選擇產業類別、類股和股票"
200
 
@@ -211,7 +211,7 @@ def predict_stock(category, stock, stock_item, selected_features):
211
  return gr.update(value=None), "無法獲取股票代碼"
212
 
213
  # 下載股票數據,根據用戶選擇的時間範圍
214
- df = yf.download(stock_code, period="1y")
215
  if df.empty:
216
  raise ValueError("無法獲取股票數據")
217
 
@@ -305,11 +305,10 @@ with gr.Blocks() as demo:
305
 
306
  predict_button.click(
307
  predict_stock,
308
- inputs=[category_dropdown, stock_dropdown, stock_item_dropdown, features_checkbox],
309
  outputs=[stock_plot, status_output]
310
  )
311
 
312
  # 啟動應用
313
  if __name__ == "__main__":
314
  demo.launch(share=False)
315
-
 
194
  status_output: gr.update(value="")
195
  }
196
 
197
+ def predict_stock(category, stock, stock_item, period, selected_features):
198
  if not all([category, stock, stock_item]):
199
  return gr.update(value=None), "請選擇產業類別、類股和股票"
200
 
 
211
  return gr.update(value=None), "無法獲取股票代碼"
212
 
213
  # 下載股票數據,根據用戶選擇的時間範圍
214
+ df = yf.download(stock_code, period=period)
215
  if df.empty:
216
  raise ValueError("無法獲取股票數據")
217
 
 
305
 
306
  predict_button.click(
307
  predict_stock,
308
+ inputs=[category_dropdown, stock_dropdown, stock_item_dropdown, period_dropdown, features_checkbox],
309
  outputs=[stock_plot, status_output]
310
  )
311
 
312
  # 啟動應用
313
  if __name__ == "__main__":
314
  demo.launch(share=False)