"""Feature / Cycle pure-engine smoke tests (no DB).""" from datetime import date, timedelta from ashare_dp.domain.wyckoff import OHLCVFrame from ashare_dp.wyckoff.cycle import CycleEngine from ashare_dp.wyckoff.features import FeatureEngine def _synth_uptrend(n=120) -> OHLCVFrame: base = date(2024, 1, 1) closes = [100 + i * 0.5 for i in range(n)] return OHLCVFrame( ts_code="000001.SZ", timeframe="1d", trade_dates=[base + timedelta(days=i) for i in range(n)], open=closes, high=[c * 1.01 for c in closes], low=[c * 0.99 for c in closes], close=closes, volume=[1_000_000 + i * 1000 for i in range(n)], ) def test_feature_engine_snapshot(): fe = FeatureEngine() out = fe.run(_synth_uptrend()) assert out.name == "Feature" assert "ma20" in out.payload assert out.payload["bars"] == 120 assert out.confidence > 50 def test_cycle_engine_markup_on_uptrend(): fe = FeatureEngine() ce = CycleEngine() feat = fe.run(_synth_uptrend(150)) # Use monthly timeframe rules feat.payload["timeframe"] = "1M" cyc = ce.run(feat, "1M") assert cyc.payload["cycle"] in ("Markup", "Accumulation", "Unknown", "Distribution") assert "cycle" in cyc.payload