Files
crypto_monitor/tests/test_hub_cond_orders_dedupe.py
T
dekun 24270944e7 fix(hub,gate): cross-margin TP/SL and dedupe hub conditional orders
Gate hedge position triggers use close=false; stop silent ccxt fallback on cross margin. Hub merges agent and Flask TP/SL by trigger price and labels Gate orders correctly.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-04 19:48:04 +08:00

33 lines
1.0 KiB
Python

"""中控条件单列表:子代理与 Flask exchange_tpsl 合并去重。"""
from manual_trading_hub.hub import _merge_conditional_orders_no_dup
def test_merge_skips_duplicate_trigger_prices():
existing = [
{
"id": "100",
"label": "市价 买入 ·只减仓",
"trigger_price": 57,
"amount": 11,
},
{
"id": "101",
"label": "市价 买入 ·只减仓",
"trigger_price": 71,
"amount": 11,
},
]
extra = [
{"id": "", "label": "止损 57", "trigger_price": 57, "amount": 11},
{"id": "", "label": "止盈 71", "trigger_price": 71, "amount": 11},
]
merged = _merge_conditional_orders_no_dup(existing, extra)
assert len(merged) == 2
assert {round(o["trigger_price"]) for o in merged} == {57, 71}
def test_merge_uses_extra_when_existing_empty():
extra = [{"id": "1", "label": "止损 57", "trigger_price": 57}]
assert _merge_conditional_orders_no_dup([], extra) == extra