`kraken`: use `MktPair` in trasactions

rekt_pps
Tyler Goodlet 2023-03-20 20:01:26 -04:00
parent da10422160
commit 7aba290541
1 changed files with 8 additions and 30 deletions

View File

@ -49,9 +49,7 @@ from piker.accounting import (
get_likely_pair, get_likely_pair,
) )
from piker.accounting._mktinfo import ( from piker.accounting._mktinfo import (
Symbol,
MktPair, MktPair,
digits_to_dec,
) )
from piker.clearing._messages import ( from piker.clearing._messages import (
Order, Order,
@ -1201,45 +1199,25 @@ def norm_trade_records(
bs_mktid, pair_info = Client.normalize_symbol( bs_mktid, pair_info = Client.normalize_symbol(
record['pair'] record['pair']
) )
fqsn = f'{bs_mktid}.kraken' fqme = f'{bs_mktid}.kraken'
dst, src = pair_info.wsname.lower().split('/') dst, src = pair_info.wsname.lower().split('/')
# mkpair = MktPair( mkt = MktPair.from_fqme(
# src=src, fqme,
# dst=dst, price_tick=pair_info.price_tick,
# price_tick=digits_to_dec(pair_info.pair_decimals), size_tick=pair_info.size_tick,
# size_tick=digits_to_dec(pair_info.lot_decimals), bs_mktid=bs_mktid,
# dst_type='crypto_currency',
# )
# breakpoint()
mktpair = Symbol.from_fqsn(
fqsn,
info={
'lot_size_digits': pair_info.lot_decimals,
'lot_tick_size': digits_to_dec(
pair_info.lot_decimals,
),
'tick_size_digits': pair_info.pair_decimals,
'price_tick_size': digits_to_dec(
pair_info.pair_decimals,
),
'asset_type': 'crypto',
},
) )
records[tid] = Transaction( records[tid] = Transaction(
fqsn=fqsn, fqsn=fqme,
sym=mktpair, sym=mkt,
tid=tid, tid=tid,
size=size, size=size,
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'])),
bs_mktid=bs_mktid, bs_mktid=bs_mktid,
# XXX: there are no derivs on kraken right?
# expiry=expiry,
) )
return records return records