Miruzen commited on
Commit
c3a6607
·
verified ·
1 Parent(s): fa6a7c9

Upload update_scaler.py

Browse files
Files changed (1) hide show
  1. update_scaler.py +32 -0
update_scaler.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import yfinance as yf
2
+ import json
3
+ import os
4
+
5
+ def update_scaler(symbol="EURUSD=X", days=30, output_path="scaler_config.json"):
6
+ print(f"📈 Fetching {days}-day close data for {symbol}...")
7
+ data = yf.download(symbol, period=f"{days}d", interval="1d")
8
+
9
+ if data.empty:
10
+ print("⚠️ Failed to fetch data from yfinance.")
11
+ return
12
+
13
+ close_min = float(data["Close"].min())
14
+ close_max = float(data["Close"].max())
15
+
16
+ config = {
17
+ "CLOSE_MIN": close_min,
18
+ "CLOSE_MAX": close_max,
19
+ "symbol": symbol,
20
+ "updated_at": str(data.index[-1].date())
21
+ }
22
+
23
+ with open(output_path, "w") as f:
24
+ json.dump(config, f, indent=2)
25
+
26
+ print(f"✅ Scaler updated and saved to {output_path}")
27
+ print(f" MIN={close_min:.5f}, MAX={close_max:.5f}")
28
+
29
+
30
+ if __name__ == "__main__":
31
+ os.makedirs(os.path.dirname("scaler_config.json"), exist_ok=True)
32
+ update_scaler()