{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://polytraders.dev/schemas/Signal.json",
  "title": "Signal",
  "description": "A scored observation emitted by a Strategy bot for one market at one moment. Inputs to Risk are OrderIntents, not Signals. Signals are the upstream artefact a Strategy uses to decide whether to emit an OrderIntent.",
  "type": "object",
  "required": [
    "signal_id",
    "strategy_id",
    "portfolio_id",
    "condition_id",
    "score_type",
    "strategy_score",
    "side",
    "ts"
  ],
  "properties": {
    "signal_id":      { "type": "string", "pattern": "^sig_[0-9a-zA-Z]{12,}$" },
    "strategy_id":    { "$ref": "_common.json#/$defs/StrategyId" },
    "portfolio_id":   { "$ref": "_common.json#/$defs/PortfolioId" },
    "condition_id":   { "$ref": "_common.json#/$defs/ConditionId" },
    "score_type":     { "$ref": "_common.json#/$defs/ScoreType" },
    "strategy_score": { "$ref": "_common.json#/$defs/Decimal", "description": "Generic score field. Interpreted by the strategy according to its score_type." },
    "side":           { "$ref": "_common.json#/$defs/Side" },
    "ts":             { "$ref": "_common.json#/$defs/ISO8601" },
    "reason":         { "$ref": "_common.json#/$defs/ReasonCode" }
  },
  "additionalProperties": false
}
