Download update_scaler.py from Miruzen/LSTM_API: direct link, hf CLI and curl.
- Browser
- Download file 948 Bytes
-
https://huggingface.co/spaces/Miruzen/LSTM_API/resolve/main/update_scaler.py
- Command line
-
hf download hf://spaces/Miruzen/LSTM_API/update_scaler.py
-
curl -L -o update_scaler.py https://huggingface.co/spaces/Miruzen/LSTM_API/resolve/main/update_scaler.py
948 Bytes
| import yfinance as yf | |
| import json | |
| import os | |
| def update_scaler(symbol="EURUSD=X", days=30, output_path="scaler_config.json"): | |
| print(f"📈 Fetching {days}-day close data for {symbol}...") | |
| data = yf.download(symbol, period=f"{days}d", interval="1d") | |
| if data.empty: | |
| print("⚠️ Failed to fetch data from yfinance.") | |
| return | |
| close_min = float(data["Close"].min()) | |
| close_max = float(data["Close"].max()) | |
| config = { | |
| "CLOSE_MIN": close_min, | |
| "CLOSE_MAX": close_max, | |
| "symbol": symbol, | |
| "updated_at": str(data.index[-1].date()) | |
| } | |
| with open(output_path, "w") as f: | |
| json.dump(config, f, indent=2) | |
| print(f"✅ Scaler updated and saved to {output_path}") | |
| print(f" MIN={close_min:.5f}, MAX={close_max:.5f}") | |
| if __name__ == "__main__": | |
| os.makedirs(os.path.dirname("scaler_config.json"), exist_ok=True) | |
| update_scaler() | |