{
  "$defs": {
    "CciDivergenceIndicator": {
      "additionalProperties": false,
      "description": "Commodity Channel Index parameters for divergence detection.",
      "properties": {
        "indicator_type": {
          "const": "CCI",
          "default": "CCI",
          "title": "Indicator Type",
          "type": "string"
        },
        "period": {
          "default": 14,
          "description": "CCI period",
          "maximum": 500,
          "minimum": 2,
          "title": "Period",
          "type": "integer"
        },
        "type": {
          "const": "CCI",
          "default": "CCI",
          "title": "Type",
          "type": "string"
        }
      },
      "title": "CciDivergenceIndicator",
      "type": "object"
    },
    "MacdDivergenceIndicator": {
      "additionalProperties": false,
      "description": "MACD indicator parameters for divergence detection.\n\nUses the MACD histogram (fast EMA - slow EMA) as the divergence series.",
      "properties": {
        "fast_period": {
          "default": 12,
          "description": "Fast EMA period",
          "maximum": 200,
          "minimum": 2,
          "title": "Fast Period",
          "type": "integer"
        },
        "indicator_type": {
          "const": "MACD",
          "default": "MACD",
          "title": "Indicator Type",
          "type": "string"
        },
        "signal_period": {
          "default": 9,
          "description": "Signal line period",
          "maximum": 50,
          "minimum": 2,
          "title": "Signal Period",
          "type": "integer"
        },
        "slow_period": {
          "default": 26,
          "description": "Slow EMA period",
          "maximum": 200,
          "minimum": 2,
          "title": "Slow Period",
          "type": "integer"
        },
        "type": {
          "const": "MACD",
          "default": "MACD",
          "title": "Type",
          "type": "string"
        }
      },
      "title": "MacdDivergenceIndicator",
      "type": "object"
    },
    "ObvDivergenceIndicator": {
      "additionalProperties": false,
      "description": "On-Balance Volume \u2014 no parameters required.",
      "properties": {
        "indicator_type": {
          "const": "OBV",
          "default": "OBV",
          "title": "Indicator Type",
          "type": "string"
        },
        "type": {
          "const": "OBV",
          "default": "OBV",
          "title": "Type",
          "type": "string"
        }
      },
      "title": "ObvDivergenceIndicator",
      "type": "object"
    },
    "RsiDivergenceIndicator": {
      "additionalProperties": false,
      "description": "RSI indicator parameters for divergence detection.\n\nSupported range: period 2\u2013500. Default 14 is standard.",
      "properties": {
        "indicator_type": {
          "const": "RSI",
          "default": "RSI",
          "title": "Indicator Type",
          "type": "string"
        },
        "period": {
          "default": 14,
          "description": "RSI period",
          "maximum": 500,
          "minimum": 2,
          "title": "Period",
          "type": "integer"
        },
        "type": {
          "const": "RSI",
          "default": "RSI",
          "title": "Type",
          "type": "string"
        }
      },
      "title": "RsiDivergenceIndicator",
      "type": "object"
    },
    "StoDivergenceIndicator": {
      "additionalProperties": false,
      "description": "Stochastic %K indicator parameters for divergence detection.",
      "properties": {
        "indicator_type": {
          "const": "STO",
          "default": "STO",
          "title": "Indicator Type",
          "type": "string"
        },
        "period": {
          "default": 14,
          "description": "Stochastic period",
          "maximum": 500,
          "minimum": 2,
          "title": "Period",
          "type": "integer"
        },
        "type": {
          "const": "STO",
          "default": "STO",
          "title": "Type",
          "type": "string"
        }
      },
      "title": "StoDivergenceIndicator",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "description": "Price/indicator divergence detection.\n\nDetects when price makes a new high/low but the indicator does not,\nsignaling potential reversal.\n\nBullish divergence: price makes lower low, indicator makes higher low\nBearish divergence: price makes higher high, indicator makes lower high\n\nIndicator options:\n- RSI (default): {\"indicator_type\": \"RSI\", \"period\": 14}\n- MACD: {\"indicator_type\": \"MACD\", \"fast_period\": 12, \"slow_period\": 26, \"signal_period\": 9}\n- STO: {\"indicator_type\": \"STO\", \"period\": 14}\n- CCI: {\"indicator_type\": \"CCI\", \"period\": 14}\n- OBV: {\"indicator_type\": \"OBV\"}",
  "properties": {
    "card_type": {
      "const": "divergence",
      "default": "divergence",
      "title": "Card Type",
      "type": "string"
    },
    "divergence_type": {
      "default": "bullish",
      "enum": [
        "bullish",
        "bearish"
      ],
      "title": "Divergence Type",
      "type": "string"
    },
    "indicator": {
      "discriminator": {
        "mapping": {
          "CCI": "#/$defs/CciDivergenceIndicator",
          "MACD": "#/$defs/MacdDivergenceIndicator",
          "OBV": "#/$defs/ObvDivergenceIndicator",
          "RSI": "#/$defs/RsiDivergenceIndicator",
          "STO": "#/$defs/StoDivergenceIndicator"
        },
        "propertyName": "indicator_type"
      },
      "oneOf": [
        {
          "$ref": "#/$defs/RsiDivergenceIndicator"
        },
        {
          "$ref": "#/$defs/MacdDivergenceIndicator"
        },
        {
          "$ref": "#/$defs/StoDivergenceIndicator"
        },
        {
          "$ref": "#/$defs/CciDivergenceIndicator"
        },
        {
          "$ref": "#/$defs/ObvDivergenceIndicator"
        }
      ],
      "title": "Indicator"
    },
    "strength": {
      "default": 5,
      "description": "Swing detection strength",
      "maximum": 20,
      "minimum": 1,
      "title": "Strength",
      "type": "integer"
    }
  },
  "title": "DivergenceCard",
  "type": "object"
}
