feat(V2): URL exchange configurabili da .env (DERIBIT_URL_*, BYBIT_URL_*, ecc.)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user