feat(selection): add Zhixing line indicators to selection chart and update related components

This commit is contained in:
yuxuanhui
2026-09-01 22:57:58 +08:00
parent 3da90f7df8
commit f41ad0915e
10 changed files with 100 additions and 25 deletions
@@ -9,7 +9,10 @@ from zhixing_server.modules.selection.application.chart import (
GetSelectionChart,
SelectionChartNotFound,
)
from zhixing_server.modules.selection.domain.indicators import compute_kdj
from zhixing_server.modules.selection.domain.indicators import (
compute_kdj,
compute_zhixing_lines,
)
from zhixing_server.modules.selection.domain.models import SelectionBar, StockHistory
@@ -61,9 +64,12 @@ def test_chart_computes_on_full_history_before_returning_last_250_points() -> No
}
)
expected = compute_kdj(frame).iloc[-1]
expected_white, expected_yellow = compute_zhixing_lines(frame["close"])
assert chart.points[-1].k == pytest.approx(float(expected["K"]))
assert chart.points[-1].d == pytest.approx(float(expected["D"]))
assert chart.points[-1].j == pytest.approx(float(expected["J"]))
assert chart.points[-1].trend_white == pytest.approx(float(expected_white.iloc[-1]))
assert chart.points[-1].trend_yellow == pytest.approx(float(expected_yellow.iloc[-1]))
def test_chart_filters_future_rows_and_preserves_nullable_points() -> None: