feat(mcp-deribit,mcp-bybit): add place_combo_order

Deribit: private/create_combo + place_order sul combo instrument → una
sola crociata di spread invece di N (slippage atteso ridotto su
strutture liquide). ACL core + leverage cap su tutti i leg.

Bybit: place_batch_order su category=option (atomic multi-leg, 1
round-trip API). Reject su category != option (perp/linear non
supportano batch nativo). orderLinkId auto-generato per leg.

Tutti i test: deribit 48/48, bybit 123/123.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
AdrianoDev
2026-04-27 23:12:09 +02:00
parent bacd5aab33
commit c2fd8330ca
9 changed files with 358 additions and 1 deletions
@@ -1401,6 +1401,38 @@ class DeribitClient:
return {"error": raw.get("error", "unknown"), "state": "error"}
return r
async def place_combo_order(
self,
legs: list[dict[str, Any]],
side: str,
amount: float,
type: str = "limit",
price: float | None = None,
label: str | None = None,
) -> dict:
"""Crea un combo via private/create_combo poi piazza un singolo ordine
(buy/sell) sull'instrument_name del combo. Una sola crociata di spread
invece di N (uno per leg) → minor slippage su strutture liquide.
legs: [{instrument_name, direction: 'buy'|'sell', ratio: int}].
"""
combo_raw = await self._request("private/create_combo", {"trades": legs})
combo = combo_raw.get("result")
if combo is None:
return {"state": "error", "error": combo_raw.get("error", "unknown")}
combo_instrument = combo.get("instrument_name") or combo.get("id")
order = await self.place_order(
instrument_name=combo_instrument,
side=side,
amount=amount,
type=type,
price=price,
label=label,
)
if order.get("state") == "error":
return {"state": "error", "error": order.get("error"), "combo_instrument": combo_instrument}
return {"combo_instrument": combo_instrument, **order}
async def set_leverage(self, instrument_name: str, leverage: int) -> dict:
"""CER-016: pre-set account leverage per evitare default 50x testnet."""
raw = await self._request(