Skip to content

Close Location Value

Intuição

O Close Location Value (CLV) mede onde o fechamento ocorreu dentro do range (high-low) do candle. Valores próximos de +1 indicam fechamento perto da máxima; próximos de -1, perto da mínima.

Definição

Para cada barra:

CLV = ((close - low) - (high - close)) / (high - low)

O output é limitado a [-1, 1].

Uso

from quantmaster.features.volume import close_location_value

df["clv"] = close_location_value(df)

API

Source code in src/quantmaster/features/volume.py
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
def close_location_value(
    data: pd.DataFrame,
    *,
    high_col: str = "high",
    low_col: str = "low",
    close_col: str = "close",
) -> pd.Series:
    validate_columns(data, required=[high_col, low_col, close_col])

    high = pd.to_numeric(data[high_col], errors="coerce").astype(float)
    low = pd.to_numeric(data[low_col], errors="coerce").astype(float)
    close = pd.to_numeric(data[close_col], errors="coerce").astype(float)

    denom = (high - low).where((high - low) != 0)
    out = ((close - low) - (high - close)) / denom
    out = out.clip(lower=-1.0, upper=1.0)
    out.name = "close_location_value"
    return out