-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvx_enum.py
595 lines (493 loc) · 15.7 KB
/
vx_enum.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
from enum import IntEnum, Enum
#--------------------------------------------------------
# Field Identification
#--------------------------------------------------------
Fids = [
"header.instrumentID", # Unique ID given by the exchange used to Identify the contract
"header.sequence",
"header.time", # Time in with nanosecond precision
"header.channelSequence", # Packet level sequence number per channel multiple instrumentSequence #'s for multiple contracts can have the same ChannelSequence #
"header.instrumentSequence", # Unique ID given by the exchange to each Market event a contract has. These sequentially get larger.
"header.unionID",
"header.eventIndicator",
"header.flag",
"header.baseExponent",
"transactionMarker.type",
"channelReset.type",
"tradeSummary.price", # Price at which the event occurred
"tradeSummary.quantity", # Quantity matched for this event
"tradeSummary.matches", # Identifies the total number of non-implied orders that participated in this trade event
"tradeSummary.aggressor", # The side of the aggressor: 1=Buy, 2=Sell and 0=Implied
"tradeSummary.isImplied",
"tradeSummary.isSnapshot",
"tradeSummary.volume",
"tradeMatch.isAggressor",
"tradeMatch.number", # The order of this match if example if value of 2 this is the second order matched
"tradeMatch.price", # The price the match occurred at
"tradeMatch.orderID", # The Order ID only available when trader ops in
"tradeMatch.auxillaryID",
"tradeMatch.quantity", # The amount filled in this match
"tradeMatch.flags",
"volumeUpdate.volume", # Represents cumulative traded volume of the Daily Trade session
"volumeUpdate.vwap", # No value for CME data
# bookLevel represent quote messages for messages within the first 10 levels of the book and give details about the type of book event that occured and the make up of the book at that price level
"bookLevel.price", # Price at which the quote event occurred
"bookLevel.quantity", # Total quantity at this book level after this event
"bookLevel.orders", # Number of orders at this book level after this event
"bookLevel.impliedQuantity",
"bookLevel.impliedOrders",
"bookLevel.level", # The number of price levels away from the market at which the event occurred
"bookLevel.action", # What occurred in the book. It can be New, Delete or Change
"bookLevel.type", # Is it a Bid or an Offer.
"bookLevel.isEndEvent", # EOE (end-of-Event) appears when more than one book update comes on the same message and is used to announce the end of book updates for the message.
# orderBook represent quote messages at all price levels and give only details about that specific quote message
"orderBook.orderID", # Identification number of the order can be used to trace the life cycle of the order
"orderBook.auxilaryID", # Not in use for CME data
"orderBook.priorityID", # Order priority for execution on the order book. A lower value is a higher priority
"orderBook.price", # Price where the event occurred
"orderBook.previousID", # Not in use for CME data
"orderBook.quantity", # Visible quantity of an order to the market
"orderBook.action", # What occurred in the book. It can be overlay, new, delete, or change
"orderBook.type", # Side of the book. 0 = Bid And 1 = Offer
"orderBook.isSnapshot",
"securityStatus.group", # Root symbol of the asset. EX: If pulling an option this will have the root of the option
"securityStatus.asset", # Unique instrument ID
"securityStatus.sessionDate", # Indicates the date of the trade session
"securityStatus.type", # 2 = Trading Halt, 4 = Close, 15 = New Price Indication, 17 = Ready to trade (Start of Session), 18 = Not available for trading, 20 = Unknown or Invalid, 21 = Pre-Open, 24 = Pre-Cross, 25 = Cross, 26 = Post Cross,103 = No Change
"securityStatus.haltReason", # 0 = Group schedule, 1 = Surveillance intervention, 2 = Market event, 3 = Instrument activation, 4 = Instrument expiration, 5 = Unknown, 6 = Recovery in Process
"securityStatus.event", # 0 = No Event (default), 1 = No Cancel, 4 = Change of trading session (reset statistics), 5 = Implied matching ON, 6 = Implied matching OFF
"dailyStatistics.instrumentID", # Unique ID given by the exchange used to Identify the contract
"dailyStatistics.price", # for Settlement messages - Price of the product Settlement
"dailyStatistics.size", # for Open Interest messages - The total Open Interest, For Cleared Volumne - New The total volume
"dailyStatistics.sessionDate", # Date of trade session corresponding to the statistic entry
"dailyStatistics.settleType", # for settlement messages - Which type of settle price.
"dailyStatistics.type", # type of Statistice can be: Settlement, Open Interest, Fixed Price or Cleared Volume
"sessionStatistics.instrumentID", # Unique ID given by the exchange used to Identify the contract
"sessionStatistics.price", # Price at which the statistic is referencing
"sessionStatistics.stateType", # Identifies Session Statisitc type: Opening Price, New High Bid or Low Ask, Session High or Low
"sessionStatistics.action",
"sessionStatistics.type", # Is this the opening price. 0=Daily Open Price, 5=Indicative Opening
"sessionStatistics.size",
"limitsBanding.highLimit", # the Limit High price for the current session
"limitsBanding.lowLimit", # the Limit Low price for the current session
"limitsBanding.maxVariation",
"clearingPrice.price",
"clearingPrice.quantity"
]
#--------------------------------------------------------
#--------------------------------------------------------
# Enums
#--------------------------------------------------------
class Trigger(IntEnum):
IcebergOrders = 1
TradeSweeps = 2
StopOrders = 4
Trades = 8
Summary = 16
class Bucket(IntEnum):
Summary = 1
class Session(IntEnum):
Current = 0
Previous = 1
class SideType(IntEnum):
Ask = 0
Bid = 1
class Aggressor(IntEnum):
NoAggressor = 0
Buy = 1
Sell = 2
class HaltReason(IntEnum):
NotSet = 255
GroupSchedule = 0
SurveillanceIntervention = 1
MarketEvent = 2
InstrumentActivation = 3
InstrumentExpiration = 4
Unknown = 5
RecoveryInProcess = 6
class SecurityType(IntEnum):
NotSet = 0
TradingHalt = 2
Close = 4
NewPriceIndication = 15
ReadyToTrade = 17
NotAvailableForTrading = 18
UnknownorInvalid = 20
PreOpen = 21
PreCross = 24
Cross = 25
PostClose = 26
NoChange = 103
# ICE
PreClose = 150
# Eurex
Restricted = 200
Freeze = 201
class SecurityEvent(IntEnum):
NoEvent = 0
NoCancel = 1
ResetStatistics = 4
ImpliedMatchingON = 5
ImpliedMatchingOFF = 6
class BookType(Enum):
NotSet = 'U'
Bid = 'B'
Ask = 'S'
ImpliedBid = 'b'
ImpliedAsk = 's'
BookReset = 'R'
class DailyStatisticsType(Enum):
SettlementPrice = '6'
ClearedVolume = 'B'
OpenInterest = 'C'
FixingPrice = 'W'
class SessionStatisticsType(IntEnum):
NotSet = 127
OpenPrice = 0
HighTrade = 1
LowTrade = 2
LastTrade = 3
HighestBid = 4
LowestAsk = 5
ClosePrice = 6
class BookAction(IntEnum):
NotSet = 255
New = 0
Change = 1
Delete = 2
DeleteThru = 3
DeleteFrom = 4
Overlay = 5
Replace = 6
class StateType(IntEnum):
NotSet = 255
DailyOpenPrice = 0
IndicativeOpeningPrice = 5
DailyClosePrice = 10
class PutOrCall(IntEnum):
NotSet = 255
Put = 0
Call = 1
class SettleType(IntEnum):
Final = 0x01
Actual = 0x02
Rounded = 0x04
Intraday = 0x08
ReservedBits = 0x10
NullValue = 0x80
class TransactionType(IntEnum):
NotSet = 255
TransactionStart = 0
TransactionEnd = 1
class EventIndicator(IntEnum):
NotSet = 0x0
LastOfType = 1
EndOfEvent = 0x80
class InvestigateStatus(IntEnum):
NotSet = 0x0
UnderInvestigation = 1
InvestigationCompleted = 2
class UnionID(IntEnum):
NotSet = 255
NotMapped = 250
TradeSummary = 0
TradeMatch = 1
VolumeUpdate = 2
BookLevel = 3
OrderBook = 4
SecurityStatus = 5
DailyStatistics = 6
SessionStatistics = 7
LimitsBanding = 8
ChannelReset = 9
TransactionMarker = 10
ClearingPrice = 12
#--------------------------------------------------------
# Predefined FID definitions
#--------------------------------------------------------
"""
const static std::string kFidsFull = R"xxxx(
{
"CodeFids":[
"header.instrumentID",
"header.sequence",
"header.time",
"header.channelSequence",
"header.instrumentSequence",
"header.unionID",
"header.eventIndicator",
"header.flag",
"header.baseExponent",
"transactionMarker.type",
"channelReset.type",
"tradeSummary.price",
"tradeSummary.quantity",
"tradeSummary.matches",
"tradeSummary.aggressor",
"tradeSummary.isImplied",
"tradeSummary.isSnapshot",
"tradeSummary.volume",
"tradeMatch.isAggressor",
"tradeMatch.number",
"tradeMatch.price",
"tradeMatch.orderID",
"tradeMatch.auxillaryID",
"tradeMatch.quantity",
"tradeMatch.flags",
"volumeUpdate.volume",
"volumeUpdate.vwap",
"bookLevel.price",
"bookLevel.quantity",
"bookLevel.orders",
"bookLevel.impliedQuantity",
"bookLevel.impliedOrders",
"bookLevel.level",
"bookLevel.action",
"bookLevel.type",
"bookLevel.isEndEvent",
"orderBook.orderID",
"orderBook.auxilaryID",
"orderBook.priorityID",
"orderBook.price",
"orderBook.previousID",
"orderBook.quantity",
"orderBook.action",
"orderBook.type",
"orderBook.isSnapshot",
"securityStatus.group",
"securityStatus.asset",
"securityStatus.sessionDate",
"securityStatus.type",
"securityStatus.haltReason",
"securityStatus.event",
"dailyStatistics.instrumentID",
"dailyStatistics.price",
"dailyStatistics.size",
"dailyStatistics.sessionDate",
"dailyStatistics.settleType",
"dailyStatistics.type",
"sessionStatistics.instrumentID",
"sessionStatistics.price",
"sessionStatistics.stateType",
"sessionStatistics.action",
"sessionStatistics.type",
"sessionStatistics.size",
"limitsBanding.highLimit",
"limitsBanding.lowLimit",
"limitsBanding.maxVariation",
"clearingPrice.price",
"clearingPrice.quantity"
]
}
)xxxx";
const static std::string kFidsNorm = R"xxxx(
{
"CodeFids":[
"header.instrumentID",
"header.sequence",
"header.time",
"header.channelSequence",
"header.instrumentSequence",
"header.unionID",
"header.eventIndicator",
"header.flag",
"header.baseExponent",
"transactionMarker.type",
"channelReset.type",
"tradeSummary.price",
"tradeSummary.quantity",
"tradeSummary.matches",
"tradeSummary.aggressor",
"tradeSummary.isImplied",
"tradeSummary.isSnapshot",
"tradeSummary.volume",
"tradeMatch.isAggressor",
"tradeMatch.number",
"tradeMatch.price",
"tradeMatch.orderID",
"tradeMatch.auxillaryID",
"tradeMatch.quantity",
"tradeMatch.flags",
"volumeUpdate.volume",
"volumeUpdate.vwap",
"orderBook.orderID",
"orderBook.auxilaryID",
"orderBook.priorityID",
"orderBook.price",
"orderBook.previousID",
"orderBook.quantity",
"orderBook.action",
"orderBook.type",
"orderBook.isSnapshot",
"securityStatus.group",
"securityStatus.asset",
"securityStatus.sessionDate",
"securityStatus.type",
"securityStatus.haltReason",
"securityStatus.event",
"dailyStatistics.instrumentID",
"dailyStatistics.price",
"dailyStatistics.size",
"dailyStatistics.sessionDate",
"dailyStatistics.settleType",
"dailyStatistics.type",
"sessionStatistics.instrumentID",
"sessionStatistics.price",
"sessionStatistics.stateType",
"sessionStatistics.action",
"sessionStatistics.type",
"sessionStatistics.size",
"limitsBanding.highLimit",
"limitsBanding.lowLimit",
"limitsBanding.maxVariation",
"clearingPrice.price",
"clearingPrice.quantity"
]
}
)xxxx";
const static std::string kFidsTrds = R"xxxx(
{
"CodeFids":[
"header.instrumentID",
"header.sequence",
"header.time",
"header.unionID",
"tradeSummary.price",
"tradeSummary.quantity",
"tradeSummary.matches",
"tradeSummary.aggressor",
"tradeSummary.isImplied",
"tradeSummary.isSnapshot",
"tradeSummary.volume"
]
}
)xxxx";
"""
#--------------------------------------------------------
# c++ Structs Reference
#--------------------------------------------------------
"""
struct TransactionMarker
{
uint8_t type;
};
struct ChannelReset
{
uint8_t type;
};
struct TradeSummary
{
double price;
int32_t quantity;
uint32_t matches;
uint8_t aggressor;
bool isImplied;
bool isSnapshot;
uint32_t volume; // sometimes trades contain volume;
};
struct TradeMatch
{
bool isAggressor;
uint16_t number;
double price;
uint64_t orderID;
uint64_t auxillaryID; // ice secondary, originating order
int32_t quantity;
int32_t flags;
};
struct VolumeUpdate
{
uint32_t volume;
double vwap; // ice stat metric
};
struct BookLevel
{
double price;
int32_t quantity;
int32_t orders;
int32_t impliedQuantity;
int32_t impliedOrders;
uint8_t level;
uint8_t action;
uint8_t type;
bool isEndEvent;
};
struct OrderBook
{
uint64_t orderID;
uint64_t auxilaryID; // needed for ice, eurex
uint64_t priorityID;
double price;
uint64_t previousID; // eurex only
int32_t quantity;
uint8_t action;
uint8_t type;
bool isSnapshot;
};
struct SecurityStatus
{
char group[10];
char asset[10];
uint16_t sessionDate;
uint8_t type;
uint8_t haltReason;
uint8_t event;
};
struct DailyStatistics
{
uint32_t instrumentID;
double price;
int32_t size;
uint16_t sessionDate; // Reference for the date it occured
uint8_t settleType;
uint8_t type;
};
struct LimitsBanding
{
double highLimit;
double lowLimit;
double maxVariation;
};
struct SessionStatistics
{
uint32_t instrumentID;
double price;
uint8_t stateType;
uint8_t action;
uint8_t type;
int32_t size;
};
struct ClearingPrice // eurex
{
double price;
uint32_t quantity;
};
struct Header
{
uint32_t instrumentID = 0;
uint32_t sequence = 0;
uint64_t time = 0;
uint32_t channelSequence = 0;
uint32_t instrumentSequence = 0;
uint8_t unionID = 0;
uint8_t eventIndicator = 0;
bool flag = false;
uint8_t baseExponent = 0;
};
struct Event
{
Header header;
TradeSummary tradeSummary;
TradeMatch tradeMatch;
VolumeUpdate volumeUpdate;
BookLevel bookLevel;
OrderBook orderBook;
SecurityStatus securityStatus;
DailyStatistics dailyStatistics;
LimitsBanding limitsBanding;
SessionStatistics sessionStatistics;
ChannelReset channelReset;
TransactionMarker transactionMarker;
ClearingPrice clearingPrice;
};
"""