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>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
"""中控条件单列表:子代理与 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
|
||||
Reference in New Issue
Block a user