Update api.py

get_currencies function
max_pain_deribit
Nelson Torres 2024-11-29 10:41:20 -03:00
parent 4ccda643b8
commit 24bf19c1fb
1 changed files with 17 additions and 5 deletions

View File

@ -319,6 +319,20 @@ class Client:
return balances return balances
async def get_currencies(
self,
) -> list[dict]:
'''
Return the set of currencies for deribit.
'''
assets = {}
resp = await self._json_rpc_auth_wrapper(
'public/get_currencies',
params={}
)
return resp.result
async def get_assets( async def get_assets(
self, self,
venue: str | None = None, venue: str | None = None,
@ -331,11 +345,7 @@ class Client:
''' '''
assets = {} assets = {}
resp = await self._json_rpc_auth_wrapper( currencies = await self.get_currencies()
'public/get_currencies',
params={}
)
currencies: list[dict] = resp.result
for currency in currencies: for currency in currencies:
name: str = currency['currency'] name: str = currency['currency']
tx_tick: Decimal = digits_to_dec(currency['fee_precision']) tx_tick: Decimal = digits_to_dec(currency['fee_precision'])
@ -844,6 +854,8 @@ async def open_oi_feed(
instruments: list[Symbol] instruments: list[Symbol]
async with get_client( async with get_client(
) as client: ) as client:
# to get all currencies available in deribit
# currencies = await client.get_currencies()
instruments = await client.get_instruments() instruments = await client.get_instruments()
fh: FeedHandler fh: FeedHandler