Files
crypto_monitor/tests/test_gate_position_history_lib.py
dekun 59a45ed027 fix: Gate hub close sync and trade record open stop-loss snapshot
Sync order monitors from Gate position history after hub flat close. Store and display initial_stop_loss in trade records instead of post-amend exchange stops.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-09 18:01:59 +08:00

27 lines
729 B
Python

from gate_position_history_lib import pick_gate_position_close, unified_symbol_for_match
def test_unified_symbol_strips_settle_suffix():
assert unified_symbol_for_match("BTC/USDT:USDT") == "BTC/USDT"
def test_pick_gate_position_close_matches_symbol_side_and_time():
hist = [
{
"symbol_u": "SOL/USDT",
"side": "short",
"close_ms": 1_700_000_000_000,
"open_ms": 1_699_999_000_000,
"pnl": -1.25,
"sync_key": "SOL_USDT|1|short",
}
]
hit = pick_gate_position_close(
hist,
"SOL/USDT:USDT",
"short",
opened_at_ms=1_699_999_500_000,
)
assert hit is not None
assert hit["pnl"] == -1.25