Skip to content
Skip to main content

Featured recipe

Place Your First Order

Authenticate, confirm credentials, check buying power, place a market order, and verify the status - your first end-to-end TradeZero integration.

In this recipe
  1. Authenticate
  2. Confirm credentials
  3. Check buying power
Open Recipe

Getting Started

Stand up your first authenticated TradeZero integration and learn the request shape every other recipe builds on.

Account & Monitoring

Real-time dashboards, parallel data fetching, and order-status notifications - production patterns for keeping your app in sync with the broker.

Short Selling & Locates

Borrow availability, locate quotes, and inventory management - the workflows specific to short selling on TradeZero.

5 steps

Locate Shares & Sell Short

Check Easy-To-Borrow, request and accept a locate quote for hard-to-borrow symbols, confirm the inventory landed, then open the short with `side: "Sell"` / `openClose: "Open"`.

3 steps

Cancel a Pending Locate

Locate quotes are not free - every offer ties up inventory. When the offered rate exceeds your threshold, cancel cleanly via `DELETE /locates/cancel/accounts/{id}/quoteReqID/{q}` and confirm the cancel landed in `/locates/history` before moving on.

4 steps

Handle Locate Rejections

Every locate rejection lands in `/locates/history` with `locateStatus: 56`. The `text` field tells you why. This recipe shows how to classify each rejection code and build the appropriate recovery path - skip ETB symbols, back off on "no inventory", and reuse live quotes instead of re-quoting when already pending.

4 steps

Reuse Locate Inventory

Check existing locate inventory before requesting a new quote. Pre-Borrow locates survive multiple short/cover cycles intraday - no re-quoting needed. Sell back unused inventory end-of-day to stop the billing clock.

4 steps

Select Between Pre-Borrow and Single Use

When a Reg SHO threshold symbol returns two locate offers - Pre-Borrow (`locateType: 3`) and Single Use (`locateType: 4`) - pick the one that minimises your borrow cost for your planned trade count.

4 steps

Cancel a Pending Sell-Back

After queuing a locate sell-back with `POST /locates/sell`, you can reverse the decision using the same `DELETE /locates/cancel` endpoint before the sell settles. The shares return to your `available` inventory.

5 steps

Locate a Basket of Symbols

Fan-out ETB checks across a list of short candidates, fire locate quotes for all hard-to-borrow names in parallel, poll a single history response to classify all outcomes at once, then accept only the offers that fit within your rate budget.

5 steps

Pre-Market Short Setup

A morning checklist for short sellers: check existing inventory for reuse, ETB-filter the entire watchlist in one parallel pass, fan out locate quotes for hard-to-borrow names, auto-accept or cancel on price, then confirm a clean inventory snapshot before market open.

Equity Orders

Submit, cancel, and cancel-and-replace single-leg stock orders - market, limit, stop, and stop-limit - with safe cleanup patterns.

5 steps

Place a Limit Order & Cancel It

Submit a resting limit buy far below the market, confirm it is on the book, cancel by `clientOrderId`, and poll until the order reaches a terminal state.

3 steps

Watch a Single Order to Completion

Place one order then poll `GET /order/{clientOrderId}` - a lightweight single-order endpoint that returns the result directly, without scanning all of today's orders or parsing `userOrderId`.

4 steps

Pre-Trade Validation

Run five guard rails - account status, available cash, route capability, existing position, option trading level - *before* `POST /order`. Eliminates the most common 4xx rejections and gives users every failure at once instead of one per retry.

3 steps

Route-Aware Order Submission

Query `GET /routes` to discover available execution venues, select the best one for your order characteristics, and pass the `route` field in `POST /order` to direct the order precisely.

4 steps

Stop-Loss On a Long Position

Look up an existing long position, size a stop relative to the average entry price, submit a Sell/Close stop order with `timeInForce: GoodTillCancel`, and verify it parks on the book.

4 steps

Use clientOrderId for Idempotency

Never submit the same order twice. Generate a stable `clientOrderId` before the first attempt, check `GET /order/{clientOrderId}` to dedupe client-side, and reconcile through the same key after any transport failure.

4 steps

Cancel All Open Orders

Use `DELETE /v1/api/accounts/orders` to flatten every working order in one call (optionally scoped by symbol), poll until terminal, and fall back to per-order cancellation when you need finer-grained subsets.

4 steps

Flatten All Positions

Emergency exit. Walk every row of `/positions`, build the inverse market order (longs → Sell/Close, shorts → Buy/Close, options use `tradedSymbol`), submit sequentially, and poll until the account is fully flat.

Options

OCC symbol construction, single-leg lifecycles, and multi-leg spreads against the TradeZero options API.

WebSocket Streams

Real-time P&L and portfolio updates over persistent WebSocket connections - live account dashboards and order-state tracking without polling.