From 0656108b9ea3e028bfb2b933af7df5d02c18569c Mon Sep 17 00:00:00 2001 From: claude_dev Date: Fri, 10 Jul 2026 08:49:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(live):=20live=5Fstep=E4=BC=A0qfq=5Fbars?= =?UTF-8?q?=E5=AF=B9=E9=BD=90step=E5=8F=8C=E6=BA=90=E7=AD=BE=E5=90=8D(?= =?UTF-8?q?=E7=AB=AF=E5=88=B0=E7=AB=AF=E8=B7=91=E9=80=9A)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit live_step当日补fetch_day qfq + step(today,raw,qfq,prev,pending)5参数对齐. 修前 step5参数 vs live_step4参数 missing pending(预存, c6b19f4双源后未对齐). 容器verify_live_step端到端跑通(live_step@2026-07-07, _restore_ledger不崩, 分红/占用成本加载OK). 139 passed. --- sanguo_trader/live_orchestrator.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sanguo_trader/live_orchestrator.py b/sanguo_trader/live_orchestrator.py index bbb119d..03a7f76 100644 --- a/sanguo_trader/live_orchestrator.py +++ b/sanguo_trader/live_orchestrator.py @@ -106,12 +106,16 @@ def live_step(db_path: str, account_id: int, data_source, cfg, today: str | None runner.paper_cta_engine.on_bar(wbars[runner.symbol]) runner.paper_cta_engine.pop_orders() # warmup 单丢弃(不撮合) - # 4. 当日 raw bar(Mac launchd 已推 NAS) + # 4. 当日 raw bar(撮合)+ qfq bar(策略 on_bar 信号) bars = {} + qfq_bars = {} for sym in symbols: - bar = data_source.fetch_day(sym, today, interval, adjust="raw", cfg=cfg) - if bar is not None: - bars[sym] = bar + rbar = data_source.fetch_day(sym, today, interval, adjust="raw", cfg=cfg) + if rbar is not None: + bars[sym] = rbar + qbar = data_source.fetch_day(sym, today, interval, adjust="qfq", cfg=cfg) + if qbar is not None: + qfq_bars[sym] = qbar if not bars: logger.info("live_step %s: 当日无 raw bar(%s 非交易日或未推?),跳过", account_id, today) return @@ -141,7 +145,7 @@ def live_step(db_path: str, account_id: int, data_source, cfg, today: str | None pe = PaperEngine(account, runners, data_source, acc_cfg, db_path, account_id, symbols, acc.get("start_date") or today, today, interval, risk_free_rate=getattr(cfg, "risk_free_rate", 0.0)) - pending_new, _closes = pe.step(today, bars, prev_close, pending) + pending_new, _closes = pe.step(today, bars, qfq_bars, prev_close, pending) # 6. 存状态(pending + positions) save_pending_orders(db_path, account_id, [