Trading API
The minimum trading integration is a TradingBrokerAdapter that reports account state and accepts orders; the account manager, order ticket, and position UI light up from its capabilities.
Search 322 supported trading contracts below. Expand a result to see its TypeScript declaration, properties, methods, parameters, return values, and errors. Share a filtered URL or a symbol anchor when another engineer needs the same contract.
Start here
TradingBrokerAdapter— the broker contract — orders, positions, executions, and account stateTradingState— Complete broker-owned trading snapshot the trading controller maintains: connection, accounts, orders, positions, executions, and optional history and balance collections.TradingOrder— A broker order record carried in trading state: identity, routing, pricing, lifecycle status, bracket links, and provider metadata.TradingPosition— One broker net position, tracked inTradingState.positionsand rendered as on-chart position lines and Account Manager rows.TradingExecution— One broker execution (fill) record carried inTradingState.executionsand rendered as execution markers on the chart.- Trading quickstart and integration surfaces
- Production broker integration
Browse the reference
Classes 2
Session-scoped authority for model-authored strategy proposals. The controller validates opaque model output, applies revision guards, and can request human approval for one exact canonical digest. It owns no execution or approval-grant operation, so an agent cannot turn its own proposal into a trade.
Canonical SDK trading controller that wraps a host-supplied
TradingBrokerAdapter behind entitlement, authorization, and host risk-policy gates, maintains a normalized TradingState from broker events, and renders trading overlays (position entry lines, execution markers) on attached charts. Hosts create one per broker session to drive order tickets, account panels, and on-chart trading UI.Interfaces 170
Framework-neutral account-panel mount contract.
Framework-neutral account-summary mount contract.
Framework-neutral account-action-dialog mount contract.
Typed renderer state for a broker-backed execution marker. It is carried by a trading-line resource and never becomes a public drawing-tool entitlement.
Resolved renderer style carried by one broker-backed execution marker.
Framework-neutral depth-ladder mount contract.
Framework-neutral facts describing one built-in Buy/Sell selector choice.
Framework-neutral context for a host-owned Buy/Sell selector override.
Framework-neutral order-ticket-launcher mount contract.
Live calculated facts shared by declarative and renderer-specific order-info adapters.
Framework-neutral context for a host-owned complete order-info override.
Calculated order and account values available to declarative order-info rows.
Framework-neutral order-ticket mount contract. React render extensions stay on the component props.
Stable identity and presentation overrides shared by every order-info row.
Row ordering and presentation options for the order ticket's information section.
Typed renderer state for a broker-backed position entry line. This remains a trading resource: the chart controller materializes it through trading-line CRUD rather than exposing the internal renderer as a customer-placeable drawing tool.
Visible panel titles used by the composed broker trading terminal.
Which panels the terminal composes. The chart is always present. Agent Chat and Agent Console are independently selectable. The fresh complete Agent Workspace places Watchlist, Chart, Order ticket, and Agent Console on top, with Account, Agent Chat, Market depth, and Time & Sales below. Chat and Account are distinct groups; Console has Time & Sales below it. Partial configurations keep Chat independent, with a 260px bottom split when Account is absent. A restored arrangement takes precedence.
Optional account and market-session content rendered in the terminal status bar.
Framework-neutral options accepted by the complete broker trading terminal SDK surface.
Framework-neutral watchlist mount contract. Row rendering stays on the component props.
Watchlist row facts and default DOM content supplied to a host row extension.
Snapshot of the trading controller's open on-chart order draft, carried by the
order-draft-open and order-draft-change trading events so the chart layer and any order-ticket widget share one source of truth.Options for
ChartApi.createOrderLine / ChartApi.createPositionLine / ChartApi.createExecutionShape.Live handle to an execution mark created with
ChartApi.createExecutionShape.Stable, JSON-safe definition of one chart-owned execution mark: the full execution state plus its id and kind discriminant. One member of the
TradingLineDefinition union.Canonical serializable state for an execution mark.
Strategy proposal that needs more facts before it can be normalized.
Framework-neutral option-chain mount contract. React cell renderers stay on the component props.
Semantic option quote and selection facts supplied to a provider-metric cell.
Provider-metric cell facts plus the SDK-rendered default DOM content.
Host-defined provider metric displayed as an option-chain column.
Host/provider bridge mapping a complete option-contract resource identity to a normal chart symbol selection. Contract-to-chart mapping is a host-composition concern: the market-data feed never depends on broker-domain contracts, and the chart never parses OCC or provider strings. The bridge owner returns the exact selection its catalog resolves — typically carrying a provider-owned
selectionId (and, on resolution, an instrument: { kind: 'option', ... } details block) so the contract's resource identity round-trips losslessly. The returned selection is a normal SymbolSelection: hosts feed it to ChartApi.setSymbol, which resolves it through the SDK's shared symbol resolver exactly like any other selection.Shared option-ticket state supplied to host DOM extension callbacks.
Framework-neutral option-order-ticket mount contract. React regions stay on the component props.
Option-ticket state and default content supplied when overriding a semantic region.
One host-owned DOM section inserted at a stable option-ticket placement.
Option-ticket state plus the identity and placement of one custom section.
Live handle to an order line created with
ChartApi.createOrderLine. Every setter mutates the on-chart line in place and returns this for chaining; every callback is invoked with no arguments (read the current state through the getters). The handle must not be used after remove.Serializable order-line record:
OrderLineState plus stable identity. Used by the controller's trading-line CRUD and carried in TradingLineChangePayload snapshots.Canonical serializable state for an order line.
Live handle to a position line created with
ChartApi.createPositionLine.Serializable position-line record:
PositionLineState plus stable identity. Used by the controller's trading-line CRUD and carried in TradingLineChangePayload snapshots.Canonical serializable state for a position line.
Presentation options for event, market, trading-close, and resolution details.
One exact outcome token and its provider-owned quote within a prediction market.
Quote snapshot whose identity is statically tied to a prediction outcome symbol.
Live semantic state and actions supplied to host-owned prediction-ticket extensions.
Prediction-ticket state and default content supplied when overriding a semantic region.
One retained framework-neutral DOM section inserted at a stable ticket placement.
Prediction-ticket state plus the identity and placement of one custom section.
Successfully normalized paper-strategy proposal and its canonical identity.
Host-reported per-account utilization facts consumed by the daily-loss and order-frequency limit checks.
Exact risk-owned facts consumed by host policy and narrower agent sessions.
One machine-readable reason attached to a risk decision receipt, explaining a rejection, an approval requirement, or the autonomy disposition applied.
Immutable, sequenced evidence record for one risk decision: the outcome, the policy and utilization versions in force, the frozen normalized request, and every reason that fired.
Cursor-style query over the controller's bounded in-memory decision-receipt window.
Fields shared by every risk decision request: the evidence identity, request timing, and the exact account, instrument, session, and environment facts checked against the policy scopes.
Attributed request to engage or clear the risk kill switch; both fields are validated as non-empty and recorded in the resulting emergency state.
Current kill-switch posture of the risk controller; while engaged, every evaluation gains an 'emergency.kill-switch-engaged' reason and is rejected.
Risk decision request for a leverage change, checked against the policy scopes and the
maxLeverage limit; the market-data-age and slippage limits do not apply to this kind.Risk decision request for an order that adds or changes exposure, carrying the proposed order facts plus the host-projected post-fill position exposure. Evaluated against the policy's side, order-type, quantity, notional, slippage, and market-data-age constraints.
Agent-facing risk authority. Host-only reset and lifecycle stay on the host interface below.
Construction options for
createRiskPolicyController: the host-authored policy envelope and the host utilization source, plus an optional injectable clock and receipt-window capacity.One complete host-authored envelope. Nothing is inferred from ticket or chart defaults.
Host retains this concrete authority; it is deliberately not registered as an agentic contract.
The complete set of numeric risk limits carried by a policy envelope; every key must be present, each either a finite non-negative number or
null for an explicitly unbounded host limit.Frozen snapshot of a risk policy controller: the host and effective policy envelopes, current utilization and emergency state, and the recent decision evidence window.
Options for
RiskPolicyControllerApi.subscribe controlling initial delivery.Host-owned current facts. The controller validates and relays; it never reconstructs them.
Host-implemented feed of current utilization facts consumed by the risk controller, which validates and relays each snapshot but never reconstructs the numbers itself.
Risk decision request for changing a position's protective coverage (stops/brackets), evaluated against the unprotected-quantity and market-data-age limits.
One host-reported open-position exposure row inside a
RiskPolicyUtilization snapshot, keyed by account and instrument.Host-facing request for human approval of one exact canonical strategy draft.
Notification emitted after a proposal or approval-request mutation commits.
Immutable proposal state published by the strategy draft controller.
Stable machine-readable validation issue; messages are UI-ready but never semantic authority.
Strict, declarative strategy grammar accepted from an untrusted model. It deliberately contains no executable source, callback, or live-trading mode.
Versioned indicator authority pinned to the canonical TradeScript TA runtime. EMA reads completed-bar close, seeds from the first close, and uses alpha=2/(period+1). ATR uses gap-aware true range (falling back to high-low when previous close is unavailable) and Wilder RMA seeded from the first period mean. A different algorithm requires a new strategy schema contract.
One broker account exposed to the trading subsystem and Account Manager, carrying its identity, balance, and per-account capability declaration.
Account-level balance figures shown in trading UI; monetary values are denominated in
currency.Structural per-account declaration of supported trading features — order types, durations, bracket and protective-stop support, and ticket configuration — used to shape the order ticket and overlays for that account.
A
TradingOrder narrowed to a bracket (protective child) order that is guaranteed to be linked to a parent order rather than a position.The broker integration contract a host implements to connect its trading backend to the SDK. A trading controller wraps this adapter, so only
getState and placeOrder are required; every other capability is optional and its absence narrows what the controller declares as supported.Broker-native scope and idempotency facts for atomic emergency mutations.
Connection details reported by a broker adapter, resolved from
connect and carried on connection-status trading events.Options accepted when creating a trading controller, covering initial chart attachment plus notification and modify-order-context policies.
Style overrides for the native pre-trade order-draft overlay lines. Extends the base line-style patch with per-kind patches (entry, take-profit, stop-loss) and per-side patches applied once a draft side is selected.
Intent snapshot of a pending
trading.editIndividualPositionBrackets mutation, handed to the host's editIndividualPositionBrackets factory to build the RiskPositionProtectionDecisionRequest evaluated before the broker call.Scope for an account-equity subscription passed to
subscribeEquity.One equity leg in a canonical multi-instrument strategy draft.
One broker execution (fill) record carried in
TradingState.executions and rendered as execution markers on the chart.Style overrides for broker-backed execution markers: buy/sell accent and arrow colors, marker shape and geometry, and label typography, text, and opacity.
Default distances the native order draft seeds a clicked take-profit or stop-loss leg at, set under
ChartOverrideSettings.trading.exitDefaults and editable from the chart settings modal's Trading section. Unset values fall back to the built-in seed (0.25% of the entry price, floored at one price step). Dragging a leg to an exact price is never affected.Asynchronous runtime/account feature metadata. These facts may narrow whether a structurally supported operation is eligible in the current context, but they never widen
TradingControllerOperationSupport.One audited financial mutation.
requested is emitted before any risk evaluation, so an attempt is recorded even when it is refused; authorized and rejected carry the host risk decision that settled it.Guarded operation identity carried explicitly from the agentic registry.
Optional protocol-neutral identity injected only by a guarded agentic call.
Callback surface the SDK passes to a broker adapter in
connect. The adapter uses it to push notifications, replace trading state, emit events, and write log entries back into the controller.One individual (non-netted) position for brokers that report per-entry positions alongside net positions. Carried in
TradingState.individualPositions and shown in the Account Manager's Individual positions view.Broker leverage facts for a symbol/side/order-type route: the current leverage plus the allowed selection range. Returned by
leverageInfo and used to drive leverage UI.Route parameters identifying which leverage setting is being queried: account, symbol, order side, and order type. Passed to
leverageInfo and extended by TradingLeverageSetParams.Outcome of previewing a leverage change via
previewLeverage: broker message lists describing the proposed change without applying it.Parameters for previewing or applying a leverage change: the leverage-info route plus the requested leverage value. Passed to
previewLeverage and setLeverage.Result of
setLeverage, reporting the leverage now in effect at the broker. Also carried on the leverage-change trading event.Payload of the
trading-line-change chart event, describing one mutation to a chart-owned trading line together with the complete post-mutation snapshot.Filter accepted by
listTradingLines to narrow which chart-owned trading lines are returned.Style overrides for broker order and position overlay lines. Extends the base line-style patch with conditional patches keyed by side, activity, order type, status, class, role, and P&L state, plus ordered
stateStyles rules where later matches win.One diagnostic entry in the trading controller's log, written via
TradingHost.log or by the SDK itself and read back with getLogs.Scope for a
subscribeMarginAvailable subscription: the symbol whose available margin to stream, optionally pinned to one account.One persisted trading message in the
TradingState.messages history, optionally linked to an order or position. Delivered incrementally via the message trading event.Intent snapshot of a pending
trading.modifyOrder mutation, handed to the host's modifyOrder factory to build the RiskOrderDecisionRequest evaluated before the broker call.Intent snapshot of a pending
trading.modifyPosition mutation, handed to the host's modifyPosition factory to build the RiskPositionProtectionDecisionRequest evaluated before the broker call.A transient user-facing trading notification pushed through
TradingHost.notify and delivered on the notification trading event, typically rendered as a toast by the host.Per-channel switches for native trading notifications: transient
notification events for host toast surfaces and persisted message history in TradingState.messages. Both channels default to enabled.Canonical option-contract identity used by option and mixed-instrument order legs.
Broker-owned option-contract resolution returned without SDK-side identity reconstruction.
One option leg in a canonical option order draft.
Related pages
- Broker Adapter — the staged implementation path for this contract
- Orders — the order state machine these methods drive
- Order Ticket Configuration — the declarative field schema brokers publish