kraken: asyncify and use `get_mkt_info()` in `norm_trade_records()`
parent
d7288972b7
commit
4a0beda77e
|
@ -69,6 +69,7 @@ from .api import (
|
||||||
get_client,
|
get_client,
|
||||||
)
|
)
|
||||||
from .feed import (
|
from .feed import (
|
||||||
|
get_mkt_info,
|
||||||
open_autorecon_ws,
|
open_autorecon_ws,
|
||||||
NoBsWs,
|
NoBsWs,
|
||||||
stream_messages,
|
stream_messages,
|
||||||
|
@ -489,7 +490,7 @@ async def trades_dialogue(
|
||||||
) as ledger,
|
) as ledger,
|
||||||
):
|
):
|
||||||
# transaction-ify the ledger entries
|
# transaction-ify the ledger entries
|
||||||
ledger_trans = norm_trade_records(ledger)
|
ledger_trans = await norm_trade_records(ledger)
|
||||||
|
|
||||||
if not table.pps:
|
if not table.pps:
|
||||||
# NOTE: we can't use this since it first needs
|
# NOTE: we can't use this since it first needs
|
||||||
|
@ -507,7 +508,7 @@ async def trades_dialogue(
|
||||||
if tids2trades:
|
if tids2trades:
|
||||||
ledger.write_config()
|
ledger.write_config()
|
||||||
|
|
||||||
api_trans = norm_trade_records(tids2trades)
|
api_trans = await norm_trade_records(tids2trades)
|
||||||
|
|
||||||
# retrieve kraken reported balances
|
# retrieve kraken reported balances
|
||||||
# and do diff with ledger to determine
|
# and do diff with ledger to determine
|
||||||
|
@ -823,7 +824,7 @@ async def handle_order_updates(
|
||||||
)
|
)
|
||||||
await ems_stream.send(status_msg)
|
await ems_stream.send(status_msg)
|
||||||
|
|
||||||
new_trans = norm_trade_records(trades)
|
new_trans = await norm_trade_records(trades)
|
||||||
ppmsgs = trades2pps(
|
ppmsgs = trades2pps(
|
||||||
table,
|
table,
|
||||||
acctid,
|
acctid,
|
||||||
|
@ -1185,7 +1186,7 @@ async def handle_order_updates(
|
||||||
log.warning(f'Unhandled trades update msg: {msg}')
|
log.warning(f'Unhandled trades update msg: {msg}')
|
||||||
|
|
||||||
|
|
||||||
def norm_trade_records(
|
async def norm_trade_records(
|
||||||
ledger: dict[str, Any],
|
ledger: dict[str, Any],
|
||||||
|
|
||||||
) -> dict[str, Transaction]:
|
) -> dict[str, Transaction]:
|
||||||
|
@ -1200,18 +1201,9 @@ def norm_trade_records(
|
||||||
}[record['type']]
|
}[record['type']]
|
||||||
|
|
||||||
# we normalize to kraken's `altname` always..
|
# we normalize to kraken's `altname` always..
|
||||||
bs_mktid, pair_info = Client.normalize_symbol(
|
bs_mktid = Client.normalize_symbol(record['pair'])
|
||||||
record['pair']
|
|
||||||
)
|
|
||||||
fqme = f'{bs_mktid}.kraken'
|
fqme = f'{bs_mktid}.kraken'
|
||||||
|
mkt: MktPair = (await get_mkt_info(fqme))[0]
|
||||||
dst, src = pair_info.wsname.lower().split('/')
|
|
||||||
mkt = MktPair.from_fqme(
|
|
||||||
fqme,
|
|
||||||
price_tick=pair_info.price_tick,
|
|
||||||
size_tick=pair_info.size_tick,
|
|
||||||
bs_mktid=bs_mktid,
|
|
||||||
)
|
|
||||||
|
|
||||||
records[tid] = Transaction(
|
records[tid] = Transaction(
|
||||||
fqsn=fqme,
|
fqsn=fqme,
|
||||||
|
|
Loading…
Reference in New Issue