{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tradecopier.org/downloads/trading-webhook-record-only.schema.json",
  "title": "Educational trading alert record-only envelope, version 2",
  "description": "Fictional offline signal-recording contract. This is not a TradingView or TradeCopier API specification and never authorizes order submission. Enable date-time format assertions. Reject duplicate JSON object keys and oversized input before validation. Runtime checks must validate expiry, clock skew, authorized stream and symbol mappings, idempotency and ordering. Schema validation alone is not authorization or safe execution.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "mode",
    "event_id",
    "strategy_version",
    "stream_id",
    "sequence",
    "event_time_utc",
    "valid_until_utc",
    "condition",
    "symbol_reference",
    "quantity"
  ],
  "properties": {
    "schema_version": {
      "type": "integer",
      "const": 2
    },
    "mode": {
      "type": "string",
      "const": "record_only"
    },
    "event_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*(?![\\s\\S])",
      "description": "Stable logical-event identifier within the authorized stream. Reuse this identifier for retries of the unchanged event."
    },
    "strategy_version": {
      "type": "string",
      "minLength": 1,
      "maxLength": 32,
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*(?![\\s\\S])"
    },
    "stream_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*(?![\\s\\S])",
      "description": "Illustrative single-producer ordered stream. Text does not grant authority to write to this stream."
    },
    "sequence": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483647,
      "description": "Monotonically increasing within the stream. Schema cannot compare this value with prior records."
    },
    "event_time_utc": {
      "type": "string",
      "minLength": 20,
      "maxLength": 20,
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z(?![\\s\\S])",
      "format": "date-time",
      "description": "Whole-second UTC observation time. Receiver must independently apply freshness and future-skew checks."
    },
    "valid_until_utc": {
      "type": "string",
      "minLength": 20,
      "maxLength": 20,
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z(?![\\s\\S])",
      "format": "date-time",
      "description": "Exclusive expiry: receiver time must be strictly earlier. Runtime must enforce event_time < valid_until <= event_time + 120 seconds for this example policy."
    },
    "condition": {
      "type": "string",
      "enum": [
        "bar_close_above_demo_threshold",
        "bar_close_below_demo_threshold"
      ]
    },
    "symbol_reference": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*(?![\\s\\S])",
      "description": "Fictional observation label; not a broker instrument identifier or a claim of platform compatibility."
    },
    "quantity": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "value",
        "unit"
      ],
      "properties": {
        "value": {
          "type": "string",
          "minLength": 1,
          "maxLength": 21,
          "pattern": "^(?:0|[1-9][0-9]{0,11})(?:\\.[0-9]{1,8})?(?![\\s\\S])",
          "not": {
            "pattern": "^0(?:\\.0+)?(?![\\s\\S])"
          },
          "description": "Positive decimal text, at most 12 whole digits and 8 fractional digits. No signs, exponents, whitespace or ambiguous numeric coercion. This transport bound is not an allowed account size."
        },
        "unit": {
          "type": "string",
          "enum": [
            "contracts",
            "lots",
            "units"
          ],
          "description": "Explicit descriptive unit. Schema does not establish an instrument contract size or valid broker volume."
        }
      }
    }
  }
}
