# app/src/trading/debug/state.py

from __future__ import annotations

from dataclasses import dataclass, field


@dataclass(slots=True)
class DebugPositionState:
    side: str = "NONE"
    symbol: str = ""

    entry_price: float | None = None
    size: float | None = None
    leverage: float | None = None

    unrealized_pnl_usd: float | None = None

    opened_at: str | None = None
    updated_at: str | None = None


@dataclass(slots=True)
class DebugTradeState:
    status: str = "OFF"

    strategy: str | None = "TREND"
    symbol: str = "BTC/USD_LEVERAGE"

    allocated_balance_usd: float = 1000.0
    realized_pnl_usd: float = 0.0

    risk_percent: float | None = 1.0
    leverage: float | None = 2.0

    stop_loss_percent: float | None = 1.0
    take_profit_percent: float | None = None
    max_loss_usd: float | None = None
    max_reserved_balance_percent: float | None = 50.0

    last_signal: str | None = "HOLD"
    last_signal_confidence: float = 0.0
    last_signal_repeat_count: int = 0
    last_signal_reason: str | None = None
    signal_started_at: float | None = None

    decision_status: str = "WAITING"
    decision_reason: str | None = None
    is_signal_confirmed: bool = False
    is_signal_ready: bool = False

    execution_block_reason: str | None = None
    execution_size_adjustment_reason: str | None = None

    position: DebugPositionState = field(default_factory=DebugPositionState)

    last_check_at: str | None = None