Prep for dropping `Transaction.sym`
Instead let's name it `.sys` for "system", the thing we use to conduct the "transactions" .. Also rename `.bsuid` -> `.bs_mktid` for "backend system market id` which is more explicit, easier to remember and read.pre_overruns_ctxcancelled
parent
e5eb317b47
commit
9ab196d778
|
@ -38,6 +38,7 @@ from ..log import get_logger
|
||||||
from ._mktinfo import (
|
from ._mktinfo import (
|
||||||
Symbol, # legacy
|
Symbol, # legacy
|
||||||
MktPair,
|
MktPair,
|
||||||
|
Asset,
|
||||||
)
|
)
|
||||||
|
|
||||||
log = get_logger(__name__)
|
log = get_logger(__name__)
|
||||||
|
@ -98,7 +99,18 @@ class Transaction(Struct, frozen=True):
|
||||||
# once we have that as a required field,
|
# once we have that as a required field,
|
||||||
# we don't really need the fqsn any more..
|
# we don't really need the fqsn any more..
|
||||||
fqsn: str
|
fqsn: str
|
||||||
sym: Symbol | MktPair
|
|
||||||
|
# TODO: drop the Symbol type
|
||||||
|
|
||||||
|
# the underlying "transaction system", normally one of a ``MktPair``
|
||||||
|
# (a description of a tradable double auction) or a ledger-recorded
|
||||||
|
# ("ledger" in any sense as long as you can record transfers) of any
|
||||||
|
# sort) ``Asset``.
|
||||||
|
sym: MktPair | Asset | Symbol
|
||||||
|
|
||||||
|
@property
|
||||||
|
def sys(self) -> Symbol:
|
||||||
|
return self.sym
|
||||||
|
|
||||||
tid: Union[str, int] # unique transaction id
|
tid: Union[str, int] # unique transaction id
|
||||||
size: float
|
size: float
|
||||||
|
@ -107,35 +119,22 @@ class Transaction(Struct, frozen=True):
|
||||||
dt: datetime
|
dt: datetime
|
||||||
expiry: datetime | None = None
|
expiry: datetime | None = None
|
||||||
|
|
||||||
@property
|
|
||||||
def mktpair(self) -> MktPair:
|
|
||||||
sym = self.sym
|
|
||||||
|
|
||||||
if isinstance(sym, MktPair):
|
|
||||||
# presume it's already set as our desired
|
|
||||||
# ``MktPair`` type:
|
|
||||||
return sym
|
|
||||||
|
|
||||||
# cast to new type
|
|
||||||
return MktPair.from_fqme(
|
|
||||||
sym.fqme,
|
|
||||||
price_tick=digits_to_dec(
|
|
||||||
Decimal(str(sym.tick_size)),
|
|
||||||
),
|
|
||||||
size_tick=digits_to_dec(
|
|
||||||
Decimal(str(sym.lot_tick_size)),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
# remap for back-compat
|
# remap for back-compat
|
||||||
@property
|
@property
|
||||||
def fqme(self) -> str:
|
def fqme(self) -> str:
|
||||||
return self.fqsn
|
return self.fqsn
|
||||||
|
|
||||||
# optional key normally derived from the broker
|
# (optional) key-id defined by the broker-service backend which
|
||||||
# backend which ensures the instrument-symbol this record
|
# ensures the instrument-symbol market key for this record is unique
|
||||||
# is for is truly unique.
|
# in the "their backend/system" sense; i.e. this uid for the market
|
||||||
bsuid: Union[str, int] | None = None
|
# as defined (internally) in some namespace defined by the broker
|
||||||
|
# service.
|
||||||
|
bsuid: str | int | None = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def bs_mktid(self) -> str | int | None:
|
||||||
|
print(f'STOP USING .bsuid` for {self.fqme}')
|
||||||
|
return self.bs_mktid
|
||||||
|
|
||||||
# XXX NOTE: this will come from the `MktPair`
|
# XXX NOTE: this will come from the `MktPair`
|
||||||
# instead of defined here right?
|
# instead of defined here right?
|
||||||
|
|
Loading…
Reference in New Issue