/positions/{positionId}/marginMueve el saldo de cotización dentro o fuera del margen de una posición abierta, lo que desplaza con ello su apalancamiento y su precio de liquidación.
- La posición debe seguir abierta, y su cuenta debe pertenecer a quien llama y estar
active— una cuenta bloqueada por el límite de capital gestionado se rechaza aquí. - El mercado debe estar abierto y no en modo de solo cierre.
marginChange: "0"se acepta y devuelve la posición sin cambios.- Agregar más de lo que cubre el saldo libre falla con
insufficient_balance; dejar un margen nominal cero o negativo falla connon_positive_margin. - El apalancamiento resultante debe mantenerse dentro del rango permitido; de lo contrario, la solicitud falla con
invalid_leverage. - Retirar margen debe dejar la posición fuera de liquidación al precio de mercado actual. Alcanzar o cruzar el precio de liquidación recalculado falla con
margin_withdrawal_liquidation(HTTP 400); no se aplican cambios de margen ni de saldo.
https://api.upscale.tradeParámetros
positionIdstring · uuidobligatorioIdentificador de posición. Su cuenta debe pertenecer al llamador.
00000000-0000-4000-8000-000000000000Cuerpo de la solicitud · obligatorio
marginChangestring · fp9obligatorioSigned 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"
}Ejemplos
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)Respuestas
No autorizado
La cuenta pertenece a otro usuario (account_access_denied), o la solicitud se autentica con una clave de API mientras api_trading está deshabilitado en la cuenta (api_trading_not_enabled). La cuenta no está en un estado activo. El mercado está en pausa (market_paused) o solo acepta órdenes de cierre (market_close_only).
No existe ninguna posición con este identificador.
Se superó el límite de velocidad de la clave de API (api_key_rate_limit_exceeded). Retry-After indica cuándo volver; el cuerpo incluye el bucket (read / write), la ventana que se activó, su límite y retryAt.
defaultRespuestaapplication/json
idxstring · nullableobligatorioPosition identifier.
stringversionnumberobligatorioRevision of the position: incremented by every event applied to it.
0openedAtstring · date-timeobligatorioWhen the position was opened.
2026-05-01T12:30:00.000ZlastUpdatedAtstring · date-timeobligatorioWhen the last event was applied to the position.
2026-05-01T12:30:00.000ZclosedAtstring · date-time · nullableobligatorioWhen the position was closed; null while it is still open.
2026-05-01T12:30:00.000Zstatusstring · enumobligatorioWhether the position is still open, closed by the trader, or liquidated.
"opened" "closed" "liquidated"openedmarketstring · uuidobligatorioMarket 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 · uuidobligatorioTrader 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 · fp9obligatorioPosition size in base asset units, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000notionalstring · fp9obligatorioOpen notional of the position in quote currency, fp9 raw — size at entry price.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000marginstring · fp9obligatorioMargin currently backing the position, fp9 raw. Moves with pnl, funding and manual margin changes.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000pnlstring · fp9 · nullableobligatorioRealised pnl accumulated over every event of the position, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000fundingstring · fp9 · nullableobligatorioFunding paid (negative) or received (positive) over the life of the position, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000feestring · fp9obligatorioTrading fees charged over the life of the position, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000feeRatestring · fp9obligatorioFee rate applied to the position, fp9 raw fraction (1000000 = 0.1%).
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000exchangedQuotestring · fp9obligatorioQuote amount exchanged by the most recent event, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000exchangedBasestring · fp9obligatorioBase amount exchanged by the most recent event, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000directionstring · enumobligatorioDirection of the position.
"long" "short"longeventNamestring · enumobligatorioType of the most recent event applied to the position.
"addMargin" "removeMargin" "closePosition" "increasePosition" "liquidate" "forceClose" "payFunding"addMarginpnlInEventstring · fp9obligatorioRealised pnl of the most recent event, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000rawPnlInEventstring · fp9obligatorioRealised 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)$
1000000000profitAdjustmentAppliedbooleanobligatorioWhether 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 · nullableobligatorioHow 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.
stringfeeInEventstring · fp9obligatorioFee charged by the most recent event, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000fundingInEventstring · fp9obligatorioFunding settled by the most recent event, fp9 raw.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000roestring · fp9obligatorioReturn on equity of the position — realised pnl over the margin put up, fp9 raw fraction.
- pattern
- ^(?:-?[1-9][0-9]*|0)$
1000000000scalpingCoefficientstring · fp9obligatorioDynamic 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 · nullableobligatorioWhy the platform closed the position (for example weekly_session_risk_close). Null for positions closed by the trader and for open ones.
string{
"idx": "string",
"version": 0,
"openedAt": "2026-05-01T12:30:00.000Z",
"lastUpdatedAt": "2026-05-01T12:30:00.000Z",
"closedAt": "2026-05-01T12:30:00.000Z",
"status": "opened",
"market": "00000000-0000-4000-8000-000000000000",
"trader": "00000000-0000-4000-8000-000000000000",
"size": "1000000000",
"notional": "1000000000",
"margin": "1000000000",
"pnl": "1000000000",
"funding": "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",
"roe": "1000000000",
"scalpingCoefficient": "1000000000",
"closeReason": "string"
}