Compare commits

...

2 Commits

Author SHA1 Message Date
Nelson Torres 5304a36b87 get_assets now uses public endpoint
It's better if the data is available through a public endpoint.
2024-11-13 10:43:30 -03:00
Nelson Torres 089c79e905 now using exch_info in search_symbols 2024-11-13 10:40:05 -03:00
1 changed files with 12 additions and 18 deletions

View File

@ -65,6 +65,7 @@ from .venues import (
) )
from piker.accounting import ( from piker.accounting import (
Asset, Asset,
digits_to_dec,
MktPair, MktPair,
) )
from piker.data import ( from piker.data import (
@ -308,18 +309,16 @@ class Client:
""" """
assets = {} assets = {}
resp = await self.json_rpc( resp = await self.json_rpc(
'private/get_account_summaries', 'public/get_currencies',
params={ params={}
'extended' : True
}
) )
summaries = resp.result['summaries'] currencies = resp.result
for summary in summaries: for currency in currencies:
currency = summary['currency'] name = currency['currency']
tx_tick = Decimal('1e-08') tx_tick = digits_to_dec(currency['fee_precision'])
atype='crypto_currency' atype='crypto_currency'
assets[currency] = Asset( assets[name] = Asset(
name=currency, name=name,
atype=atype, atype=atype,
tx_tick=tx_tick) tx_tick=tx_tick)
return assets return assets
@ -452,20 +451,15 @@ class Client:
Fuzzy search symbology set for pairs matching `pattern`. Fuzzy search symbology set for pairs matching `pattern`.
''' '''
pairs: dict[str, Pair] = await self.symbol_info() pairs: dict[str, Pair] = await self.exch_info()
matches: dict[str, Pair] = match_from_pairs(
return match_from_pairs(
pairs=pairs, pairs=pairs,
query=pattern.upper(), query=pattern.upper(),
score_cutoff=35, score_cutoff=35,
limit=limit limit=limit
) )
# repack in name-keyed table
return {
pair.instrument_name.lower(): pair
for pair in matches.values()
}
async def bars( async def bars(
self, self,
mkt: MktPair, mkt: MktPair,