Skip to main content
POST
/
api
/
v1
/
trading
/
execution
/
demo
/
market-close-orders
/
positions
/
{positionId}
Creates a market order to close a position or partially close it by specifying the number of units to deduct.
curl --request POST \
  --url https://public-api.etoro.com/api/v1/trading/execution/demo/market-close-orders/positions/{positionId} \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <x-api-key>' \
  --header 'x-request-id: <x-request-id>' \
  --header 'x-user-key: <x-user-key>' \
  --data '
{
  "InstrumentId": 123,
  "UnitsToDeduct": 123
}
'
{
  "orderForClose": {
    "positionID": 2150941015,
    "instrumentID": 1111,
    "unitsToDeduct": 2,
    "orderID": 13904638,
    "orderType": 19,
    "statusID": 1,
    "CID": 7765437,
    "openDateTime": "2025-04-02T16:07:54.0880338Z",
    "lastUpdate": "2025-04-02T16:07:54.0880338Z"
  },
  "token": "5fe065bc-f6f9-4897-a2ce-c4fccef73ff8"
}

Headers

x-request-id
string<uuid>
required

A unique request identifier.

Example:

"dc71207a-252d-4666-822b-c76782ebf6e4"

x-api-key
string<password>
required

API key for authentication.

Example:

"lhgfaslk21490FAScVPkdsb53F9dNkfHG4faZSG5vfjndfcfgdssdgsdHF4663"

x-user-key
string<password>
required

User-specific authentication key.

Example:

"eyJlYW4iOiJVbnJlZ2lzdGVyZWRBcHBsaWNhdGlvbiIsImVrIjoiOE5sZ2cwcW5EUVdROUFNWGpXT2lmOWktZnpidG5KcUlqWGJ3WHJZZkpZcldrbG90ZEhvLVBjSWhQaU8xU1ZtMW84aU1WZGZqN2xWNzFjLXFxLmcybXE1dnh4Q1hUT25xaWRUaTFlcEhmVk1fIn0_"

Path Parameters

positionId
integer<int64>
required

The unique identifier of the position to close.

Body

application/json
InstrumentId
integer<int32>
required

The ID of the financial instrument associated with the position.

UnitsToDeduct
number<double> | null

The number of units to close. If omitted or null, the entire position will be closed.

Response

200 - application/json

Successfully closed a position or a part of it.

orderForClose
object
token
string<uuid>

A unique confirmation token for the closing order.