Count instance win rate by positive PnL and show external closes as manual close.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-25 22:27:52 +08:00
parent 0a20ee7eec
commit 448e88ec55
7 changed files with 54 additions and 27 deletions
+14 -1
View File
@@ -1,4 +1,4 @@
from trade_result_lib import normalize_result_with_pnl
from trade_result_lib import normalize_result_with_pnl, normalize_display_result, is_winning_pnl
def test_stop_loss_with_profit_becomes_trailing_tp():
@@ -15,3 +15,16 @@ def test_stop_loss_with_loss_unchanged():
def test_take_profit_unchanged():
assert normalize_result_with_pnl("止盈", 5) == "止盈"
def test_external_close_becomes_manual_close():
assert normalize_display_result("外部平仓") == "手动平仓"
assert normalize_result_with_pnl("外部平仓", 2.5) == "手动平仓"
assert normalize_result_with_pnl("外部平仓(自动同步)", -1) == "手动平仓"
def test_winning_pnl_positive_only():
assert is_winning_pnl(2.96) is True
assert is_winning_pnl(0) is False
assert is_winning_pnl(-1.05) is False
assert is_winning_pnl(None) is False