/positions/{positionId}/marginПеремещает баланс в котируемой валюте в маржу открытой позиции или из неё, что вместе с этим изменяет её кредитное плечо и цену ликвидации.
- Позиция должна всё ещё быть открытой, а её счёт должен принадлежать вызывающей стороне и быть
active— счёт, заблокированный лимитом управляемого капитала, здесь отклоняется. - Рынок должен быть открыт и не находиться в режиме только закрытия.
marginChange: "0"принимается, и позиция возвращается без изменений.- Добавление суммы больше, чем покрывает свободный баланс, завершается ошибкой
insufficient_balance; снятие суммы больше, чем позиция может выделить, завершается ошибкойnon_positive_margin.
https://api.upscale.tradeПараметры
positionIdstring · uuidобязательноИдентификатор позиции. Его аккаунт должен принадлежать вызывающему.
00000000-0000-4000-8000-000000000000Тело запроса · обязательно
marginChangestring · int32обязательноSigned quote amount to move in or out of the position margin, fp9 raw. Positive adds margin and requires that much free balance, negative withdraws it and must keep the remaining margin positive. 0 is accepted and changes nothing.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000{
"marginChange": "1000000000"
}Примеры
curl --request PATCH 'https://api.upscale.trade/positions/{positionId}/margin' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"marginChange": "1000000000"
}'const response = await fetch("https://api.upscale.trade/positions/{positionId}/margin", {
method: "PATCH",
headers: {
"Accept": "application/json",
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: "{\n \"marginChange\": \"1000000000\"\n}",
});
console.log(response.status, await response.text());import requests
response = requests.request(
"PATCH",
"https://api.upscale.trade/positions/{positionId}/margin",
headers={"Accept":"application/json","Authorization":"Bearer YOUR_API_KEY","Content-Type":"application/json"},
data="{\n \"marginChange\": \"1000000000\"\n}",
timeout=30,
)
print(response.status_code, response.text)Ответы
Неавторизовано
Счёт принадлежит другому пользователю (account_access_denied), или запрос аутентифицирован с помощью API-ключа, в то время как api_trading отключён на счёте (api_trading_not_enabled). Счёт не находится в активном статусе. Рынок приостановлен (market_paused) или принимает только ордера на закрытие (market_close_only).
Нет позиции с этим идентификатором.
Превышен лимит частоты запросов API-ключа (api_key_rate_limit_exceeded). Retry-After указывает, когда вернуться; тело содержит бакет (read / write), окно, которое сработало, его лимит и retryAt.
defaultОтветapplication/json
idxstring[]обязательноPosition identifier. Same value as txId.
Элементы массива · string
string
Посмотреть пример
[
"string"
]txIdstring[]обязательноPosition identifier. Kept for backward compatibility, always equal to idx.
Элементы массива · string
string
Посмотреть пример
[
"string"
]versionnumberобязательноRevision of the position: incremented by every event applied to it.
0openedAtstring · date-timeобязательноWhen the position was opened.
2026-05-01T12:30:00.000ZlastUpdatedAtstring · date-timeобязательноWhen the last event was applied to the position.
2026-05-01T12:30:00.000ZclosedAtstring · date-time · nullableобязательноWhen the position was closed; null while it is still open.
2026-05-01T12:30:00.000Ztypestring · enumобязательноDirection of the position. Same value as direction.
"long" "short"longstatusstring · enumобязательноWhether the position is still open, closed by the trader, or liquidated.
"opened" "closed" "liquidated"openedmarketstring · uuidобязательноMarket the position is held 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-000000000000traderstring · uuidобязательноTrader account the position 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-000000000000sizestring · int32обязательноPosition size in base asset units, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000notionalstring · int32обязательноOpen notional of the position in quote currency, fp9 raw — size at entry price.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000fractionstring · int32обязательноAlways 0. Kept for backward compatibility.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000marginstring · int32обязательноMargin currently backing the position, fp9 raw. Moves with pnl, funding and manual margin changes.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000pnlstring · int32 · nullableобязательноRealised pnl accumulated over every event of the position, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000fundingstring · int32 · nullableобязательноFunding paid (negative) or received (positive) over the life of the position, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000rolloverFeestring · int32обязательноAlways 0. Kept for backward compatibility.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000settlementOraclePricestring · int32обязательноAlways 1000000000 (1.0). Kept for backward compatibility.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000feestring · int32обязательноTrading fees charged over the life of the position, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000feeRatestring · int32обязательноFee rate applied to the position, fp9 raw fraction (1000000 = 0.1%).
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000exchangedQuotestring · int32обязательноQuote amount exchanged by the most recent event, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000exchangedBasestring · int32обязательноBase amount exchanged by the most recent event, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000directionstring · enumобязательноDirection of the position.
"long" "short"longeventNamestring · enumобязательноType of the most recent event applied to the position.
"addMargin" "removeMargin" "closePosition" "increasePosition" "liquidate" "forceClose" "payFunding"addMarginpnlInEventstring · int32обязательноRealised pnl of the most recent event, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000rawPnlInEventstring · int32обязательноRealised pnl of the most recent event before the 60-second adjustment, fp9 raw. Differs from pnlInEvent only when the adjustment fired.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000profitAdjustmentAppliedbooleanобязательноWhether the 60-second adjustment capped the profit of the most recent event — inside a minute of an open or increase the position pnl cannot grow above what it was at that moment.
trueholdingTimeMsstring[]обязательноHow long the position was held before the most recent close, in milliseconds, counted from the open or the last increase. Null on events that are not closes.
Элементы массива · string
string
Посмотреть пример
[
"string"
]feeInEventstring · int32обязательноFee charged by the most recent event, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000fundingInEventstring · int32обязательноFunding settled by the most recent event, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000rolloverFeeInEventstring · int32обязательноAlways 0. Kept for backward compatibility.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000executionFeeRatestring · int32обязательноAlways 0. Kept for backward compatibility.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000executionFeeInEventstring · int32обязательноAlways 0. Kept for backward compatibility.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000executionFeestring · int32обязательноAlways 0. Kept for backward compatibility.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000timestampstring · date-timeобязательноTimestamp of the most recent event. Same value as lastUpdatedAt.
2026-05-01T12:30:00.000ZisOnchainbooleanобязательноAlways true. Kept for backward compatibility.
trueroestring · int32обязательноReturn on equity of the position — realised pnl over the margin put up, fp9 raw fraction.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000scalpingCoefficientstring · int32обязательноDynamic spread multiplier the position was charged, fp9 raw (1000000000 = 1.0). Above 1 when the trade fell inside the market scalping window.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000closeReasonstring[]обязательноWhy the platform closed the position (for example weekly_session_risk_close). Null for positions closed by the trader and for open ones.
Элементы массива · string
string
Посмотреть пример
[
"string"
]{
"idx": [
"string"
],
"txId": [
"string"
],
"version": 0,
"openedAt": "2026-05-01T12:30:00.000Z",
"lastUpdatedAt": "2026-05-01T12:30:00.000Z",
"closedAt": "2026-05-01T12:30:00.000Z",
"type": "long",
"status": "opened",
"market": "00000000-0000-4000-8000-000000000000",
"trader": "00000000-0000-4000-8000-000000000000",
"size": "1000000000",
"notional": "1000000000",
"fraction": "1000000000",
"margin": "1000000000",
"pnl": "1000000000",
"funding": "1000000000",
"rolloverFee": "1000000000",
"settlementOraclePrice": "1000000000",
"fee": "1000000000",
"feeRate": "1000000000",
"exchangedQuote": "1000000000",
"exchangedBase": "1000000000",
"direction": "long",
"eventName": "addMargin",
"pnlInEvent": "1000000000",
"rawPnlInEvent": "1000000000",
"profitAdjustmentApplied": true,
"holdingTimeMs": [
"string"
],
"feeInEvent": "1000000000",
"fundingInEvent": "1000000000",
"rolloverFeeInEvent": "1000000000",
"executionFeeRate": "1000000000",
"executionFeeInEvent": "1000000000",
"executionFee": "1000000000",
"timestamp": "2026-05-01T12:30:00.000Z",
"isOnchain": true,
"roe": "1000000000",
"scalpingCoefficient": "1000000000",
"closeReason": [
"string"
]
}