Skip to main content
POST
TypeScript

Authorizations

Authorization
string
header
required

The Trading API key (trdrs_sk_…), for market data, orders and account state on the accounts its owner holds. Use it server-to-server, and keep it on your server. Its scope is named trading in the API.

Query Parameters

provider
string

The provider the account is at, such as rithmic or paper. Omit it to use your default provider. An unknown value is refused with 400, never replaced with another provider.

account
string

The account number at that provider. It must be one of your own accounts, or the call is refused with 400.

Body

application/json

The position to close part of, and how much.

instrument
string
required

The instrument.

qty
number
required

How much to close, positive.

clientOrderId
string
required

Your own id for this close, and its idempotency key.

positionId
string

The one position to act on, by the id the account snapshot gives it: a ticket on an account that holds separate tickets, or the net position. Only where the provider names its positions. Anywhere else the request is refused, rather than applied to the instrument.

positionRevision
integer

The position revision you saw. If the position has changed since, the request is refused with position_revision_stale. Only with positionId.

Required range: x >= 1

Response

The close is accepted. The response is the order that closes it.

The market order that closes part of the position.

providerOrderId
string
required

The order id at the provider.

filledQty
number | null
required

How much filled, or null when the provider hasn't reported it.

avgFillPrice
number | null
required

The average fill price, or null when the provider hasn't reported it.

requestedQty
number
required

The quantity you asked to close.

refusal
object

Present when the paper book closed more than the largest market order the instrument takes as several market orders and refused one after the first: why, with filledQty what the orders before it closed. Read the account to see what remains.

Example: