Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -147,10 +147,10 @@ class TradingBacktester:
|
|
| 147 |
|
| 148 |
# 為每個交易日生成預測
|
| 149 |
for i in range(60, len(data)): # 從第60天開始,確保有足夠歷史資料
|
| 150 |
-
|
| 151 |
-
|
| 152 |
|
| 153 |
-
|
| 154 |
if 'Close' not in historical_data.columns and 'close' in historical_data.columns:
|
| 155 |
historical_data['Close'] = historical_data['close']
|
| 156 |
if 'Volume' not in historical_data.columns and 'volume' in historical_data.columns:
|
|
|
|
| 147 |
|
| 148 |
# 為每個交易日生成預測
|
| 149 |
for i in range(60, len(data)): # 從第60天開始,確保有足夠歷史資料
|
| 150 |
+
current_date = data.index[i]
|
| 151 |
+
historical_data = data.iloc[:i+1].copy() # 到當前日期的歷史資料
|
| 152 |
|
| 153 |
+
# 確保歷史資料有必要的欄位結構 (yfinance格式)
|
| 154 |
if 'Close' not in historical_data.columns and 'close' in historical_data.columns:
|
| 155 |
historical_data['Close'] = historical_data['close']
|
| 156 |
if 'Volume' not in historical_data.columns and 'volume' in historical_data.columns:
|