API  Version 2.0.1
Low-Latency HFT API
 All Classes Functions Variables
sgMktData.h
1 #ifndef SG_COMMON_MKDATAH
2 #define SG_COMMON_MKDATAH
3 #include <cmdDefines.h>
4 #include <apiStructs.h>
5 //#include <volumeProfile/defines.h>
6 #include <sharedCommands.h>
7 #include <boost/date_time/gregorian/gregorian.hpp>
8 #include <boost/date_time/posix_time/posix_time.hpp>
9 #include <queue>
10 
11 namespace TBTDATA {
12  struct SymbolData ;
13 }
14 
15 
16 namespace API2 { namespace COMMON {
17 
18  class OhlcQuoteImpl;
19 
23  class OhlcQuote{
24 
28  OhlcQuoteImpl *_impl;
29 
30  public:
31 
36  OhlcQuote(UNSIGNED_LONG symbolId);
37 
42  DATA_TYPES::PRICE getOpenPrice();
43 
48  DATA_TYPES::PRICE getHighPrice();
49 
54  DATA_TYPES::PRICE getLowPrice();
55 
60  DATA_TYPES::PRICE getClosePrice();
61 
66  DATA_TYPES::PRICE getAverageOhlcPrice();
67 
72  time_t getLastProcessTimestamp();
73 
79  bool checkForModification(time_t lastProcessTimeStamp);
80 
81 
82  };
83 
87  struct TradeTick{
88 
89  CREATE_FIELD(DATA_TYPES::PRICE, Price);
90  CREATE_FIELD(DATA_TYPES::QTY, Qty);
91  CREATE_FIELD(UNSIGNED_LONG, Timestamp);
92 
93  public:
94 
102  const DATA_TYPES::PRICE &price,
103  const DATA_TYPES::QTY &qty,
104  const UNSIGNED_LONG &timestamp
105  )
106  :
107  _Price(price),
108  _Qty(qty),
109  _Timestamp(timestamp)
110  {}
111 
112  };
113 
114 
118  class MktData
119  {
120 
124  DATA_TYPES::SYMBOL_ID _symbolId;
125 
129  CREATE_FIELD( COMMON::MarketDataWrapper, Quote);
130 
131 
135  CREATE_FIELD( bool, IsSnapShot);
136 
140  CREATE_FIELD( int, multiplier);
141 
145  TBTDATA::SymbolData *_tbtData;
146 
147  CREATE_FIELD(std::queue<TradeTick>, TradeTicks);
148 
152  volatile unsigned long _LatestIndexCounter;
153 
157  int _LatestTickIndex;
158 
159  private:
166  DATA_TYPES::PRICE getPrice(const COMMON::MarketDepthWrapper &wrapper,
167  const DATA_TYPES::OrderMode & mode);
168 
175  DATA_TYPES::QTY getQty(const COMMON::MarketDepthWrapper &wrapper,
176  const DATA_TYPES::OrderMode & mode);
181  bool updateTbt();
182 
183 
188  bool updateMcl();
189  public:
194  DATA_TYPES::PRICE getOpenPrice();
195 
200  DATA_TYPES::PRICE getHighPrice();
201 
206  DATA_TYPES::PRICE getLowPrice();
207 
212  DATA_TYPES::PRICE getClosePrice();
213 
218  DATA_TYPES::VOLUME getVolume();
219 
224  DATA_TYPES::QTY getLastTradeQty();
225 
230  DATA_TYPES::PRICE getLastTradePrice();
231 
238  DATA_TYPES::PRICE getPrice(size_t position, const DATA_TYPES::OrderMode & mode);
239 
246  DATA_TYPES::QTY getQty(size_t position, const DATA_TYPES::OrderMode & mode);
247 
253  DATA_TYPES::PRICE getBidPrice(size_t pos);
254 
260  DATA_TYPES::QTY getBidQty(size_t pos);
261 
267  DATA_TYPES::PRICE getAskPrice(size_t pos);
268 
274  DATA_TYPES::QTY getAskQty(size_t pos);
275 
282  bool subscribe(DATA_TYPES::SYMBOL_ID symbol,bool isSnapshot);
283 
287  void unsubscribe();
288 
294  MktData(DATA_TYPES::SYMBOL_ID symbolId,bool isSnapshot = true);
295 
296  //MktData();
297  ~MktData();
298 
303  bool update();
304 
309  bool updateTbtTradeTicks();
310 
311 
312 #if 0
313 
318  bool checkUpdateStatus(time_t lastProcessTime);
319 
325  bool checkUpdateStatus(boost::posix_time::ptime lastProcessTime);
326 #endif
327 
330  void operator ()();
331 
335  void dump();
336 
337  };
338  }
339  }
340 #endif
DATA_TYPES::PRICE getLowPrice()
getLowPrice
bool checkForModification(time_t lastProcessTimeStamp)
checkForModification
void operator()()
operator ()
DATA_TYPES::QTY getLastTradeQty()
getLastTradeQty
DATA_TYPES::PRICE getBidPrice(size_t pos)
getBidPrice
DATA_TYPES::QTY getBidQty(size_t pos)
getBidQty
DATA_TYPES::QTY getAskQty(size_t pos)
getAskQty
void unsubscribe()
unsubscribe
DATA_TYPES::PRICE getAverageOhlcPrice()
getAverageOhlcPrice
DATA_TYPES::PRICE getHighPrice()
getHighPrice
The MktData class, The wrapper class for getting Market Feed for both Snapshot and Tick-By-Tick...
Definition: sgMktData.h:118
The TradeTick struct.
Definition: sgMktData.h:87
DATA_TYPES::PRICE getOpenPrice()
getOpenPrice
MktData(DATA_TYPES::SYMBOL_ID symbolId, bool isSnapshot=true)
MktData.
DATA_TYPES::PRICE getLastTradePrice()
getLastTradePrice
DATA_TYPES::PRICE getClosePrice()
getClosePrice
time_t getLastProcessTimestamp()
getLastProcessTimestamp
OhlcQuote(UNSIGNED_LONG symbolId)
OhlcQuote.
The MarketDepthWrapper class will store Bid Ask Price at particular level.
Definition: apiStructs.h:13
bool updateTbtTradeTicks()
updateTbtTradeTicks
DATA_TYPES::PRICE getHighPrice()
getHighPrice
DATA_TYPES::PRICE getLowPrice()
getLowPrice
The OhlcQuote class.
Definition: sgMktData.h:23
DATA_TYPES::PRICE getClosePrice()
getClosePrice
DATA_TYPES::PRICE getOpenPrice()
getOpenPrice
DATA_TYPES::VOLUME getVolume()
getVolume
DATA_TYPES::PRICE getAskPrice(size_t pos)
getAskPrice
bool subscribe(DATA_TYPES::SYMBOL_ID symbol, bool isSnapshot)
subscribe
TradeTick(const DATA_TYPES::PRICE &price, const DATA_TYPES::QTY &qty, const UNSIGNED_LONG &timestamp)
TradeTick.
Definition: sgMktData.h:101
The MarketDataWrapper class will contain the Snapshot/TBT Market Data.
Definition: apiStructs.h:47
bool update()
update