Skip to main content
The Trading API trades on the exchange accounts you connected to TakeProfit, from your own code. Place, amend and cancel orders, close positions and protect them with take-profit/stop-loss over REST, and follow every order, fill, position and balance over WebSocket. It trades through the same connection as the platform’s order form, so you don’t share your exchange API keys with your script: the script signs its requests with a TakeProfit key of its own.

Create a trading key

A key with the trading scope and a private key that signs every request.

Quickstart

List your accounts, read an instrument’s rules, place an order and watch it fill.
Base URL: https://public-api.charting.com/api/v1/trading, for REST and WebSocket alike.

Endpoints

Each REST endpoint has its own page in the sidebar with every field.

How a request is put together

  • The account is its accountId, and the connector is its connectorCode, such as binance_spot or binance_usdm. Both come from GET /account/list. Every trading request names the connector, even when the account has only one.
  • The instrument is {"exchange": ..., "symbol": ...}, the same pair the market data Securities endpoints return, for example CXBNCE and BTC/USDT.
  • An order has exactly one of market and limit, and at most one of stop (conditional) and trailingStop. takeProfit and stopLoss attach to it.
  • Prices and quantities are decimal strings, such as "0.001", never JSON numbers. Check them against the order data stream first: the exchange rejects a price off the price step or a quantity below the minimum.
  • label tags the orders of one script. A bulk cancel narrowed to a label leaves your manual orders and other scripts’ orders alone, and the events stream can be filtered to it too.
  • Unknown fields are rejected with 400, so a typo fails loudly.

Requests are asynchronous

A 202 Accepted means TakeProfit checked the request and took it for processing. It doesn’t mean the order reached the exchange, was placed or was filled: the exchange can still reject it, for example for insufficient balance. Follow the outcome on the events stream. order, execution and position frames show what happened, and commandError and notification frames say why a request failed.

Retrying safely

502, 503 and 504 are temporary: retry with exponential backoff, and wait at least Retry-After when the response has it.

Connectors

Each connected account trades through one or more connectors, one per market: Binance, for example, has binance_spot and binance_usdm. Connectors differ in what they accept, and a field a connector doesn’t support is rejected. Read GET /connector/capabilities before building requests for a new connector. Take-profit/stop-loss is the field that differs most:
  • Bybit: attached to the order. On derivatives, once the order fills, it becomes a separate take-profit/stop-loss order on the position.
  • Binance spot: the order and its take-profit/stop-loss form one order list. It needs a limit order, and cancelling any part cancels the whole list.
  • Binance USD-M: not accepted on the order. Place the order, then protect the position with POST /position/add-tpsl.
  • Exness: price levels on the order and its position, not separate orders.

Cashback

Orders placed through the API trade on your connected account, so they earn cashback the same way as orders from the platform. userRebateRate in GET /account/list and in the order data snapshot is your cashback rate, and each execution frame on the events stream carries that fill’s cashback in userRebateUsdt.

Credits and limits

The Trading API draws on the same credits as the rest of the Platform API, shared by all keys of your account:
  • Every REST request costs 1,000 credits from the REST quota of 100,000 per 60 seconds. Only a successful request is billed.
  • Every stream costs 25 credits per 300-second window from the streaming quota, charged when it opens and again in every window it stays open.
  • At most 4 REST requests in flight per account. A fifth is rejected with 429.
  • At most 5 trading streams open per account. A sixth handshake is rejected with 429.

Errors

Every error has the same shape: