Upscale
Menu
On this page

Создать новый ордер

Попробовать ↓
POST/orders
Создать новый ордерТорговля

Размещает ордер и возвращает его в том виде, в котором его сохранил торговый движок. Ордера на увеличение (market, limit, stop_market, stop_limit) открывают или увеличивают позицию; ордера закрытия (stop, take, trailing_stop) привязываются к существующей позиции через positionId.

amount читается в разных единицах для каждого из двух: в ордере на увеличение это сумма в котируемой валюте, зарезервированная из свободного баланса; в ордере на закрытие это размер базового актива позиции для закрытия, при этом ничего не резервируется. Остальные поля размера (expectedAmount, sizeMode, baseSize, leverage) относятся только к ордерам на увеличение.

Помимо схемы на уровне полей, запрос проверяется на:

  • Форма для типа. Каждое отклонение здесь — это 400, код которого указывает на проблемную комбинацию полей:
    • размер — amount_not_positive, base_size_required, base_size_negative, base_size_not_allowed;
    • плечо — leverage_required, leverage_negative;
    • цена триггера — trigger_price_required, trigger_price_negative;
    • стоп-лосс / тейк-профит, привязанные к ордеру на увеличение — stop_trigger_price_negative, take_trigger_price_negative, stop_trigger_price_gt_trigger_price, stop_trigger_price_lt_trigger_price, take_trigger_price_gt_trigger_price, take_trigger_price_lt_trigger_price;
    • цена стоп-лимит — stop_limit_price_required, stop_limit_price_negative, stop_limit_price_gt_trigger_price, stop_limit_price_lt_trigger_price;
    • трейлинг-стоп — trailing_stop_activation_price_negative, trailing_stop_offset_required, trailing_stop_offset_conflict, trailing_stop_offset_negative, trailing_stop_offset_percent_negative, trailing_stop_offset_percent_gte_one;
    • ордера на закрытие — position_id_required.
  • Плечо ордера на увеличение. Должно оставаться в границах рынка: не ниже минимума рынка и не выше максимума фазы, с invalid_leverage (leverage плюс minLeverage или maxLeverage в теле).
  • Аккаунт. Должен принадлежать вызывающему и находиться в торговом статусе; ордера на увеличение дополнительно отклоняются, пока аккаунт заблокирован лимитом управляемого капитала, и требуют, чтобы amount был доступен как свободный баланс.
  • Рынок. Должен быть открыт и относиться к категории, в которой аккаунт может торговать (crypto или RWA). Рынок только для закрытия принимает только take-ордер, созданный без триггерной цены.
  • Позиция, когда задан positionId: она должна существовать (position_not_found), быть открытой, находиться на том же аккаунте, принадлежать тому же рынку и иметь то же направление, что и ордер (position_not_available).
  • Триггерная цена, относительно текущей рыночной цены и — для stop / take — относительно цены ликвидации позиции (trigger_price_gt_current, trigger_price_lt_current, trigger_price_gt_liquidation, trigger_price_lt_liquidation). market-ордер с прикреплённым стоп-лоссом / тейк-профитом проверяется относительно цены ликвидации, которая будет у его позиции после исполнения: market_price_unavailable когда нет текущей цены для проверки, order_validation_invariant когда поля размера, необходимые для этого прогноза, отсутствуют.
  • Нотионал ордера на увеличение. (amount − fee) × leverage должен укладываться в максимальный открытый нотионал, который рынок допускает в этом направлении (order_exceeds_max_open_notional).

Отложенный ордер здесь не исполняется, поэтому он всё ещё может завершиться ошибкой, когда позже сработает его триггер: тогда он получает статус canceled_by_error и errorCode (insufficient_reserve_at_execution, order_below_min_notional, order_exceeds_market_depth, order_exceeds_max_open_notional, order_zero_size_at_execution, slippage_tolerance, market_close_only_at_execution), а его резерв освобождается.

