"""Candle body strength relative to 10-bar avg body — port fedele da V15."""

from __future__ import annotations

import pandas as pd


def calc_candle_strength(df: pd.DataFrame) -> float:
    """
    body_now / avg_body_10. Values:
        ~1.0 = normal candle
        > 1.8 = very strong (capitulation candidate in TF entry)
        > 2.5 = giant (capitulation pattern in MR exit)
    """
    body = abs(df["close"].iloc[-1] - df["open"].iloc[-1])
    avg_body = abs(df["close"] - df["open"]).rolling(10).mean().iloc[-1]
    return round(float(body / (avg_body + 1e-9)), 2)
