@@ -107,9 +107,9 @@ class Cancel(Struct):
107
107
broker-submitted (live) trigger/order.
108
108
109
109
'''
110
- action : str = 'cancel'
111
110
oid : str # uuid4
112
111
symbol : str
112
+ action : str = 'cancel'
113
113
114
114
115
115
# --------------
@@ -120,7 +120,6 @@ class Cancel(Struct):
120
120
121
121
class Status (Struct ):
122
122
123
- name : str = 'status'
124
123
time_ns : int
125
124
oid : str # uuid4 ems-order dialog id
126
125
@@ -135,6 +134,8 @@ class Status(Struct):
135
134
'error' ,
136
135
]
137
136
137
+ name : str = 'status'
138
+
138
139
# this maps normally to the ``BrokerdOrder.reqid`` below, an id
139
140
# normally allocated internally by the backend broker routing system
140
141
reqid : Optional [int | str ] = None
@@ -168,7 +169,6 @@ class Status(Struct):
168
169
169
170
class BrokerdCancel (Struct ):
170
171
171
- action : str = 'cancel'
172
172
oid : str # piker emsd order id
173
173
time_ns : int
174
174
@@ -180,6 +180,7 @@ class BrokerdCancel(Struct):
180
180
# on the emsd order request stream as the ``BrokerdOrderAck.reqid``
181
181
# field
182
182
reqid : Optional [int | str ] = None
183
+ action : str = 'cancel'
183
184
184
185
185
186
class BrokerdOrder (Struct ):
@@ -188,6 +189,10 @@ class BrokerdOrder(Struct):
188
189
account : str
189
190
time_ns : int
190
191
192
+ symbol : str # fqsn
193
+ price : float
194
+ size : float
195
+
191
196
# TODO: if we instead rely on a +ve/-ve size to determine
192
197
# the action we more or less don't need this field right?
193
198
action : str = '' # {buy, sell}
@@ -200,10 +205,6 @@ class BrokerdOrder(Struct):
200
205
# field
201
206
reqid : Optional [int | str ] = None
202
207
203
- symbol : str # fqsn
204
- price : float
205
- size : float
206
-
207
208
208
209
# ---------------
209
210
# emsd <- brokerd
@@ -218,19 +219,18 @@ class BrokerdOrderAck(Struct):
218
219
``.oid`` (which is a uuid4).
219
220
220
221
'''
221
- name : str = 'ack'
222
222
223
223
# defined and provided by backend
224
224
reqid : int | str
225
225
226
226
# emsd id originally sent in matching request msg
227
227
oid : str
228
228
account : str = ''
229
+ name : str = 'ack'
229
230
230
231
231
232
class BrokerdStatus (Struct ):
232
233
233
- name : str = 'status'
234
234
reqid : int | str
235
235
time_ns : int
236
236
status : Literal [
@@ -242,6 +242,7 @@ class BrokerdStatus(Struct):
242
242
]
243
243
244
244
account : str
245
+ name : str = 'status'
245
246
filled : float = 0.0
246
247
reason : str = ''
247
248
remaining : float = 0.0
@@ -260,24 +261,22 @@ class BrokerdFill(Struct):
260
261
if avaiable.
261
262
262
263
'''
263
- name : str = 'fill'
264
+ # brokerd timestamp required for order mode arrow placement on x-axis
265
+ # TODO: maybe int if we force ns?
266
+ # we need to normalize this somehow since backends will use their
267
+ # own format and likely across many disparate epoch clocks...
268
+ broker_time : float
264
269
reqid : int | str
265
270
time_ns : int
266
271
267
272
# order exeuction related
268
273
size : float
269
274
price : float
270
275
276
+ name : str = 'fill'
271
277
action : Optional [str ] = None
272
278
broker_details : dict = {} # meta-data (eg. commisions etc.)
273
279
274
- # brokerd timestamp required for order mode arrow placement on x-axis
275
-
276
- # TODO: maybe int if we force ns?
277
- # we need to normalize this somehow since backends will use their
278
- # own format and likely across many disparate epoch clocks...
279
- broker_time : float
280
-
281
280
282
281
class BrokerdError (Struct ):
283
282
'''
@@ -286,27 +285,27 @@ class BrokerdError(Struct):
286
285
This is still a TODO thing since we're not sure how to employ it yet.
287
286
288
287
'''
289
- name : str = 'error'
290
288
oid : str
289
+ symbol : str
290
+ reason : str
291
291
292
292
# if no brokerd order request was actually submitted (eg. we errored
293
293
# at the ``pikerd`` layer) then there will be ``reqid`` allocated.
294
294
reqid : Optional [int | str ] = None
295
295
296
- symbol : str
297
- reason : str
296
+ name : str = 'error'
298
297
broker_details : dict = {}
299
298
300
299
301
300
class BrokerdPosition (Struct ):
302
301
'''Position update event from brokerd.
303
302
304
303
'''
305
- name : str = 'position'
306
304
307
305
broker : str
308
306
account : str
309
307
symbol : str
310
308
size : float
311
309
avg_price : float
312
310
currency : str = ''
311
+ name : str = 'position'
0 commit comments