Отправьте заголовок x-idempotency-key, чтобы сделать вызов безопасным при повторной отправке: в пределах окна повторной отправки, указанного в этом заголовке, тот же ключ на том же маршруте воспроизводит сохранённый ответ (помеченный X-Idempotency-Cached: true и X-Idempotency-Timestamp) вместо повторного выполнения, а второй вызов, поступивший, пока первый всё ещё выполняется, получает 409 (idempotency_key_in_flight).

Базовый URL https://api.upscale.trade

Авторизация

bearerhttp · bearerобязательно

Персональный API-ключ с префиксом usk_.

Параметры

Заголовок
x-idempotency-keystringнеобязательно

Ключ идемпотентности — любая непрозрачная строка, uuid v4 хорошо подходит. Повторный вызов с тем же ключом на этом маршруте в течение 1 часа воспроизводит сохранённый ответ вместо повторного выполнения; при воспроизведении возвращаются X-Idempotency-Cached: true и X-Idempotency-Timestamp. Чтобы отказаться, не указывайте заголовок.

Пример: 9f1c2b7e-5a3d-4f61-9b0e-2c7d4a8e1f35

Тело запроса · обязательно

accountIdstring · uuidобязательно

Trader account the order is placed on. Must belong to the caller.

pattern
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$
Пример: 00000000-0000-4000-8000-000000000000
marketIdstring · uuidобязательно

Market the order is placed on, as returned by GET /v2/markets.

pattern
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$
Пример: 00000000-0000-4000-8000-000000000000
typestring · enumобязательно

Order type. Increase (position-opening) types: market, limit, stop_market, stop_limit. Close types, attached to an existing position: stop, take, trailing_stop. liquidation is raised by the platform itself and add_margin / remove_margin are legacy — none of the three is accepted here.

Допустимо: "market" "limit" "stop" "trailing_stop" "take" "stop_limit" "stop_market"
Пример: market
directionstring · enumобязательно

Order direction. For a close order it must match the direction of the position it is attached to.

Допустимо: "long" "short"
Пример: long
amountstring · int32обязательно

What the order is sized by, fp9 raw — the unit depends on the order class. On an increase order (market, limit, stop_market, stop_limit) it is a quote amount reserved from the free balance (margin, fee, spread and buffer): the account must hold at least this much, and the reserve is released when the order is cancelled. On a close order (stop, take, trailing_stop) it is the base asset size of the position to close and nothing is reserved; a size larger than the position holds closes it in full.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 100000000000
Необязательные поля: 12
positionIdstring · uuid · nullableнеобязательно

Position a close order (stop, take, trailing_stop) is attached to. Required for those types, ignored for increase orders.

pattern
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$
Пример: 00000000-0000-4000-8000-000000000000
expectedAmountstring · int32 · nullableнеобязательно

Slippage tolerance for increase orders: the position size the caller expects for amount, fp9 raw. Execution outside the tolerance fails with slippage_tolerance. Omitted or 0 — no tolerance check. Not applicable to close orders.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 0
leveragestring · int32 · nullableнеобязательно

Leverage, fp9 raw (10000000000 = 10x). Required for increase orders and must be within the leverage bounds of the market.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 10000000000
triggerPricestring · int32 · nullableнеобязательно

Price at which the order fires, fp9 raw. Required for limit, stop, take, stop_market and stop_limit, and rejected for market. For stop / take, 0 means the order is created without a trigger and can be set later.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 65000000000000
stopTriggerPricestring · int32 · nullableнеобязательно

Stop-loss attached to an increase order, fp9 raw. Must sit below the entry trigger price for long and above it for short.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
takeTriggerPricestring · int32 · nullableнеобязательно

Take-profit attached to an increase order, fp9 raw. Must sit above the entry trigger price for long and below it for short.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
trailingStopActivationPricestring · int32 · nullableнеобязательно

Price at which a trailing_stop starts trailing, fp9 raw. Omitted — the order trails from the moment it is created.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
trailingStopOffsetstring · int32 · nullableнеобязательно

Trailing distance as an absolute quote amount, fp9 raw. Exactly one of trailingStopOffset / trailingStopOffsetPercent is required.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
trailingStopOffsetPercentstring · int32 · nullableнеобязательно

