mirror of
https://github.com/BrentNeale1/fx-quant.git
synced 2026-08-22 06:28:05 +00:00
Add config-driven system.yaml and multi-window indicators
- Create config/system.yaml with full master prompt template - Create src/config_loader.py to load YAML config and .env - Update data_engine.build_all_features() to support lists of windows (e.g. sma_windows: [3, 20] produces sma_3 and sma_20 columns) - Rewrite get_candles.py to loop over all instruments × granularities from config instead of hardcoding EUR_USD/M5 - Fix supabase_upload.py indentation bug and wire up config for table name Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
256dffaae1
commit
0d0c363bfa
@@ -0,0 +1,56 @@
|
||||
# src/get_candles.py
|
||||
"""
|
||||
Fetch OANDA candles for every instrument × granularity defined in
|
||||
config/system.yaml, build indicator features, and print the result.
|
||||
"""
|
||||
|
||||
import os
|
||||
import requests
|
||||
from config_loader import load_config
|
||||
from data_engine import candles_to_df, build_all_features
|
||||
|
||||
|
||||
def fetch_candles(instrument, granularity, count, base_url, api_key):
|
||||
"""Pull raw candle dicts from the OANDA v20 REST API."""
|
||||
url = (
|
||||
f"{base_url}/v3/instruments/{instrument}/candles"
|
||||
f"?count={count}&granularity={granularity}"
|
||||
)
|
||||
headers = {"Authorization": f"Bearer {api_key}"}
|
||||
r = requests.get(url, headers=headers)
|
||||
r.raise_for_status()
|
||||
return r.json()["candles"]
|
||||
|
||||
|
||||
def main():
|
||||
cfg = load_config()
|
||||
|
||||
# OANDA credentials (loaded into env by config_loader)
|
||||
api_key = os.getenv("OANDA_API_KEY")
|
||||
env = os.getenv("OANDA_ENV", "practice")
|
||||
base_url = (
|
||||
"https://api-fxpractice.oanda.com"
|
||||
if env == "practice"
|
||||
else "https://api-fxtrade.oanda.com"
|
||||
)
|
||||
|
||||
# Config-driven parameters
|
||||
broker = cfg["brokers"][0]
|
||||
instruments = broker["instruments"]
|
||||
granularities = cfg["data"]["candle_granularities"]
|
||||
count = cfg["data"]["candle_count"]
|
||||
feature_cfg = cfg.get("features", {})
|
||||
|
||||
for instrument in instruments:
|
||||
for granularity in granularities:
|
||||
print(f"\n--- {instrument} | {granularity} ---")
|
||||
candles = fetch_candles(
|
||||
instrument, granularity, count, base_url, api_key
|
||||
)
|
||||
df = candles_to_df(candles)
|
||||
df = build_all_features(df, config=feature_cfg)
|
||||
print(df.tail(10).to_string())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user