{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "phase6/order_event.schema.json",
  "title": "CanonicalOrderEvent",
  "type": "object",
  "required": [
    "event_id",
    "event_type",
    "event_time",
    "source",
    "env",
    "mode",
    "client_order_id"
  ],
  "properties": {
    "event_id": {"type": "string"},
    "event_type": {
      "type": "string",
      "enum": [
        "order_submitted",
        "order_accepted",
        "order_rejected",
        "order_partially_filled",
        "order_filled",
        "order_cancel_requested",
        "order_cancelled",
        "order_replaced",
        "order_expired",
        "trade_bust",
        "heartbeat_lost",
        "heartbeat_restored"
      ]
    },
    "event_time": {"type": "string", "format": "date-time"},
    "source": {"type": "string"},
    "env": {"type": "string"},
    "mode": {"type": "string", "enum": ["dry_run", "paper", "live"]},
    "client_order_id": {"type": "string"},
    "broker_order_id": {"type": ["string", "null"]},
    "symbol": {"type": ["string", "null"]},
    "side": {"type": ["string", "null"], "enum": [null, "buy", "sell"]},
    "qty": {"type": ["number", "null"]},
    "filled_qty": {"type": ["number", "null"]},
    "fill_price": {"type": ["number", "null"]},
    "reason": {"type": ["string", "null"]},
    "payload_hash": {"type": ["string", "null"]}
  },
  "additionalProperties": true
}