Trailing distance as a fraction of price, fp9 raw and strictly below 1000000000 (100%). Exactly one of trailingStopOffset / trailingStopOffsetPercent is required.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 50000000
stopLimitPricestring · int32 · nullableнеобязательно

Limit price a stop_limit order is placed at once its trigger fires, fp9 raw. Required for that type; must be at or below the trigger price for long and at or above it for short.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
sizeModestring · enumнеобязательно

How the size of an increase order is expressed: quote (default) sizes it by amount, base sizes it by baseSize while amount stays the reserve. Increase orders only — a close order is always sized by amount in base asset units.

Допустимо: "quote" "base"
Пример: quote
baseSizestring · int32 · nullableнеобязательно

Order size in base asset units, fp9 raw. Required when sizeMode is base and rejected otherwise, and meaningful for increase orders only.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000

Примеры

curl --request POST 'https://api.upscale.trade/orders' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "accountId": "00000000-0000-4000-8000-000000000000",
  "marketId": "00000000-0000-4000-8000-000000000000",
  "type": "market",
  "direction": "long",
  "amount": "100000000000"
}'

Ответы

401

Неавторизовано

403

Аккаунт принадлежит другому пользователю (account_access_denied), или запрос аутентифицирован с помощью API-ключа, тогда как api_trading отключён на аккаунте (api_trading_not_enabled). Торговля на аккаунте завершена в его текущем статусе (challenge_closed), или аккаунт заблокирован лимитом управляемого капитала (funded_limit_trading_locked). Рынок приостановлен (market_paused) или принимает только ордера на закрытие (market_close_only).

404

Нет такого аккаунта, рынка или позиции.

409

Другой вызов с тем же x-idempotency-key всё ещё выполняется (idempotency_key_in_flight). Повторите попытку, когда он завершится.

429

Превышен лимит частоты запросов API-ключа (api_key_rate_limit_exceeded). Retry-After указывает, когда вернуться; тело содержит бакет (read / write), окно, которое сработало, его лимит и retryAt.

defaultОтветapplication/json
idstring · uuidобязательно

Order identifier.

pattern
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$
Пример: 00000000-0000-4000-8000-000000000000
txIdstringобязательно

Order identifier. Kept for backward compatibility, always equal to id.

Пример: string
traderstring · uuidобязательно

Trader account the order belongs to.

pattern
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$
Пример: 00000000-0000-4000-8000-000000000000
marketstring · uuidобязательно

Market the order is placed on.

pattern
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$
Пример: 00000000-0000-4000-8000-000000000000
statusstring · enumобязательно

Lifecycle state: active while it waits, executed once filled, canceled when cancelled by the trader or the platform, canceled_by_update when replaced by an edit, canceled_by_position when the position it was attached to went away, canceled_by_error when execution failed — see errorCode.

Допустимо: "active" "canceled" "canceled_by_update" "canceled_by_error" "canceled_by_position" "executed"
Пример: active
typestring · enumобязательно

Order type. liquidation marks an order the engine raised itself.

Допустимо: "market" "limit" "stop" "trailing_stop" "take" "stop_limit" "stop_market" "liquidation"
Пример: market
directionstring · enumобязательно

Order direction.

Допустимо: "long" "short"
Пример: long
triggerPricestring · int32обязательно

Price at which the order fires, fp9 raw. 0 when the order carries no trigger.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
requestedTriggerPricestring · int32 · nullableобязательно

Trigger price as requested, before the engine pushed it out to the minimum stop distance, fp9 raw. Null when the requested price was kept as is.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
stopPricestring · int32обязательно

Trigger price of a stop_market / stop_limit order, fp9 raw; 0 for every other type.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
limitPricestring · int32обязательно

Price the order is placed at once triggered, fp9 raw: the stop-limit price, falling back to the trigger price.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
stopTriggerPricestring · int32обязательно

Stop-loss attached to the order, fp9 raw. 0 when none is attached.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
takeTriggerPricestring · int32обязательно

