AlanRex commited on
Commit
6298a0f
·
verified ·
1 Parent(s): b3b1c36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py CHANGED
@@ -15,6 +15,32 @@ import dash
15
  import plotly.express as px
16
  import plotly.graph_objects as go
17
  from plotly.subplots import make_subplots
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  # 台股代號對應表 (移除台指期,因為它現在是獨立區塊)
20
  TAIWAN_STOCKS = {
 
15
  import plotly.express as px
16
  import plotly.graph_objects as go
17
  from plotly.subplots import make_subplots
18
+ from predictor import predict_next_day_price
19
+
20
+
21
+ try:
22
+ df_tsmc_raw = pd.read_csv('df_2330.csv')
23
+ df_climate_raw = pd.read_csv('business_climate.csv')
24
+ print("成功讀取原始資料檔案。")
25
+ except FileNotFoundError:
26
+ print("錯誤:找不到 'df_2330.csv' 或 'business_climate.csv'。")
27
+ exit()
28
+
29
+ # --- 2. 直接呼叫函式進行預測 ---
30
+ # 您只需要將原始的 DataFrame 傳進去,剩下的交給 predictor 模組處理
31
+ print("\n呼叫模型進行預測...")
32
+ prediction = predict_next_day_price(df_tsmc_raw, df_climate_raw)
33
+
34
+ # --- 3. 使用預測結果 ---
35
+ if prediction is not None:
36
+ print("\n" + "="*40)
37
+ print(f" ✅ 預測成功!")
38
+ print(f" 模型預測的下一日收盤價為: {prediction:.2f}")
39
+ print("="*40)
40
+ else:
41
+ print("\n" + "="*40)
42
+ print(f" ❌ 預測失敗。請檢查 predictor 模組的錯誤訊息。")
43
+ print("="*40)
44
 
45
  # 台股代號對應表 (移除台指期,因為它現在是獨立區塊)
46
  TAIWAN_STOCKS = {