feat(deribit): get_open_orders (limit resting + trigger non scattati)
Espone private/get_open_orders_by_currency sul router Deribit (pattern gia' presente per Hyperliquid/IBKR). Serve al reconciler resting di PythagorasGoal: TP/DSL attesi dai libri vs ordini realmente in book (caso MR02_BTC 2026-06-12: TP resting fillato di notte + disaster-SL sparito, scoperti solo al close sim). NB: per i trigger untriggered interrogare anche type='trigger_all' e fare merge per order_id. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -412,6 +412,37 @@ class DeribitClient:
|
||||
"testnet": self.testnet,
|
||||
}
|
||||
|
||||
async def get_open_orders(
|
||||
self, currency: str = "USDC", kind: str | None = None, type: str = "all"
|
||||
) -> list:
|
||||
"""Ordini APERTI sul conto: limit resting e trigger non scattati.
|
||||
NB Deribit: con type='all' gli untriggered possono essere omessi ->
|
||||
chi vuole anche i bracket interroga type='trigger_all' e merge per
|
||||
order_id (e' cio' che fa il reconciler di PythagorasGoal)."""
|
||||
params: dict = {"currency": currency, "type": type}
|
||||
if kind:
|
||||
params["kind"] = kind
|
||||
raw = await self._request("private/get_open_orders_by_currency", params)
|
||||
result = raw.get("result") or []
|
||||
return [
|
||||
{
|
||||
"order_id": o.get("order_id"),
|
||||
"instrument": o.get("instrument_name"),
|
||||
"direction": o.get("direction"),
|
||||
"order_type": o.get("order_type"),
|
||||
"order_state": o.get("order_state"),
|
||||
"amount": o.get("amount"),
|
||||
"filled_amount": o.get("filled_amount"),
|
||||
"price": o.get("price"),
|
||||
"trigger_price": o.get("trigger_price"),
|
||||
"reduce_only": o.get("reduce_only"),
|
||||
"label": o.get("label"),
|
||||
"creation_timestamp": o.get("creation_timestamp"),
|
||||
}
|
||||
for o in result
|
||||
if isinstance(o, dict)
|
||||
]
|
||||
|
||||
async def get_trade_history(
|
||||
self, limit: int = 100, instrument_name: str | None = None
|
||||
) -> list:
|
||||
|
||||
Reference in New Issue
Block a user