Skip to main content

Instruments & prices

Symbols​

GET /api/v1/symbols/me lists every symbol your account can trade, with the settings of your group (spread, lot limits, margin). Load it once at startup and cache it by id.

To fetch one symbol by name:

curl "https://api.onlytradeplatform.com/api/v1/symbols/me/by_name?symbol=EURUSD" \
-H "Authorization: Bearer $TOKEN"

GET /api/v1/symbols/me/tree returns the same symbols grouped by class (Forex, Metals, Indices…).

Fields a bot needs​

FieldMeaning
idNumeric ID. Orders, positions and price ticks use this.
symbol, descName (e.g. EURUSD) and description.
digitsPrice decimals. Round every price you send to this. One point = 10^-digits.
contract_sizeUnits per 1.0 lot (e.g. 100000 for FX).
min_value, max_valueSmallest and largest order, in lots.
stepLot increment. Round volumes to it yourself — the server only checks min/max.
stop_levelMinimum SL/TP distance in points. See SL/TP rules.
trade_level0 full access, 1 buy only, 2 sell only, 3 close only, 4 disabled.
ordersComma-separated order kinds allowed: 0 market, 1 limit, 2 stop, 3 stop loss, 4 take profit, 5 close-by.
expirationComma-separated expiration policies allowed for pending orders.
status0 enabled, 1 disabled; higher values mean closed or expired.
trade_sessions, quote_sessionsWhen the symbol trades and quotes. Orders outside trading hours are rejected with the market is closed for ….
spreadYour group's spread setting.
swaps_enabled, swap_long, swap_short, swap_typeOvernight financing.
margin_initial, calculationHow margin is computed.
last_bid, last_askThe last price when you made the request — handy at startup, but use the WebSocket for live prices.

A helper to prepare an order:

def round_price(price, digits):
return round(price, digits)

def round_volume(volume, sym):
steps = round(volume / sym["step"])
vol = round(steps * sym["step"], 8)
return min(max(vol, sym["min_value"]), sym["max_value"])

Historical candles​

GET /api/v1/market/history returns OHLC bars for one symbol. Use it to warm up indicators before you switch to live ticks.

ParameterRequiredNotes
symbol_idyesSymbol ID.
resolutionyes<n>m, <n>h, <n>d, <n>w or <n>mo — e.g. 1m, 5m, 15m, 1h, 4h, 1d, 1w, 1mo.
from, toyesUnix time in seconds.
count_backyesMaximum number of bars to return. Must be > 0 — with 0 you get an empty list.
typenobid (default) or ask.
NOW=$(date +%s)
curl "https://api.onlytradeplatform.com/api/v1/market/history?symbol_id=26100001&resolution=1m&from=$((NOW-86400))&to=$NOW&count_back=300" \
-H "Authorization: Bearer $TOKEN"
{
"success": true,
"code": 200,
"data": [
{ "time": 1781251140000, "open": 1.08210, "high": 1.08241, "low": 1.08205, "close": 1.08232, "volume": 184 },
{ "time": 1781251200000, "open": 1.08232, "high": 1.08250, "low": 1.08221, "close": 1.08238, "volume": 97 }
]
}

Bars are oldest first; time is the bar's open time in Unix milliseconds. The last bar is usually still forming.

Live prices​

Live prices come only from the WebSocket. After you connect, send once:

{ "type": "start_market_feed", "payload": {} }

and you receive a tick for every symbol as it changes. Ticks are compact binary frames containing a CSV line, not JSON:

26100001,1.08232,1.08244,1.08301,1.08012,1.08120,1.08232,0,1781251234567,1781251234570,1781251234571
ColumnField
0symbol_id
1bid
2ask
3–6high, low, open, close as reported by the price provider
7volume
8ts — tick time, Unix ms
9, 10internal latency stamps — ignore

Prices already include your group's spread, so the ask is what you'd buy at and the bid what you'd sell at. Filter by symbol_id for the symbols you trade. See WebSocket → Subscribing.

There is no order book (depth) or live candle stream. Build bars from ticks yourself, as the bot example does.