Take-profit attached to the order, fp9 raw. 0 when none is attached.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
trailingStopActivationPricestring · int32обязательно

Price at which a trailing stop starts trailing, fp9 raw. 0 when it trails from creation.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
trailingStopOffsetstring · int32обязательно

Trailing distance as an absolute quote amount, fp9 raw. 0 when the distance is set as a percent.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
trailingStopOffsetPercentstring · int32обязательно

Trailing distance as a fraction of price, fp9 raw. 0 when the distance is absolute.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
leveragestring · int32 · nullableобязательно

Leverage of the order, fp9 raw. Null on close orders, which inherit the leverage of the position.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
indexstringобязательно

Order identifier. Kept for backward compatibility, always equal to id.

Пример: string
positionIdstring[]обязательно

Position a close order is attached to. Null for orders that open or grow a position.

Элементы массива · string

string

Посмотреть пример
[
  "string"
]
parentOrderIdstring[]обязательно

Order this one was spawned from: a stop or take created out of stopTriggerPrice / takeTriggerPrice, or the limit order a stop_limit turned into. Null when the order was submitted directly.

Элементы массива · string

string

Посмотреть пример
[
  "string"
]
expirationstring · date-time · nullableобязательно

Always null. Kept for backward compatibility — orders do not expire on their own.

Пример: 2026-05-01T12:30:00.000Z
amountstring · int32обязательно

Size of the order, fp9 raw, in the unit its class uses: on an increase order a quote amount — the reserve while it waits, and what it actually spent once executed; on a close order (stop, take, trailing_stop) the base asset size it closes, as requested at creation.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
indexPricestring · int32 · nullableобязательно

Index price the order executed at, fp9 raw. Null while the order has not executed.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
settlementOraclePricestring · int32обязательно

Always 1000000000 (1.0). Kept for backward compatibility.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
createdAtstring · date-timeобязательно

When the order was accepted.

Пример: 2026-05-01T12:30:00.000Z
errorstring[]обязательно

Always null. Kept for backward compatibility — use errorCode.

Элементы массива · string

string

Посмотреть пример
[
  "string"
]
realizedPnlstring · int32 · nullableобязательно

Pnl realised by this order, fp9 raw. Set only on an executed close order; null while pending and on orders that open or grow a position.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
rawRealizedPnlstring · int32 · nullableобязательно

Realised pnl before the 60-second adjustment, fp9 raw. Differs from realizedPnl only when the adjustment fired.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
profitAdjustmentAppliedbooleanобязательно

Whether the 60-second adjustment capped the profit of this order — inside a minute of an open or increase the position pnl cannot grow above what it was at that moment.

Пример: true
executedAfterPausebooleanобязательно

Whether the order executed after a market pause. Not set by the current engine — always false.

Пример: true
sizeModestring · enumобязательно

How the size was expressed on creation: quote sizes the order by amount, base sizes it by baseSize.

Допустимо: "quote" "base"
Пример: quote
baseSizestring · int32 · nullableобязательно

Order size in base asset units, fp9 raw. Null for quote-sized orders.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
reservedAmountstring · int32 · nullableобязательно

Quote amount reserved when the order with sizeMode=base was created, fp9 raw. Stays at the original reserve after execution, while amount is rewritten to what was spent. Null for quote-sized orders, where amount is the reserve.

pattern
^(?:-?[1-9][0-9]*|0)$
Пример: 1000000000
errorCodestring[]обязательно

Why execution failed, set together with status canceled_by_error — for example insufficient_reserve_at_execution, order_below_min_notional, order_exceeds_market_depth or slippage_tolerance. Null otherwise.

Элементы массива · string

string

Посмотреть пример
[
  "string"
]
reasonstring · enum · nullableобязательно

Why the platform cancelled the order itself, for example force_close or weekly_session_risk_close. Null for trader-driven cancellations.

Допустимо: "force_close" "stop_accounts_fail" "stop_accounts_freeze" "stop_accounts_promote" "stop_accounts_manual" "weekly_session_risk_close" null
Пример: force_close