paper engine: use the `fqme` for the `bs_mktid`

Instead of stripping the broker part just use the full fqme for all
`Transaction.bs_mktid: str` values since it makes indexing the `PpTable`
much easier with less key mangling..
rekt_pps
Tyler Goodlet 2023-04-04 13:31:55 -04:00
parent 9770a39d7b
commit f51361435f
1 changed files with 11 additions and 7 deletions

View File

@ -249,8 +249,10 @@ class PaperBoi(Struct):
) )
await self.ems_trades_stream.send(msg) await self.ems_trades_stream.send(msg)
# lookup any existing position # NOTE: for paper we set the "bs_mktid" as just the fqme since
key = fqme.rstrip(f'.{self.broker}') # we don't actually have any unique backend symbol ourselves
# other then this thing, our fqme address.
bs_mktid: str = fqme
t = Transaction( t = Transaction(
fqsn=fqme, fqsn=fqme,
sym=self._syms[fqme], sym=self._syms[fqme],
@ -259,7 +261,7 @@ class PaperBoi(Struct):
price=price, price=price,
cost=0, # TODO: cost model cost=0, # TODO: cost model
dt=pendulum.from_timestamp(fill_time_s), dt=pendulum.from_timestamp(fill_time_s),
bs_mktid=key, bs_mktid=bs_mktid,
) )
tx = t.to_dict() tx = t.to_dict()
@ -270,17 +272,19 @@ class PaperBoi(Struct):
self.ppt.update_from_trans({oid: t}) self.ppt.update_from_trans({oid: t})
# transmit pp msg to ems # transmit pp msg to ems
pp = self.ppt.pps[key] pp = self.ppt.pps[bs_mktid]
pp_msg = BrokerdPosition( pp_msg = BrokerdPosition(
broker=self.broker, broker=self.broker,
account='paper', account='paper',
symbol=fqme, symbol=fqme,
size=pp.size,
avg_price=pp.ppu,
# TODO: we need to look up the asset currency from # TODO: we need to look up the asset currency from
# broker info. i guess for crypto this can be # broker info. i guess for crypto this can be
# inferred from the pair? # inferred from the pair?
currency=key, # currency=bs_mktid,
size=pp.size,
avg_price=pp.ppu,
) )
await self.ems_trades_stream.send(pp_msg) await self.ems_trades_stream.send(pp_msg)