feat: 威科夫多周期选股引擎与中文图表界面
新增规则驱动的月/周/日结构识别、决策融合与交易计划,提供扫描 API、本地 K 线(成交量/MACD/吸筹区间标注)及回填调度;K 线无起始日时默认取最近 N 根。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
"""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
|
||||
Reference in New Issue
Block a user