feat(V2): URL exchange configurabili da .env (DERIBIT_URL_*, BYBIT_URL_*, ecc.)

This commit is contained in:
AdrianoDev
2026-04-30 20:36:31 +02:00
parent b71c66917c
commit 436dfd6f5a
6 changed files with 141 additions and 13 deletions
+14 -5
View File
@@ -30,15 +30,24 @@ class BybitClient:
api_secret: str,
testnet: bool = True,
http: Any | None = None,
base_url: str | None = None,
) -> None:
self.api_key = api_key
self.api_secret = api_secret
self.testnet = testnet
self._http = http or HTTP(
api_key=api_key,
api_secret=api_secret,
testnet=testnet,
)
# pybit HTTP non accetta `endpoint` come kwarg (vedi _V5HTTPManager.__init__:
# solo `domain`/`tld`/`testnet`). Override URL applicato post-init
# sovrascrivendo l'attributo `endpoint` dell'istanza HTTP.
self.base_url = base_url
if http is None:
http = HTTP(
api_key=api_key,
api_secret=api_secret,
testnet=testnet,
)
if base_url:
http.endpoint = base_url
self._http = http
async def _run(self, fn, /, **kwargs):
return await asyncio.to_thread(fn, **kwargs)