fix(live): skip market-triggered ticks while the market is closed - #1253
Open
he-yufeng wants to merge 1 commit into
Open
fix(live): skip market-triggered ticks while the market is closed#1253he-yufeng wants to merge 1 commit into
he-yufeng wants to merge 1 commit into
Conversation
_jobs_from_triggers downgraded a MARKET trigger to a plain 60s interval job, and the tick never re-checked the session: due_now sat imported with zero call sites, so weekend ticks ran the full pipeline and submitted orders that queue into the Monday open. The runner now gates on the trigger layer the jobs were synthesized from: with MARKET triggers attached, a tick proceeds only when at least one of their markets is open at the tick instant. Interval-only and 24/7 (crypto) channels never block, and the skip stops before reconcile, so a closed session costs no broker calls and writes no audit records. Refs HKUDS#1207 (Phase 0, item 5). Signed-off-by: Yufeng He <40085740+he-yufeng@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_jobs_from_triggersdowngraded a MARKET trigger to a plain 60s interval job and the tick never re-checked the session:due_nowsat imported inruntime/runner.pywith zero call sites. Weekend ticks ran the full pipeline and submitted orders that queue into the Monday open.Why
Refs #1207 (Phase 0, item 5). The design always intended this:
_jobs_from_triggers' docstring says the tick itself re-checks market state, but nothing ever called it.Changes
runner._any_market_open: union over attached MARKET triggers via the trigger layer'sdue_now. Runners without MARKET triggers never gate; 24/7 markets (crypto) report open at every instant.run_oncereturns a newmarket_closedoutcome before reconcile when every attached market is closed, so a closed session costs no broker calls and writes no audit records (a 60s watch cadence all weekend would otherwise flood the ledger).Test Plan
test_runtime_runner.py: pre-open skip stops after the mandate check with no reconcile/invoke/audit, mid-session ticks proceed, a closed us_equity plus 24/7 crypto union stays open, interval-only runners ignore the gate.pytest agent/tests/test_runtime_runner.py -q: 29 passed. Live safety set (flatten, sweep latch, api runtime, order gate, mandate enforcement, killswitch, readonly): 150 passed.ruff checkclean on the touched files (two pre-existing F401s in runner.py left alone).Risk: fail-closed in the trading direction only. Ticks outside market hours become no-ops; nothing about open-session behavior changes. Rollback is a plain revert.
Prepared with AI assistance (Kimi K3); all verification above was run locally.