修复bug

This commit is contained in:
dekun
2026-05-18 08:10:28 +08:00
parent 24550b0ce0
commit 82a7237063
8 changed files with 132 additions and 58 deletions
@@ -0,0 +1,23 @@
from app.candle_rows import rows_to_ohlcv
def test_rows_to_ohlcv_skips_empty_volume() -> None:
rows = [
["1", "100", "101", "99", "100.5", "123"],
["2", "100.5", "102", "100", "101", ""],
["3", "101", "103", "100.5", "102", "50"],
]
o, h, l, c, v = rows_to_ohlcv(rows)
assert len(c) == 2
assert c == [100.5, 102.0]
assert v == [123.0, 50.0]
def test_rows_to_ohlcv_skips_invalid_ohlc() -> None:
rows = [
["1", "", "101", "99", "100.5", "10"],
["2", "100", "101", "99", "100.5", "20"],
]
_, _, _, c, v = rows_to_ohlcv(rows)
assert c == [100.5]
assert v == [20.0]