trade / wire operation
Cancel an open paper order
totalfinance.trade.cancel
Journal cancel-requested then cancelled for an open order in the journal store under `<sourceId>:journal`; a terminal order is not cancelled twice (accepted: false, the state says why). Cancelling a combo leg cancels all remaining legs of that plan-local combo. Both the original journal and authorization stores are required to recover pending submissions before cancellation; no new grant is needed. A fill delivered after the cancellation is Decision 6's late-fill path. Paper only; requires trade:paper. Opt-in (tradePack).
| Pack / profiles | trade / full |
|---|---|
| Default discovery | Opt-in |
| Required capabilities | trade:paper |
| Effects / authorization | external-order / policy |
| Cost / cancellation | small / Do not assume inline interruption |
| Handle-eligible inputs | None |
| Idempotency | optional |
Input schema
{
"type": "object",
"properties": {
"orderId": {
"type": "string",
"minLength": 1
},
"now": {
"type": "number"
},
"sourceId": {
"type": "string",
"minLength": 1
},
"accountId": {
"type": "string",
"minLength": 1
},
"baseCurrency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"idempotencyKey": {
"type": "string",
"minLength": 1
},
"journal": {
"type": "array",
"items": {
"allOf": [
{
"type": "object",
"properties": {
"eventId": {
"type": "string",
"minLength": 1
},
"journalId": {
"type": "string",
"minLength": 1
},
"timestampMs": {
"type": "number",
"description": "Epoch milliseconds"
},
"orderId": {
"type": "string",
"minLength": 1
},
"planHash": {
"type": "string",
"minLength": 1
},
"idempotencyKey": {
"type": "string",
"minLength": 1
},
"sourceId": {
"type": "string",
"minLength": 1
},
"provenance": {
"type": "object",
"properties": {
"provider": {
"type": "string"
},
"dataset": {
"type": "string"
},
"asOf": {
"type": "number",
"description": "Epoch milliseconds"
},
"receivedAt": {
"type": "number",
"description": "Epoch milliseconds"
},
"sourceVersion": {
"type": "string"
},
"requestId": {
"type": "string"
},
"warnings": {
"type": "array",
"items": {
"type": "object",
"properties": {
"code": {
"type": "string",
"minLength": 1
},
"message": {
"type": "string"
},
"severity": {
"type": "string",
"enum": [
"info",
"warn",
"error"
]
},
"context": {
"type": "object",
"additionalProperties": {}
}
},
"additionalProperties": false,
"required": [
"code",
"message",
"severity"
]
}
}
},
"additionalProperties": false
},
"eventType": {},
"detail": {}
},
"additionalProperties": false,
"required": [
"eventId",
"journalId",
"timestampMs",
"orderId",
"planHash",
"sourceId",
"provenance",
"eventType",
"detail"
]
},
{
"anyOf": [
{
"properties": {
"eventType": {
"const": "proposed",
"type": "string"
},
"detail": {
"$ref": "#/$defs/Detail"
}
}
},
{
"properties": {
"eventType": {
"const": "preflighted",
"type": "string"
},
"detail": {
"$ref": "#/$defs/Detail"
}
}
},
{
"properties": {
"eventType": {
"const": "authorized",
"type": "string"
},
"detail": {
"$ref": "#/$defs/Detail"
}
}
},
{
"properties": {
"eventType": {
"const": "submitted",
"type": "string"
},
"detail": {
"type": "object",
"properties": {
"quantity": {
"type": "number",
"exclusiveMinimum": 0
},
"fillId": {
"type": "string"
},
"pricePerUnit": {
"type": "number"
},
"reason": {
"type": "string"
},
"replacementOrderId": {
"type": "string"
},
"artifactHash": {
"type": "string"
},
"note": {
"type": "string"
},
"order": {
"allOf": [
{
"type": "object",
"properties": {
"instrumentId": {
"type": "string",
"minLength": 1
},
"side": {
"type": "string",
"enum": [
"buy",
"sell"
]
},
"timeInForce": {
"type": "string",
"enum": [
"day",
"gtc"
],
"description": "Default: the paper execution policy’s day time-in-force"
},
"comboId": {
"type": "string",
"minLength": 1,
"description": "The multi-leg order this is a leg of (B5)"
},
"orderId": {
"type": "string",
"minLength": 1
},
"quantity": {
"type": "number",
"exclusiveMinimum": 0,
"description": "Units/contracts, strictly positive; side carries direction"
},
"plannedTimestampMs": {
"type": "number",
"description": "When the plan was made — never when a broker saw the order"
},
"submittedTimestampMs": {
"type": "number",
"description": "Epoch milliseconds"
},
"type": {},
"limitPrice": {},
"stopPrice": {}
},
"additionalProperties": false,
"required": [
"instrumentId",
"side",
"orderId",
"quantity",
"plannedTimestampMs",
"type"
]
},
{
"anyOf": [
{
"properties": {
"type": {
"const": "market",
"type": "string"
}
},
"not": {
"anyOf": [
{
"required": [
"limitPrice"
]
},
{
"required": [
"stopPrice"
]
}
]
}
},
{
"properties": {
"type": {
"const": "market-on-open",
"type": "string"
}
},
"not": {
"anyOf": [
{
"required": [
"limitPrice"
]
},
{
"required": [
"stopPrice"
]
}
]
}
},
{
"properties": {
"type": {
"const": "market-on-close",
"type": "string"
}
},
"not": {
"anyOf": [
{
"required": [
"limitPrice"
]
},
{
"required": [
"stopPrice"
]
}
]
}
},
{
"properties": {
"type": {
"const": "limit",
"type": "string"
},
"limitPrice": {
"type": "number",
"exclusiveMinimum": 0
}
},
"required": [
"limitPrice"
],
"not": {
"anyOf": [
{
"required": [
"stopPrice"
]
}
]
}
},
{
"properties": {
"type": {
"const": "stop",
"type": "string"
},
"stopPrice": {
"type": "number",
"exclusiveMinimum": 0
}
},
"required": [
"stopPrice"
],
"not": {
"anyOf": [
{
"required": [
"limitPrice"
]
}
]
}
},
{
"properties": {
"type": {
"const": "stop-limit",
"type": "string"
},
"limitPrice": {
"type": "number",
"exclusiveMinimum": 0
},
"stopPrice": {
"type": "number",
"exclusiveMinimum": 0
}
},
"required": [
"limitPrice",
"stopPrice"
]
}
]
}
]
},
"instrument": {
"type": "object",
"properties": {
"currency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"contractMultiplier": {
"type": "number",
"exclusiveMinimum": 0
},
"contract": {
"$ref": "#/$defs/Contract"
},
"settlementStyle": {
"type": "string",
"enum": [
"cash-on-trade",
"variation-margin"
]
},
"settlementLag": {
"anyOf": [
{
"const": 0,
"type": "number"
},
{
"const": 1,
"type": "number"
},
{
"const": 2,
"type": "number"
}
],
"description": "T+n 24-hour days in the paper broker; default 0"
}
},
"additionalProperties": false,
"required": [
"currency"
]
},
"accountId": {
"type": "string",
"minLength": 1
},
"baseCurrency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"executionPolicyHash": {
"type": "string",
"minLength": 1
},
"comboId": {
"type": "string",
"minLength": 1
},
"netLimitPrice": {
"type": "number"
}
},
"additionalProperties": false,
"required": [
"quantity"
]
}
}
},
{
"properties": {
"eventType": {
"const": "acknowledged",
"type": "string"
},
"detail": {
"$ref": "#/$defs/Detail"
}
}
},
{
"properties": {
"eventType": {
"const": "partially-filled",
"type": "string"
},
"detail": {
"$ref": "#/$defs/Detail2"
}
}
},
{
"properties": {
"eventType": {
"const": "filled",
"type": "string"
},
"detail": {
"$ref": "#/$defs/Detail2"
}
}
},
{
"properties": {
"eventType": {
"const": "rejected",
"type": "string"
},
"detail": {
"$ref": "#/$defs/Detail"
}
}
},
{
"properties": {
"eventType": {
"const": "cancel-requested",
"type": "string"
},
"detail": {
"$ref": "#/$defs/Detail"
}
}
},
{
"properties": {
"eventType": {
"const": "cancelled",
"type": "string"
},
"detail": {
"$ref": "#/$defs/Detail"
}
}
},
{
"properties": {
"eventType": {
"const": "replaced",
"type": "string"
},
"detail": {
"type": "object",
"properties": {
"quantity": {
"type": "number"
},
"fillId": {
"type": "string"
},
"pricePerUnit": {
"type": "number"
},
"reason": {
"type": "string"
},
"replacementOrderId": {
"type": "string",
"minLength": 1
},
"artifactHash": {
"type": "string"
},
"note": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"replacementOrderId"
]
}
}
},
{
"properties": {
"eventType": {
"const": "expired",
"type": "string"
},
"detail": {
"$ref": "#/$defs/Detail"
}
}
},
{
"properties": {
"eventType": {
"const": "reconciled",
"type": "string"
},
"detail": {
"$ref": "#/$defs/Detail"
}
}
},
{
"properties": {
"eventType": {
"const": "unresolved",
"type": "string"
},
"detail": {
"$ref": "#/$defs/Detail"
}
}
}
]
}
]
},
"description": "Optional exact canonical snapshot of the persisted journal; checked inside the transaction. Never imports or replaces history. An execution-journal store is required."
}
},
"additionalProperties": false,
"required": [
"orderId",
"now",
"sourceId",
"accountId",
"baseCurrency"
],
"$id": "https://totalfinance.dev/schemas/trade.cancel.input",
"$defs": {
"Detail": {
"type": "object",
"properties": {
"quantity": {
"type": "number"
},
"fillId": {
"type": "string"
},
"pricePerUnit": {
"type": "number"
},
"reason": {
"type": "string"
},
"replacementOrderId": {
"type": "string"
},
"artifactHash": {
"type": "string"
},
"note": {
"type": "string"
}
},
"additionalProperties": false
},
"Contract": {
"anyOf": [
{
"type": "object",
"properties": {
"kind": {
"const": "option",
"type": "string"
},
"underlyingInstrumentId": {
"type": "string",
"minLength": 1
},
"type": {
"type": "string",
"enum": [
"call",
"put"
]
},
"strikePricePerUnit": {
"type": "number"
},
"expiryTimestampMs": {
"type": "number",
"description": "Epoch milliseconds"
}
},
"additionalProperties": false,
"required": [
"kind",
"underlyingInstrumentId",
"type",
"strikePricePerUnit",
"expiryTimestampMs"
]
},
{
"type": "object",
"properties": {
"kind": {
"const": "future",
"type": "string"
},
"underlyingInstrumentId": {
"type": "string",
"minLength": 1
},
"expiryTimestampMs": {
"type": "number",
"description": "Epoch milliseconds"
}
},
"additionalProperties": false,
"required": [
"kind",
"underlyingInstrumentId",
"expiryTimestampMs"
]
},
{
"type": "object",
"properties": {
"kind": {
"const": "perpetual",
"type": "string"
},
"underlyingInstrumentId": {
"type": "string",
"minLength": 1
}
},
"additionalProperties": false,
"required": [
"kind",
"underlyingInstrumentId"
]
}
]
},
"Detail2": {
"type": "object",
"properties": {
"quantity": {
"type": "number",
"exclusiveMinimum": 0
},
"fillId": {
"type": "string",
"minLength": 1
},
"pricePerUnit": {
"type": "number"
},
"reason": {
"type": "string"
},
"replacementOrderId": {
"type": "string"
},
"artifactHash": {
"type": "string"
},
"note": {
"type": "string"
},
"observationTimestampMs": {
"type": "number",
"description": "Epoch milliseconds"
},
"fill": {
"type": "object",
"properties": {
"fillId": {
"type": "string",
"minLength": 1
},
"accountId": {
"type": "string",
"minLength": 1
},
"instrumentId": {
"type": "string",
"minLength": 1
},
"side": {
"type": "string",
"enum": [
"buy",
"sell"
]
},
"quantity": {
"type": "number",
"exclusiveMinimum": 0
},
"pricePerUnit": {
"type": "number"
},
"currency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"filledTimestampMs": {
"type": "number",
"description": "Epoch milliseconds"
},
"settleTimestampMs": {
"type": "number",
"description": "Epoch milliseconds"
},
"contractMultiplier": {
"type": "number",
"exclusiveMinimum": 0
},
"settlementStyle": {
"type": "string",
"enum": [
"cash-on-trade",
"variation-margin"
]
},
"contract": {
"$ref": "#/$defs/Contract"
},
"accruedInterest": {
"type": "number"
},
"executionPriceAdjustment": {
"type": "number",
"minimum": 0
},
"costs": {
"type": "object",
"properties": {
"commission": {
"type": "number",
"minimum": 0
},
"exchangeFees": {
"type": "number",
"minimum": 0
},
"regulatoryFees": {
"type": "number",
"minimum": 0
},
"slippageAdjustment": {
"type": "number",
"minimum": 0
}
},
"additionalProperties": false
},
"orderId": {
"type": "string",
"minLength": 1
},
"venue": {
"type": "string"
},
"liquidity": {
"type": "string",
"enum": [
"maker",
"taker",
"unknown"
]
}
},
"additionalProperties": false,
"required": [
"fillId",
"accountId",
"instrumentId",
"side",
"quantity",
"pricePerUnit",
"currency",
"filledTimestampMs"
]
}
},
"additionalProperties": false,
"required": [
"quantity",
"fillId"
]
}
}
}Output schema
{
"type": "object",
"properties": {
"orderId": {
"type": "string"
},
"accepted": {
"type": "boolean"
},
"state": {
"type": "object",
"properties": {
"orderId": {
"type": "string",
"minLength": 1
},
"planHash": {
"type": "string",
"minLength": 1
},
"state": {
"type": "string",
"enum": [
"submitted",
"acknowledged",
"partially-filled",
"filled",
"cancelled",
"rejected",
"expired",
"unresolved"
]
},
"submittedQuantity": {
"type": "number",
"minimum": 0
},
"filledQuantity": {
"type": "number",
"minimum": 0
},
"remainingQuantity": {
"type": "number",
"minimum": 0
},
"averageFillPrice": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
]
},
"fillIds": {
"type": "array",
"items": {
"type": "string"
}
},
"lateFillIds": {
"type": "array",
"items": {
"type": "string"
}
},
"lastEventId": {
"type": "string",
"minLength": 1
},
"lastTimestampMs": {
"type": "number",
"description": "Epoch milliseconds"
},
"terminal": {
"type": "boolean"
},
"cancelRequested": {
"type": "boolean"
},
"reason": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"replacedBy": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"reconciledEventId": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false,
"required": [
"orderId",
"planHash",
"state",
"submittedQuantity",
"filledQuantity",
"remainingQuantity",
"averageFillPrice",
"fillIds",
"lateFillIds",
"lastEventId",
"lastTimestampMs",
"terminal",
"cancelRequested",
"reason",
"replacedBy",
"reconciledEventId"
]
},
"journal": {
"type": "object",
"properties": {
"journalId": {
"type": "string",
"minLength": 1
},
"appended": {
"type": "integer",
"minimum": 0
},
"total": {
"type": "integer",
"minimum": 0
}
},
"additionalProperties": false,
"required": [
"journalId",
"appended",
"total"
]
}
},
"additionalProperties": false,
"required": [
"orderId",
"accepted",
"state",
"journal"
],
"$id": "https://totalfinance.dev/schemas/trade.cancel.output"
}