"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
docs(paper-trade): document the 5m selectors and their known limits
shadowinlife3286b8e823f2
diff --git a/README.md b/README.mdindex ca1a32986..6f273c9dc 100644--- a/README.md+++ b/README.md@@ -1489,8 +1489,39 @@ and inspect fills, rejections and NAV history. Strategy history stops before theexecution date, and each day receives the ledger after preceding fills. Theagent/MCP `paper_trade_step` remains a stateless research primitive.-Execution uses raw prices (Tencent raw for A-shares/HK, raw-capable US providers).-A-shares require a complete ClickHouse calendar. Unavailable data/calendar and+`paper_trade_step` also takes `interval="5m"` for A-shares: one step covers one+completed session and matches against that session's single assembled bar, built+from the 48 continuous five-minute bars. The 09:30 label is the opening+call-auction print, single-priced on 4 of 5 probed days, and is excluded by+policy; labels in 09:15-09:25 or from 14:57 up to but not including 15:00 are+auction-window anomalies, and 15:00 is a continuous bar. The 5m leg uses Tushare+`stk_mins`, separate from the daily chain, which serves daily bars only. It+accepts one order symbol per step: the measured provider budget is 1+call/minute, 1 call/hour and 2 calls/day, and a refused call still consumes the+daily budget. It fills all-or-none at the `path_model` reference (`bar_median` or+`bar_close`) and requires a non-empty `UNIVERSE` in strategy mode. `session`,+`path_model` and `fill_model` default to the daily behaviour, so every existing+call is unchanged; `session` is a coherence selector only (`cn_a` requires+`market="cn_a"`) and does not change the day boundary.++Known limits: a mid-range zero-calendar (HK/US) weekday with no bar for any+symbol is inferred closed (`market_closed_inferred` with a warning) with no NAV+row, its orders reject `suspended` and positions carry the last available close+forward; an all-market zero bar on the target day is `PAPER_DATA_NOT_READY`+(retryable), and+a saved account advance reports `committed: false` instead of moving the+watermark. The provider's bar count is authoritative: a partial session still+fills with its `N/48` coverage warning. Payload faults fail closed: off-grid+labels (for example a 1m payload served as 5m) and all-NaN continuous bars are+`PAPER_DATA_NOT_READY`, while a zero-volume session is a halt. A 5m step with no+orders issues no `stk_mins` request and follows the 1d valuation contract: it+needs the target daily bar and values from that day's closes. The persistent v1.2+runner/account/store layer is a follow-up branch (`paper-trade-v12-persistence`)+and is not wired to any CLI, API or MCP surface in this PR.++Execution uses raw prices (Tencent raw for A-shares/HK, raw-capable US providers;+Tushare `stk_mins` for the A-share 5m leg). A-shares require a complete ClickHouse+calendar. Unavailable data/calendar andunverified split-like events fail visibly without committing a saved ledger;price/volume ratios never authorize multiplying a position. Cash dividends andautomatic corporate-action reconciliation are not implemented. See thediff --git a/agent/src/tools/paper_trade/README.md b/agent/src/tools/paper_trade/README.mdindex f79741c15..7fe24f952 100644--- a/agent/src/tools/paper_trade/README.md+++ b/agent/src/tools/paper_trade/README.md@@ -83,6 +83,83 @@ fills. The spawned child receives no current/future bars and retains its instancacross dates in one call. Source validation and process timeouts apply. Anystrategy failure discards the whole call, including earlier uncommitted results.+## Five-minute cn_a steps++`paper_trade_step` accepts `interval="5m"` for A-shares. One step covers exactly+one completed session and matches against that session's single assembled bar,+built from the 48 continuous five-minute bars. The 09:30 label is the opening+call-auction print, single-priced on 4 of 5 probed days, and is excluded by+policy without an event. A label in 09:15-09:25 or from 14:57 up to but not+including 15:00 is an auction-window anomaly, excluded from matching and+reported as an `auction_window` event; the 15:00 label is a continuous bar.++A symbol with 5m rows but no continuous session bar on a calendar-open day is+`halted`: its position is valued at the last available close (carry-forward),+and an order on it is rejected `suspended` with one+`canceled_after_failed_match` row. A requested 5m symbol whose response carried+no row at all while its daily bar exists is a provider omission and returns+`PAPER_DATA_NOT_READY`, not a halt.++| Field | Values | Default | Meaning |+| --- | --- | --- | --- |+| `interval` | `1d`, `5m` | `1d` | `5m` is cn_a-only and accepts one date per step |+| `session` | `auto`, `cn_a` | `auto` | coherence selector only: `cn_a` requires `market="cn_a"` and does not change the day boundary |+| `path_model` | `bar_median`, `bar_close` | `bar_median` | reference price from the session bar |+| `fill_model` | `all_or_none` | `all_or_none` | no partial fills |++The 5m leg uses Tushare `stk_mins` and is resolved separately from the daily+chain: Tencent's raw loader serves daily bars only. The measured provider limit+is one symbol per step (1 call/minute, 1 call/hour and 2 calls/day; a refused+call still consumes the daily budget), so a 5m step with two order symbols is+refused before any fetch. Split the orders across steps or use `interval="1d"`.+Orders mode derives the 5m universe from the order symbols; strategy mode+requires a non-empty `UNIVERSE` and refuses any order outside it. When no+5m-capable loader is configured, the step returns `PAPER_DATA_NOT_READY` naming+the loader instead of reading the daily source as a 5m source.++A step with `"orders": []` issues no `stk_mins` request. Its NAV comes from the+daily leg and follows the `interval="1d"` contract exactly: without the target+daily bar it returns the same `PAPER_DATA_NOT_READY`; with the target daily bar+it produces the NAV row from that day's closes.++The 5m leg is stateless. It is exposed through the agent/MCP step tool,+`POST /api/paper-trade/step` and `vibe-trading paper step`; saved accounts+remain daily-only. The persistent v1.2 runner/account/store layer is a follow-up+branch (`paper-trade-v12-persistence`) and is not wired to any CLI, API or MCP+surface in this PR.++The daily close still anchors price-limit bands and NAV; `path_model` selects the+5m fill reference only. Corporate actions remain fail-closed.++## Known limits++- **Zero-calendar markets (HK/US).** A mid-range candidate weekday with no bar+ for any symbol is inferred closed: the day is recorded as+ `market_closed_inferred` with a warning, no NAV row is produced for it, its+ orders are rejected `suspended` and positions carry the last available close+ forward. An all-market zero bar+ on the target day is `PAPER_DATA_NOT_READY` (retryable), because a provider+ outage looks identical; a saved-account advance then returns `committed:+ false` and leaves the account unchanged, since a result with an empty+ `nav_series` is never committed. A single-symbol zero bar on a day another+ symbol traded is `suspended` with carry-forward valuation.+- **5m payload integrity.** A zero-volume 48-bar session is a halt: the day is+ dropped with a warning, orders are rejected `suspended` and positions are+ valued at the last available close. Off-grid continuous labels (for example a+ 1m payload served as 5m) and continuous bars that are all NaN are provider+ faults, so the step returns `PAPER_DATA_NOT_READY` instead of a session.+- **The provider's bar count is authoritative.** There is no 48-bar gate: a+ session assembled from fewer bars still fills, and the `N/48 continuous bars`+ warning is returned in the step's `warnings`. Run a same-day step only after+ the session has settled, or the step prices a partial-session bar.+- **5m halt detection needs 5m evidence.** A requested 5m symbol with no row at+ all while its daily bar exists is a provider omission and returns+ `PAPER_DATA_NOT_READY`. A symbol that produced any 5m row (the 09:30 auction+ print counts) but no continuous session is `halted`, not data-not-ready.+- **5m strategy UNIVERSE is strict.** An order on a position outside the+ declared `UNIVERSE` fails the whole call, so such a position cannot be reduced+ by a 5m strategy step; use the 1d step for that.+## Data and model limitsExecution requires raw prices. Tencent's unadjusted endpoint serves A-shares/HK;@@ -98,8 +175,9 @@ discontinuities reject affected orders and disclose the issue. Automatic actionreconciliation and cash dividends are not implemented. NAV is not total return.A-shares are included in the raw-price discontinuity checks.-Matching is daily close, all-or-none, with simplified fees, price limits, board-lots and T+1 checks. HK lot fallback is disclosed. Invalid OHLC prevents fills;-valuation uses a finite prior close or the disclosed average-cost fallback.-This is not intraday or broker-execution simulation. The 5-minute, settlement,-margin, options and cross-market phases in #1938 remain follow-up work.+Matching is all-or-none, with simplified fees, price limits, board lots and T+1+checks. HK lot fallback is disclosed. Invalid OHLC prevents fills; valuation+uses a finite prior close or the disclosed average-cost fallback. This is not+broker-execution simulation. Settlement, margin, options and cross-market phases+in #1938 remain follow-up work, as does the intraday order lifecycle (partial+fills, resting orders across bars).