Close every open leg of a group at once.
POST
/api/position-groups/{id}/close
const url = 'https://api.tradr.cloud/api/position-groups/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/close';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"closedAt":"2026-04-15T12:00:00Z","exits":[{"fees":"example","positionId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","price":"example"}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.tradr.cloud/api/position-groups/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/close \ --header 'Content-Type: application/json' \ --data '{ "closedAt": "2026-04-15T12:00:00Z", "exits": [ { "fees": "example", "positionId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "price": "example" } ] }'Authed. In one transaction, writes one exit fill per open leg for its open units (carrying no lot selection) and closes it, all dated at closedAt or now; an already-closed leg is skipped even if named. Posts through the existing fill and close hooks per leg, under its own symbol — no group-level ledger row. An open leg missing from exits is a validation error naming it; any failure (including a closedAt before a leg’s open date, or a leg refused by the reopen guard) rolls back every leg and names the offending leg.
Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters”id
required
string format: uuid
Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
closedAt
string format: date-time
exits
required
Array<object>
object
fees
string
positionId
required
string format: uuid
price
required
string
Examplegenerated
{ "closedAt": "2026-04-15T12:00:00Z", "exits": [ { "fees": "example", "positionId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "price": "example" } ]}Responses
Section titled “ Responses ”The group
Validation error — a missing exit
The group was not found
Every leg is already closed