> Every Taji docs page as Markdown: https://docs.taji.is/llms.txt

# Tradovate: how it works

Tradovate is a futures FCM whose partner docs are now NinjaTrader's. Taji uses it as an order venue: dated-future orders (single, bracket, OTO, OCO, multibracket), the account's book, money and margin, and reference data for futures (search, instrument, details, and an option chain's strikes). Taji takes no market data from it. The crate is `plugins/tradovate/` (`taji-tradovate`). It talks to two REST hosts, demo and live, plus each host's user-sync WebSocket, and it registers a venue arm, a link `Auth` and a data `Source` under one id, `tradovate`.

## The vendor

**Hosts and environments.** The vendor has two environments, each with its own production host (Environments page, fetched 2026-12-02):

| Environment | REST | User-sync socket | Taji env |
|---|---|---|---|
| Live | `https://live.tradovateapi.com/v1` | `wss://live.tradovateapi.com/v1/websocket` | `live` |
| Demo | `https://demo.tradovateapi.com/v1` | `wss://demo.tradovateapi.com/v1/websocket` | `paper` |

Demo fills are simulated against real market data. Market data has a separate socket, `wss://md.tradovateapi.com/v1/websocket`. Staging hosts (`*.staging.ninjatrader.dev`) and a market-replay socket also exist. Taji uses none of these three.

**Auth.** There is no OAuth for a retail user. `POST /auth/accesstokenrequest` takes `name` and `password` (both required) plus `appId`, `appVersion`, `deviceId`, `cid` and `sec`. It answers `accessToken`, `mdAccessToken`, `expirationTime` and `userId`. A failed login is still HTTP 200, with `errorText` set.

- **Token lifetime.** A token lives 80 minutes. `GET /auth/renewaccesstoken`, called with the current bearer, extends it without opening a new session. There is no refresh token: once a token is lost, only a password login gets a new one.
- **Two sessions per user.** Each successful `accesstokenrequest` opens a server-side session, and a user holds at most two. A third login closes the oldest, and a login on a `tradovate.com` website counts toward the two.
- **Device id.** `deviceId` must be unique per machine and stable on it. Live checks it more strictly than demo: a moved device id is the common cause of a live 401 on `placeorder` (example-api-faq, `UnderstandingDeviceId.md`).

**API families Taji calls** (all `/v1`):

- Auth: `auth/accesstokenrequest`, `auth/renewaccesstoken`, `auth/me`.
- Accounting and risk: `account/list`, `cashBalance/getcashbalancesnapshot`, `marginSnapshot/ldeps`, `accountRiskStatus/deps`, `userAccountAutoLiq/ldeps`.
- Orders:
  - placing: `order/placeorder`, `order/placeoso`, `order/placeoco`, `order/modifyorder`, `order/cancelorder`;
  - reading: `order/list` and `order/item`, `orderVersion/list` and `orderVersion/deps`, `fill/list` and `fill/deps`, `fillFee/items`, `command/list` and `command/deps`, `executionReport/ldeps`.
- Order strategies: `orderStrategy/startorderstrategy`, `orderStrategy/interruptorderstrategy`, `orderStrategy/item`, `orderStrategy/deps`, `orderStrategyLink/deps`, `orderStrategyLink/list`.
- Positions: `position/list`.
- Contract library: `contract/find`, `contract/item`, `contract/suggest`, `contract/getproductfeeparams`, `contract/getoptionschain`, `contractMaturity/item`, `product/find`, `product/item`, `productSession/deps`, `contractMargin/deps`, `productMargin/ldeps`, `exchange/item`, `currency/item`.
- Socket: `authorize` and `user/syncrequest` on the user-sync socket.

The socket speaks SockJS-style frames:

- `o` opens the connection, `h` is a server heartbeat, `a[...]` carries an array of messages, and `c` closes.
- A request is `<endpoint>\n<id>\n\n<json>`, and the server sends updates as `props` events.
- The client sends `[]` as its heartbeat every 2.5 s; a connection that sends nothing for 15 s is dropped.
- With `entityTypes` omitted, `user/syncrequest` delivers every entity type. User- and account-level events such as `userSessionStats` arrive whatever `entityTypes` lists, and a misspelled type is accepted and delivers nothing (User sync page, fetched 2026-12-02).

`contract/getoptionschain` is absent from the current endpoint index. Taji's call to it rests on the OpenAPI spec embedded in `api.tradovate.com`, as the README records.

**Accounts and entitlements.**

- One login can hold several accounts; `account/list` returns them with `id`, `name` (the account number, which orders name as `accountSpec`), `accountType` and `active`.
- API access needs a funded live account (over $1,000 equity) and the API Access add-on. The manifest's link steps cover both.
- Market data over the API needs a CME plan plus CME sub-vendor registration. Without them the md socket answers "symbol is inaccessible". Orders do not need market data.

**Stated limits.**

- **User level.** 5,000 requests an hour for an authenticated user, 1,000 anonymous. Going over answers HTTP 429 with an empty body (or `s: 429` on a socket), and any call inside the next hour restarts that hour.
- **Endpoint level.** These limits apply per IPv4 /24 subnet over a rolling hour:
  - `accesstokenrequest`: 5 failed, back-off 15 s;
  - `renewaccesstoken`: 15 of any outcome, back-off 15 s;
  - `me`: 10 failed, back-off 30 s;
  - `syncrequest`: 300 of any outcome, back-off 3 s.
- **Penalty tickets.** Going over an endpoint limit answers HTTP 200 carrying a penalty ticket (`p-ticket`, `p-time`, optionally `p-captcha`, `p-message`), and the request is not handled. You wait `p-time` seconds and resend the identical body with `p-ticket` added. Each further ticket adds one back-off to the remaining wait.
- **Captcha.** `p-captcha: true` cannot be answered by a third-party app: you wait about an hour. A retry without a solved captcha answers 423 (Locked), which Taji reads as the same captcha.

The README's [Access](https://docs.taji.is/catalog/tradovate.md#access) and [Before you link](https://docs.taji.is/catalog/tradovate.md#before-you-link) sections hold the measured numbers.

**Vendor capabilities Taji does not use, and why:**

- **The md socket** (`md/getChart`, `md/subscribeQuote`, `md/subscribeDOM`, `md/subscribeHistogram`): it needs the CME sub-vendor fee Taji does not pay (`plugins/tradovate/src/lib.rs`). `plugins/tradovate/src/offer.rs` declares these products as offered and not taken; what they serve is in [Offered, not read](#offered-not-read).
- **Order types with no `OrderWord`:** `LimitIfTouched`, `MarketLimit`, `QTS`, `MarketWithProtection` and `MarketStopWithProtection` (`plugins/tradovate/src/offer.rs`).
- **`TrailingStopLimit`:** no documented field carries its limit offset.
- **`liquidateposition(s)` and `contract/rollcontract(s)`:** neither carries a `clOrdId` (README, "Excluded").
- **Risk-setting writes, `cashBalance*`, `fillPair*`, `account/resetdemoaccountstate` and `tradingPermission*`:** the README excludes them; no reason is on record.
- **`orderStrategy/modifyorderstrategy`:** its `command` string is undocumented (`plugins/tradovate/src/broker.rs`, `replace`).
- **Not yet built:**
  - `customTag50` and `activationTime` on orders;
  - `splitResponses` and sharding on `user/syncrequest`;
  - the OAuth token endpoint;
  - staging hosts and market replay.

### Offered, not read

What Taji reads, down to each field it fills, is [`docs/reference/coverage/tradovate.md`](https://docs.taji.is/reference/coverage/tradovate.md). Every REST row below is a field of the OpenAPI spec embedded in `api.tradovate.com` (`assets/index-u7qQqTGM.js`, fetched 2026-12-04), which needs a login with API access and no market-data plan. The `instrument` answer keeps the margins, fees and session times it calls for in its raw body (`tradovate.instrument.v1`), and no `instrument` or `details` column holds them:

| Offered | Endpoint | Plan | Source |
|---|---|---|---|
| A product's contract and maintenance margins, and its day and night margins | `contractMargin/deps`, `productMargin/ldeps`, `contract/getproductfeeparams` (`ContractMargin`, `ProductFeeParams`) | API access | [`docs`](https://api.tradovate.com/), spec schemas as named |
| A product's clearing, exchange, NFA, brokerage, IP, commission and order-routing fees | `contract/getproductfeeparams` (`ProductFeeParams`) | API access | [`docs`](https://api.tradovate.com/) |
| A session's `openTime`, `closeTime`, `sundayOpenTime` and `allDay`: `session_hours` keeps `startTime`-`stopTime`, and nothing states what `openTime` and `closeTime` bound | `productSession/deps` (`ProductSession`) | API access | [`docs`](https://api.tradovate.com/) |
| A maturity's `isFront`, `underlyingId` and `kalshiEventId`: `isFront` is in the raw body, and no column holds it | `contractMaturity/item` (`ContractMaturity`) | API access | [`docs`](https://api.tradovate.com/) |
| An exchange's `micCode`, which `search` has a column for (`mic`) and the decoder never reads | `exchange/item` (`Exchange`) | API access | [`docs`](https://api.tradovate.com/) |
| A product's `priceFormatType` and `priceFormat`, whose `details` columns are `price_decimals` and `price_fraction`: the spec gives them no description, so what `priceFormat` counts is unstated | `product/item`, `product/find` (`Product`) | API access | [`docs`](https://api.tradovate.com/) |
| A product's `productType` and `months`: Taji reads Futures products alone, and `productType` also lists CommonStock, Continuous, Cryptocurrency, MarketInternals, Options, Spread and Swap | `product/item`, `product/find` | API access | [`docs`](https://api.tradovate.com/) |
| An option contract's `providerTickSize`: in a demo answer and in the `chain_live` assertion, absent from the spec's `Contract`, and no `chains` row carries its `ticks` | `contract/getoptionschain` | API access | measured on the demo host 2026-10-26 (`plugins/tradovate/tests/chain_live.rs`) |
| An option chain's quote, volume, open interest, IV and greeks: the REST chain is its listed contracts alone, and the spec's `Contract` has `id`, `name`, `contractMaturityId` and `timestamp` only | `contract/getoptionschain` | none on REST; `md/subscribeQuote` needs the CME plan below | [`docs`](https://api.tradovate.com/) |
| Quotes (bid, offer and last, each price and size; total volume; open interest; opening, high, low and settlement price), depth (bids and offers, price and size, depth varying with data), volume at price, and bars (tick, minute and daily; volume, range, Renko and point-and-figure; up and down volume and ticks, bid and offer volume; "about two months" of tick and minute bars per request, minute history back to 2017-01-01) | `md/subscribeQuote`, `md/subscribeDOM`, `md/subscribeHistogram`, `md/getChart` on `wss://md.tradovateapi.com/v1/websocket` | a CME plan and CME sub-vendor registration (README [Fees and data subscriptions](https://docs.taji.is/catalog/tradovate.md#fees-and-data-subscriptions)); the partner page states no entitlement | [Market data request reference](https://partner.ninjatrader.com/connect/overview/core-concepts/web-sockets/market-data/market-data-request-reference.md), 2026-12-04 |

Two fields are filled without a page to hold them. `session_time_zone` is the constant `America/Chicago`: the spec's `TradeTime` is an hour and a minute, and the only Central Time statement on the partner pages is the [maintenance-window table](https://partner.ninjatrader.com/connect/resources/reference/maintenance-windows.md) (2026-12-04). The constant rests on a demo MNQ session of 17:00-16:00 against [CME's published](https://www.cmegroup.com/markets/equities/nasdaq/micro-e-mini-nasdaq-100.contractSpecs.html) 5:00 p.m. to 4:00 p.m. CT Globex week for it (2026-12-04, from a search summary: the page itself did not answer a fetch). `first_notice_date` is `ContractMaturity.firstIntentDate`, which the spec leaves undescribed. `tradable` is not declared of `instrument`, `details` or `chains`: `Product.status` is a listing state, and no field states whether a contract trades.

## Code map

- `plugins/tradovate/taji-plugin.toml`: identity, `[[sources]]`, and the two link forms `tradovate-demo` and `tradovate-live`, with their steps, fields, holds and refusal words.
- `plugins/tradovate/src/lib.rs`: the `Plugin` (`build` registers source, venue and auth), the host constants `DEMO_URL` and `LIVE_URL`, `ws_url`, and `TradovateError` with its `From` into `BrokerageError`. Read it first.
- `plugins/tradovate/src/session.rs`: one access token per login and host.
  - Token lifecycle: sign-in, renewal and `warm`.
  - Lockouts: the hold file and the penalty handling.
  - Budgets: the user and subnet budgets.
  - Also `accounts`, which reads `account/list`.
  - Entry point: `Session::shared`, then `token`.
- `plugins/tradovate/src/venue.rs`: `FACTS` (the venue facts), `LINK`, `base(env)`, and the `Arm` whose `bind` builds broker, reads and wake for one account row. Entry point: `Arm::bind`.
- `plugins/tradovate/src/link.rs`: the link `Auth::check` (sign in, list accounts), the `Refusal` words, and `hold`, which names the lockout file. Entry point: `Auth::check`.
- `plugins/tradovate/src/broker.rs`: `TradovateBroker` (`ExecutionOps`, `FuturesOps`), `TradovateReads` (`VenueReads`), the capability and protection matrices, the order bodies, the book fold, and the group and multibracket folds.
  - Entry points: `place`, `orders`, `status`.
- `plugins/tradovate/src/wake.rs`: the user-sync socket, which only wakes reconcile. Entry point: `wake`.
- `plugins/tradovate/src/source.rs`: the data `Source`. It covers `FACTS`, the `search`, `instrument`, `details` and `chains` reads, the raw-page `parse`, and the row mappers. Entry point: `record`.
- `plugins/tradovate/src/offer.rs`: `OFFER` and `VENUE_OFFER`, which record what the vendor offers for `data/coverage`.
- `plugins/tradovate/src/symbol.rs`: `MNQZ26` ↔ `MNQZ6`, in `spell` and `inbound`.
- `plugins/tradovate/tests/egress.rs` and `plugins/tradovate/tests/egress/`: byte goldens of what leaves.
- `plugins/tradovate/tests/chain_live.rs` and `plugins/tradovate/tests/tiers_live.rs`: ignored demo-host probes.
- `plugins/tradovate/tests/common/mod.rs`: the demo login those probes use.
- `plugins/tradovate/scripts/tradovate_walk.py`: the demo walk through a running kernel.

## How it plugs into Taji

**Traits.**

- `link::Auth` implements `taji_plugin::vendor::Auth`. `check` signs in on the env's host and answers one account row per active account, marked live on the live env.
- `venue::Arm` implements `VenueArm`; its admission is `Admission::Login`. `bind` returns `(TradovateBroker, TradovateReads, Some(wake))`.
- `TradovateBroker` implements `ExecutionOps` by delegating to its `FuturesOps`. `supports_replace` answers yes for futures alone.
- `TradovateReads` implements `VenueReads`: `money`, `margin` and `multiplier`, with `clock` always `None`.
- `source::Tradovate` implements `Source`, but only `raw_read` answers:
  - `history` and `read` refuse with `NoSource`;
  - `seat` is `None`;
  - `in_session` is true while either env's login holds a live `Session`.
- No `HistoricalData` or `LiveStream` is implemented.

**Statics.**

- **`venue::FACTS`** has two records, `(Paper, "tradovate")` and `(Live, "tradovate-live")`, and sets `unprovided: true` (the provider under this id is not a bars provider).
- **`LINK`** is `LinkMethod::Login`. It types `name`, `password`, `cid` and `sec`, and reveals only `name`, so the hold file can be keyed by it.
- **`source::FACTS`**:
  - `Seat::Session` and `permits: SOCKETS` (16 concurrent);
  - reads: future `search`, `instrument` and `details`, and future-option `chains`;
  - three raw formats, `tradovate.search.v1`, `tradovate.instrument.v1` and `tradovate.chains.v1`;
  - a bars row (`CAP`) with no classes.
- **`OFFER` and `VENUE_OFFER`**: audited against the embedded OpenAPI on 2026-10-20.
- **`FILLS`** in `plugins/tradovate/src/source.rs` names the columns each read fills. The decode tests in that file fail when a decoder fills a column `FILLS` does not name, or the reverse.

**Link forms.** The manifest defines `tradovate-demo` and `tradovate-live`, both of `kind = "fields"`. `POST /verb/link/venue/link` takes `{name, password, cid, sec}`. The kernel mints a `device_id` once, keeps it across relinks, and seals all five under the env's record. The steps and refusal words live in `plugins/tradovate/taji-plugin.toml`; a refusal maps from `link::Refusal` as follows:

- `denied`: the venue's own `errorText`;
- `captcha`;
- `penalized`, for a ticket, a running hold, or the local failed-login budget spent;
- `unreachable`;
- `no_accounts`.

**Surfaces.** What each cell serves is on the [coverage page](https://docs.taji.is/reference/coverage/tradovate.md).

| Taji surface | Vendor call | File |
|---|---|---|
| `POST /verb/link/venue/link` (futures body) | `auth/accesstokenrequest`, `account/list` | `link.rs`, `session.rs` |
| Arm bind (boot, unlock, link) | `account/list`, then the socket | `venue.rs`, `wake.rs` |
| `POST /verb/trading/orders/future/place` (single) | `contract/find` (once per contract), `order/placeorder` | `broker.rs` `order_body`, `place` |
| the same, with one exit pair | `order/placeoso` (`bracket1`, `bracket2`) | `broker.rs` |
| the same, exits only on a held position | `order/placeoco` (`other`) | `broker.rs` |
| the same, two or more tranches | `product/find` (tick), `orderStrategy/startorderstrategy` | `broker.rs` `start_strategy` |
| `POST /verb/trading/<acct>/orders/<id>/reprice` | `orderVersion/deps`, `command/deps`, `order/modifyorder` | `broker.rs` `replace` |
| `POST /verb/trading/<acct>/orders/<id>/cancel` | `order/cancelorder` per working member, or `orderStrategy/interruptorderstrategy` | `broker.rs` `cancel`, `interrupt` |
| `GET /read/trading/<acct>/orders`, reconcile | `orderStrategy/deps`, `orderStrategyLink/list`, `order/list`, `orderVersion/list`, `fill/list`, `command/list`, `fillFee/items`, `executionReport/ldeps` | `broker.rs` `orders` |
| `GET /read/trading/<acct>/account`: positions | `position/list`, `contract/item` | `broker.rs` `book` |
| `GET /read/trading/<acct>/account`: money, margin | `cashBalance/getcashbalancesnapshot`; `marginSnapshot/ldeps`, `accountRiskStatus/deps`, `userAccountAutoLiq/ldeps` | `broker.rs` `TradovateReads` |
| `GET /get/search?class=future&provider=tradovate` | `contract/suggest`, `product/find`, `exchange/item` | `source.rs` `suggest` |
| `GET /get/instrument`, `GET /get/details` | `contract/find`, `contractMaturity/item`, `product/item`, `productSession/deps`, `contractMargin/deps` (else `productMargin/ldeps`), `contract/getproductfeeparams`, `exchange/item`, `currency/item` | `source.rs` `instrument` |
| `GET /get/chains` on a `future_option` | `contract/find`, `contract/getoptionschain` | `source.rs` `record`, `chain_rows` |
| `GET /read/link/rate_limits` | none: the local budgets | `session.rs` `rate_limits` |

**One read: `GET /get/instrument?symbols=future:MNQZ26&provider=tradovate`.**

1. The hub sends the ask to `source::Tradovate::raw_read`.
2. `record` finds the `Session` that a bound arm holds, trying the paper login first and then live. With neither bound it answers `NoStoredCredentials`; it never signs in.
3. `instrument` spells the contract `MNQZ6` and makes the chain of GETs (plus one POST), each through `Session::get`:
   - `get` takes the held token, or renews or signs in once;
   - it admits the request on the user budget, then sends it through the egress `Login`, which swaps the bearer marker for the real token.
4. Each answer is kept, keyed by its path, as a raw page.
5. `parse` replays the same builder over those pages to produce the row, and the hub stores and caches it.

**One order: `POST /verb/trading/orders/future/place` with a `Limit` on `future:MNQZ26`.**

1. The kernel routes the order to the account row's arm and calls `ExecutionOps::place_order`.
2. `TradovateBroker::place` validates the intent and builds the body with `order_body`: `clOrdId` is the intent id, `isAutomated` is `false` (user, 2026-12-02), and the symbol is `MNQZ6`.
3. It resolves the contract id (cached after the first lookup), then sends the order with `Session::post_write`. A write is admitted into the user budget's debt, so only a hold refuses it.
4. A `failureReason` other than `Success` becomes `OrderRejected`, or `AckedUnconfirmed` where the venue may still hold the order. The `orderId` becomes a `pendingnew` snapshot.
5. The order's change arrives on the sync socket as a `props` event, and `wake` sends `()`.
6. Reconcile calls `orders_since`, which lists orders, versions, fills, commands and fees and folds them into `OrderSnapshot`s. These are what `GET /read/trading/<acct>/orders` shows.

## Why it is built this way

**Orders only.**

- Every data product needs the md socket, and the md socket needs a CME sub-vendor fee: $290 to $500 a month by community reports in the README's [Fees and data subscriptions](https://docs.taji.is/catalog/tradovate.md#fees-and-data-subscriptions).
- Order placement does not need market data, so the crate implements no bars, quotes or depth.
- Position marks read the basis instead (README, "Measured on demo").

**One session per login per host, process-wide.**

- The user's two-session cap means a link check, the bound arm and the data source must not each sign in. `Session::shared` keys a static table by `(base, login id)`, so all three share one token.
- `Session::warm` and `source::Tradovate` never log in.
- A renewal that fails for another reason keeps the old token rather than spend a session. Only a renewal refused 401 (or one unreadable) triggers a fresh login.

**Renew inside the last 15 minutes; warm every 300 s.**

- The docs give the token 80 minutes, as measured on demo (2026-10-02), and their own example renews within 15. That gives `RENEW_BEFORE`, counted back from each answer's `expirationTime`, so it holds for any life over 15 minutes.
- Both hosts drop an idle connection between 600 and 900 s (README [Transport and limits](https://docs.taji.is/catalog/tradovate.md#transport-and-limits)), so `WARM_EVERY` sends `GET /auth/me`, and only when a live token is held.

**Penalties are errors, never results.**

- A ticketed call was not handled, so it is never resent automatically, with one exception: a sign-in retries once with its ticket when `p-time` is at most 60 s (`PENALTY_MAX_SECS`). The link verb blocks its caller, and the token lock stays held through the sleep.
- A 429 or captcha holds every call for an hour, because any call inside the hour restarts it.
- The hold is written to a file under the plugin home, so a restart honours it. The file is named `hold-<sha256(base, name)>.json`, so no filename carries the username.

**Budgets enforced locally.** `queue::Budget` scopes mirror the vendor's tables:

- the user's 5,000 an hour, which every call spends;
- the subnet's 5 failed logins and 15 renewals an hour, shared by every login in the process (`Subnet::shared`).

A call over budget is refused `Budget` and never sent.

**A write that may have reached the venue is never sent twice.**

- A 401 on a write drops the token, but the write is not retried (`a_401_on_a_place_is_sent_once`).
- A 429 on a place reads `AckedUnconfirmed`, because the venue never says whether a 429'd place was handled.
- A transport error after send is also `AckedUnconfirmed`; only a connect refusal is `NotSent`.
- `clOrdId` is not unique at the venue (measured 2026-11-02: identical bodies sent twice make two orders), so a resend would duplicate the order.

**The socket wakes; the REST book is the truth.**

- The platform's `BoundArm` contract says a push "wakes reconcile and carries nothing else" (`engine/crates/taji-plugin/src/vendor/venue.rs`).
- `wake.rs` therefore reads no entity past its `entityType`. It sends `()` once on each sync answer (so a reconnect wakes reconcile once) and once per `props` event of a type reconcile reads.
- `user/syncrequest` names the account and those types in `entityTypes` (`ENTITY_TYPES`). Because the venue still sends user- and account-level events such as `userSessionStats`, `wake.rs` also wakes only on a `props` event whose `entityType` is in that list.
- Each redial re-sends `user/syncrequest`, which is capped at 300 an hour per /24. After any socket that synced, redials start at `SYNC_FLOOR` (12 s).
- If no frame arrives in 30 s, including the server's `h` heartbeat, the socket is redialled.

**Groups are found by `clOrdId` suffix.**

- Neither `Order` nor `OrderVersion` carries `clOrdId`; only the `New` command on `command/list` does.
- A bracket's legs are sent as `<intent>:tp` and `<intent>:sl`. That is how `Book::of` rebuilds a group after a restart, when the in-memory `groups` map is empty.

**A group's snapshot names each member's price, limit and tranche.** Every leg's `price` is its stop, else its limit (a market member has none), and a stop-limit member's `limit` is its limit. An exit's `tranche` is 0 for a bracket's own pair, and for a multibracket's exit the bracket index its link label is; the entry has none.

**Multibrackets read as one order.**

- A strategy is not an order, so Taji's id for it is `strategy:<id>` (`STRATEGY`). The strategy's `uuid` is the intent id, so a restart adopts the strategy by `uuid` through `orderStrategy/deps`.
- `orderStrategyTypeId` is hard-coded to 2, the vendor example's value, because `orderStrategyType/find` answered 401 to an API key on demo (walk, 2026-10-01).
- Exit offsets must be whole ticks off the limit, so `strategy_body` reads `product/find`'s `tickSize`.
- Before the fill, a reprice is refused `NotInPlace`. The brackets are only the strategy's `params` until then, and `modifyorderstrategy`'s command is undocumented.

**No error carries a body.** A body can hold a token or an account number. `exchange` keeps the venue's `errorText` alone, and `shape` names the call, never the answer.

**The device id is minted once and kept.** A device id that moves is the documented cause of live 401s on `placeorder` (`DEVICE_ID` in `session.rs`).

**`tradable` is `null`.** `Product.status` is a listing state: MNQ trades on demo while it reads otherwise (`source.rs`).

**A fee summed across currencies is dropped.** `fee_total` answers `None` rather than add amounts in different currencies.

## Constraints and limits

- **Budgets.** All live in `plugins/tradovate/src/session.rs`; there is no `ratelimit.rs`. You can read them at `GET /read/link/rate_limits`:
  - the user scope (`user`; its budget is named `tradovate-user`), 5,000 an hour, serving `orders`, `account` and `quotes`;
  - the subnet scopes `login` (5 failed an hour) and `renew` (15 an hour), listed as `process`.
- **Concurrency.** The hub's gate admits 16 Tradovate reads at once and holds the 17th (`the_tradovate_gate_admits_16_and_holds_the_17th`, `engine/crates/taji-trading/src/hub/gate.rs`).
- **Lockouts.** A 429, on REST or on the socket, holds the session for an hour (`Session::hold`), and so does a captcha, `p-captcha` or a 423. `TradovateError::wait_secs` gives the caller the wait, and `BrokerageError::RateLimited` carries it to the kernel. The manifest's `holds` (`captcha = 3600`, `penalized = 60`) are what the link form shows.
- **Entitlements.**
  - The link refuses `no_accounts` when `account/list` lists no active account.
  - Bind refuses `Config` when the row's account hash is not listed.
  - Data is entitled only while an arm is bound.
- **Symbology.** Taji's `MNQZ26` crosses as `MNQZ6` (one year digit). `inbound_at` reads a digit back against the current year, so `ESF0` read in 2029 is `ESF30`. The README's [Symbology and gotchas](https://docs.taji.is/catalog/tradovate.md#symbology-and-gotchas) has the open 2030 case.
- **Refused before sending** (`unsent`):
  - any class but `future`;
  - a fractional or zero qty;
  - a `clOrdId` over 64 characters;
  - trailing stops by percent or ticks, and `trailing_stop_limit`;
  - `moc`, `moo`, `loo`, `loc`, `lit`, `mtl`, `auction` and `vol`;
  - GTD on a date (only an instant is sent);
  - an order with `constraints`, or a stop with `adjust`;
  - a group entry that is not `Market` or `Limit`;
  - a multibracket entry that is not `Limit`, or one with a stop-limit or a tranche with no take;
  - an OCO with no take.
- **Sessions.** `SessionSet::regular_only()`; there is no extended-hours flag.
- **Measured order behaviour** (bracket offsets, `modifyorder` versions, `isAutomated`): README [Orders](https://docs.taji.is/catalog/tradovate.md#orders).
- **Data probes** (the tiers and the chain): README [Data](https://docs.taji.is/catalog/tradovate.md#data).

## Examples

**A sign-in, as Taji sends it**, from `plugins/tradovate/tests/egress/login.txt` (synthetic values; markers already substituted):

```
http POST /v1/auth/accesstokenrequest
content-type: application/json
body {"appId":"Taji","appVersion":"0.1.0","cid":"cid-test","deviceId":"device-test","name":"name-test","password":"pw-test-login","sec":"sec-test"}
```

**A renewal inside the last 15 minutes, then a read on the new token**, from `plugins/tradovate/tests/egress/renew.txt`:

```
http GET /v1/auth/renewaccesstoken
authorization: Bearer at-test-one

http GET /v1/account/list
authorization: Bearer at-test-two
```

**The sync socket's opening**, from `plugins/tradovate/tests/egress/sync.txt`, with the account id masked:

```
handshake /v1/websocket
frame authorize
0

at-test-one

frame user/syncrequest
1

{"accounts":[p1],"entityTypes":["order","orderVersion","fill","position","executionReport","command","orderStrategy","orderStrategyLink","cashBalance","accountRiskStatus"]}
```

**A limit placed and cancelled**, from the test `a_limit_is_placed_working_and_cancelled` in `plugins/tradovate/src/broker.rs`, with ids masked. Taji sends:

```json
POST /v1/order/placeorder
{"accountSpec": "<ACCT>", "accountId": p1, "action": "Sell", "symbol": "MNQZ6",
 "orderQty": 1, "isAutomated": false, "orderType": "Limit", "price": 21000.25,
 "timeInForce": "Day", "clOrdId": "p3"}
```

The venue answers `{"failureReason": "Success", "orderId": p2}`, and `place` answers a snapshot whose `order_id` is `p2` and whose `state` is `pendingnew`. The cancel Taji sends is `POST /v1/order/cancelorder {"orderId": p2, "clOrdId": "cancel:p2"}`.

**A bracket**, from the test `a_bracket_oto_and_oco_mark_every_leg_manual` in `plugins/tradovate/src/broker.rs`:

```json
POST /v1/order/placeoso
{"accountSpec": "<ACCT>", "accountId": p1, "action": "Buy", "symbol": "MNQZ6",
 "orderQty": 1, "isAutomated": false, "clOrdId": "p3", "orderType": "Limit",
 "price": 21000.0, "timeInForce": "Day",
 "bracket1": {"action": "Sell", "clOrdId": "p3:tp", "isAutomated": false,
              "orderType": "Limit", "price": 21100.0, "timeInForce": "Day"},
 "bracket2": {"action": "Sell", "clOrdId": "p3:sl", "isAutomated": false,
              "orderType": "StopLimit", "stopPrice": 20900.0, "price": 20890.0,
              "timeInForce": "Day"}}
```

**The kernel's answer for a Tradovate account**, the `accounts` row of `engine/crates/taji/tests/fixtures/wire/trading-book.json` (trimmed):

```json
{"brokerage": "tradovate", "id": "tradovate_live_xxxx", "kind": "futures",
 "classes": ["future"], "equity": "50000", "buying_power": "40000", "cash": null,
 "margin": {"admin_action": null, "auto_liq_level": "25000.00", "initial": "5000.00",
            "liquidation_only": false, "maintenance": "4500.00", "used": "5000.00", …},
 "state": "bound", "tail": "XXXX", …}
```

**What `data/coverage` says for futures**, from the `provider: "tradovate"`, `class: "future"` row of `engine/crates/taji/tests/fixtures/wire/data-coverage.json` (trimmed):

```json
{"provider": "tradovate", "class": "future", "serves": true,
 "reads": {"history": ["search", "instrument", "details"], "live": [], …},
 "offered_data": {"live": ["bars", "trades", "quotes", "depth"],
                  "note": "bars, quotes, depth and trades ride the md socket, which needs a CME sub-vendor agreement Taji has not signed", …}}
```

There is no capture yet of a real vendor answer or of the kernel's answer to a Tradovate placement. `plugins/tradovate/scripts/tradovate_walk.py <port> order` against the demo host prints both.

## Testing

- **Offline, no key.** `cargo test -p taji-tradovate` runs:
  - the unit tests in `src/`, against a wiremock vendor (sign-in, renewal, penalties, holds, budgets, order bodies, folds, the socket);
  - the egress goldens in `plugins/tradovate/tests/egress.rs`. Rewrite a golden with `EGRESS_RECORD=1` only when the change to what leaves is intended.
- **Kernel side, no key:**
  - `cargo test -p taji-trading --lib tradovate`: the hub's search and instrument on the seated session, the gate, and the link check;
  - `cargo test -p taji --lib tradovate`: the link verb, and the paper row it lists.
- **Against the vendor, demo host only.** Both need `TRADOVATE_NAME`, `TRADOVATE_PASSWORD`, `TRADOVATE_CID` and `TRADOVATE_SEC`, from the process or the `.env` that `TAJI_LIVE_ENV` names; with them absent, each prints `SKIP`. Run them one at a time, so no run trips the hour lockout:
  - `cargo test -p taji-tradovate --test chain_live -- --ignored --nocapture` (`CHAIN_OUT=<file>` saves the raw answer);
  - `cargo test -p taji-tradovate --test tiers_live -- --ignored --test-threads=1 native_tiers_on_tajis_grid --nocapture`.
- **No `tests/live.rs`.** `vendor_live.sh` runs two legs instead: `tiers_live native_tiers_on_tajis_grid` and `chain_live the_demo_chain_of_es_front_month_carries_its_contracts`.
- **The walk.** `python3 plugins/tradovate/scripts/tradovate_walk.py <port> <phase>` drives a headless kernel you start yourself (`AGENTS.md`).
  - The phases are `link`, `account`, `margin`, `order`, `bracket`, `oco`, `plan`, `multibracket`, `fees`, `reference` and `cleanup`.
  - It refuses any row but `tradovate_paper_*`, and stops if a live Tradovate row is linked.
  - The fill-dependent parts of `multibracket` and `fees` run only in a CME session.
  - Its header lists the env it needs.

## References

Fetched 2026-12-02. `partner.tradovate.com` now redirects to `partner.ninjatrader.com/connect`.

- Environments: https://partner.ninjatrader.com/connect/resources/reference/environments
- Auth overview: https://partner.ninjatrader.com/connect/overview/quick-setup/auth-overview
- Access token request: https://partner.ninjatrader.com/connect/api/rest-api-endpoints/authentication/access-token-request
- Renew access token: https://partner.ninjatrader.com/connect/api/rest-api-endpoints/authentication/renew-access-token
- Rate limits: https://partner.ninjatrader.com/connect/overview/core-concepts/rate-limits
- Penalty tickets: https://partner.ninjatrader.com/connect/overview/core-concepts/penalty-tickets
- Error handling: https://partner.ninjatrader.com/connect/overview/core-concepts/error-handling
- WebSocket connection overview: https://partner.ninjatrader.com/connect/overview/core-concepts/web-sockets/connection-overview
- User sync: https://partner.ninjatrader.com/connect/overview/core-concepts/web-sockets/user-syncrequest
- Market data: https://partner.ninjatrader.com/connect/overview/core-concepts/web-sockets/market-data/market-data
- Place order: https://partner.ninjatrader.com/connect/api/rest-api-endpoints/orders/place-order
- Place OSO: https://partner.ninjatrader.com/connect/api/rest-api-endpoints/orders/place-oso
- Start order strategy: https://partner.ninjatrader.com/connect/api/rest-api-endpoints/orders/start-order-strategy
- Modify order strategy: https://partner.ninjatrader.com/connect/api/rest-api-endpoints/orders/modify-order-strategy
- Contract suggest: https://partner.ninjatrader.com/connect/api/rest-api-endpoints/contract-library/contract-suggest
- Cash balance snapshot: https://partner.ninjatrader.com/connect/api/rest-api-endpoints/accounting/get-cash-balance-snapshot
- Device ids: https://github.com/tradovate/example-api-faq/blob/main/docs/UnderstandingDeviceId.md
- API reference with the embedded OpenAPI (renders client-side; its spec text did not fetch as a page): https://api.tradovate.com/
