{
  "$defs": {
    "CustomEventSelector": {
      "additionalProperties": false,
      "description": "Select a user-registered custom event type.\n\nCustom events are registered via the API and referenced by event_type_id.\nThe event_type_id must correspond to an active EventType in Firestore.\n\nExample:\n    {\"type\": \"custom\", \"event_type_id\": \"my-llm-signal\"}",
      "properties": {
        "event_type_id": {
          "description": "ID of the custom event type (must be registered and active)",
          "title": "Event Type Id",
          "type": "string"
        },
        "type": {
          "const": "custom",
          "default": "custom",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "event_type_id"
      ],
      "title": "CustomEventSelector",
      "type": "object"
    },
    "SystemEventSelector": {
      "additionalProperties": false,
      "description": "Select a built-in system event type.\n\nSystem event types are the kinds populated by the ingestion service\n(corporate actions, earnings filings, plus FRED-backed macro / treasury /\nmarket releases such as ``macro.cpi`` and ``market.vix``). Distinct from\ncustom user-registered event types \u2014 use this when reacting to first-class\ningested events.\n\nExample:\n    {\"type\": \"system\", \"event_type_id\": \"macro.cpi\"}",
      "properties": {
        "event_type_id": {
          "description": "Built-in system event type (one of the seeded system kinds).",
          "enum": [
            "corporate.dividend",
            "corporate.split",
            "corporate.ticker_change",
            "corporate.ipo",
            "earnings.filing",
            "news.article",
            "macro.cpi",
            "macro.pce",
            "macro.ppi",
            "macro.unemployment",
            "macro.nonfarm_payrolls",
            "macro.jobless_claims",
            "macro.gdp",
            "macro.retail_sales",
            "macro.consumer_sentiment",
            "macro.industrial_production",
            "macro.housing_starts",
            "macro.core_pce",
            "macro.durable_goods_orders",
            "macro.fed_funds_rate",
            "macro.fed_funds_effective",
            "macro.sofr",
            "macro.fed_balance_sheet",
            "treasury.3m",
            "treasury.2y",
            "treasury.5y",
            "treasury.10y",
            "treasury.30y",
            "market.vix",
            "energy.crude_inventory",
            "energy.spr_inventory",
            "energy.cushing_inventory",
            "energy.gasoline_inventory",
            "energy.distillate_inventory",
            "energy.refinery_utilization",
            "energy.crude_imports",
            "energy.crude_production",
            "energy.product_supplied",
            "energy.natgas_storage",
            "energy.natgas_storage_east",
            "energy.natgas_storage_midwest",
            "energy.natgas_storage_south_central",
            "energy.natgas_storage_mountain",
            "energy.natgas_storage_pacific",
            "social.post"
          ],
          "title": "Event Type Id",
          "type": "string"
        },
        "type": {
          "const": "system",
          "default": "system",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "event_type_id"
      ],
      "title": "SystemEventSelector",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "description": "Trigger based on proximity to custom calendar events (e.g., FOMC, earnings).\n\nFires within a configurable window before/after registered event occurrences.\nUse as an entry trigger around known events or as a gate to block trading near events.",
  "properties": {
    "event": {
      "description": "Which event to trigger on (custom event_type_id)",
      "discriminator": {
        "mapping": {
          "custom": "#/$defs/CustomEventSelector",
          "system": "#/$defs/SystemEventSelector"
        },
        "propertyName": "type"
      },
      "oneOf": [
        {
          "$ref": "#/$defs/SystemEventSelector"
        },
        {
          "$ref": "#/$defs/CustomEventSelector"
        }
      ],
      "title": "Event"
    },
    "mode": {
      "default": "within",
      "description": "Trigger behavior: within = condition is True inside the window, outside = condition is True outside the window (for blocking)",
      "enum": [
        "within",
        "outside"
      ],
      "title": "Mode",
      "type": "string"
    },
    "offset_bars": {
      "anyOf": [
        {
          "maximum": 200,
          "minimum": 0,
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Bars before/after event for pre/post triggers. For in_window: PRE-event side.",
      "title": "Offset Bars"
    },
    "offset_minutes": {
      "anyOf": [
        {
          "maximum": 20160,
          "minimum": 0,
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Minutes before/after event for pre/post triggers (wall-clock). For in_window: PRE-event side.",
      "title": "Offset Minutes"
    },
    "trigger_type": {
      "default": "pre_event",
      "description": "When to trigger relative to event: pre_event = N units before, post_event = N units after, in_window = asymmetric window from `offset_*` units before to `window_*` units after the event (window_* falls back to offset_* if omitted, giving a symmetric window). NOTE: forward-looking triggers (pre_event, in_window) on a SYSTEM event require a scheduled event with a forward release calendar (currently macro.cpi, macro.nonfarm_payrolls, macro.unemployment). Using them on any other system event (e.g. corporate.split, earnings.filing, un-scheduled macro releases) is rejected at compile time, because the platform cannot anticipate the event ahead of time \u2014 use post_event to react after it occurs. Custom events are unrestricted.",
      "enum": [
        "pre_event",
        "post_event",
        "in_window"
      ],
      "title": "Trigger Type",
      "type": "string"
    },
    "type": {
      "const": "event",
      "default": "event",
      "title": "Type",
      "type": "string"
    },
    "window_bars": {
      "anyOf": [
        {
          "maximum": 200,
          "minimum": 1,
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "For in_window: POST-event side in bars. Falls back to offset_bars if omitted (symmetric window).",
      "title": "Window Bars"
    },
    "window_minutes": {
      "anyOf": [
        {
          "maximum": 20160,
          "minimum": 1,
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "For in_window: POST-event side in minutes. Falls back to offset_minutes if omitted (symmetric window).",
      "title": "Window Minutes"
    }
  },
  "required": [
    "event"
  ],
  "title": "EventCondition",
  "type": "object"
}
