# app/src/trading/market_intelligence/common/reasons.py

from __future__ import annotations

from enum import StrEnum


class ReasonCode(StrEnum):
    # Универсальный код причины.
    # Движки используют эти значения, чтобы объяснить результат
    # в машинно-читаемом виде. Человекочитаемый текст будет строиться
    # отдельным слоем диагностики, а не внутри движка.

    # ---------- Common ----------
    UNKNOWN = "unknown"
    OK = "ok"
    NOT_APPLICABLE = "not_applicable"
    SKIPPED = "skipped"

    # ---------- Data ----------
    INSUFFICIENT_DATA = "insufficient_data"
    EMPTY_MARKET_DATA = "empty_market_data"
    STALE_MARKET_DATA = "stale_market_data"
    INVALID_MARKET_DATA = "invalid_market_data"
    MISSING_PRICE_DATA = "missing_price_data"
    MISSING_VOLUME_DATA = "missing_volume_data"
    MISSING_TIMEFRAME_DATA = "missing_timeframe_data"

    # ---------- Engine Runtime ----------
    ENGINE_DISABLED = "engine_disabled"
    ENGINE_ERROR = "engine_error"
    ENGINE_PARTIAL_RESULT = "engine_partial_result"
    ENGINE_DEPENDENCY_MISSING = "engine_dependency_missing"
    ENGINE_DEPENDENCY_STALE = "engine_dependency_stale"
    ENGINE_DEPENDENCY_ERROR = "engine_dependency_error"

    # ---------- Validation ----------
    VALIDATION_PASSED = "validation_passed"
    VALIDATION_FAILED = "validation_failed"
    SCORE_OUT_OF_RANGE = "score_out_of_range"
    CONFIDENCE_OUT_OF_RANGE = "confidence_out_of_range"
    PROBABILITY_OUT_OF_RANGE = "probability_out_of_range"
    FORBIDDEN_TRADING_FIELD_FOUND = "forbidden_trading_field_found"
    REQUIRED_FIELD_MISSING = "required_field_missing"

    # ---------- Market State ----------
    MARKET_UNDEFINED = "market_undefined"
    MARKET_CLEAR = "market_clear"
    MARKET_NOISY = "market_noisy"
    MARKET_CONFLICTED = "market_conflicted"
    MARKET_QUALITY_LOW = "market_quality_low"
    MARKET_QUALITY_NORMAL = "market_quality_normal"
    MARKET_QUALITY_HIGH = "market_quality_high"

    # ---------- Structure ----------
    STRUCTURE_UNDEFINED = "structure_undefined"
    STRUCTURE_UP = "structure_up"
    STRUCTURE_DOWN = "structure_down"
    STRUCTURE_SIDEWAYS = "structure_sideways"
    STRUCTURE_CHANGED = "structure_changed"
    STRUCTURE_BROKEN = "structure_broken"

    # ---------- Trend ----------
    TREND_UNDEFINED = "trend_undefined"
    TREND_UP = "trend_up"
    TREND_DOWN = "trend_down"
    TREND_SIDEWAYS = "trend_sideways"
    TREND_STRONG = "trend_strong"
    TREND_NORMAL = "trend_normal"
    TREND_WEAK = "trend_weak"
    TREND_CLEAN = "trend_clean"
    TREND_NOISY = "trend_noisy"
    TREND_OVEREXTENDED = "trend_overextended"

    # ---------- Momentum ----------
    MOMENTUM_UNDEFINED = "momentum_undefined"
    MOMENTUM_UP = "momentum_up"
    MOMENTUM_DOWN = "momentum_down"
    MOMENTUM_ACCELERATING = "momentum_accelerating"
    MOMENTUM_DECELERATING = "momentum_decelerating"
    MOMENTUM_EXHAUSTED = "momentum_exhausted"
    MOMENTUM_ABSENT = "momentum_absent"

    # ---------- Volatility ----------
    VOLATILITY_UNDEFINED = "volatility_undefined"
    VOLATILITY_LOW = "volatility_low"
    VOLATILITY_NORMAL = "volatility_normal"
    VOLATILITY_HIGH = "volatility_high"
    VOLATILITY_EXPANDING = "volatility_expanding"
    VOLATILITY_COMPRESSING = "volatility_compressing"
    VOLATILITY_UNSTABLE = "volatility_unstable"

    # ---------- Wave ----------
    WAVE_UNDEFINED = "wave_undefined"
    WAVE_IMPULSE = "wave_impulse"
    WAVE_PULLBACK = "wave_pullback"
    WAVE_RECOVERY = "wave_recovery"
    WAVE_MATURE = "wave_mature"
    WAVE_COMPLETED = "wave_completed"
    WAVE_TOO_SHORT = "wave_too_short"

    # ---------- Cycle ----------
    CYCLE_UNDEFINED = "cycle_undefined"
    CYCLE_IMPULSE = "cycle_impulse"
    CYCLE_PULLBACK = "cycle_pullback"
    CYCLE_RECOVERY = "cycle_recovery"
    CYCLE_EXPANSION = "cycle_expansion"
    CYCLE_EXHAUSTION = "cycle_exhaustion"
    CYCLE_REVERSAL = "cycle_reversal"

    # ---------- Liquidity ----------
    LIQUIDITY_UNDEFINED = "liquidity_undefined"
    LIQUIDITY_GOOD = "liquidity_good"
    LIQUIDITY_NORMAL = "liquidity_normal"
    LIQUIDITY_POOR = "liquidity_poor"
    SPREAD_NORMAL = "spread_normal"
    SPREAD_WIDE = "spread_wide"
    DEPTH_NORMAL = "depth_normal"
    DEPTH_THIN = "depth_thin"
    EXECUTION_QUALITY_LOW = "execution_quality_low"

    # ---------- Regime ----------
    REGIME_UNDEFINED = "regime_undefined"
    REGIME_TRENDING = "regime_trending"
    REGIME_RANGE = "regime_range"
    REGIME_BREAKOUT = "regime_breakout"
    REGIME_MEAN_REVERSION = "regime_mean_reversion"
    REGIME_HIGH_VOLATILITY = "regime_high_volatility"
    REGIME_LOW_VOLATILITY = "regime_low_volatility"
    REGIME_PANIC = "regime_panic"
    REGIME_EUPHORIA = "regime_euphoria"
    REGIME_ACCUMULATION = "regime_accumulation"
    REGIME_DISTRIBUTION = "regime_distribution"

    # ---------- Confidence ----------
    CONFIDENCE_UNDEFINED = "confidence_undefined"
    CONFIDENCE_LOW = "confidence_low"
    CONFIDENCE_NORMAL = "confidence_normal"
    CONFIDENCE_HIGH = "confidence_high"
    CONFIDENCE_UNSTABLE = "confidence_unstable"
    CONFIDENCE_STABLE = "confidence_stable"

    # ---------- Signal Aging ----------
    SIGNAL_NEW = "signal_new"
    SIGNAL_ACTIVE = "signal_active"
    SIGNAL_AGING = "signal_aging"
    SIGNAL_EXPIRED = "signal_expired"

    # ---------- Timeframe ----------
    TIMEFRAME_UNDEFINED = "timeframe_undefined"
    TIMEFRAME_ALIGNED = "timeframe_aligned"
    TIMEFRAME_CONFLICTED = "timeframe_conflicted"
    TIMEFRAME_PRIMARY_MISSING = "timeframe_primary_missing"