`pprint.pformat()` IB position mismatch log msgs

rekt_pps
Tyler Goodlet 2023-04-05 19:02:33 -04:00
parent 55b4866d5e
commit f42bc2dbce
1 changed files with 14 additions and 13 deletions

View File

@ -369,6 +369,9 @@ async def update_and_audit_msgs(
) )
msgs.append(msg) msgs.append(msg)
ibfmtmsg = pformat(ibppmsg.to_dict())
pikerfmtmsg = pformat(msg.to_dict())
if validate: if validate:
ibsize = ibppmsg.size ibsize = ibppmsg.size
pikersize = msg.size pikersize = msg.size
@ -388,13 +391,13 @@ async def update_and_audit_msgs(
# raise ValueError( # raise ValueError(
log.error( log.error(
f'POSITION MISMATCH ib <-> piker ledger:\n' f'Pos mismatch in ib vs. the piker ledger!\n'
'FIGURE OUT WHY TF YOUR LEDGER IS OFF!?!?\n\n' f'IB:\n{ibfmtmsg}\n\n'
f'PIKER:\n{pikerfmtmsg}\n\n'
'If you are expecting a (reverse) split in this ' 'If you are expecting a (reverse) split in this '
'instrument you should probably put the following\n\n' 'instrument you should probably put the following'
f'in the `pps.toml` section:\n{entry}' 'in the `pps.toml` section:\n'
f'IB:\nm{ibppmsg.to_dict()}\n\n' f'{entry}\n'
f'PIKER:\n{msg.to_dict()}\n\n'
# f'reverse_split_ratio: {reverse_split_ratio}\n' # f'reverse_split_ratio: {reverse_split_ratio}\n'
# f'split_ratio: {split_ratio}\n\n' # f'split_ratio: {split_ratio}\n\n'
) )
@ -403,10 +406,9 @@ async def update_and_audit_msgs(
if ibppmsg.avg_price != msg.avg_price: if ibppmsg.avg_price != msg.avg_price:
# TODO: make this a "propaganda" log level? # TODO: make this a "propaganda" log level?
log.warning( log.warning(
'The mega-cucks at IB want you to believe with their ' f'IB "FIFO" avg price for {msg.symbol} is DIFF:\n'
f'"FIFO" positioning for {msg.symbol}:\n' f'ib: {ibppmsg.avg_price}\n'
f'"ib" mega-cucker avg price: {ibppmsg.avg_price}\n' f'piker: {msg.avg_price}'
f'piker, LIFO breakeven PnL price: {msg.avg_price}'
) )
else: else:
@ -431,9 +433,8 @@ async def update_and_audit_msgs(
# raise ValueError( # raise ValueError(
log.error( log.error(
f'UNEXPECTED POSITION says IB:\n' f'UNEXPECTED POSITION says IB:\n'
'YOU SHOULD FIGURE OUT WHY TF YOUR LEDGER IS OFF!?\n' 'Maybe they LIQUIDATED YOU or your missing ledger records?\n'
'THEY LIQUIDATED YOU OR YOUR MISSING LEDGER RECORDS!?\n' f'PIKER:\n{pikerfmtmsg}\n\n'
f'PIKER:\n{msg.to_dict()}\n'
) )
msgs.append(msg) msgs.append(msg)