File size: 948 Bytes
c3a6607
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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()