5797d49d8a
统一 strategy、key_monitor、trade、hub 等共用库到 lib/ 子包,并补充 lib-structure 文档,便于四所与中控维护。 Co-authored-by: Cursor <cursoragent@cursor.com>
27 lines
768 B
Python
27 lines
768 B
Python
from lib.exchange.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
|