kraken: rename `Client._atable` -> `_altnames`

rekt_pps
Tyler Goodlet 2023-04-05 13:07:22 -04:00
parent 1d2d4b40a8
commit 3f2f5edb28
1 changed files with 13 additions and 8 deletions

View File

@ -170,9 +170,12 @@ class Pair(Struct):
class Client: class Client:
# global symbol normalization table # symbol mapping from all names to the altname
_ntable: dict[str, str] = {} _ntable: dict[str, str] = {}
_atable: bidict[str, str] = bidict()
# 2-way map of symbol names to their "alt names" ffs XD
_altnames: bidict[str, str] = bidict()
_pairs: dict[str, Pair] = {} _pairs: dict[str, Pair] = {}
def __init__( def __init__(
@ -267,7 +270,7 @@ class Client:
# data and return a `decimal.Decimal` instead here! # data and return a `decimal.Decimal` instead here!
# using the underlying Asset # using the underlying Asset
return { return {
self._atable[sym].lower(): float(bal) self._altnames[sym].lower(): float(bal)
for sym, bal in by_bsmktid.items() for sym, bal in by_bsmktid.items()
} }
@ -300,7 +303,7 @@ class Client:
assets = await self.get_assets() assets = await self.get_assets()
for bs_mktid, info in assets.items(): for bs_mktid, info in assets.items():
aname = self._atable[bs_mktid] = info['altname'] aname = self._altnames[bs_mktid] = info['altname']
aclass = info['aclass'] aclass = info['aclass']
self.assets[bs_mktid] = Asset( self.assets[bs_mktid] = Asset(
@ -395,7 +398,7 @@ class Client:
# look up the normalized name and asset info # look up the normalized name and asset info
asset_key = entry['asset'] asset_key = entry['asset']
asset = self.assets[asset_key] asset = self.assets[asset_key]
asset_key = self._atable[asset_key].lower() asset_key = self._altnames[asset_key].lower()
# XXX: this is in the asset units (likely) so it isn't # XXX: this is in the asset units (likely) so it isn't
# quite the same as a commisions cost necessarily..) # quite the same as a commisions cost necessarily..)
@ -504,9 +507,11 @@ class Client:
) -> MktPair: ) -> MktPair:
pair_info: Pair # = await self.pair_info(pair) (
bs_mktid: str bs_mktid, # str
bs_mktid, pair_info = Client.normalize_symbol(pair_str) pair_info, # Pair
) = Client.normalize_symbol(pair_str)
dst_asset = self.assets[pair_info.base] dst_asset = self.assets[pair_info.base]
# NOTE XXX parse out the src asset name until we figure out # NOTE XXX parse out the src asset name until we figure out