The finance developer workbenchSearch the reference Development · 0.1.4 · unpublished

trade / wire operation

Preflight a trade plan against the ledger, the market, and the policy

totalfinance.trade.preflight

Normalize an intent (or take an execution plan) and judge it: the portfolio before and after through the ledger's own fold of hypothetical fills, every policy check with its verdict, declared-rate cost estimates, the monitor's alerts on the after-state, and one decision — allow only when every check passes, deny on any failure, require-approval when evidence is missing; never an allow from missing information. No effect. Opt-in (tradePack).

Pack / profilestrade / full
Default discoveryOpt-in
Required capabilitiestrade:propose
Effects / authorizationnone / none
Cost / cancellationsmall / Do not assume inline interruption
Handle-eligible inputsportfolio, market
Idempotencynot-applicable
Input schema
{
  "type": "object",
  "properties": {
    "plan": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "totalfinance.execution-plan",
          "type": "string"
        },
        "schemaVersion": {
          "const": 1,
          "type": "number"
        },
        "accountId": {
          "type": "string",
          "minLength": 1
        },
        "asOf": {
          "type": "number",
          "description": "Epoch milliseconds"
        },
        "baseCurrency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "portfolioId": {
          "type": "string",
          "minLength": 1
        },
        "orders": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Orders"
          },
          "minItems": 1,
          "maxItems": 1000
        },
        "combos": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "comboId": {
                "type": "string",
                "minLength": 1
              },
              "orderIds": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                },
                "minItems": 2,
                "description": "The legs, in plan order (at least two)"
              },
              "netLimitPrice": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "comboId",
              "orderIds"
            ]
          }
        },
        "trades": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "accountId": {
                "type": "string",
                "minLength": 1
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "side": {
                "type": "string",
                "enum": [
                  "buy",
                  "sell"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "referencePricePerUnit": {
                "type": "number"
              },
              "contractMultiplier": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "estimatedNotional": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "accountId",
              "instrumentId",
              "side",
              "quantity",
              "currency",
              "referencePricePerUnit",
              "contractMultiplier",
              "estimatedNotional"
            ]
          }
        },
        "source": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "kind": {
                  "const": "intent",
                  "type": "string"
                },
                "intentHash": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "additionalProperties": false,
              "required": [
                "kind",
                "intentHash"
              ]
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "const": "rebalance-proposal",
                  "type": "string"
                },
                "planHash": {
                  "type": "string",
                  "minLength": 1
                },
                "policyContentHash": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "additionalProperties": false,
              "required": [
                "kind",
                "planHash",
                "policyContentHash"
              ]
            }
          ]
        },
        "rationale": {
          "type": "string"
        },
        "evidence": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "contentHash": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "schemaVersion",
        "accountId",
        "asOf",
        "baseCurrency",
        "orders",
        "combos",
        "trades",
        "source",
        "evidence",
        "contentHash"
      ]
    },
    "intent": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "totalfinance.trade-intent",
          "type": "string"
        },
        "schemaVersion": {
          "const": 1,
          "type": "number"
        },
        "accountId": {
          "type": "string",
          "minLength": 1
        },
        "asOf": {
          "type": "number",
          "description": "Epoch milliseconds"
        },
        "orders": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "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)"
                      },
                      "quantity": {
                        "type": "number",
                        "exclusiveMinimum": 0
                      },
                      "type": {},
                      "limitPrice": {},
                      "stopPrice": {}
                    },
                    "additionalProperties": false,
                    "required": [
                      "instrumentId",
                      "side",
                      "quantity",
                      "type"
                    ]
                  },
                  {
                    "$ref": "#/$defs/Orders3"
                  }
                ]
              },
              {
                "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)"
                      },
                      "notionalWeight": {
                        "type": "number",
                        "maximum": 1,
                        "exclusiveMinimum": 0,
                        "description": "Notional as a fraction of NAV at the mark, (0, 1]; mutually exclusive with quantity"
                      },
                      "type": {},
                      "limitPrice": {},
                      "stopPrice": {}
                    },
                    "additionalProperties": false,
                    "required": [
                      "instrumentId",
                      "side",
                      "notionalWeight",
                      "type"
                    ]
                  },
                  {
                    "$ref": "#/$defs/Orders3"
                  }
                ]
              }
            ]
          },
          "minItems": 1,
          "maxItems": 1000
        },
        "combos": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "comboId": {
                "type": "string",
                "minLength": 1
              },
              "netLimitPrice": {
                "type": "number",
                "description": "Net limit per combo unit: debit positive (pay at most), credit negative"
              }
            },
            "additionalProperties": false,
            "required": [
              "comboId"
            ]
          }
        },
        "rationale": {
          "type": "string"
        },
        "evidence": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "schemaVersion",
        "accountId",
        "asOf",
        "orders"
      ]
    },
    "portfolio": {
      "anyOf": [
        {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "kind": {
                  "const": "totalfinance.portfolio-ledger",
                  "type": "string"
                },
                "schemaVersion": {
                  "const": 1,
                  "type": "number"
                },
                "portfolioId": {
                  "type": "string",
                  "minLength": 1
                },
                "baseCurrency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "lotRelief": {
                  "type": "string",
                  "enum": [
                    "fifo",
                    "lifo",
                    "highest-cost",
                    "specific-lot"
                  ]
                },
                "events": {
                  "type": "array",
                  "items": {
                    "$ref": "#/$defs/PortfolioEventEnvelope"
                  }
                },
                "provenance": {
                  "$ref": "#/$defs/Provenance"
                }
              },
              "additionalProperties": false,
              "required": [
                "kind",
                "schemaVersion",
                "baseCurrency",
                "lotRelief",
                "events"
              ]
            },
            {
              "type": "object",
              "properties": {
                "schemaVersion": {
                  "const": 1,
                  "type": "number"
                },
                "portfolioId": {
                  "type": "string",
                  "minLength": 1
                },
                "baseCurrency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "lotRelief": {
                  "type": "string",
                  "enum": [
                    "fifo",
                    "lifo",
                    "highest-cost",
                    "specific-lot"
                  ]
                },
                "accounts": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "properties": {
                      "cashBalances": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "totalAmount": {
                              "type": "number"
                            },
                            "settlementSchedule": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "eventId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "amount": {
                                    "type": "number"
                                  },
                                  "settleTimestampMs": {
                                    "type": "number",
                                    "description": "Epoch milliseconds"
                                  }
                                },
                                "additionalProperties": false,
                                "required": [
                                  "eventId",
                                  "amount",
                                  "settleTimestampMs"
                                ]
                              }
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "totalAmount",
                            "settlementSchedule"
                          ]
                        }
                      },
                      "positions": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "instrumentId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "currency": {
                              "type": "string",
                              "pattern": "^[A-Z]{3}$"
                            },
                            "contractMultiplier": {
                              "type": "number",
                              "exclusiveMinimum": 0
                            },
                            "settlementStyle": {
                              "type": "string",
                              "enum": [
                                "cash-on-trade",
                                "variation-margin"
                              ]
                            },
                            "contract": {
                              "$ref": "#/$defs/Contract"
                            },
                            "quantity": {
                              "type": "number"
                            },
                            "lots": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "lotId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "openedByEventId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "openedTimestampMs": {
                                    "type": "number",
                                    "description": "Epoch milliseconds"
                                  },
                                  "quantity": {
                                    "type": "number"
                                  },
                                  "costBasisPerUnit": {
                                    "type": "number"
                                  }
                                },
                                "additionalProperties": false,
                                "required": [
                                  "lotId",
                                  "openedByEventId",
                                  "openedTimestampMs",
                                  "quantity",
                                  "costBasisPerUnit"
                                ]
                              }
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "instrumentId",
                            "currency",
                            "contractMultiplier",
                            "settlementStyle",
                            "quantity",
                            "lots"
                          ]
                        }
                      },
                      "realizedPnl": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "number"
                        }
                      },
                      "incomeReceived": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "number"
                        }
                      },
                      "transactionCosts": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "number"
                        }
                      },
                      "financingCosts": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "number"
                        }
                      },
                      "realizedPnlByInstrument": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "number"
                          }
                        }
                      },
                      "incomeByInstrument": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "number"
                          }
                        }
                      },
                      "transactionCostsByInstrument": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "cashBalances",
                      "positions",
                      "realizedPnl",
                      "incomeReceived",
                      "transactionCosts",
                      "financingCosts",
                      "realizedPnlByInstrument",
                      "incomeByInstrument",
                      "transactionCostsByInstrument"
                    ]
                  }
                },
                "appliedEvents": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string"
                  }
                },
                "eventCount": {
                  "type": "integer",
                  "minimum": 0
                },
                "lastEffectiveTimestampMs": {
                  "anyOf": [
                    {
                      "type": "number",
                      "description": "Epoch milliseconds"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "lotSequence": {
                  "type": "integer",
                  "minimum": 0
                },
                "fillEffects": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "properties": {
                      "accountId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "instrumentId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "currency": {
                        "type": "string",
                        "pattern": "^[A-Z]{3}$"
                      },
                      "openedLotIds": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "relievedQuantity": {
                        "type": "number"
                      },
                      "realizedPnl": {
                        "type": "number"
                      },
                      "cashDelta": {
                        "type": "number"
                      },
                      "accruedInterest": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "accountId",
                      "instrumentId",
                      "currency",
                      "openedLotIds",
                      "relievedQuantity",
                      "realizedPnl",
                      "cashDelta",
                      "accruedInterest"
                    ]
                  }
                },
                "reversals": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string"
                  }
                },
                "accountMigrations": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "eventId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "fromAccountId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "toAccountId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "effectiveTimestampMs": {
                        "type": "number",
                        "description": "Epoch milliseconds"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "eventId",
                      "fromAccountId",
                      "toAccountId",
                      "effectiveTimestampMs"
                    ]
                  }
                }
              },
              "additionalProperties": false,
              "required": [
                "schemaVersion",
                "baseCurrency",
                "lotRelief",
                "accounts",
                "appliedEvents",
                "eventCount",
                "lastEffectiveTimestampMs",
                "lotSequence",
                "fillEffects",
                "reversals",
                "accountMigrations"
              ]
            }
          ]
        },
        {
          "type": "string",
          "pattern": "^totalfinance:\\/\\/portfolios\\/"
        }
      ]
    },
    "market": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "totalfinance.market-snapshot",
              "type": "string"
            },
            "schemaVersion": {
              "const": 1,
              "type": "number"
            },
            "asOf": {
              "type": "number",
              "description": "Epoch milliseconds"
            },
            "conventions": {
              "type": "object",
              "properties": {
                "conventionsVersion": {
                  "type": "string"
                },
                "asOfConvention": {
                  "type": "string",
                  "enum": [
                    "explicit-instant",
                    "date-midnight-utc"
                  ],
                  "description": "How asOf was expressed at create time: an instant, or a bare date (00:00 UTC of that date — refused by option pricing)"
                },
                "dayCount": {
                  "type": "string",
                  "enum": [
                    "ACT/365F",
                    "ACT/360",
                    "30/360"
                  ]
                },
                "compounding": {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "simple",
                        "continuous",
                        "annual",
                        "semiannual",
                        "quarterly",
                        "monthly"
                      ]
                    },
                    {
                      "$ref": "#/$defs/Compounding"
                    }
                  ]
                },
                "calendar": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "conventionsVersion",
                "asOfConvention"
              ]
            },
            "observations": {
              "type": "object",
              "properties": {
                "spots": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "properties": {
                      "price": {
                        "type": "number"
                      },
                      "currency": {
                        "type": "string"
                      },
                      "timestampMs": {
                        "type": "number"
                      }
                    },
                    "additionalProperties": true,
                    "required": [
                      "price"
                    ]
                  }
                },
                "riskFreeRates": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "number"
                  }
                },
                "dividendYields": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "number"
                  }
                },
                "volatilities": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "curves": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "properties": {
                      "currency": {
                        "type": "string",
                        "minLength": 1,
                        "description": "Currency the curve discounts in (e.g. 'USD') — the curve states its own"
                      },
                      "asOf": {
                        "type": "number",
                        "description": "Curve valuation instant (epoch ms); every pillar is at or after it"
                      },
                      "dayCount": {
                        "type": "string",
                        "enum": [
                          "ACT/365F",
                          "ACT/360",
                          "30/360"
                        ],
                        "description": "Day-count convention the zero rates are quoted under"
                      },
                      "compounding": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "simple",
                              "continuous",
                              "annual",
                              "semiannual",
                              "quarterly",
                              "monthly"
                            ]
                          },
                          {
                            "$ref": "#/$defs/Compounding"
                          }
                        ],
                        "description": "Interest compounding convention: 'simple' | 'continuous' | 'annual' | 'semiannual' | 'quarterly' | 'monthly' or { type: 'periodic', periodsPerYear }"
                      },
                      "points": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "date": {
                              "type": "string",
                              "format": "date",
                              "description": "Pillar date, 'YYYY-MM-DD'"
                            },
                            "zeroRate": {
                              "type": "number",
                              "description": "Decimal zero rate quoted under the curve's own compounding/dayCount"
                            }
                          },
                          "additionalProperties": true,
                          "required": [
                            "date",
                            "zeroRate"
                          ]
                        },
                        "description": "Pillar points — nonempty and strictly ascending by date (refused with teaching by the semantic validator)"
                      },
                      "interpolation": {
                        "type": "string",
                        "description": "Interpolation-name string when present (e.g. 'linearZero')"
                      }
                    },
                    "additionalProperties": true,
                    "required": [
                      "currency",
                      "asOf",
                      "dayCount",
                      "compounding",
                      "points"
                    ],
                    "description": "A stored RateCurve as plain data: { currency, asOf, dayCount, compounding, points: [{ date: 'YYYY-MM-DD', zeroRate }...], interpolation? } — structural shape above, semantics by core requireRateCurveData (nonempty strictly-ascending pillars at/after asOf, representable discount factors, open to vendor decoration)"
                  }
                },
                "surfaces": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "properties": {
                      "timeToExpiryYears": {
                        "type": "array",
                        "items": {
                          "type": "number",
                          "minimum": 0
                        }
                      },
                      "strikes": {
                        "type": "array",
                        "items": {
                          "type": "number",
                          "exclusiveMinimum": 0
                        }
                      },
                      "impliedVolatilities": {
                        "type": "array",
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "number",
                            "minimum": 0
                          }
                        }
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "timeToExpiryYears",
                      "strikes",
                      "impliedVolatilities"
                    ]
                  }
                },
                "chains": {
                  "type": "object",
                  "additionalProperties": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "quotes": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "bid": {
                                  "type": "number"
                                },
                                "ask": {
                                  "type": "number"
                                },
                                "bidSize": {
                                  "type": "number"
                                },
                                "askSize": {
                                  "type": "number"
                                },
                                "mid": {
                                  "type": "number"
                                },
                                "last": {
                                  "type": "number"
                                },
                                "mark": {
                                  "type": "number"
                                },
                                "price": {
                                  "type": "number"
                                },
                                "size": {
                                  "type": "number"
                                },
                                "volume": {
                                  "type": "number"
                                },
                                "openInterest": {
                                  "type": "number"
                                },
                                "underlyingPrice": {
                                  "type": "number"
                                },
                                "impliedVolatility": {
                                  "type": "number"
                                },
                                "timestampMs": {
                                  "type": "number"
                                },
                                "sequence": {
                                  "type": "number"
                                },
                                "premium": {
                                  "type": "number"
                                },
                                "notional": {
                                  "type": "number"
                                }
                              },
                              "additionalProperties": true
                            }
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "quotes"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "table": {
                            "type": "object",
                            "properties": {
                              "kind": {
                                "const": "totalfinance.table-handle",
                                "type": "string"
                              },
                              "contentHash": {
                                "type": "string"
                              },
                              "rowCount": {
                                "type": "integer",
                                "minimum": 0
                              },
                              "columnCount": {
                                "type": "integer",
                                "minimum": 0
                              },
                              "columns": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "locator": {
                                "type": "string"
                              },
                              "mediaType": {
                                "type": "string"
                              }
                            },
                            "additionalProperties": false,
                            "required": [
                              "kind",
                              "contentHash",
                              "rowCount",
                              "columnCount"
                            ]
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "table"
                        ]
                      }
                    ]
                  }
                }
              },
              "additionalProperties": false
            },
            "provenance": {
              "$ref": "#/$defs/Provenance"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "schemaVersion",
            "asOf",
            "conventions",
            "observations"
          ]
        },
        {
          "type": "string",
          "pattern": "^totalfinance:\\/\\/markets\\/"
        }
      ]
    },
    "asOf": {
      "type": "number",
      "description": "Epoch ms — the instant the plan is judged at"
    },
    "policy": {
      "type": "object",
      "properties": {
        "mode": {
          "const": "paper",
          "type": "string"
        },
        "limits": {
          "type": "object",
          "properties": {
            "maximumPositionWeight": {
              "type": "number",
              "minimum": 0
            },
            "maximumGroupWeights": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "group": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "instrumentId": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "instrumentId"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "sleeveId": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "sleeveId"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "assetClass": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "assetClass"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "currency": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "currency"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "tag": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "tag"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "underlying": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "underlying"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "strategy": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "strategy"
                        ]
                      }
                    ]
                  },
                  "maximumWeight": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "group",
                  "maximumWeight"
                ]
              }
            },
            "maximumGrossLeverage": {
              "type": "number",
              "exclusiveMinimum": 0
            },
            "maximumDrawdown": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "maximumDailyLoss": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "maximumDaysToLiquidate": {
              "type": "number",
              "exclusiveMinimum": 0
            },
            "minimumSettledCash": {
              "type": "number"
            }
          },
          "additionalProperties": false
        },
        "allowedAccounts": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "allowedAssetClasses": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "allowedInstruments": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "allowedOrderTypes": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "market",
              "limit",
              "stop",
              "stop-limit",
              "market-on-open",
              "market-on-close"
            ]
          }
        },
        "maximumOrderQuantity": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "maximumOrderNotional": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "maximumEstimatedCost": {
          "type": "number",
          "minimum": 0,
          "description": "Absolute base-currency estimated-cost ceiling; zero is a binding zero ceiling"
        },
        "maximumSlippageBps": {
          "type": "number",
          "minimum": 0,
          "description": "Slippage ceiling in basis points; zero permits no positive estimated slippage"
        },
        "maximumParticipation": {
          "type": "number",
          "maximum": 1,
          "exclusiveMinimum": 0
        },
        "allowUndefinedRiskOptions": {
          "type": "boolean",
          "description": "Default false: undefined-risk options are denied"
        },
        "marketMaximumAgeMs": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "maximumTurnover": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "requireApprovalAbove": {
          "type": "object",
          "properties": {
            "notional": {
              "type": "number",
              "minimum": 0
            },
            "quantity": {
              "type": "number",
              "minimum": 0
            }
          },
          "additionalProperties": false
        },
        "onUnverifiable": {
          "type": "string",
          "enum": [
            "require-approval",
            "deny"
          ],
          "description": "Default require-approval; missing evidence never implies allow"
        }
      },
      "additionalProperties": false,
      "required": [
        "mode"
      ]
    },
    "costs": {
      "type": "object",
      "properties": {
        "commissionBps": {
          "type": "number",
          "minimum": 0
        },
        "commissionPerOrder": {
          "type": "number",
          "minimum": 0
        },
        "spreadBps": {
          "type": "number",
          "minimum": 0
        },
        "slippageBps": {
          "type": "number",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "instruments": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "contractMultiplier": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "contract": {
            "$ref": "#/$defs/Contract"
          },
          "assetClass": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "currency"
        ]
      }
    },
    "session": {
      "type": "object",
      "properties": {
        "open": {
          "type": "boolean"
        },
        "halted": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false,
      "required": [
        "open"
      ]
    },
    "openOrders": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Orders"
      }
    },
    "volumes": {
      "type": "object",
      "additionalProperties": {
        "type": "number",
        "minimum": 0
      }
    }
  },
  "additionalProperties": false,
  "required": [
    "portfolio",
    "market",
    "asOf",
    "policy"
  ],
  "oneOf": [
    {
      "required": [
        "plan"
      ],
      "not": {
        "required": [
          "intent"
        ]
      }
    },
    {
      "required": [
        "intent"
      ],
      "not": {
        "required": [
          "plan"
        ]
      }
    }
  ],
  "$id": "https://totalfinance.dev/schemas/trade.preflight.input",
  "$defs": {
    "PortfolioEventEnvelope": {
      "allOf": [
        {
          "type": "object",
          "properties": {
            "eventId": {
              "type": "string",
              "minLength": 1
            },
            "schemaVersion": {
              "const": 1,
              "type": "number"
            },
            "sourceId": {
              "type": "string",
              "minLength": 1
            },
            "accountId": {
              "type": "string",
              "minLength": 1
            },
            "effectiveTimestampMs": {
              "type": "number",
              "description": "Epoch milliseconds"
            },
            "recordedTimestampMs": {
              "type": "number",
              "description": "Epoch milliseconds"
            },
            "correlationId": {
              "type": "string",
              "minLength": 1
            },
            "causationId": {
              "type": "string",
              "minLength": 1
            },
            "reversesEventId": {
              "type": "string",
              "minLength": 1
            },
            "provenance": {
              "$ref": "#/$defs/Provenance"
            },
            "eventType": {},
            "event": {}
          },
          "additionalProperties": false,
          "required": [
            "eventId",
            "schemaVersion",
            "sourceId",
            "accountId",
            "effectiveTimestampMs",
            "recordedTimestampMs",
            "provenance",
            "eventType",
            "event"
          ]
        },
        {
          "anyOf": [
            {
              "properties": {
                "eventType": {
                  "const": "cash.deposit",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CashDeposit"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "cash.withdrawal",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CashWithdrawal"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "cash.transfer",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CashTransfer"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "cash.conversion",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CashConversion"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "trade.fill",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/TradeFill"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "cost.charge",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CostCharge"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "income.received",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/IncomeReceived"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "financing.charge",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/FinancingCharge"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "corporate.split",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CorporateSplit"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "derivative.exercise",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/DerivativeExercise"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "derivative.assignment",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/DerivativeAssignment"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "derivative.expiration",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/DerivativeExpiration"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "derivative.multiplier-change",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/DerivativeMultiplierChange"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "derivative.variation-margin",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/DerivativeVariationMargin"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "derivative.roll",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/DerivativeRoll"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "fixed-income.redemption",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/FixedIncomeRedemption"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "corporate.symbol-change",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CorporateSymbolChange"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "corporate.merger",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CorporateMerger"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "corporate.spin-off",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CorporateSpinOff"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "corporate.return-of-capital",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CorporateReturnOfCapital"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "corporate.cash-in-lieu",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CorporateCashInLieu"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "position.transfer",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/PositionTransfer"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "admin.reversal",
                  "type": "string"
                },
                "event": {
                  "type": "object",
                  "properties": {
                    "eventType": {
                      "const": "admin.reversal",
                      "type": "string"
                    },
                    "original": {
                      "$ref": "#/$defs/PortfolioEventEnvelope"
                    },
                    "reason": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "eventType",
                    "original"
                  ]
                }
              },
              "required": [
                "reversesEventId"
              ]
            },
            {
              "properties": {
                "eventType": {
                  "const": "admin.correction",
                  "type": "string"
                },
                "event": {
                  "type": "object",
                  "properties": {
                    "eventType": {
                      "const": "admin.correction",
                      "type": "string"
                    },
                    "original": {
                      "$ref": "#/$defs/PortfolioEventEnvelope"
                    },
                    "replacement": {
                      "anyOf": [
                        {
                          "$ref": "#/$defs/CashDeposit"
                        },
                        {
                          "$ref": "#/$defs/CashWithdrawal"
                        },
                        {
                          "$ref": "#/$defs/CashTransfer"
                        },
                        {
                          "$ref": "#/$defs/CashConversion"
                        },
                        {
                          "$ref": "#/$defs/TradeFill"
                        },
                        {
                          "$ref": "#/$defs/CostCharge"
                        },
                        {
                          "$ref": "#/$defs/IncomeReceived"
                        },
                        {
                          "$ref": "#/$defs/FinancingCharge"
                        },
                        {
                          "$ref": "#/$defs/CorporateSplit"
                        },
                        {
                          "$ref": "#/$defs/DerivativeExercise"
                        },
                        {
                          "$ref": "#/$defs/DerivativeAssignment"
                        },
                        {
                          "$ref": "#/$defs/DerivativeExpiration"
                        },
                        {
                          "$ref": "#/$defs/DerivativeMultiplierChange"
                        },
                        {
                          "$ref": "#/$defs/DerivativeVariationMargin"
                        },
                        {
                          "$ref": "#/$defs/DerivativeRoll"
                        },
                        {
                          "$ref": "#/$defs/FixedIncomeRedemption"
                        },
                        {
                          "$ref": "#/$defs/CorporateSymbolChange"
                        },
                        {
                          "$ref": "#/$defs/CorporateMerger"
                        },
                        {
                          "$ref": "#/$defs/CorporateSpinOff"
                        },
                        {
                          "$ref": "#/$defs/CorporateReturnOfCapital"
                        },
                        {
                          "$ref": "#/$defs/CorporateCashInLieu"
                        },
                        {
                          "$ref": "#/$defs/PositionTransfer"
                        }
                      ]
                    },
                    "reason": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "eventType",
                    "original",
                    "replacement"
                  ]
                }
              },
              "required": [
                "reversesEventId"
              ]
            },
            {
              "properties": {
                "eventType": {
                  "const": "admin.account-migration",
                  "type": "string"
                },
                "event": {
                  "type": "object",
                  "properties": {
                    "eventType": {
                      "const": "admin.account-migration",
                      "type": "string"
                    },
                    "fromAccountId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "toAccountId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "reason": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "eventType",
                    "fromAccountId",
                    "toAccountId"
                  ]
                }
              }
            }
          ]
        }
      ]
    },
    "Orders": {
      "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"
          ]
        },
        {
          "$ref": "#/$defs/Orders3"
        }
      ]
    },
    "Orders3": {
      "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"
          ]
        }
      ]
    },
    "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
    },
    "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"
          ]
        }
      ]
    },
    "Compounding": {
      "type": "object",
      "properties": {
        "type": {
          "const": "periodic",
          "type": "string"
        },
        "periodsPerYear": {
          "type": "number",
          "exclusiveMinimum": 0
        }
      },
      "additionalProperties": true,
      "required": [
        "type",
        "periodsPerYear"
      ]
    },
    "CashDeposit": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "cash.deposit",
          "type": "string"
        },
        "amount": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "amount",
        "currency"
      ]
    },
    "CashWithdrawal": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "cash.withdrawal",
          "type": "string"
        },
        "amount": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "amount",
        "currency"
      ]
    },
    "CashTransfer": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "cash.transfer",
          "type": "string"
        },
        "amount": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "fromAccountId": {
          "type": "string",
          "minLength": 1
        },
        "toAccountId": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "amount",
        "currency",
        "fromAccountId",
        "toAccountId"
      ]
    },
    "CashConversion": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "cash.conversion",
          "type": "string"
        },
        "fromCurrency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "toCurrency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "fromAmount": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "toAmount": {
          "type": "number",
          "exclusiveMinimum": 0
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "fromCurrency",
        "toCurrency",
        "fromAmount",
        "toAmount"
      ]
    },
    "TradeFill": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "trade.fill",
          "type": "string"
        },
        "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}$"
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        },
        "lotSelections": {
          "$ref": "#/$defs/LotSelections"
        },
        "contractMultiplier": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "settlementStyle": {
          "type": "string",
          "enum": [
            "cash-on-trade",
            "variation-margin"
          ]
        },
        "contract": {
          "$ref": "#/$defs/Contract"
        },
        "accruedInterest": {
          "type": "number"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "side",
        "quantity",
        "pricePerUnit",
        "currency"
      ]
    },
    "LotSelections": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "lotId": {
            "type": "string",
            "minLength": 1
          },
          "quantity": {
            "type": "number",
            "exclusiveMinimum": 0
          }
        },
        "additionalProperties": false,
        "required": [
          "lotId",
          "quantity"
        ]
      },
      "minItems": 1
    },
    "CostCharge": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "cost.charge",
          "type": "string"
        },
        "costType": {
          "type": "string",
          "enum": [
            "commission",
            "exchange-fee",
            "regulatory-fee",
            "slippage-adjustment"
          ]
        },
        "amount": {
          "type": "number"
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "relatesToEventId": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "costType",
        "amount",
        "currency"
      ]
    },
    "IncomeReceived": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "income.received",
          "type": "string"
        },
        "incomeType": {
          "type": "string",
          "enum": [
            "dividend",
            "coupon",
            "interest",
            "staking-reward",
            "funding-receipt"
          ]
        },
        "amount": {
          "type": "number"
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "incomeType",
        "amount",
        "currency"
      ]
    },
    "FinancingCharge": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "financing.charge",
          "type": "string"
        },
        "financingType": {
          "type": "string",
          "enum": [
            "margin-interest",
            "borrow-charge",
            "funding-payment"
          ]
        },
        "amount": {
          "type": "number"
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "financingType",
        "amount",
        "currency"
      ]
    },
    "CorporateSplit": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "corporate.split",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "sharesAfterSplit": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "sharesBeforeSplit": {
          "type": "number",
          "exclusiveMinimum": 0
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "sharesAfterSplit",
        "sharesBeforeSplit"
      ]
    },
    "DerivativeExercise": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "derivative.exercise",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "quantity": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "settlement": {
          "$ref": "#/$defs/Settlement"
        },
        "premiumTreatment": {
          "type": "string",
          "enum": [
            "fold-into-underlying-basis",
            "realize"
          ]
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        },
        "lotSelections": {
          "$ref": "#/$defs/LotSelections"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "quantity",
        "settlement",
        "premiumTreatment"
      ]
    },
    "Settlement": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "physical",
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "cash",
              "type": "string"
            },
            "settlementPricePerUnit": {
              "type": "number"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "settlementPricePerUnit"
          ]
        }
      ]
    },
    "DerivativeAssignment": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "derivative.assignment",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "quantity": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "settlement": {
          "$ref": "#/$defs/Settlement"
        },
        "premiumTreatment": {
          "type": "string",
          "enum": [
            "fold-into-underlying-basis",
            "realize"
          ]
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        },
        "lotSelections": {
          "$ref": "#/$defs/LotSelections"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "quantity",
        "settlement",
        "premiumTreatment"
      ]
    },
    "DerivativeExpiration": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "derivative.expiration",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "quantity": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "lotSelections": {
          "$ref": "#/$defs/LotSelections"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "quantity"
      ]
    },
    "DerivativeMultiplierChange": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "derivative.multiplier-change",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "contractMultiplierAfter": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "strikePricePerUnitAfter": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "reason": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "contractMultiplierAfter"
      ]
    },
    "DerivativeVariationMargin": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "derivative.variation-margin",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "settlementPricePerUnit": {
          "type": "number"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "settlementPricePerUnit"
      ]
    },
    "DerivativeRoll": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "derivative.roll",
          "type": "string"
        },
        "fromInstrumentId": {
          "type": "string",
          "minLength": 1
        },
        "toInstrumentId": {
          "type": "string",
          "minLength": 1
        },
        "quantity": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "closePricePerUnit": {
          "type": "number"
        },
        "openPricePerUnit": {
          "type": "number"
        },
        "contract": {
          "$ref": "#/$defs/Contract"
        },
        "lotSelections": {
          "$ref": "#/$defs/LotSelections"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "fromInstrumentId",
        "toInstrumentId",
        "quantity",
        "closePricePerUnit",
        "openPricePerUnit"
      ]
    },
    "FixedIncomeRedemption": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "fixed-income.redemption",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "redemptionType": {
          "type": "string",
          "enum": [
            "maturity",
            "call",
            "principal-paydown",
            "sinking-fund"
          ]
        },
        "quantity": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "pricePerUnit": {
          "type": "number"
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        },
        "lotSelections": {
          "$ref": "#/$defs/LotSelections"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "redemptionType",
        "quantity",
        "pricePerUnit",
        "currency"
      ]
    },
    "CorporateSymbolChange": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "corporate.symbol-change",
          "type": "string"
        },
        "fromInstrumentId": {
          "type": "string",
          "minLength": 1
        },
        "toInstrumentId": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "fromInstrumentId",
        "toInstrumentId"
      ]
    },
    "CorporateMerger": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "corporate.merger",
          "type": "string"
        },
        "fromInstrumentId": {
          "type": "string",
          "minLength": 1
        },
        "toInstrumentId": {
          "type": "string",
          "minLength": 1
        },
        "sharesPerShare": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "cashPerShare": {
          "type": "number"
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "fromInstrumentId"
      ]
    },
    "CorporateSpinOff": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "corporate.spin-off",
          "type": "string"
        },
        "parentInstrumentId": {
          "type": "string",
          "minLength": 1
        },
        "childInstrumentId": {
          "type": "string",
          "minLength": 1
        },
        "sharesPerParentShare": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "basisAllocationFraction": {
          "type": "number"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "parentInstrumentId",
        "childInstrumentId",
        "sharesPerParentShare",
        "basisAllocationFraction"
      ]
    },
    "CorporateReturnOfCapital": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "corporate.return-of-capital",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "amountPerShare": {
          "type": "number"
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "amountPerShare",
        "currency"
      ]
    },
    "CorporateCashInLieu": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "corporate.cash-in-lieu",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "quantity": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "amount": {
          "type": "number"
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "relatesToEventId": {
          "type": "string",
          "minLength": 1
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "quantity",
        "amount",
        "currency"
      ]
    },
    "PositionTransfer": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "position.transfer",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "quantity": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "fromAccountId": {
          "type": "string",
          "minLength": 1
        },
        "toAccountId": {
          "type": "string",
          "minLength": 1
        },
        "lotSelections": {
          "$ref": "#/$defs/LotSelections"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "quantity",
        "fromAccountId",
        "toAccountId"
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "properties": {
    "kind": {
      "const": "totalfinance.preflight-report",
      "type": "string"
    },
    "schemaVersion": {
      "const": 1,
      "type": "number"
    },
    "asOf": {
      "type": "number",
      "description": "Epoch milliseconds"
    },
    "planHash": {
      "type": "string",
      "minLength": 1
    },
    "portfolioHash": {
      "type": "string",
      "minLength": 1
    },
    "marketHash": {
      "type": "string",
      "minLength": 1
    },
    "marketAsOf": {
      "type": "number",
      "description": "Epoch milliseconds"
    },
    "before": {
      "$ref": "#/$defs/Before"
    },
    "after": {
      "$ref": "#/$defs/Before"
    },
    "hypotheticalFills": {
      "type": "array",
      "items": {
        "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"
        ]
      }
    },
    "hypotheticalEvents": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/PortfolioEventEnvelope"
      }
    },
    "estimates": {
      "type": "object",
      "properties": {
        "tradedNotional": {
          "type": "number"
        },
        "commission": {
          "type": "number"
        },
        "spread": {
          "type": "number"
        },
        "slippage": {
          "type": "number"
        },
        "totalCost": {
          "type": "number"
        },
        "turnover": {
          "type": "number"
        }
      },
      "additionalProperties": false,
      "required": [
        "tradedNotional",
        "commission",
        "spread",
        "slippage",
        "totalCost",
        "turnover"
      ]
    },
    "checks": {
      "$ref": "#/$defs/Checks"
    },
    "alerts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "minLength": 1
          },
          "family": {
            "type": "string",
            "enum": [
              "allocation-drift",
              "concentration-limit",
              "leverage-limit",
              "drawdown",
              "daily-loss",
              "cash-reserve",
              "margin-pressure",
              "liquidity",
              "option-expiration",
              "assignment-risk",
              "stale-market-data",
              "reconciliation-difference",
              "unexplained-residual",
              "unusual-pnl"
            ]
          },
          "subject": {
            "type": "string"
          },
          "severity": {
            "type": "string",
            "enum": [
              "informational",
              "warning",
              "critical"
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "raised",
              "active",
              "acknowledged",
              "suppressed",
              "cleared"
            ]
          },
          "value": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "threshold": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "direction": {
            "type": "string",
            "enum": [
              "above",
              "below"
            ]
          },
          "message": {
            "type": "string"
          },
          "evidence": {
            "type": "object",
            "additionalProperties": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "key",
          "family",
          "subject",
          "severity",
          "state",
          "value",
          "threshold",
          "direction",
          "message",
          "evidence"
        ]
      }
    },
    "decision": {
      "allOf": [
        {
          "type": "object",
          "properties": {
            "verdict": {},
            "checks": {
              "$ref": "#/$defs/Checks"
            },
            "requiredScope": {}
          },
          "additionalProperties": false,
          "required": [
            "verdict",
            "checks"
          ]
        },
        {
          "anyOf": [
            {
              "properties": {
                "verdict": {
                  "const": "allow",
                  "type": "string"
                }
              },
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "requiredScope"
                    ]
                  }
                ]
              }
            },
            {
              "properties": {
                "verdict": {
                  "const": "deny",
                  "type": "string"
                }
              },
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "requiredScope"
                    ]
                  }
                ]
              }
            },
            {
              "properties": {
                "verdict": {
                  "const": "require-approval",
                  "type": "string"
                },
                "requiredScope": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "required": [
                "requiredScope"
              ]
            }
          ]
        }
      ]
    },
    "unverifiable": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "monitorState": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "schemaVersion": {
              "const": 1,
              "type": "number"
            },
            "asOf": {
              "type": "number",
              "description": "Epoch milliseconds"
            },
            "netAssetValue": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ]
            },
            "peakNetAssetValue": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ]
            },
            "evaluationCount": {
              "type": "integer",
              "minimum": 0
            },
            "rules": {
              "type": "object",
              "additionalProperties": {
                "type": "object",
                "properties": {
                  "active": {
                    "type": "boolean"
                  },
                  "consecutiveBreaches": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "lastRaisedAtMs": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "acknowledged": {
                    "type": "boolean"
                  },
                  "lastValue": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "active",
                  "consecutiveBreaches",
                  "lastRaisedAtMs",
                  "acknowledged",
                  "lastValue"
                ]
              }
            }
          },
          "additionalProperties": false,
          "required": [
            "schemaVersion",
            "asOf",
            "netAssetValue",
            "peakNetAssetValue",
            "evaluationCount",
            "rules"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "assumptions": {
      "type": "object",
      "properties": {
        "conventionsVersion": {
          "type": "string"
        },
        "policyContentHash": {
          "type": "string"
        },
        "mode": {
          "const": "paper",
          "type": "string"
        },
        "costRates": {
          "type": "object",
          "properties": {
            "commissionBps": {
              "type": "number",
              "minimum": 0
            },
            "commissionPerOrder": {
              "type": "number",
              "minimum": 0
            },
            "spreadBps": {
              "type": "number",
              "minimum": 0
            },
            "slippageBps": {
              "type": "number",
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "commissionBps",
            "commissionPerOrder",
            "spreadBps",
            "slippageBps"
          ]
        },
        "fillConvention": {
          "type": "string"
        },
        "instrumentSources": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "decisionConvention": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "conventionsVersion",
        "policyContentHash",
        "mode",
        "costRates",
        "fillConvention",
        "instrumentSources",
        "decisionConvention"
      ]
    },
    "diagnostics": {
      "type": "object",
      "properties": {
        "engine": {
          "const": "trade-preflight",
          "type": "string"
        },
        "method": {
          "const": "hypothetical-fold",
          "type": "string"
        },
        "converged": {
          "const": true,
          "type": "boolean"
        },
        "warnings": {
          "$ref": "#/$defs/Warnings"
        },
        "checkCount": {
          "type": "integer",
          "minimum": 0
        },
        "failedCount": {
          "type": "integer",
          "minimum": 0
        },
        "unverifiableCount": {
          "type": "integer",
          "minimum": 0
        }
      },
      "additionalProperties": false,
      "required": [
        "engine",
        "method",
        "converged",
        "warnings",
        "checkCount",
        "failedCount",
        "unverifiableCount"
      ]
    },
    "contentHash": {
      "type": "string",
      "minLength": 1
    },
    "plan": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "totalfinance.execution-plan",
          "type": "string"
        },
        "schemaVersion": {
          "const": 1,
          "type": "number"
        },
        "accountId": {
          "type": "string",
          "minLength": 1
        },
        "asOf": {
          "type": "number",
          "description": "Epoch milliseconds"
        },
        "baseCurrency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "portfolioId": {
          "type": "string",
          "minLength": 1
        },
        "orders": {
          "type": "array",
          "items": {
            "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"
                    ]
                  }
                ]
              }
            ]
          },
          "minItems": 1,
          "maxItems": 1000
        },
        "combos": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "comboId": {
                "type": "string",
                "minLength": 1
              },
              "orderIds": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                },
                "minItems": 2,
                "description": "The legs, in plan order (at least two)"
              },
              "netLimitPrice": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "comboId",
              "orderIds"
            ]
          }
        },
        "trades": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "accountId": {
                "type": "string",
                "minLength": 1
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "side": {
                "type": "string",
                "enum": [
                  "buy",
                  "sell"
                ]
              },
              "quantity": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "referencePricePerUnit": {
                "type": "number"
              },
              "contractMultiplier": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "estimatedNotional": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "accountId",
              "instrumentId",
              "side",
              "quantity",
              "currency",
              "referencePricePerUnit",
              "contractMultiplier",
              "estimatedNotional"
            ]
          }
        },
        "source": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "kind": {
                  "const": "intent",
                  "type": "string"
                },
                "intentHash": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "additionalProperties": false,
              "required": [
                "kind",
                "intentHash"
              ]
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "const": "rebalance-proposal",
                  "type": "string"
                },
                "planHash": {
                  "type": "string",
                  "minLength": 1
                },
                "policyContentHash": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "additionalProperties": false,
              "required": [
                "kind",
                "planHash",
                "policyContentHash"
              ]
            }
          ]
        },
        "rationale": {
          "type": "string"
        },
        "evidence": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "contentHash": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "schemaVersion",
        "accountId",
        "asOf",
        "baseCurrency",
        "orders",
        "combos",
        "trades",
        "source",
        "evidence",
        "contentHash"
      ]
    }
  },
  "additionalProperties": false,
  "required": [
    "kind",
    "schemaVersion",
    "asOf",
    "planHash",
    "portfolioHash",
    "marketHash",
    "marketAsOf",
    "before",
    "after",
    "hypotheticalFills",
    "hypotheticalEvents",
    "estimates",
    "checks",
    "alerts",
    "decision",
    "unverifiable",
    "monitorState",
    "assumptions",
    "diagnostics",
    "contentHash",
    "plan"
  ],
  "$id": "https://totalfinance.dev/schemas/trade.preflight.output",
  "$defs": {
    "PortfolioEventEnvelope": {
      "allOf": [
        {
          "type": "object",
          "properties": {
            "eventId": {
              "type": "string",
              "minLength": 1
            },
            "schemaVersion": {
              "const": 1,
              "type": "number"
            },
            "sourceId": {
              "type": "string",
              "minLength": 1
            },
            "accountId": {
              "type": "string",
              "minLength": 1
            },
            "effectiveTimestampMs": {
              "type": "number",
              "description": "Epoch milliseconds"
            },
            "recordedTimestampMs": {
              "type": "number",
              "description": "Epoch milliseconds"
            },
            "correlationId": {
              "type": "string",
              "minLength": 1
            },
            "causationId": {
              "type": "string",
              "minLength": 1
            },
            "reversesEventId": {
              "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": {
                  "$ref": "#/$defs/Warnings"
                }
              },
              "additionalProperties": false
            },
            "eventType": {},
            "event": {}
          },
          "additionalProperties": false,
          "required": [
            "eventId",
            "schemaVersion",
            "sourceId",
            "accountId",
            "effectiveTimestampMs",
            "recordedTimestampMs",
            "provenance",
            "eventType",
            "event"
          ]
        },
        {
          "anyOf": [
            {
              "properties": {
                "eventType": {
                  "const": "cash.deposit",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CashDeposit"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "cash.withdrawal",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CashWithdrawal"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "cash.transfer",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CashTransfer"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "cash.conversion",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CashConversion"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "trade.fill",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/TradeFill"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "cost.charge",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CostCharge"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "income.received",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/IncomeReceived"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "financing.charge",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/FinancingCharge"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "corporate.split",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CorporateSplit"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "derivative.exercise",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/DerivativeExercise"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "derivative.assignment",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/DerivativeAssignment"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "derivative.expiration",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/DerivativeExpiration"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "derivative.multiplier-change",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/DerivativeMultiplierChange"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "derivative.variation-margin",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/DerivativeVariationMargin"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "derivative.roll",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/DerivativeRoll"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "fixed-income.redemption",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/FixedIncomeRedemption"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "corporate.symbol-change",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CorporateSymbolChange"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "corporate.merger",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CorporateMerger"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "corporate.spin-off",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CorporateSpinOff"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "corporate.return-of-capital",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CorporateReturnOfCapital"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "corporate.cash-in-lieu",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/CorporateCashInLieu"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "position.transfer",
                  "type": "string"
                },
                "event": {
                  "$ref": "#/$defs/PositionTransfer"
                }
              }
            },
            {
              "properties": {
                "eventType": {
                  "const": "admin.reversal",
                  "type": "string"
                },
                "event": {
                  "type": "object",
                  "properties": {
                    "eventType": {
                      "const": "admin.reversal",
                      "type": "string"
                    },
                    "original": {
                      "$ref": "#/$defs/PortfolioEventEnvelope"
                    },
                    "reason": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "eventType",
                    "original"
                  ]
                }
              },
              "required": [
                "reversesEventId"
              ]
            },
            {
              "properties": {
                "eventType": {
                  "const": "admin.correction",
                  "type": "string"
                },
                "event": {
                  "type": "object",
                  "properties": {
                    "eventType": {
                      "const": "admin.correction",
                      "type": "string"
                    },
                    "original": {
                      "$ref": "#/$defs/PortfolioEventEnvelope"
                    },
                    "replacement": {
                      "anyOf": [
                        {
                          "$ref": "#/$defs/CashDeposit"
                        },
                        {
                          "$ref": "#/$defs/CashWithdrawal"
                        },
                        {
                          "$ref": "#/$defs/CashTransfer"
                        },
                        {
                          "$ref": "#/$defs/CashConversion"
                        },
                        {
                          "$ref": "#/$defs/TradeFill"
                        },
                        {
                          "$ref": "#/$defs/CostCharge"
                        },
                        {
                          "$ref": "#/$defs/IncomeReceived"
                        },
                        {
                          "$ref": "#/$defs/FinancingCharge"
                        },
                        {
                          "$ref": "#/$defs/CorporateSplit"
                        },
                        {
                          "$ref": "#/$defs/DerivativeExercise"
                        },
                        {
                          "$ref": "#/$defs/DerivativeAssignment"
                        },
                        {
                          "$ref": "#/$defs/DerivativeExpiration"
                        },
                        {
                          "$ref": "#/$defs/DerivativeMultiplierChange"
                        },
                        {
                          "$ref": "#/$defs/DerivativeVariationMargin"
                        },
                        {
                          "$ref": "#/$defs/DerivativeRoll"
                        },
                        {
                          "$ref": "#/$defs/FixedIncomeRedemption"
                        },
                        {
                          "$ref": "#/$defs/CorporateSymbolChange"
                        },
                        {
                          "$ref": "#/$defs/CorporateMerger"
                        },
                        {
                          "$ref": "#/$defs/CorporateSpinOff"
                        },
                        {
                          "$ref": "#/$defs/CorporateReturnOfCapital"
                        },
                        {
                          "$ref": "#/$defs/CorporateCashInLieu"
                        },
                        {
                          "$ref": "#/$defs/PositionTransfer"
                        }
                      ]
                    },
                    "reason": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "eventType",
                    "original",
                    "replacement"
                  ]
                }
              },
              "required": [
                "reversesEventId"
              ]
            },
            {
              "properties": {
                "eventType": {
                  "const": "admin.account-migration",
                  "type": "string"
                },
                "event": {
                  "type": "object",
                  "properties": {
                    "eventType": {
                      "const": "admin.account-migration",
                      "type": "string"
                    },
                    "fromAccountId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "toAccountId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "reason": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "eventType",
                    "fromAccountId",
                    "toAccountId"
                  ]
                }
              }
            }
          ]
        }
      ]
    },
    "Before": {
      "type": "object",
      "properties": {
        "asOf": {
          "type": "number",
          "description": "Epoch milliseconds"
        },
        "baseCurrency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "netAssetValue": {
          "type": "number"
        },
        "cash": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "accountId": {
                "type": "string",
                "minLength": 1
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "totalAmount": {
                "type": "number"
              },
              "settledAmount": {
                "type": "number"
              },
              "unsettledReceivable": {
                "type": "number"
              },
              "unsettledPayable": {
                "type": "number"
              },
              "baseCurrencyValue": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "accountId",
              "currency",
              "totalAmount",
              "settledAmount",
              "unsettledReceivable",
              "unsettledPayable",
              "baseCurrencyValue"
            ]
          }
        },
        "totalCashBaseCurrencyValue": {
          "type": "number"
        },
        "positions": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "accountId": {
                "type": "string",
                "minLength": 1
              },
              "instrumentId": {
                "type": "string",
                "minLength": 1
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "quantity": {
                "type": "number"
              },
              "markPricePerUnit": {
                "type": "number"
              },
              "contractMultiplier": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "settlementStyle": {
                "type": "string",
                "enum": [
                  "cash-on-trade",
                  "variation-margin"
                ]
              },
              "marketValue": {
                "type": "number"
              },
              "baseCurrencyMarketValue": {
                "type": "number"
              },
              "notionalValue": {
                "type": "number"
              },
              "baseCurrencyNotionalValue": {
                "type": "number"
              },
              "costBasis": {
                "type": "number"
              },
              "unrealizedPnl": {
                "type": "number"
              },
              "baseCurrencyUnrealizedPnl": {
                "type": "number"
              },
              "lotCount": {
                "type": "integer",
                "minimum": 0
              }
            },
            "additionalProperties": false,
            "required": [
              "accountId",
              "instrumentId",
              "currency",
              "quantity",
              "markPricePerUnit",
              "contractMultiplier",
              "settlementStyle",
              "marketValue",
              "baseCurrencyMarketValue",
              "notionalValue",
              "baseCurrencyNotionalValue",
              "costBasis",
              "unrealizedPnl",
              "baseCurrencyUnrealizedPnl",
              "lotCount"
            ]
          }
        },
        "totalPositionsBaseCurrencyValue": {
          "type": "number"
        },
        "assumptions": {
          "type": "object",
          "properties": {
            "conventionsVersion": {
              "type": "string"
            },
            "lotRelief": {
              "type": "string",
              "enum": [
                "fifo",
                "lifo",
                "highest-cost",
                "specific-lot"
              ]
            },
            "marketAsOf": {
              "type": "number",
              "description": "Epoch milliseconds"
            },
            "currencyConversionsUsed": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "baseCurrency": {
                    "type": "string",
                    "pattern": "^[A-Z]{3}$"
                  },
                  "quoteCurrency": {
                    "type": "string",
                    "pattern": "^[A-Z]{3}$"
                  },
                  "quotePerBase": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  }
                },
                "additionalProperties": false,
                "required": [
                  "baseCurrency",
                  "quoteCurrency",
                  "quotePerBase"
                ]
              }
            },
            "valuationConvention": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "conventionsVersion",
            "lotRelief",
            "marketAsOf",
            "currencyConversionsUsed",
            "valuationConvention"
          ]
        },
        "diagnostics": {
          "type": "object",
          "properties": {
            "warnings": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "accountCount": {
              "type": "integer",
              "minimum": 0
            },
            "positionCount": {
              "type": "integer",
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": [
            "warnings",
            "accountCount",
            "positionCount"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "asOf",
        "baseCurrency",
        "netAssetValue",
        "cash",
        "totalCashBaseCurrencyValue",
        "positions",
        "totalPositionsBaseCurrencyValue",
        "assumptions",
        "diagnostics"
      ]
    },
    "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"
          ]
        }
      ]
    },
    "Checks": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "verdict": {
            "type": "string",
            "enum": [
              "pass",
              "fail",
              "unverifiable",
              "require-approval"
            ]
          },
          "value": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "limit": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "detail": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "name",
          "verdict",
          "value",
          "limit",
          "detail"
        ]
      }
    },
    "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"
        ]
      }
    },
    "CashDeposit": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "cash.deposit",
          "type": "string"
        },
        "amount": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "amount",
        "currency"
      ]
    },
    "CashWithdrawal": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "cash.withdrawal",
          "type": "string"
        },
        "amount": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "amount",
        "currency"
      ]
    },
    "CashTransfer": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "cash.transfer",
          "type": "string"
        },
        "amount": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "fromAccountId": {
          "type": "string",
          "minLength": 1
        },
        "toAccountId": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "amount",
        "currency",
        "fromAccountId",
        "toAccountId"
      ]
    },
    "CashConversion": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "cash.conversion",
          "type": "string"
        },
        "fromCurrency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "toCurrency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "fromAmount": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "toAmount": {
          "type": "number",
          "exclusiveMinimum": 0
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "fromCurrency",
        "toCurrency",
        "fromAmount",
        "toAmount"
      ]
    },
    "TradeFill": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "trade.fill",
          "type": "string"
        },
        "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}$"
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        },
        "lotSelections": {
          "$ref": "#/$defs/LotSelections"
        },
        "contractMultiplier": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "settlementStyle": {
          "type": "string",
          "enum": [
            "cash-on-trade",
            "variation-margin"
          ]
        },
        "contract": {
          "$ref": "#/$defs/Contract"
        },
        "accruedInterest": {
          "type": "number"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "side",
        "quantity",
        "pricePerUnit",
        "currency"
      ]
    },
    "LotSelections": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "lotId": {
            "type": "string",
            "minLength": 1
          },
          "quantity": {
            "type": "number",
            "exclusiveMinimum": 0
          }
        },
        "additionalProperties": false,
        "required": [
          "lotId",
          "quantity"
        ]
      },
      "minItems": 1
    },
    "CostCharge": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "cost.charge",
          "type": "string"
        },
        "costType": {
          "type": "string",
          "enum": [
            "commission",
            "exchange-fee",
            "regulatory-fee",
            "slippage-adjustment"
          ]
        },
        "amount": {
          "type": "number"
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "relatesToEventId": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "costType",
        "amount",
        "currency"
      ]
    },
    "IncomeReceived": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "income.received",
          "type": "string"
        },
        "incomeType": {
          "type": "string",
          "enum": [
            "dividend",
            "coupon",
            "interest",
            "staking-reward",
            "funding-receipt"
          ]
        },
        "amount": {
          "type": "number"
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "incomeType",
        "amount",
        "currency"
      ]
    },
    "FinancingCharge": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "financing.charge",
          "type": "string"
        },
        "financingType": {
          "type": "string",
          "enum": [
            "margin-interest",
            "borrow-charge",
            "funding-payment"
          ]
        },
        "amount": {
          "type": "number"
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "financingType",
        "amount",
        "currency"
      ]
    },
    "CorporateSplit": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "corporate.split",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "sharesAfterSplit": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "sharesBeforeSplit": {
          "type": "number",
          "exclusiveMinimum": 0
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "sharesAfterSplit",
        "sharesBeforeSplit"
      ]
    },
    "DerivativeExercise": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "derivative.exercise",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "quantity": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "settlement": {
          "$ref": "#/$defs/Settlement"
        },
        "premiumTreatment": {
          "type": "string",
          "enum": [
            "fold-into-underlying-basis",
            "realize"
          ]
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        },
        "lotSelections": {
          "$ref": "#/$defs/LotSelections"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "quantity",
        "settlement",
        "premiumTreatment"
      ]
    },
    "Settlement": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "physical",
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "cash",
              "type": "string"
            },
            "settlementPricePerUnit": {
              "type": "number"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "settlementPricePerUnit"
          ]
        }
      ]
    },
    "DerivativeAssignment": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "derivative.assignment",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "quantity": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "settlement": {
          "$ref": "#/$defs/Settlement"
        },
        "premiumTreatment": {
          "type": "string",
          "enum": [
            "fold-into-underlying-basis",
            "realize"
          ]
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        },
        "lotSelections": {
          "$ref": "#/$defs/LotSelections"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "quantity",
        "settlement",
        "premiumTreatment"
      ]
    },
    "DerivativeExpiration": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "derivative.expiration",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "quantity": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "lotSelections": {
          "$ref": "#/$defs/LotSelections"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "quantity"
      ]
    },
    "DerivativeMultiplierChange": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "derivative.multiplier-change",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "contractMultiplierAfter": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "strikePricePerUnitAfter": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "reason": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "contractMultiplierAfter"
      ]
    },
    "DerivativeVariationMargin": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "derivative.variation-margin",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "settlementPricePerUnit": {
          "type": "number"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "settlementPricePerUnit"
      ]
    },
    "DerivativeRoll": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "derivative.roll",
          "type": "string"
        },
        "fromInstrumentId": {
          "type": "string",
          "minLength": 1
        },
        "toInstrumentId": {
          "type": "string",
          "minLength": 1
        },
        "quantity": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "closePricePerUnit": {
          "type": "number"
        },
        "openPricePerUnit": {
          "type": "number"
        },
        "contract": {
          "$ref": "#/$defs/Contract"
        },
        "lotSelections": {
          "$ref": "#/$defs/LotSelections"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "fromInstrumentId",
        "toInstrumentId",
        "quantity",
        "closePricePerUnit",
        "openPricePerUnit"
      ]
    },
    "FixedIncomeRedemption": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "fixed-income.redemption",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "redemptionType": {
          "type": "string",
          "enum": [
            "maturity",
            "call",
            "principal-paydown",
            "sinking-fund"
          ]
        },
        "quantity": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "pricePerUnit": {
          "type": "number"
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        },
        "lotSelections": {
          "$ref": "#/$defs/LotSelections"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "redemptionType",
        "quantity",
        "pricePerUnit",
        "currency"
      ]
    },
    "CorporateSymbolChange": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "corporate.symbol-change",
          "type": "string"
        },
        "fromInstrumentId": {
          "type": "string",
          "minLength": 1
        },
        "toInstrumentId": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "fromInstrumentId",
        "toInstrumentId"
      ]
    },
    "CorporateMerger": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "corporate.merger",
          "type": "string"
        },
        "fromInstrumentId": {
          "type": "string",
          "minLength": 1
        },
        "toInstrumentId": {
          "type": "string",
          "minLength": 1
        },
        "sharesPerShare": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "cashPerShare": {
          "type": "number"
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "fromInstrumentId"
      ]
    },
    "CorporateSpinOff": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "corporate.spin-off",
          "type": "string"
        },
        "parentInstrumentId": {
          "type": "string",
          "minLength": 1
        },
        "childInstrumentId": {
          "type": "string",
          "minLength": 1
        },
        "sharesPerParentShare": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "basisAllocationFraction": {
          "type": "number"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "parentInstrumentId",
        "childInstrumentId",
        "sharesPerParentShare",
        "basisAllocationFraction"
      ]
    },
    "CorporateReturnOfCapital": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "corporate.return-of-capital",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "amountPerShare": {
          "type": "number"
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "amountPerShare",
        "currency"
      ]
    },
    "CorporateCashInLieu": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "corporate.cash-in-lieu",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "quantity": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "amount": {
          "type": "number"
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        "relatesToEventId": {
          "type": "string",
          "minLength": 1
        },
        "settleTimestampMs": {
          "type": "number",
          "description": "Epoch milliseconds"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "quantity",
        "amount",
        "currency"
      ]
    },
    "PositionTransfer": {
      "type": "object",
      "properties": {
        "eventType": {
          "const": "position.transfer",
          "type": "string"
        },
        "instrumentId": {
          "type": "string",
          "minLength": 1
        },
        "quantity": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "fromAccountId": {
          "type": "string",
          "minLength": 1
        },
        "toAccountId": {
          "type": "string",
          "minLength": 1
        },
        "lotSelections": {
          "$ref": "#/$defs/LotSelections"
        }
      },
      "additionalProperties": false,
      "required": [
        "eventType",
        "instrumentId",
        "quantity",
        "fromAccountId",
        "toAccountId"
      ]
    }
  }
}

All operations · Setup, handles, jobs & permissions