Flip to `.bs_mktid` in `ib` and `kraken`
parent
b4ab1675fc
commit
3ead16c47c
|
@ -58,7 +58,7 @@ your ``pps.toml`` file will have position entries like,
|
|||
[kraken.spot."xmreur.kraken"]
|
||||
size = 4.80907954
|
||||
ppu = 103.97000000
|
||||
bsuid = "XXMRZEUR"
|
||||
bs_mktid = "XXMRZEUR"
|
||||
clears = [
|
||||
{ tid = "TFJBKK-SMBZS-VJ4UWS", cost = 0.8, price = 103.97, size = 4.80907954, dt = "2022-05-20T02:26:33.413397+00:00" },
|
||||
]
|
||||
|
|
|
@ -255,14 +255,14 @@ class Client:
|
|||
'Balance',
|
||||
{},
|
||||
)
|
||||
by_bsuid = resp['result']
|
||||
by_bsmktid = resp['result']
|
||||
|
||||
# TODO: we need to pull out the "asset" decimals
|
||||
# data and return a `decimal.Decimal` instead here!
|
||||
# using the underlying Asset
|
||||
return {
|
||||
self._atable[sym].lower(): float(bal)
|
||||
for sym, bal in by_bsuid.items()
|
||||
for sym, bal in by_bsmktid.items()
|
||||
}
|
||||
|
||||
async def get_assets(self) -> dict[str, dict]:
|
||||
|
@ -292,12 +292,12 @@ class Client:
|
|||
|
||||
'''
|
||||
assets = await self.get_assets()
|
||||
for bsuid, info in assets.items():
|
||||
for bs_mktid, info in assets.items():
|
||||
|
||||
aname = self._atable[bsuid] = info['altname']
|
||||
aname = self._atable[bs_mktid] = info['altname']
|
||||
aclass = info['aclass']
|
||||
|
||||
self.assets[bsuid] = Asset(
|
||||
self.assets[bs_mktid] = Asset(
|
||||
name=aname.lower(),
|
||||
atype=f'crypto_{aclass}',
|
||||
tx_tick=digits_to_dec(info['decimals']),
|
||||
|
@ -398,31 +398,25 @@ class Client:
|
|||
fqsn = asset_key + '.kraken'
|
||||
|
||||
# pair = MktPair(
|
||||
# src=Asset(
|
||||
# name=asset_key,
|
||||
# type='crypto_currency',
|
||||
# tx_tick=asset_info['decimals']
|
||||
|
||||
# tx_tick=
|
||||
# info=asset_info,
|
||||
# )
|
||||
# src=asset,
|
||||
# dst=asset,
|
||||
# broker='kraken',
|
||||
# )
|
||||
|
||||
pairinfo = Symbol.from_fqsn(
|
||||
fqsn,
|
||||
info={
|
||||
'asset_type': 'crypto',
|
||||
'lot_tick_size': asset.tx_tick,
|
||||
},
|
||||
)
|
||||
# pairinfo = Symbol.from_fqsn(
|
||||
# fqsn,
|
||||
# info={
|
||||
# 'asset_type': 'crypto',
|
||||
# 'lot_tick_size': asset.tx_tick,
|
||||
# },
|
||||
# )
|
||||
|
||||
tran = Transaction(
|
||||
fqsn=fqsn,
|
||||
sym=pairinfo,
|
||||
sym=asset,
|
||||
tid=entry['txid'],
|
||||
dt=pendulum.from_timestamp(entry['time']),
|
||||
bsuid=f'{asset_key}{src_asset}',
|
||||
bs_mktid=f'{asset_key}{src_asset}',
|
||||
size=-1*(
|
||||
float(entry['amount'])
|
||||
+
|
||||
|
|
|
@ -518,7 +518,7 @@ async def trades_dialogue(
|
|||
if (
|
||||
dst == src_fiat
|
||||
or not any(
|
||||
dst in bsuid for bsuid in table.pps
|
||||
dst in bs_mktid for bs_mktid in table.pps
|
||||
)
|
||||
):
|
||||
log.warning(
|
||||
|
@ -534,11 +534,11 @@ async def trades_dialogue(
|
|||
|
||||
src2dst: dict[str, str] = {}
|
||||
|
||||
for bsuid in table.pps:
|
||||
for bs_mktid in table.pps:
|
||||
likely_pair = get_likely_pair(
|
||||
src_fiat,
|
||||
dst,
|
||||
bsuid,
|
||||
bs_mktid,
|
||||
)
|
||||
if likely_pair:
|
||||
src2dst[src_fiat] = dst
|
||||
|
@ -558,7 +558,7 @@ async def trades_dialogue(
|
|||
):
|
||||
log.warning(
|
||||
f'`kraken` account says you have a ZERO '
|
||||
f'balance for {bsuid}:{pair}\n'
|
||||
f'balance for {bs_mktid}:{pair}\n'
|
||||
f'but piker seems to think `{pp.size}`\n'
|
||||
'This is likely a discrepancy in piker '
|
||||
'accounting if the above number is'
|
||||
|
@ -594,11 +594,11 @@ async def trades_dialogue(
|
|||
# in the ``pps.toml`` for the necessary pair
|
||||
# yet and thus this likely pair grabber will
|
||||
# likely fail.
|
||||
for bsuid in table.pps:
|
||||
for bs_mktid in table.pps:
|
||||
likely_pair = get_likely_pair(
|
||||
src_fiat,
|
||||
dst,
|
||||
bsuid,
|
||||
bs_mktid,
|
||||
)
|
||||
if likely_pair:
|
||||
break
|
||||
|
@ -1198,10 +1198,10 @@ def norm_trade_records(
|
|||
}[record['type']]
|
||||
|
||||
# we normalize to kraken's `altname` always..
|
||||
bsuid, pair_info = Client.normalize_symbol(
|
||||
bs_mktid, pair_info = Client.normalize_symbol(
|
||||
record['pair']
|
||||
)
|
||||
fqsn = f'{bsuid}.kraken'
|
||||
fqsn = f'{bs_mktid}.kraken'
|
||||
|
||||
dst, src = pair_info.wsname.lower().split('/')
|
||||
# mkpair = MktPair(
|
||||
|
@ -1236,7 +1236,7 @@ def norm_trade_records(
|
|||
price=float(record['price']),
|
||||
cost=float(record['fee']),
|
||||
dt=pendulum.from_timestamp(float(record['time'])),
|
||||
bsuid=bsuid,
|
||||
bs_mktid=bs_mktid,
|
||||
|
||||
# XXX: there are no derivs on kraken right?
|
||||
# expiry=expiry,
|
||||
|
|
Loading…
Reference in New Issue