DMA Embedded Python Engine  Build 21
 All Classes Files Functions Variables Enumerations Enumerator Groups Pages
pyEngine.h
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * pyEngine.h
4 *
5 * REVISION HISTORY:
6 * 15 DEC 2019 jcs Build 20: Created
7 * 12 FEB 2020 jcs Build 21: PrcLvl._OrderID
8 * 24 MAR 2021 jcs Build 21: OnStart()
9 * 18 OCT 2021 jcs Build xx: Pause / Resume
10 * 23 JAN 2022 jcs Cleaned up
11 *
12 * (c) 1994-2022, Gatea Ltd.
13 ******************************************************************************/
14 #ifndef __PYDMA_ENGINE_FCN
15 #define __PYDMA_ENGINE_FCN
16 
63 typedef enum {
70 } BookType;
71 
76 typedef enum {
78  act_add = 0,
80  act_mod = 1,
82  act_del = 2,
87 } Action;
88 
116 typedef struct {
118  int _Price;
120  int _Size;
122  int _NumOrds;
124  int _Time;
126  int _Level;
128  long _OrdID;
129 } PriceLevel;
130 
145 typedef struct {
147  long _OrdID;
149  int _Size;
151  int _Time;
152 } Order;
153 
170 typedef struct {
172  int _SecID;
174  int _NumUpd;
179 } BookStats;
180 
181 
195 typedef struct {
199  bool _bBuy;
201  bool _bImplied;
202 } UpdAction;
203 
210 class DMA
211 {
212 public:
213 
225 string version();
226 
242 PyList getStats( Context cxt );
243 
261 bool ioctl( Context cxt, string cmd, int val );
262 
270 string getError();
271 
289 void OnEngineLoad( Context cxt );
290 
299 void OnStart( Context cxt );
300 
308 void OnEngineUnload( Context cxt );
309 
328 void OnInitialize( Context cxt, int sid );
329 
336 void OnQuote( Context cxt, int sid );
337 
344 void OnTrade( Context cxt, int sid );
345 
359 void log( string ty, string msg );
360 
366 void logRaw( string msg );
367 
392 void registerTickers( Context cxt, list tickers );
393 
394 #ifndef DOXYGEN_OMIT
395 
411 void registerTickerByRegEx( Context cxt, string regEx );
412 
413 #endif // DOXYGEN_OMIT
414 
430 double wallTime( Context cxt );
431 
438 double replayTime( Context cxt );
439 
446 int hour( double tm );
447 
454 int minute( double tm );
455 
462 int second( double tm );
463 
470 int seconds_Today( double tm );
471 
478 string dateTime( double tm );
479 
480 
502 PyList getUpdate( Context cxt );
516 PyList getTrade( Context cxt );
517 
524 string getSecurityName( Context cxt );
525 
532 string getSecurityID( Context cxt );
533 
549 PyList getBook( Context cxt, int depth, BookType bkTy );
550 
567 PyList getOrders( Context cxt, bool buy, int level, BookType bkTy );
568 
593 PyList lvc_getBook( Context cxt, int sid, int depth, BookType bkTy );
594 
611 PyList lvc_getBook( Context cxt, const char *tkr, int depth, BookType bkTy );
612 
629 PyList lvc_getOrders( Context cxt,
630  int sid,
631  bool buy,
632  int level,
633  BookType bkTy );
634 
651 PyList lvc_getOrders( Context cxt,
652  const char *tkr,
653  bool buy,
654  int level,
655  BookType bkTy );
656 
671 PyList pause( Context cxt );
672 
679 PyList resume( Context cxt );
680 
683 }; // class DMA
684 
685 #endif // __PYDMA_ENGINE_FCN
PyList lvc_getOrders(Context cxt, int sid, bool buy, int level, BookType bkTy)
Return all Orders from specified Price Level from Security by ID.
bool _bImplied
True if Update to Implied Book; False for Native.
Definition: pyEngine.h:201
Definition: pyEngine.h:195
Definition: pyEngine.h:116
long _OrdID
Order ID (If order-based feed)
Definition: pyEngine.h:128
int minute(double tm)
Return minute, not using localtime()
void registerTickers(Context cxt, list tickers)
Register a Python list, CSV list or single ticker to receive updates.
int _Price
Price Level.
Definition: pyEngine.h:118
bool ioctl(Context cxt, string cmd, int val)
Configure server.
Definition: pyEngine.h:170
Implied Book.
Definition: pyEngine.h:67
void logRaw(string msg)
Log raw message.
int _Time
Last Update Time in Nanos since Jan 1, 1970.
Definition: pyEngine.h:124
double replayTime(Context cxt)
Return replay (tape) time.
string dateTime(double tm)
Return string-ified Unix time as YYYY-MM-DD HH:MM:SS.uuuuuu.
Action
Update Action : Add, Delete, etc.
Definition: pyEngine.h:76
PyList getBook(Context cxt, int depth, BookType bkTy)
Return Book contents from current Security.
int _SecID
Security ID.
Definition: pyEngine.h:172
PyList getUpdate(Context cxt)
Return the current real-time update message.
void log(string ty, string msg)
Log INFO, WARNING or ERROR message.
Add Price Level to Book.
Definition: pyEngine.h:78
int seconds_Today(double tm)
Return number of seconds today, not using localtime()
int _NumOrds
Number of Orders.
Definition: pyEngine.h:122
string getSecurityName(Context cxt)
Return name of Security receiving the real-time update.
int hour(double tm)
Return hour not using localtime()
PyList getOrders(Context cxt, bool buy, int level, BookType bkTy)
Return all Orders from specified Price Level from current Security.
Delete Price Level from Book.
Definition: pyEngine.h:82
Delete ALL Price Levels in Book above this one.
Definition: pyEngine.h:86
double wallTime(Context cxt)
Return local (wall) time.
void OnStart(Context cxt)
Called after all records have been OnInitialize()'ed and data is ready to flow.
int _NumUpdAsk
Num Updates to Book - ASK Side.
Definition: pyEngine.h:178
PyList getStats(Context cxt)
Return Engine Stats.
void OnEngineUnload(Context cxt)
Called when Engine is unloaded.
BookType
Book Type - Native, Implied, Combined.
Definition: pyEngine.h:63
string getSecurityID(Context cxt)
Return unique ID of Security receiving the real-time update.
long _OrdID
Order ID (If order-based feed)
Definition: pyEngine.h:147
void OnEngineLoad(Context cxt)
Called when Engine is loaded.
int _NumUpdBid
Num Updates to Book - BID Side.
Definition: pyEngine.h:176
Action _Action
Action Type.
Definition: pyEngine.h:197
int _Size
Total Quantity at Level.
Definition: pyEngine.h:120
PyList resume(Context cxt)
Resume pumping of data.
PyList pause(Context cxt)
Pause pumping of data.
int second(double tm)
Return second, not using localtime()
int _Size
Total Quantity at Level.
Definition: pyEngine.h:149
void OnInitialize(Context cxt, int sid)
Called when a registered Security is created off tape.
Combined Book.
Definition: pyEngine.h:69
int _NumUpd
Num Updates to Book.
Definition: pyEngine.h:174
Native Book.
Definition: pyEngine.h:65
Modify Price Level in Book.
Definition: pyEngine.h:80
Delete ALL Price Levels in Book.
Definition: pyEngine.h:84
The Embedded DMA Python Interpreter.
Definition: pyEngine.h:210
void OnTrade(Context cxt, int sid)
Called when a registered Security trades.
string getError()
Return Python errno if set.
string version()
Return server version.
PyList getTrade(Context cxt)
Return the current real-time Trade message.
int _Level
Level Number; Top = 0.
Definition: pyEngine.h:126
bool _bBuy
True if Update to BID; False for ASK.
Definition: pyEngine.h:199
void OnQuote(Context cxt, int sid)
Called when a real-time update has been processed.
int _Time
Last Update Time in Nanos since Jan 1, 1970.
Definition: pyEngine.h:151
Definition: pyEngine.h:145
PyList lvc_getBook(Context cxt, int sid, int depth, BookType bkTy)
Return Book contents from any Security by ID.