diff --git a/piker/clearing/_allocate.py b/piker/clearing/_allocate.py index 34f59571..d201368d 100644 --- a/piker/clearing/_allocate.py +++ b/piker/clearing/_allocate.py @@ -43,6 +43,14 @@ SizeUnit = Enum( class Allocator(Struct): symbol: Symbol + + # TODO: if we ever want ot support non-uniform entry-slot-proportion + # "sizes" + # disti_weight: str = 'uniform' + + units_limit: float + currency_limit: float + slots: int account: Optional[str] = 'paper' _size_units: bidict[str, Optional[str]] = _size_units @@ -66,14 +74,6 @@ class Allocator(Struct): self._size_unit = v return v - # TODO: if we ever want ot support non-uniform entry-slot-proportion - # "sizes" - # disti_weight: str = 'uniform' - - units_limit: float - currency_limit: float - slots: int - def step_sizes( self, ) -> (float, float): diff --git a/piker/clearing/_messages.py b/piker/clearing/_messages.py index 2c258625..b41a565f 100644 --- a/piker/clearing/_messages.py +++ b/piker/clearing/_messages.py @@ -107,9 +107,9 @@ class Cancel(Struct): broker-submitted (live) trigger/order. ''' - action: str = 'cancel' oid: str # uuid4 symbol: str + action: str = 'cancel' # -------------- @@ -120,7 +120,6 @@ class Cancel(Struct): class Status(Struct): - name: str = 'status' time_ns: int oid: str # uuid4 ems-order dialog id @@ -135,6 +134,8 @@ class Status(Struct): 'error', ] + name: str = 'status' + # this maps normally to the ``BrokerdOrder.reqid`` below, an id # normally allocated internally by the backend broker routing system reqid: Optional[int | str] = None @@ -168,7 +169,6 @@ class Status(Struct): class BrokerdCancel(Struct): - action: str = 'cancel' oid: str # piker emsd order id time_ns: int @@ -180,6 +180,7 @@ class BrokerdCancel(Struct): # on the emsd order request stream as the ``BrokerdOrderAck.reqid`` # field reqid: Optional[int | str] = None + action: str = 'cancel' class BrokerdOrder(Struct): @@ -188,6 +189,10 @@ class BrokerdOrder(Struct): account: str time_ns: int + symbol: str # fqsn + price: float + size: float + # TODO: if we instead rely on a +ve/-ve size to determine # the action we more or less don't need this field right? action: str = '' # {buy, sell} @@ -200,10 +205,6 @@ class BrokerdOrder(Struct): # field reqid: Optional[int | str] = None - symbol: str # fqsn - price: float - size: float - # --------------- # emsd <- brokerd @@ -218,7 +219,6 @@ class BrokerdOrderAck(Struct): ``.oid`` (which is a uuid4). ''' - name: str = 'ack' # defined and provided by backend reqid: int | str @@ -226,11 +226,11 @@ class BrokerdOrderAck(Struct): # emsd id originally sent in matching request msg oid: str account: str = '' + name: str = 'ack' class BrokerdStatus(Struct): - name: str = 'status' reqid: int | str time_ns: int status: Literal[ @@ -242,6 +242,7 @@ class BrokerdStatus(Struct): ] account: str + name: str = 'status' filled: float = 0.0 reason: str = '' remaining: float = 0.0 @@ -260,7 +261,11 @@ class BrokerdFill(Struct): if avaiable. ''' - name: str = 'fill' + # brokerd timestamp required for order mode arrow placement on x-axis + # TODO: maybe int if we force ns? + # we need to normalize this somehow since backends will use their + # own format and likely across many disparate epoch clocks... + broker_time: float reqid: int | str time_ns: int @@ -268,16 +273,10 @@ class BrokerdFill(Struct): size: float price: float + name: str = 'fill' action: Optional[str] = None broker_details: dict = {} # meta-data (eg. commisions etc.) - # brokerd timestamp required for order mode arrow placement on x-axis - - # TODO: maybe int if we force ns? - # we need to normalize this somehow since backends will use their - # own format and likely across many disparate epoch clocks... - broker_time: float - class BrokerdError(Struct): ''' @@ -286,15 +285,15 @@ class BrokerdError(Struct): This is still a TODO thing since we're not sure how to employ it yet. ''' - name: str = 'error' oid: str + symbol: str + reason: str # if no brokerd order request was actually submitted (eg. we errored # at the ``pikerd`` layer) then there will be ``reqid`` allocated. reqid: Optional[int | str] = None - symbol: str - reason: str + name: str = 'error' broker_details: dict = {} @@ -302,7 +301,6 @@ class BrokerdPosition(Struct): '''Position update event from brokerd. ''' - name: str = 'position' broker: str account: str @@ -310,3 +308,4 @@ class BrokerdPosition(Struct): size: float avg_price: float currency: str = '' + name: str = 'position' diff --git a/piker/data/_web_bs.py b/piker/data/_web_bs.py index 779a7d44..8af82d61 100644 --- a/piker/data/_web_bs.py +++ b/piker/data/_web_bs.py @@ -165,8 +165,8 @@ over a NoBsWs. class JSONRPCResult(Struct): - jsonrpc: str = '2.0' id: int + jsonrpc: str = '2.0' result: Optional[dict] = None error: Optional[dict] = None diff --git a/piker/ui/_flows.py b/piker/ui/_flows.py index 175afe4f..f8a4a4c0 100644 --- a/piker/ui/_flows.py +++ b/piker/ui/_flows.py @@ -338,6 +338,7 @@ class Flow(msgspec.Struct): # , frozen=True): name: str plot: pg.PlotItem graphics: Union[Curve, BarItems] + _shm: ShmArray yrange: tuple[float, float] = None # in some cases a flow may want to change its @@ -345,7 +346,6 @@ class Flow(msgspec.Struct): # , frozen=True): # normally this is just a plain line. ds_graphics: Optional[Curve] = None - _shm: ShmArray is_ohlc: bool = False render: bool = True # toggle for display loop