Files
eth_hedge_sim/backend/tests/test_stats_summary_extra.py
2026-08-02 12:25:30 +08:00

29 lines
614 B
Python

"""统计汇总:最大单笔亏损、连亏次数。"""
from __future__ import annotations
from app.api.stats import _current_loss_streak
def test_current_loss_streak() -> None:
assert _current_loss_streak([]) == 0
assert (
_current_loss_streak(
[
{"realized_pnl": 10},
{"realized_pnl": -1},
{"realized_pnl": -2},
]
)
== 2
)
assert (
_current_loss_streak(
[
{"realized_pnl": -5},
{"realized_pnl": 1},
]
)
== 0
)