fix(V2): get_account_summary error path → numeric fields None invece di 0

Su errore di Deribit (auth fallita, ecc.) i campi equity/balance/margin/
available/unrealized_pnl/total_pnl ora sono None: signal chiaro di "valore
ignoto" vs "saldo realmente a zero". Risolve ambiguità lato client che
leggevano equity=0 senza accorgersi del campo error.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
root
2026-05-01 13:00:57 +00:00
parent 6640ede3df
commit 8a0f37ebc2
2 changed files with 8 additions and 7 deletions
+6 -6
View File
@@ -321,12 +321,12 @@ class DeribitClient:
r = raw.get("result") r = raw.get("result")
if not r: if not r:
return { return {
"equity": 0, "equity": None,
"balance": 0, "balance": None,
"margin_balance": 0, "margin_balance": None,
"available_funds": 0, "available_funds": None,
"unrealized_pnl": 0, "unrealized_pnl": None,
"total_pnl": 0, "total_pnl": None,
"testnet": self.testnet, "testnet": self.testnet,
"error": raw.get("error", "no result"), "error": raw.get("error", "no result"),
} }
+2 -1
View File
@@ -165,7 +165,8 @@ async def test_private_call_with_bad_auth_returns_error_envelope(
is_reusable=True, is_reusable=True,
) )
summary = await client.get_account_summary("USDC") summary = await client.get_account_summary("USDC")
assert summary["equity"] == 0 assert summary["equity"] is None
assert summary["balance"] is None
assert "invalid_credentials" in summary["error"] assert "invalid_credentials" in summary["error"]
positions = await client.get_positions("USDC") positions = await client.get_positions("USDC")
assert positions == [] assert positions == []