book_execute: integrazione U1+U2 — un solo Telegram in solo protezione, stato unknown, set_open_cap diretto (#18, #21, #22, #24)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-27 14:14:28 +00:00
parent 0e6cf17081
commit 841d4c78cd
4 changed files with 166 additions and 36 deletions
+3 -1
View File
@@ -96,7 +96,9 @@ class DeribitTrader(DeribitRead):
if side not in ("buy", "sell"):
raise GuardrailError(f"side non valido: {side}")
if not reduce_only: # cap SOLO sulle aperture; le chiusure si tentano sempre
cap = self._open_cap.get(instrument, MAX_AMOUNT[instrument])
# getattr, non self._open_cap diretto: un DeribitTrader creato con object.__new__
# (test che saltano __init__) non ha l'attributo, e qui non deve dare AttributeError.
cap = getattr(self, "_open_cap", {}).get(instrument, MAX_AMOUNT[instrument])
if amount <= 0 or amount > cap:
raise GuardrailError(f"size {amount} fuori dal cap apertura (0, {cap}]")
if amount <= 0: