Orders

Liquidate Position

Cancel working orders for a contract and flatten its position.

Available to: All authenticated users

Environments: Demo, Live

Rate Limit: No endpoint-specific limit

Cancels the working orders for a specific contractId on the given accountId and closes (flattens) the resulting position with a market order. This is a request, not a guarantee — it can fail for reasons ranging from exchange rejection to misconfiguration. When the request is rejected, the response carries a failureReason and failureText.

<Warning> Set `isAutomated` to `true` when this is triggered by code or an automated process, and `false` only when a human triggers it directly. </Warning>

Common Failure Scenarios

  • The trading session is closed or the market has no quote (SessionClosed, NoQuote).
  • The market lacks the liquidity to close the position (NotEnoughLiquidity).
  • The user isn't permitted to trade this account or contract (Unauthorized).

Error Messages

failureReasonTrigger
SessionClosedThe trading session is closed.
NotEnoughLiquidityThe market can't absorb the closing order.
UnauthorizedThe user isn't permitted to trade this account or contract.

See the failureReason enum in the response schema for the complete list of values.

post/order/liquidateposition

Request

  • Base URL: https://demo.tradovateapi.com/v1
  • URL: https://demo.tradovateapi.com/v1/order/liquidateposition
  • Auth: HTTP bearer

Request body

accountIdinteger required
contractIdinteger required
adminboolean required
customTag50string
isAutomatedboolean

Response

PlaceOrderResult

failureReason'AccountClosed' | 'AdvancedTrailingStopUnsupported' | 'AnotherCommandPending' | 'BackMonthProhibited' | 'ExecutionProviderNotConfigured' | 'ExecutionProviderUnavailable' | 'HomeStateRestricted' | 'InvalidContract' | 'InvalidPrice' | 'KeyInformationDocumentRequired' | 'LiquidationOnly' | 'LiquidationOnlyBeforeExpiration' | 'MaxOrderQtyIsNotSpecified' | 'MaxOrderQtyLimitReached' | 'MaxPosLimitMisconfigured' | 'MaxPosLimitReached' | 'MaxTotalPosLimitReached' | 'MinTradeDurationNotElapsed' | 'MultipleAccountPlanRequired' | 'NoQuote' | 'NotEnoughLiquidity' | 'OtherExecutionRelated' | 'ParentRejected' | 'RiskCheckTimeout' | 'SSFNFAComplianceRequired' | 'SSFNFAComplianceRequiredJointOnly' | 'SSFRiskDisclosureAcknowledgmentRequired' | 'SessionClosed' | 'Success' | 'TooLate' | 'TradingLocked' | 'TrailingStopNonOrderQtyModify' | 'Unauthorized' | 'UnknownReason' | 'Unsupported'

AccountClosed, AdvancedTrailingStopUnsupported, AnotherCommandPending, BackMonthProhibited, ExecutionProviderNotConfigured, ExecutionProviderUnavailable, HomeStateRestricted, InvalidContract, InvalidPrice, KeyInformationDocumentRequired, LiquidationOnly, LiquidationOnlyBeforeExpiration, MaxOrderQtyIsNotSpecified, MaxOrderQtyLimitReached, MaxPosLimitMisconfigured, MaxPosLimitReached, MaxTotalPosLimitReached, MinTradeDurationNotElapsed, MultipleAccountPlanRequired, NoQuote, NotEnoughLiquidity, OtherExecutionRelated, ParentRejected, RiskCheckTimeout, SSFNFAComplianceRequired, SSFNFAComplianceRequiredJointOnly, SSFRiskDisclosureAcknowledgmentRequired, SessionClosed, Success, TooLate, TradingLocked, TrailingStopNonOrderQtyModify, Unauthorized, UnknownReason, Unsupported

failureTextstring
orderIdinteger

Changes

No recorded changes to this operation across all 1 revision of this API.