Add transfers knowledge to positions validation

kraken_ws_orders
Tyler Goodlet 2022-07-22 19:11:29 -04:00
parent d502274eb9
commit 8b609f531b
1 changed files with 25 additions and 2 deletions

View File

@ -410,15 +410,38 @@ async def trades_dialogue(
if ( if (
not pair or not pp not pair or not pp
or not math.isclose(pp.size, size) or not math.isclose(pp.calc_size(), size)
): ):
return False return False
return pp return pp
pos = has_pp(dst) pos = has_pp(dst)
if not pos: if not pos:
# get transfers to make sense of abs balances.
likely_pair = {
bsuid[:3]: bsuid
for bsuid in table.pps
}.get(dst)
if likely_pair:
# this was likely pp that had a withdrawal
# from the dst asset out of the account.
xfer_trans = await client.get_xfers(
dst,
src_asset=likely_pair[3:],
)
if xfer_trans:
updated = table.update_from_trans(
xfer_trans,
cost_scalar=1,
)
log.info(
'Updated {dst} from transfers:\n'
f'{pformat(updated)}'
)
# we have a balance for which there is no pp # we have a balance for which there is no pp
# entry? so we have to likely update from the # entry? so we have to likely update from the
# ledger. # ledger.