"""
Score calculation thresholds and constants.

F07 porting: Registers threshold values used in scoring logic.
These are constants derived from GAS THRESHOLDS object.

Key thresholds:
- SP_TAKE_PROFIT (10): Score for take-profit signal (profitPct >= 10%)
- SP_HOLDINGS_ROTATE (20): Score for holdings rotation opportunity (EXIT_REVIEW)
- SP_SELL_SIGNAL (40): Score for sell-ready signal (SELL_READY / TRIM)

Ported from: src/gas_adapter_parts/gdf_01_price_metrics.gs:260-304 (THRESHOLDS object)
"""

# Exit scoring thresholds (익절 및 exit 신호 점수)
SP_TAKE_PROFIT = 10         # Profit_Pct >= 10% (익절 후보)
SP_HOLDINGS_ROTATE = 20     # EXIT_REVIEW / 보유주 교체 후보
SP_SELL_SIGNAL = 40         # SELL_READY / TRIM 신호 확정

# Profit-taking tier targets (진입가 대비)
TP_CORE_1 = 1.15   # core 1차 +15%
TP_CORE_2 = 1.25   # core 2차 +25%
TP_SAT_1 = 1.10    # satellite 1차 +10%
TP_SAT_2 = 1.20    # satellite 2차 +20%
TAKE_PROFIT_BASE = 10  # Base take-profit percentage threshold

# Time stop calendar days
TIME_STOP_STAGE1 = 60
TIME_STOP_STAGE2 = 30

# Value surge thresholds (%)
VAL_SURGE_WATCH = 15
VAL_SURGE_HOT = 35
VAL_SURGE_EXHAUSTED = 50

# Liquidity thresholds (5D average trading value in millions KRW)
LIQUIDITY_PREFERRED_M = 100
LIQUIDITY_OK_M = 50

# Bid-ask spread thresholds (%)
SPREAD_OK_PCT = 0.25
SPREAD_WARN_PCT = 0.50


def get_threshold(key: str) -> float:
    """
    Get a threshold value by key name for compatibility with GAS THRESHOLDS access pattern.

    Args:
        key: Threshold name (e.g., 'SP_TAKE_PROFIT', 'SP_SELL_SIGNAL')

    Returns:
        Threshold numeric value
    """
    thresholds = {
        'SP_TAKE_PROFIT': SP_TAKE_PROFIT,
        'SP_HOLDINGS_ROTATE': SP_HOLDINGS_ROTATE,
        'SP_SELL_SIGNAL': SP_SELL_SIGNAL,
        'TP_CORE_1': TP_CORE_1,
        'TP_CORE_2': TP_CORE_2,
        'TP_SAT_1': TP_SAT_1,
        'TP_SAT_2': TP_SAT_2,
        'TAKE_PROFIT_BASE': TAKE_PROFIT_BASE,
        'TIME_STOP_STAGE1': TIME_STOP_STAGE1,
        'TIME_STOP_STAGE2': TIME_STOP_STAGE2,
        'VAL_SURGE_WATCH': VAL_SURGE_WATCH,
        'VAL_SURGE_HOT': VAL_SURGE_HOT,
        'VAL_SURGE_EXHAUSTED': VAL_SURGE_EXHAUSTED,
        'LIQUIDITY_PREFERRED_M': LIQUIDITY_PREFERRED_M,
        'LIQUIDITY_OK_M': LIQUIDITY_OK_M,
        'SPREAD_OK_PCT': SPREAD_OK_PCT,
        'SPREAD_WARN_PCT': SPREAD_WARN_PCT,
    }
    return thresholds.get(key)
