Orders
Every order takes one path to a broker: the wire, the trading root, the account's stadium actor, the venue adapter. Your order, your agent's and an exit Taji holds differ only in the source stamped on the intent; each passes the same checks, is journaled before it leaves, and is reconciled against the venue by the same pass. This page explains that path and why it is built that way. To place and cancel orders, see Trade; every route named here is a row of the //! header of engine/crates/taji/src/wire/mod.rs.
Where does an order go before it reaches a broker?
Read it from the top. A client sends a place over the wire. If the account's approvals are on and the call was not made by hand in Taji's window, it parks until you approve it. The trading root hands the intent to the account's stadium actor, which checks it, writes it to the journal, checks for a halt once more, and only then calls the venue. Fills are not read from that answer: a later refresh pass lists the venue's orders and positions and books what it finds. A level Taji holds itself enters at the trading root, as an exit, and from there takes the same path.
Who can send an order, and as whom?
Each wire request carries a token, and the token decides both whether a trading verb is admitted and what source the order is stamped with (ORDER in engine/crates/taji/src/wire/routes.rs):
| Token | Held by | Trading verbs | Stamped as |
|---|---|---|---|
local | Taji's main process, taji-link, your scripts | admitted | Human |
page | the window's page, and Taji's own window by hand | admitted | Human |
agent | the MCP bridge your agent runs | admitted | Agent |
sheet | the key sheet | refused scope | none |
A pane a plugin draws holds no token, and its frame refuses every order verb with scope before the wire hears it (packages/plugin/frame/host.test.ts). A process plugin cannot be a venue: venues are compiled in.
An agent's draft and order carry the taji-agent source (AgentOrder in engine/crates/taji-trading/src/commands.rs). They pass the same checks as yours, and the journal row says the agent sent them. The manual order and the approved proposal are exercised end to end on the sim in engine/crates/taji/tests/trading_vs_code.rs.
When does an order wait for your approval?
While an account's approvals are on, a call that can send an order and was not made by hand in Taji's window parks and answers 202 with an approval id. It is sent only when you click Approve in the window; you or the agent can decline it, and either sends nothing (0008). Your click is the consent, so approving is by hand alone: no script, page token or agent can approve.
Approvals default on for a live account and off for paper and sim accounts. Your setting replaces the default (approvals_on in engine/crates/taji-trading/src/accounts.rs). Your agent cannot change it, and only a hand in the window can turn approvals off. A venue row reads approvals on, whatever you set, while its record cannot be verified: the vault is locked, or the file was edited and its MAC does not match. The sim row, which moves no money, reads as written.
What parks, while approvals are on:
| Call | Parks for |
|---|---|
Every trading verb that can send an order (draft/place, orders/<class>/place, plans/arm, account/market, a close, a reprice, …) | any token but the by-hand one |
draft/{stage,edit,clear}, plans/draft, orders/<class>/{route,preview} | nobody: they send nothing |
| A cancel, cancel-all or plan disarm that withdraws a protective exit | the agent alone |
| Any other cancel, cancel-all or disarm | nobody |
Two calls park whatever the account's setting. Approving a live account for routing (link/accounts/<handle>/approve) parks for any token but the by-hand one. An agent's reprice or cancel of an order Taji did not place, or a cancel-all, close or reverse that would cancel one, parks for the agent alone.
Nothing parks that approval could not make succeed. A body that does not parse, an order id nobody holds or a plan that does not exist is refused at once. An orders/<class>/place is routed and previewed first, so a refused order parks nothing. Where a call would park from a plain page or the sheet, which cannot approve, it is refused 409 not_by_hand instead.
An approval lives in memory for an hour (engine/crates/taji/src/wire/approvals.rs). An unanswered one expires and sends nothing, and a restart drops every pending one. An account holds at most five pending; the sixth is refused 429 approvals_full. Approved, the held call is sent under the token that parked it, and its own checks run then: a draft's rev, a plan's plan_rev, live, funds. So an approval granted after the draft changed places nothing.
Which account does an order go to?
An order that names an account goes there, if that row trades the class. One that names none is routed by a stated rule (engine/crates/taji-trading/src/route.rs):
- The live-intent rule: a live order goes only to a live row, a paper order only to a paper or sim row.
- The
accountthe order names, even a live row you have not approved for routing. - An order touching an existing order or position goes to the row that holds it.
- Your preference for the class (
link.prefer.orders). - Of the rows that can take the order, the lowest measured fee. A live row you have not approved for routing, or whose known buying power is under what the order spends, cannot take it.
taji_simis chosen only when nothing else can. - Otherwise the order is refused
no_route, with one line per row saying why.
Under explicit routing (link.prefer.routing: explicit), a choice rules 4 and 5 would make is refused account_required instead, and you name the row. On the named row and the holder, the route also refuses what the venue would certainly refuse, read from the facts it serves: a price not above zero, a time in force it does not take, a quantity off its step, a price off its tick, a fraction where it trades whole shares.
The route is one pure function over what the client already reads, so the answer you get before you send is the answer the order takes. POST /verb/trading/orders/<class>/route asks it and sends nothing. On a keyless kernel, with only taji_sim bound, this asks where a one-share SPY limit buy would go:
[
{"name": "route", "method": "POST", "route": "/verb/trading/orders/equity/route", "body": {"kind": {"Order": {"instrument": {"Equity": {"symbol": "SPY"}}, "side": "Buy", "qty": "1", "entry": {"Limit": "500"}, "tif": "Day"}}}}
]
{
"account": "taji_sim",
"alias": "sim",
"live": false,
"rule": "auto",
"why": "taji_sim: fee not measured",
"fee": null,
"rows": [
{
"account": "taji_sim",
"alias": "sim",
"verdict": "chosen",
"reason": null,
"fee": null
}
]
}
Captured 2026-12-03 on a keyless headless kernel.
rulenames the rule that decided:named,owner,prefer,auto(the fee rule) orexplicit.rowsholds every bound row in link order, eachchosen,passed(it qualified and lost,reasonsays to what) orskipped(it cannot take the order,reasonsays why). With a brokerage linked, a live row you have not approved for routing readsskipped,not approved.feeisnullbecause the sim's fee is not measured; an unmeasured row ranks after every measured one.
Every verb that sends a new order takes live, default false, and it must match the account's side of the line. A live account refuses an order that did not say live: true with 409 live_intent, and a paper or sim account refuses one that did with 409 not_live. The check sits inside each operation (live_intent in engine/crates/taji-trading/src/model.rs), so no client routes around it.
What checks an order before it leaves?
substrate/stadium is the execution core. One actor per account owns its whole money path and runs one command at a time (substrate/stadium/src/actor.rs); its acceptance tests are substrate/stadium/tests/actor_e2e.rs. Before any venue call, in order:
- Halt. A halt is global or on one source, and a global halt blocks every source (
substrate/stadium/src/halt.rs). It is checked at admission and again just before dispatch, so a halt latched meanwhile withdraws every submit not yet sent. A halt never flattens anything. It lives in memory: a restart clears it, unless the journal still justifies it, in which case the boot reconcile latches it again. - Replay guard. An intent id already in the journal places no second order. A client may mint the id itself (
intent_id, a UUIDv7), so a retried place answers the first one's order. - Risk gate.
RiskGate::evaluateinsubstrate/stadium/src/gate.rsprices only from the intent's ownref_price. Your order, your agent's and an exit are checked for shape and left to the venue: Taji puts no size or loss limit on them beyond their shape and the venue's own. The allow-list, rate, staleness, notional and position rules bind only anOrderSource::Seatintent, which the wire never sends. - Journal. The intent is written as
IntentReceivedbefore the venue hears of it. - Write slot. Every place, cancel, replace and exercise holds its venue login's write slot for exactly one adapter call (
substrate/taji-brokerage/src/queue.rs). Two accounts on one login share a slot; writes go in arrival order, and reads pass. - Rate budget. The request is charged against its login's budgets (
admit, same file). Nothing waits: a read over budget is refused, naming when it frees, and a write is charged into debt and refused only during a hold the venue imposed. Your agent's token has budgets of its own, 600 reads and 120 other requests a minute, charged by the sameadmit(engine/crates/taji/src/wire/agents.rs).
The journal is the book. Money events are an exhaustive set of rows (EventKind in substrate/stadium/src/event.rs), one JSON-lines file per account at <state dir>/journal/<account>.jsonl, written before the in-memory append commits and replayed at boot (engine/crates/taji-trading/src/journal.rs). A rejection is journaled with its reason. A torn last line, from a crash mid-write, is dropped. A bad line inside the file unbinds that account alone, since half a ledger is a wrong book. A journal that will not answer latches a global halt before the command replies.
What happens when the venue answers, or does not?
The actor replies on the venue's answer to its one request: OrderAcked, or the rejection, journaled. A refused place is never sent again. A submit that left and came back with neither, such as a timeout or a 5xx, reads UNCONFIRMED and is never placed again by Taji. The next refresh pass adopts it if the venue lists it; past 60 s with no venue row it ends Rejected on a venue whose listing carries every placed order (Alpaca, the sim), and Unknown on any other. Until then a new opening order on that instrument is refused, and a reduce-only close passes.
One cancel-and-place never places twice. Where a venue cannot replace an order in place, Taji cancels and places anew, and a cancel that lands with more filled than the place was sized from places nothing (fallback_cancel in engine/crates/taji-trading/src/model.rs).
How does Taji know an order filled?
A refresh pass reads the venue, never the place's answer. One pass per account runs when the venue pushes an order or position change, when a write's answer or an adoption asks for one, and on a cadence: every minute while a push stream is up, every second while an order works with no stream, else on the account's cadence (engine/crates/taji-trading/src/root.rs). A pass lists the account's orders once; clients read its record with its as_of. A rate-limited listing ends the pass, sets paused_until, and reads again only after the release.
The reconciler is the only reader of a venue's orders, positions and money. A pass compares the journal's fold with the venue's listing; a lifecycle the venue contradicts is irreconcilable and halts (substrate/stadium/tests/reconcile_golden.rs). A pass never adopts an order or position the journal did not make: a venue-held position or a break enters the book only when you adopt it (breaks/<id>/adopt) or close that position, which adopts it first.
A fill the venue lowers is booked, never halted on. Every pass reads the venue's whole order listing, so a filled order nothing else keeps open is still checked. Where a venue states each leg's cumulative filled quantity (LegState::filled), a pass books what the journal holds above it as FillCorrected rows that keep the booked price (unlisted_busts in substrate/stadium/src/halt.rs). A fill stated with no price yet is credited in flight, not booked, until a pass reads its price.
| Venue | States a leg's cumulative fill |
|---|---|
| Alpaca, TradeStation, Robinhood equities and crypto | yes |
| IBKR, Schwab and Robinhood options | one-leg orders yes, multi-leg no |
| Tradovate | no |
An order the venue no longer lists at all corrects nothing, because listings are windows: Alpaca reads at most 50 pages of 500 orders, Schwab a year, IBKR its open and completed orders with one to seven days of executions. A leg that states no cumulative reserves the pass when the venue stops listing a booked execution, and the next boot halts the account.
Which exits does Taji hold itself?
Some exits no venue will hold, such as a stop on another symbol or a pair the account's venue does not seat. Exits works every one of them, for any account or owner, on one live stream per symbol, whether a chart is open or not (engine/crates/taji-trading/src/exits.rs). When a print or quote reaches a level, it sends the account's stadium a market exit as Exit(owner), sized at the trip so it never closes more than the position Taji can see. From there the exit takes the order path above.
Holding is opt-in: a plan arm or a draft place that leaves legs for Taji is refused 409 held_exits unless it says held: true, and one with no live feed to judge a leg is refused 409 no_feed. Held levels survive a relaunch in <state dir>/exits.json, but they trip only while Taji runs on a live feed. A level crossed while Taji was closed is never fired: it is suspended, and the window says why. Quitting while exits are held is refused unless you confirm it, and your agent cannot confirm it.
How does taji_sim fill an order?
taji_sim is the account every launch has, with nothing linked and no key: SimBroker, an ExecutionOps with an injected clock and prices from the hub's bars, quotes and prints. It takes the same path as any venue, so an order on it exercises the real gates and journal.
| Order | Fills |
|---|---|
| Equity or crypto market | at the side of a usable quote standing when it arrives, a buy at the ask and a sell at the bid, else the newest print after it |
| Futures market | at the intent's ref_price, never off a bar |
| Resting equity | whole, off its quote stream, delayed or not; refused where none streams |
| Resting option spread | once its legs' net mid reaches its net |
| Any other resting order | whole, off bars, a future's off the minute still forming as well |
| Single-leg option market | refused: the sim prices no option itself |
Resting orders fill by one rule, taji_brokerage::fill::judge, the backtest's. An option whose contract has no bars never fills. An equity fill's why names its price's source and instant, and a resting fill lands on the next refresh pass, which each live quote, print and bar wakes. Each class's rules are in the //! header of substrate/stadium/src/sim.rs.
What does a venue plug in?
A venue is a compiled-in plugin: its crate registers a VenueArm with Build::venue (engine/crates/taji-plugin/src/vendor/venue.rs; plugins/alpaca/src/lib.rs is one). The arm binds an account row and its login to a BoundArm: an ExecutionOps (substrate/taji-brokerage/src/traits/execution_ops.rs), the venue's reads, and optionally a push channel whose events wake a refresh pass and carry nothing else. Its VenueFacts declare once, never probed, what it trades: classes, order shapes, protective orders, fees, and the record each environment's credential lives in. Clients see those facts as platform fields, never the venue's own shapes (0004).
Nothing above the trading root holds a broker handle or a credential: the kernel binds an arm only below it, and engine/crates/taji-trading/tests/dependency_audit.rs holds that (0005).
What does a placed order not do?
- A draft with no session chosen takes its session when it is sent: a limit shown regular-hours at 15:59 goes extended-hours at 16:00:01. A limit staged off-hours with exits goes in the regular session instead, its bracket waiting for the open.
- Held exits work only while Taji runs.
- No real venue runs in the default tests: each adapter's suite runs against a mock unless you run its live suite with your own key, on a paper, sim or demo account. No live-money account is tested.
- The gate's
OrderSource::Seatrules are tested insubstrate/stadiumalone, since the wire sends no order with that source.
See also
- Trade: placing, cancelling and setting Agent approvals.
- Have your agent place a
taji_simorder: an agent's place parked for your approval, call by call. - Security: the tokens and the trust model behind them.
- 0008. A live order waits for your approval.
- Wire: the routes and their refusals.