Lower Shadow Ratio
Intuição
Mede a proporção do shadow inferior da vela, capturando rejeição de preços baixos.
Definição
LSR = (min(open, close) - low) / (high - low)
O resultado fica em [0, 1].
Uso
from quantmaster.features.trend import lower_shadow_ratio
lsr = lower_shadow_ratio(ohlc_df)
API
Source code in src/quantmaster/features/trend.py
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208 | def lower_shadow_ratio(
data: pd.DataFrame,
*,
open_col: str = "open",
high_col: str = "high",
low_col: str = "low",
close_col: str = "close",
) -> pd.Series:
validate_columns(data, required=[open_col, high_col, low_col, close_col])
o = pd.to_numeric(data[open_col], errors="coerce").astype(float)
h = pd.to_numeric(data[high_col], errors="coerce").astype(float)
l = pd.to_numeric(data[low_col], errors="coerce").astype(float)
c = pd.to_numeric(data[close_col], errors="coerce").astype(float)
rng = h - l
bot_body = np.minimum(o, c)
out = (bot_body - l) / rng.where(rng != 0)
out = out.where(rng != 0, 0.0)
out = out.clip(lower=0.0, upper=1.0)
out.name = "lower_shadow_ratio"
return out
|