Spaces:
Running
Running
saadrizvi09 commited on
Commit ·
6c0f223
1
Parent(s): 5456a82
Lower minimum training data requirement to 250 days
Browse files- Reduced from 500 to 250 days to work with Yahoo Finance limitations
- Yahoo Finance typically provides ~365 days of data
- After feature engineering, ~250 days is sufficient for HMM-SVR
- Added detailed error messages showing actual days received
- Fixes training failures on HF Space
- model_manager.py +5 -5
model_manager.py
CHANGED
|
@@ -218,18 +218,18 @@ def train_and_save_model(symbol: str, n_states: int = 3) -> Dict[str, Any]:
|
|
| 218 |
|
| 219 |
# Try Yahoo Finance first, then Binance
|
| 220 |
df = fetch_training_data_yfinance(symbol)
|
| 221 |
-
if df is None or len(df) <
|
| 222 |
print("[ModelManager] Falling back to Binance data...")
|
| 223 |
df = fetch_training_data_binance(symbol)
|
| 224 |
|
| 225 |
-
if df is None or len(df) <
|
| 226 |
-
return {"error": f"Insufficient data for {symbol}. Need at least
|
| 227 |
|
| 228 |
# Engineer features
|
| 229 |
df = engineer_features(df)
|
| 230 |
|
| 231 |
-
if len(df) <
|
| 232 |
-
return {"error": f"Insufficient data after feature engineering for {symbol}"}
|
| 233 |
|
| 234 |
print(f"[ModelManager] Training on {len(df)} days of data...")
|
| 235 |
|
|
|
|
| 218 |
|
| 219 |
# Try Yahoo Finance first, then Binance
|
| 220 |
df = fetch_training_data_yfinance(symbol)
|
| 221 |
+
if df is None or len(df) < 250:
|
| 222 |
print("[ModelManager] Falling back to Binance data...")
|
| 223 |
df = fetch_training_data_binance(symbol)
|
| 224 |
|
| 225 |
+
if df is None or len(df) < 250:
|
| 226 |
+
return {"error": f"Insufficient data for {symbol}. Need at least 250 days, got {len(df) if df is not None else 0}."}
|
| 227 |
|
| 228 |
# Engineer features
|
| 229 |
df = engineer_features(df)
|
| 230 |
|
| 231 |
+
if len(df) < 200:
|
| 232 |
+
return {"error": f"Insufficient data after feature engineering for {symbol}. Got {len(df)} days."}
|
| 233 |
|
| 234 |
print(f"[ModelManager] Training on {len(df)} days of data...")
|
| 235 |
|