diff --git a/src/indicators.py b/src/indicators.py index 882d87e..5a2f166 100644 --- a/src/indicators.py +++ b/src/indicators.py @@ -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) diff --git a/tests/test_indicators.py b/tests/test_indicators.py index 2a10be9..9d20fbd 100644 --- a/tests/test_indicators.py +++ b/tests/test_indicators.py @@ -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()