Use `MktPair` building `Position` objects in `PpTable.update_from_trans()`
parent
8891da2ff3
commit
bd73ec4ea4
|
@ -47,7 +47,7 @@ from ._mktinfo import (
|
||||||
Symbol,
|
Symbol,
|
||||||
MktPair,
|
MktPair,
|
||||||
Asset,
|
Asset,
|
||||||
unpack_fqsn,
|
unpack_fqme,
|
||||||
)
|
)
|
||||||
from .. import config
|
from .. import config
|
||||||
from ..brokers import get_brokermod
|
from ..brokers import get_brokermod
|
||||||
|
@ -117,7 +117,7 @@ class Position(Struct):
|
||||||
s = d.pop('symbol')
|
s = d.pop('symbol')
|
||||||
fqsn = s.fqme
|
fqsn = s.fqme
|
||||||
|
|
||||||
broker, key, suffix = unpack_fqsn(fqsn)
|
broker, key, suffix = unpack_fqme(fqsn)
|
||||||
|
|
||||||
if isinstance(s, Symbol):
|
if isinstance(s, Symbol):
|
||||||
sym_info = s.broker_info[broker]
|
sym_info = s.broker_info[broker]
|
||||||
|
@ -510,18 +510,29 @@ class PpTable(Struct):
|
||||||
key=lambda t: t.dt,
|
key=lambda t: t.dt,
|
||||||
reverse=True,
|
reverse=True,
|
||||||
):
|
):
|
||||||
|
fqme = t.fqme
|
||||||
|
bs_mktid = t.bs_mktid
|
||||||
|
|
||||||
|
# template the mkt-info presuming a legacy market ticks
|
||||||
|
# if no info exists in the transactions..
|
||||||
|
mkt = t.sys
|
||||||
|
if not mkt:
|
||||||
|
mkt = MktPair.from_fqme(
|
||||||
|
fqme,
|
||||||
|
price_tick='0.01',
|
||||||
|
size_tick='0.0',
|
||||||
|
bs_mktid=bs_mktid,
|
||||||
|
)
|
||||||
|
|
||||||
pp = pps.setdefault(
|
pp = pps.setdefault(
|
||||||
t.bs_mktid,
|
bs_mktid,
|
||||||
|
|
||||||
# if no existing pp, allocate fresh one.
|
# if no existing pp, allocate fresh one.
|
||||||
Position(
|
Position(
|
||||||
Symbol.from_fqsn(
|
mkt,
|
||||||
t.fqsn,
|
|
||||||
info={},
|
|
||||||
) if not t.sym else t.sym,
|
|
||||||
size=0.0,
|
size=0.0,
|
||||||
ppu=0.0,
|
ppu=0.0,
|
||||||
bs_mktid=t.bs_mktid,
|
bs_mktid=bs_mktid,
|
||||||
expiry=t.expiry,
|
expiry=t.expiry,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue