feat: add ADX calculation to indicators
Add ADX (Average Directional Index) with period 14 to calculate_all() for sideways market filtering. Includes test verifying the adx column exists and contains non-negative values. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,10 @@ class Indicators:
|
||||
df["stoch_k"] = stoch["STOCHRSIk_14_14_3_3"]
|
||||
df["stoch_d"] = stoch["STOCHRSId_14_14_3_3"]
|
||||
|
||||
# ADX (14) — 횡보장 필터
|
||||
adx_df = ta.adx(df["high"], df["low"], df["close"], length=14)
|
||||
df["adx"] = adx_df["ADX_14"]
|
||||
|
||||
# 거래량 이동평균
|
||||
df["vol_ma20"] = ta.sma(df["volume"], length=20)
|
||||
|
||||
|
||||
@@ -45,6 +45,15 @@ def test_bollinger_bands(sample_df):
|
||||
assert (valid["bb_upper"] >= valid["bb_lower"]).all()
|
||||
|
||||
|
||||
def test_adx_column_exists(sample_df):
|
||||
"""calculate_all()이 adx 컬럼을 생성하는지 확인."""
|
||||
ind = Indicators(sample_df)
|
||||
df = ind.calculate_all()
|
||||
assert "adx" in df.columns
|
||||
valid = df["adx"].dropna()
|
||||
assert (valid >= 0).all()
|
||||
|
||||
|
||||
def test_signal_returns_direction(sample_df):
|
||||
ind = Indicators(sample_df)
|
||||
df = ind.calculate_all()
|
||||
|
||||
Reference in New Issue
Block a user