Skip to content
Skip to main content

Developer documentation

Quickstart Recipes

Runnable Python and TypeScript examples for the core TradeZero API workflows - from your first authenticated request through orders, locates, options, and streaming. Open any recipe to copy code and follow step-by-step guidance.

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

Authenticate with the API, discover your accounts, and learn the request patterns used throughout the documentation.

Account & Monitoring

Build dashboards, fetch account data in parallel, and track order status - keep your application synchronized with account state.

Short Selling & Locates

Easy-to-borrow checks, locate quotes, accept, and credit-back - the complete short-selling workflow 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 symbols you select, request locate quotes for the hard-to-borrow names in parallel, poll a single history response to classify all outcomes at once, then accept the offers that meet your rate criteria.

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, request locate quotes in parallel for hard-to-borrow names, accept or cancel offers against a rate threshold you set, then confirm a clean inventory snapshot before market open.

Equity Orders

Submit, cancel, and replace equity 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

Validate account status, available cash, route capability, existing position, and option trading level - *before* you submit POST /order. Catches the primary 4xx rejections upfront 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

clientOrderId Dedup and Safe Retry

Never submit the same order twice. Generate a stable clientOrderId before the first attempt, reconcile with GET /order/{clientOrderId} after transport failures, and use a fresh id only when the server never registered the first attempt - deduplication, not Stripe-style idempotency.

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

Close every open position when you choose to. Walk each 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 orders, and multi-leg spreads through the TradeZero Options API.

WebSocket Streams (Beta)

Real-time profit-and-loss and portfolio streams over WebSocket. Beta - design for schema updates on a normal release cycle.