{
    "schema_version": "trading_eye_analysis_v3",
    "schema": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "title": "trading_eye_analysis_v3",
        "description": "Geschlossene Enums, Zahlen, Booleans, null. Kein Freitextfeld. risk_reward wird NICHT vom Modell geliefert \u2014 der Server rechnet ihn. Zusaetzlich zur Schemapruefung laeuft eine Konsistenzpruefung ueber Feldkombinationen (schema.php).",
        "type": "object",
        "additionalProperties": false,
        "required": [
            "case_id",
            "schema_version",
            "timeframes",
            "cross_timeframe",
            "levels",
            "patterns",
            "state",
            "trigger",
            "trade_plan",
            "quality",
            "confidence",
            "wait"
        ],
        "properties": {
            "case_id": {
                "type": "string",
                "pattern": "^[0-9a-f]{12}$",
                "description": "case_uid \u2014 der Detector steht nicht im Prompt"
            },
            "schema_version": {
                "type": "string",
                "const": "trading_eye_analysis_v3"
            },
            "timeframes": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                    "4h",
                    "1h",
                    "15m"
                ],
                "properties": {
                    "4h": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                            "trend",
                            "structure",
                            "phase",
                            "volatility",
                            "momentum"
                        ],
                        "properties": {
                            "trend": {
                                "type": "string",
                                "enum": [
                                    "up",
                                    "down",
                                    "sideways",
                                    "unclear"
                                ]
                            },
                            "structure": {
                                "type": "string",
                                "enum": [
                                    "hh_hl",
                                    "lh_ll",
                                    "range",
                                    "mixed",
                                    "unclear"
                                ]
                            },
                            "phase": {
                                "type": "string",
                                "enum": [
                                    "impulse",
                                    "pullback",
                                    "compression",
                                    "expansion",
                                    "reversal_attempt",
                                    "range",
                                    "unclear"
                                ]
                            },
                            "volatility": {
                                "type": "string",
                                "enum": [
                                    "low",
                                    "normal",
                                    "high",
                                    "unclear"
                                ]
                            },
                            "momentum": {
                                "type": "string",
                                "enum": [
                                    "increasing",
                                    "decreasing",
                                    "flat",
                                    "mixed",
                                    "unclear"
                                ]
                            }
                        }
                    },
                    "1h": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                            "trend",
                            "structure",
                            "phase",
                            "volatility",
                            "momentum"
                        ],
                        "properties": {
                            "trend": {
                                "type": "string",
                                "enum": [
                                    "up",
                                    "down",
                                    "sideways",
                                    "unclear"
                                ]
                            },
                            "structure": {
                                "type": "string",
                                "enum": [
                                    "hh_hl",
                                    "lh_ll",
                                    "range",
                                    "mixed",
                                    "unclear"
                                ]
                            },
                            "phase": {
                                "type": "string",
                                "enum": [
                                    "impulse",
                                    "pullback",
                                    "compression",
                                    "expansion",
                                    "reversal_attempt",
                                    "range",
                                    "unclear"
                                ]
                            },
                            "volatility": {
                                "type": "string",
                                "enum": [
                                    "low",
                                    "normal",
                                    "high",
                                    "unclear"
                                ]
                            },
                            "momentum": {
                                "type": "string",
                                "enum": [
                                    "increasing",
                                    "decreasing",
                                    "flat",
                                    "mixed",
                                    "unclear"
                                ]
                            }
                        }
                    },
                    "15m": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                            "trend",
                            "structure",
                            "phase",
                            "volatility",
                            "momentum"
                        ],
                        "properties": {
                            "trend": {
                                "type": "string",
                                "enum": [
                                    "up",
                                    "down",
                                    "sideways",
                                    "unclear"
                                ]
                            },
                            "structure": {
                                "type": "string",
                                "enum": [
                                    "hh_hl",
                                    "lh_ll",
                                    "range",
                                    "mixed",
                                    "unclear"
                                ]
                            },
                            "phase": {
                                "type": "string",
                                "enum": [
                                    "impulse",
                                    "pullback",
                                    "compression",
                                    "expansion",
                                    "reversal_attempt",
                                    "range",
                                    "unclear"
                                ]
                            },
                            "volatility": {
                                "type": "string",
                                "enum": [
                                    "low",
                                    "normal",
                                    "high",
                                    "unclear"
                                ]
                            },
                            "momentum": {
                                "type": "string",
                                "enum": [
                                    "increasing",
                                    "decreasing",
                                    "flat",
                                    "mixed",
                                    "unclear"
                                ]
                            }
                        }
                    }
                }
            },
            "cross_timeframe": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                    "alignment",
                    "dominant_horizon",
                    "dominant_state",
                    "conflict_present",
                    "conflict_type",
                    "conflict_strength"
                ],
                "properties": {
                    "alignment": {
                        "type": "string",
                        "enum": [
                            "bullish",
                            "bearish",
                            "mixed",
                            "neutral",
                            "unclear"
                        ]
                    },
                    "dominant_horizon": {
                        "type": "string",
                        "enum": [
                            "4h",
                            "1h",
                            "15m",
                            "none"
                        ]
                    },
                    "dominant_state": {
                        "type": "string",
                        "enum": [
                            "trend",
                            "pullback",
                            "range",
                            "compression",
                            "expansion",
                            "reversal_attempt",
                            "unclear"
                        ]
                    },
                    "conflict_present": {
                        "type": "boolean"
                    },
                    "conflict_type": {
                        "type": "array",
                        "items": {
                            "type": "string",
                            "enum": [
                                "trend_conflict",
                                "structure_conflict",
                                "momentum_conflict",
                                "phase_conflict"
                            ]
                        }
                    },
                    "conflict_strength": {
                        "type": "string",
                        "enum": [
                            "none",
                            "low",
                            "medium",
                            "high"
                        ]
                    }
                }
            },
            "levels": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                    "support",
                    "resistance"
                ],
                "properties": {
                    "support": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                            "nearest",
                            "strength",
                            "tested_count"
                        ],
                        "properties": {
                            "nearest": {
                                "type": [
                                    "number",
                                    "null"
                                ]
                            },
                            "strength": {
                                "type": "string",
                                "enum": [
                                    "none",
                                    "low",
                                    "medium",
                                    "high"
                                ]
                            },
                            "tested_count": {
                                "type": [
                                    "integer",
                                    "null"
                                ]
                            }
                        }
                    },
                    "resistance": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                            "nearest",
                            "strength",
                            "tested_count"
                        ],
                        "properties": {
                            "nearest": {
                                "type": [
                                    "number",
                                    "null"
                                ]
                            },
                            "strength": {
                                "type": "string",
                                "enum": [
                                    "none",
                                    "low",
                                    "medium",
                                    "high"
                                ]
                            },
                            "tested_count": {
                                "type": [
                                    "integer",
                                    "null"
                                ]
                            }
                        }
                    }
                }
            },
            "patterns": {
                "type": "array",
                "items": {
                    "type": "string",
                    "enum": [
                        "none",
                        "trend_pullback",
                        "range_rejection",
                        "breakout_attempt",
                        "breakout_confirmed",
                        "fakeout_risk",
                        "compression",
                        "expansion",
                        "reversal_attempt",
                        "continuation_attempt",
                        "exhaustion"
                    ]
                }
            },
            "state": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                    "market_state",
                    "tradeability",
                    "direction_bias",
                    "confidence"
                ],
                "properties": {
                    "market_state": {
                        "type": "string",
                        "enum": [
                            "trend_up",
                            "trend_down",
                            "range",
                            "compression",
                            "expansion",
                            "transition",
                            "unclear"
                        ]
                    },
                    "tradeability": {
                        "type": "string",
                        "enum": [
                            "untradeable",
                            "wait",
                            "conditional",
                            "tradeable"
                        ]
                    },
                    "direction_bias": {
                        "type": "string",
                        "enum": [
                            "long",
                            "short",
                            "neutral",
                            "unclear"
                        ]
                    },
                    "confidence": {
                        "type": "string",
                        "enum": [
                            "low",
                            "medium",
                            "high"
                        ]
                    }
                }
            },
            "trigger": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                    "required",
                    "type",
                    "direction"
                ],
                "properties": {
                    "required": {
                        "type": "boolean"
                    },
                    "type": {
                        "type": "string",
                        "enum": [
                            "none",
                            "zone_touch",
                            "close_beyond",
                            "rejection",
                            "breakout",
                            "retest",
                            "swing_break",
                            "momentum_confirmation",
                            "volume_confirmation"
                        ]
                    },
                    "direction": {
                        "type": "string",
                        "enum": [
                            "long",
                            "short",
                            "none"
                        ]
                    }
                }
            },
            "trade_plan": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                    "decision",
                    "entry_type",
                    "entry_low",
                    "entry_high",
                    "stop_loss",
                    "take_profit",
                    "invalidation"
                ],
                "properties": {
                    "decision": {
                        "type": "string",
                        "enum": [
                            "long",
                            "short",
                            "wait",
                            "reject"
                        ]
                    },
                    "entry_type": {
                        "type": "string",
                        "enum": [
                            "market",
                            "limit_zone",
                            "breakout",
                            "retest",
                            "none"
                        ]
                    },
                    "entry_low": {
                        "type": [
                            "number",
                            "null"
                        ]
                    },
                    "entry_high": {
                        "type": [
                            "number",
                            "null"
                        ]
                    },
                    "stop_loss": {
                        "type": [
                            "number",
                            "null"
                        ]
                    },
                    "take_profit": {
                        "type": [
                            "number",
                            "null"
                        ]
                    },
                    "invalidation": {
                        "type": [
                            "number",
                            "null"
                        ]
                    }
                }
            },
            "quality": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                    "usable",
                    "missing_data",
                    "ambiguity"
                ],
                "properties": {
                    "usable": {
                        "type": "boolean"
                    },
                    "missing_data": {
                        "type": "array",
                        "items": {
                            "type": "string",
                            "enum": [
                                "none",
                                "price_scale",
                                "volume",
                                "structure",
                                "levels",
                                "timeframe",
                                "resolution"
                            ]
                        }
                    },
                    "ambiguity": {
                        "type": "string",
                        "enum": [
                            "none",
                            "low",
                            "medium",
                            "high"
                        ]
                    }
                }
            },
            "confidence": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                    "trend_confidence",
                    "structure_confidence",
                    "pattern_confidence",
                    "trigger_confidence",
                    "cross_timeframe_confidence"
                ],
                "properties": {
                    "trend_confidence": {
                        "type": "string",
                        "enum": [
                            "low",
                            "medium",
                            "high"
                        ]
                    },
                    "structure_confidence": {
                        "type": "string",
                        "enum": [
                            "low",
                            "medium",
                            "high"
                        ]
                    },
                    "pattern_confidence": {
                        "type": "string",
                        "enum": [
                            "low",
                            "medium",
                            "high"
                        ]
                    },
                    "trigger_confidence": {
                        "type": "string",
                        "enum": [
                            "low",
                            "medium",
                            "high"
                        ]
                    },
                    "cross_timeframe_confidence": {
                        "type": "string",
                        "enum": [
                            "low",
                            "medium",
                            "high"
                        ]
                    }
                }
            },
            "wait": {
                "type": "object",
                "additionalProperties": false,
                "description": "Nur bei decision=wait befuellt. Ohne Gueltigkeitsdauer ist ein WAIT fuer eine State Machine nicht ausfuehrbar.",
                "required": [
                    "valid_for_bars",
                    "timeframe"
                ],
                "properties": {
                    "valid_for_bars": {
                        "type": [
                            "integer",
                            "null"
                        ],
                        "minimum": 1
                    },
                    "timeframe": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "enum": [
                            "1m",
                            "15m",
                            "1h",
                            "4h",
                            null
                        ]
                    }
                }
            }
        }
    }
}
