| 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() | |