Volume Weighted Close Location
Intuição
A Volume Weighted Close Location agrega o CLV ponderando por volume em uma janela móvel, destacando candles “mais relevantes” (com maior volume).
Definição
Em uma janela n:
VWCL = sum(CLV * volume) / sum(volume)
O output fica em [-1, 1].
Uso
from quantmaster.features.volume import volume_weighted_close_location
df["vwcl_20"] = volume_weighted_close_location(df, window=20)
API
Source code in src/quantmaster/features/volume.py
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156 | def volume_weighted_close_location(
data: pd.DataFrame,
*,
window: int = 20,
high_col: str = "high",
low_col: str = "low",
close_col: str = "close",
volume_col: str = "volume",
) -> pd.Series:
window = validate_positive_int(window, name="window")
validate_columns(data, required=[high_col, low_col, close_col, volume_col])
clv = close_location_value(data, high_col=high_col, low_col=low_col, close_col=close_col)
volume = pd.to_numeric(data[volume_col], errors="coerce").astype(float)
volume = volume.where(volume > 0)
num = (clv * volume).rolling(window).sum()
den = volume.rolling(window).sum()
out = (num / den.where(den > 0)).clip(lower=-1.0, upper=1.0)
out.name = f"volume_weighted_close_location_{window}"
return out
|