Fix TP/SL exit classification when exchange fill slips past the tight band.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,4 +1,21 @@
|
||||
from lib.trade.trade_result_lib import normalize_result_with_pnl, normalize_display_result, is_winning_pnl
|
||||
from lib.trade.trade_result_lib import (
|
||||
classify_exit_by_levels,
|
||||
normalize_result_with_pnl,
|
||||
normalize_display_result,
|
||||
is_winning_pnl,
|
||||
)
|
||||
|
||||
|
||||
def test_classify_short_tp_with_slippage_past_tight_band():
|
||||
# Gate BTC 空单:计划止盈 62600,实际成交约 62738(条件单滑点),旧窄带会误判为外部平仓
|
||||
assert (
|
||||
classify_exit_by_levels("short", 64256.2, 65400, 62600, 62738.0) == "止盈"
|
||||
)
|
||||
|
||||
|
||||
def test_classify_long_sl_and_tp_basic():
|
||||
assert classify_exit_by_levels("long", 100, 95, 110, 110.05) == "止盈"
|
||||
assert classify_exit_by_levels("long", 100, 95, 110, 94.9) == "止损"
|
||||
|
||||
|
||||
def test_stop_loss_with_profit_becomes_trailing_tp():
|
||||
|
||||
Reference in New Issue
Block a user