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