diff --git a/.gitignore b/.gitignore index c64bf607..0be8da1c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ __pycache__/ *.pyc *.pyo prompt_cache.db +convert_1min.py +import_1min_qlib.py +data_raw/ diff --git a/data_config.yaml b/data_config.yaml index bec879c6..a2353662 100644 --- a/data_config.yaml +++ b/data_config.yaml @@ -5,8 +5,8 @@ # ============================================================ instrument: EURUSD -frequency: 15min # 1min, 5min, 15min, 1h, 1d -data_path: ~/.qlib/qlib_data/eurusd_data +frequency: 1min # 1min, 5min, 15min, 1h, 1d +data_path: ~/.qlib/qlib_data/eurusd_1min_data # Verfügbare Spalten (keine $factor Spalte!) columns: diff --git a/patches/eva_utils.py b/patches/eva_utils.py index 43f797bd..7acf69b4 100644 --- a/patches/eva_utils.py +++ b/patches/eva_utils.py @@ -243,7 +243,7 @@ class FactorDatetimeDailyEvaluator(FactorEvaluator): False, ) if min_diff <= pd.Timedelta(minutes=30): - return "The generated dataframe is intraday (15min bars). This is correct for EURUSD.", True + return "The generated dataframe is intraday (1min bars). This is correct for EURUSD.", True return "The generated dataframe is daily.", True diff --git a/patches/generate.py b/patches/generate.py index fb74a738..a130b3f6 100755 --- a/patches/generate.py +++ b/patches/generate.py @@ -7,12 +7,12 @@ result = subprocess.run( ["/home/nico/miniconda3/envs/rdagent4qlib/bin/python3", "-c", """ import qlib from qlib.data import D -qlib.init(provider_uri="~/.qlib/qlib_data/eurusd_data") +qlib.init(provider_uri="~/.qlib/qlib_data/eurusd_1min_data") fields = ["$open", "$close", "$high", "$low", "$volume"] -data = (D.features(["EURUSD"], fields, start_time="2022-03-14", end_time="2026-03-20", freq="15min") +data = (D.features(["EURUSD"], fields, start_time="2022-03-14", end_time="2026-03-20", freq="1min") .swaplevel().sort_index()) data.to_hdf("./daily_pv_all.h5", key="data") -data_debug = (D.features(["EURUSD"], fields, start_time="2024-01-01", end_time="2026-03-20", freq="15min") +data_debug = (D.features(["EURUSD"], fields, start_time="2024-01-01", end_time="2026-03-20", freq="1min") .swaplevel().sort_index()) data_debug.to_hdf("./daily_pv_debug.h5", key="data") print(f"Done: {data.shape[0]} rows") diff --git a/patches/qlib_rd_loop_prompts.yaml b/patches/qlib_rd_loop_prompts.yaml index 0d7ee99b..34e0fca9 100644 --- a/patches/qlib_rd_loop_prompts.yaml +++ b/patches/qlib_rd_loop_prompts.yaml @@ -1,7 +1,7 @@ hypothesis_generation: system: |- You are an expert in FX and quantitative trading, specialized in EURUSD intraday strategies. - Your task is to generate a well-reasoned hypothesis for new alpha factors based on EURUSD 15min OHLCV data. + Your task is to generate a well-reasoned hypothesis for new alpha factors based on EURUSD 1min OHLCV data. Key market knowledge: - EURUSD trades 24h with three main sessions: Asian (00:00-08:00 UTC), London (08:00-16:00 UTC), NY (13:00-21:00 UTC) diff --git a/patches/qlib_scenarios_prompts.yaml b/patches/qlib_scenarios_prompts.yaml index 1a43bf7c..c9b32364 100644 --- a/patches/qlib_scenarios_prompts.yaml +++ b/patches/qlib_scenarios_prompts.yaml @@ -101,7 +101,7 @@ factor_hypothesis_specification: |- - Asian session shows mean reversion tendencies - Spread cost ~1.5 bps per trade — avoid high-turnover factors - No $factor column exists — use only $open, $close, $high, $low, $volume - - Each "instrument" is EURUSD, each "day" is a 15min bar + - Each "instrument" is EURUSD, each "day" is a 1min bar **Factor Generation Rules:** 1. **3-5 Factors per Generation** — cover different signal types per round @@ -183,7 +183,7 @@ factor_feedback_generation: Your feedback should specify whether the current result supports or refutes the hypothesis, compare it with previous SOTA results, and suggest FX-specific improvements. **FX-specific evaluation criteria:** - - IC > 0.02 is meaningful for 15min EURUSD data + - IC > 0.02 is meaningful for 1min EURUSD data - Annualized return target: >9.62% (current SOTA to beat) - Spread cost ~1.5 bps per trade — penalize high-turnover factors - Factors using $factor column are INVALID — only $open $close $high $low $volume allowed @@ -198,7 +198,7 @@ factor_feedback_generation: 2. Development Directions: a) New Direction: Propose a new FX-specific factor (session filter, volatility regime, volume spike). b) Optimization: Refine lookback windows (4/8/16/32 bars), add ADX filter, adjust for spread costs. - 3. Final Goal: Beat 9.62% ARR on EURUSD 15min with controlled drawdown (<20%). + 3. Final Goal: Beat 9.62% ARR on EURUSD 1min with controlled drawdown (<20%). When judging results: 1. Any small improvement in annualized return → set Replace Best Result as yes. diff --git a/rdagent/app/qlib_rd_loop/prompts.yaml b/rdagent/app/qlib_rd_loop/prompts.yaml index 18c570fc..f1d4eff8 100644 --- a/rdagent/app/qlib_rd_loop/prompts.yaml +++ b/rdagent/app/qlib_rd_loop/prompts.yaml @@ -20,7 +20,7 @@ hypothesis_generation: - Statistical: Regime-switching (HMM), Kalman filter Available features in the dataset: - - OHLCV: open, high, low, close, volume (15min bars) + - OHLCV: open, high, low, close, volume (1min bars) - Returns: ret_1, ret_4, ret_8, ret_16, ret_96 - Technical: rsi_14, macd_hist, adx_14, atr_14, bb_pct, stoch_k, cci_14 - Volatility: vol_real_4, vol_real_16, vol_ratio, zscore_ret_96 @@ -36,7 +36,7 @@ hypothesis_generation: Please ensure your response is in JSON format: { - "hypothesis": "A clear and concise trading hypothesis for EURUSD 15min.", + "hypothesis": "A clear and concise trading hypothesis for EURUSD 1min.", "reason": "Detailed explanation including session, model choice, and expected edge.", "model_type": "One of: TimeSeries / Tabular / XGBoost", "target_session": "london / ny / asian / all", diff --git a/rdagent/scenarios/qlib/fx_validator/agents/analysts/macro_analyst.py b/rdagent/scenarios/qlib/fx_validator/agents/analysts/macro_analyst.py index 5179b826..8eed8835 100644 --- a/rdagent/scenarios/qlib/fx_validator/agents/analysts/macro_analyst.py +++ b/rdagent/scenarios/qlib/fx_validator/agents/analysts/macro_analyst.py @@ -27,11 +27,16 @@ def get_fx_macro_data() -> str: else: vol_24h = "N/A" + eurusd_last_str = f"{eurusd_last:.5f}" if isinstance(eurusd_last, float) else str(eurusd_last) + eurusd_change_str = f"{eurusd_change:.3f}%" if isinstance(eurusd_change, float) else str(eurusd_change) + dxy_last_str = f"{dxy_last:.2f}" if isinstance(dxy_last, float) else str(dxy_last) + vol_24h_str = f"{vol_24h:.4f}%" if isinstance(vol_24h, float) else str(vol_24h) + return f""" -EURUSD Current: {eurusd_last:.5f if isinstance(eurusd_last, float) else eurusd_last} -EURUSD 24h Change: {eurusd_change:.3f}% if isinstance(eurusd_change, float) else eurusd_change} -DXY (Dollar Index): {dxy_last:.2f if isinstance(dxy_last, float) else dxy_last} -Realized Volatility 24h: {vol_24h:.4f}% if isinstance(vol_24h, float) else vol_24h} +EURUSD Current: {eurusd_last_str} +EURUSD 24h Change: {eurusd_change_str} +DXY (Dollar Index): {dxy_last_str} +Realized Volatility 24h: {vol_24h_str} """ except Exception as e: return f"Macro data unavailable: {e}" diff --git a/rdagent/scenarios/qlib/fx_validator/agents/trader/fx_trader.py b/rdagent/scenarios/qlib/fx_validator/agents/trader/fx_trader.py index 2111f4c9..f90b6591 100644 --- a/rdagent/scenarios/qlib/fx_validator/agents/trader/fx_trader.py +++ b/rdagent/scenarios/qlib/fx_validator/agents/trader/fx_trader.py @@ -13,7 +13,7 @@ def create_fx_trader(llm): debate_history = debate_state.get("history", "") risk_report = state.get("risk_report", "") - prompt = f"""You are an FX Trading Decision Agent for EURUSD 15min intraday trading. + prompt = f"""You are an FX Trading Decision Agent for EURUSD 1min intraday trading. You have received reports from your team: diff --git a/rdagent/scenarios/qlib/fx_validator/config.py b/rdagent/scenarios/qlib/fx_validator/config.py index e07d4c74..4d00613b 100644 --- a/rdagent/scenarios/qlib/fx_validator/config.py +++ b/rdagent/scenarios/qlib/fx_validator/config.py @@ -1,12 +1,12 @@ """ FX Validator Configuration -Angepasst für EURUSD 15min intraday trading +Angepasst für EURUSD 1min intraday trading """ import os FX_CONFIG = { "instrument": "EURUSD=X", - "frequency": "15min", + "frequency": "1min", "llm_provider": "openai", "backend_url": os.getenv("OPENAI_API_BASE", "http://localhost:8081/v1"), "api_key": os.getenv("OPENAI_API_KEY", "local"), diff --git a/rdagent/scenarios/qlib/fx_validator/fx_graph.py b/rdagent/scenarios/qlib/fx_validator/fx_graph.py index a5dbff81..2be3dda5 100644 --- a/rdagent/scenarios/qlib/fx_validator/fx_graph.py +++ b/rdagent/scenarios/qlib/fx_validator/fx_graph.py @@ -1,6 +1,6 @@ """ FX Validator Graph — Multi-Agent Validierung für Predix Faktoren -Inspiriert von TradingAgents, angepasst für EURUSD 15min +Inspiriert von TradingAgents, angepasst für EURUSD 1min """ from typing import TypedDict, Optional from langgraph.graph import StateGraph, END