uTrade Frontend Algo API  Version 1.0.0.0
μTrade HFT
sharedStrutures.h
1 #ifndef SHAREDSTRUTURES_H
2 #define SHAREDSTRUTURES_H
3 #include "sharedEnums.h"
4 #if IS_QT4_VERSION
5 #include <QtGui>
6 #else
7 #include <QtWidgets>
8 #endif
9 #ifndef MUTRADE_CLIENT
10 #include "../../api2/api_includes/apiConstants.h"
11 #include "../../api2/api_includes/apiDataTypes.h"
12 #include "../../api2/api_includes/sharedResponse.h"
13 #define ResponseCategory_ORDER_CONFIRMATION 2
14 #else
15 #include "../../api2/headers/apiConstants.h"
16 #endif
17 #define STRATEGY_TYPE_MAX 16
18 typedef struct SymbolPanelElements
19 {
20  QComboBox *orderMode;
21  QComboBox *market;
22  QComboBox *source;
23  QComboBox *instrument;
24  QVBoxLayout *symbolLayout;
25  QComboBox *expiry;
26  QComboBox *optionType;
27  QComboBox *strikePrice;
28  QLineEdit *lotSize;
29  QComboBox *series;
30  QRadioButton *radioButtonClient;
31  QRadioButton *radioButtonPro;
32  QComboBox *clientProCombo;
33  QLineEdit *pcCode;
34  QComboBox *accountDetailCombo;
35 
36  SymbolPanelElements(QComboBox *ordMode,
37  QComboBox *src,
38  QComboBox *mkt,
39  QComboBox *inst,
40  QVBoxLayout *symbol,
41  QComboBox *groupName,
42  QComboBox *exp,
43  QComboBox *optType,
44  QComboBox *stkPrice,
45  QLineEdit *lot,
46  QRadioButton *radioBtnClient,
47  QRadioButton *radioBtnPro,
48  QLineEdit *pcode,
49  QComboBox *actDetailCombo)
50  :orderMode(ordMode),
51  market(mkt),
52  source(src),
53  instrument(inst),
54  symbolLayout(symbol),
55  expiry(exp),
56  optionType(optType),
57  strikePrice(stkPrice),
58  lotSize(lot),
59  series(groupName),
60  radioButtonClient(radioBtnClient),
61  radioButtonPro(radioBtnPro),
62  clientProCombo(NULL),
63  pcCode(pcode),
64  accountDetailCombo(actDetailCombo)
65  {
66 
67  }
68 
69  SymbolPanelElements(QComboBox *ordMode,
70  QComboBox *src,
71  QComboBox *mkt,
72  QComboBox *inst,
73  QVBoxLayout *symbol,
74  QComboBox *groupName,
75  QComboBox *exp,
76  QComboBox *optType,
77  QComboBox *stkPrice,
78  QLineEdit *lot,
79  QComboBox *clientProComboBox,
80  QLineEdit *pcode,
81  QComboBox *actDetailCombo)
82  :orderMode(ordMode),
83  market(mkt),
84  source(src),
85  instrument(inst),
86  symbolLayout(symbol),
87  expiry(exp),
88  optionType(optType),
89  strikePrice(stkPrice),
90  lotSize(lot),
91  series(groupName),
92  radioButtonClient(NULL),
93  radioButtonPro(NULL),
94  clientProCombo(clientProComboBox),
95  pcCode(pcode),
96  accountDetailCombo(actDetailCombo)
97  {
98 
99  }
100 
102 
103 
104 
106 {
107 public:
108  BaseSymbolIds()
109  {
110  symbolId = 0 ;
111  lotSize = 1 ;
112  orderMode = API2::DllCMD::OrderMode_MAX;
113  quantity = 0;
114  strategyType=STRATEGY_TYPE_MAX;
115  }
116 
117  BaseSymbolIds(qlonglong tempSymbolId,
118  short tempOrderMode,
119  qlonglong tempQuantity,
120  short tempStrategyType)
121  :symbolId(tempSymbolId),
122  orderMode(tempOrderMode),
123  quantity(tempQuantity),
124  strategyType(tempStrategyType)
125  {
126  }
127  virtual ~BaseSymbolIds() {}
128  int lotSize;
129  qlonglong symbolId;
130  qlonglong underlyingSymbolID;
131  short orderMode;
132  qlonglong quantity;
133  short strategyType;
134  bool contains(qlonglong symId)
135  {
136  return symId == symbolId ? true : false;
137  }
138 };
139 
140 
141 
143 {
144  int adminTokenIdIndex;
145  int strategyIdIndex;
146  int strategyLegIndex;
147  int stateIndex;
148  int strategyCommentIndex;
149  int portFolioIdIndex;
150  int portFolioNameIndex;
151  int sidQtyLeg1Index;
152  int sidQtyLeg2Index;
153  int sidQtyLeg3Index;
154  int sidQtyLeg4Index;
155  int orderMode;
156  int symbolIdLeg1;
157  int strategyType;
158  int futurePrice;
159  int dmDeltaPercentage;
160  int remQtyLeg1;
161  int spreadType;
162 
163 
164  ColumnIndex():adminTokenIdIndex(-1),
165  strategyIdIndex(-1),stateIndex(-1),
166  strategyCommentIndex(-1),portFolioIdIndex(-1),
167  portFolioNameIndex(-1),orderMode(-1),symbolIdLeg1(-1),
168  futurePrice(-1),dmDeltaPercentage(-1),spreadType(-1),strategyLegIndex(-1)
169 
170  {
171 
172  }
173 
174 };
175 
176 //Spread upadation
178 {
179  bool isUpdated;
180  QString hitSpread;
181 
182  SpreadDetails()
183  :isUpdated(true),
184  hitSpread("")
185  {
186 
187  }
188 
189  void updateSpread(SpreadDetails &detail)
190  {
191  if(hitSpread!=detail.hitSpread)
192  {
193  isUpdated = true;
194  hitSpread==detail.hitSpread;
195  }
196  }
197 
198 };
199 
200 namespace API2
201 {
202 typedef struct SymbolDetail
203 {
204  SymbolDetail():market(""), source(""), securityId(0), symbol("") , scripName(""), groupName(""),
205  instrType("C") , maturityDay(0), maturityYearMon(0),
206  optType(""), optAttribute(""), strikePrice(0), symbolType(""),
207  lotSize(1), tickSize(1), precision(2), multiplier(100), flag(false), symbolId(0),
208  contractType(""), maturityDay2(0), maturityYearMon2(0), securityId1(0), securityId2(0), tradeValue(1.00),tradeUnit(""),upperCktLimit(0),lowerCktLimit(0),
209  symbolBaseCurrency(""){}
210 
211 
212  QString market;
213  short exchangeId;
214  QString source;
215  short sourceId;
216  qlonglong securityId;
217  qlonglong symbolId;
218  QString symbol;
219  QString scripName;
220  QString groupName;
221  QString instrType;
222  int maturityDay;
223  int maturityYearMon;
224  QString optType;
225  QString optAttribute;
226  qlonglong strikePrice;
227  QString strikePriceStr;
228  QString symbolType;
229  int lotSize;
230  int tickSize;
231  int precision;
232  double multiplier;
233  bool flag;
234  QString contractType;
235  int maturityDay2;
236  int maturityYearMon2;
237  qlonglong securityId1;
238  qlonglong securityId2;
239  double tradeValue;
240  QString tradeUnit;
241  QString expiryStr;
242  QString ISIN;
243  QString symbolBaseCurrency;
244  QString scripGroup;
245  qlonglong lowerCktLimit;
246  qlonglong upperCktLimit;
247 
248  bool operator<(const SymbolDetail & r) const
249  {
250  if(securityId < r.securityId)
251  return true;
252  else if(securityId > r.securityId)
253  return false;
254  else
255  {
256  return market < r.market;
257  }
258  }
259 
260  bool operator==(const SymbolDetail & r) const
261  {
262  return (securityId == r.securityId && market == r.market);
263  }
264 
265 }SymbolDetail;
266 
267 typedef struct TradeWiseTrackerData
268 {
269  TradeWiseTrackerData():orderSeqNumber(0), strategyId(0), twoLeg3LegStrategyType(-1),
270  convRevStrategyType(-1), symbolId(0),maxPrecision(-1), lotSize(1), orderQty(1), minSpread(0), time(0),
271  minQty(1), isSquareOff(false), strikePrice(0),strikeDiff(0),execSpread(0),isSpreadInBps(false),
272  dividend(0.00),orderModeBps(API2::DllCMD::OrderMode_MAX),strategyName(""),
273  isSpreadAlreadyCalculated(false),
274  tradingCost(0),
275  execSprdExcludingCost(0)
276  {
277  portFolio.clear();
278  orderModeList.clear();
279  avgPriceList.clear();
280  OrderQtyRatio.clear();
281  }
282 
283  QString portFolio;
284  QString strategyName;
285  qlonglong orderSeqNumber;
286  qlonglong strategyId;
287  short twoLeg3LegStrategyType;
288  short convRevStrategyType;
289  qlonglong symbolId;
290  QList<API2::DllCMD::OrderMode> orderModeList;
291  int lotSize;
292  int orderQty;
293  qlonglong minSpread;
294  QList<double> avgPriceList;
295  qlonglong time;
296  int minQty;
297  QString OrderQtyRatio;
298  bool isSquareOff;
299  qlonglong strikePrice;
300  qlonglong strikeDiff;
301  qlonglong execSpread;
302  qlonglong tradingCost;
303  qlonglong execSprdExcludingCost;
304  bool isSpreadInBps;
305  double dividend;
306  API2::DllCMD::OrderMode orderModeBps;
307  short maxPrecision;
308  bool isSpreadAlreadyCalculated;
309  QString description;
311 
313 {
314  apiOrderBookParams(): cancelOrModify(0),orderPrice(0),orderId("") {}
315  char cancelOrModify;
316  qlonglong orderQty;
317  qlonglong orderPrice;
318  std::string orderId;
319 };
320 }
321 
322 #ifndef MUTRADE_CLIENT
323 namespace RSP
324 {
325 class OrderConfirmation : public API2::OrderConfirmation
326 {
327  public:
329 
331  OrderConfirmation(const char* buf);
333  API2::DATA_TYPES::CLORDER_ID &clientOrderId,
334  API2::DATA_TYPES::SYMBOL_ID &symbolId,
335  API2::DATA_TYPES::STRATEGY_ID &strategyId,
336  API2::DATA_TYPES::CLIENT_ID &clientId,
337  API2::DATA_TYPES::OrderStatus &orderStatus,
338  API2::DATA_TYPES::OrderMode &orderMode,
339  API2::DATA_TYPES::OrderType &orderType,
340  API2::DATA_TYPES::QTY &orderQty,
341  API2::DATA_TYPES::PRICE &orderPrice,
342  API2::DATA_TYPES::CLORDER_ID &origClOrdId,
343  const API2::DATA_TYPES::PRICE &stopPrice,
344  const API2::DATA_TYPES::ProductType &productType,
345  const API2::DATA_TYPES::PlatformType &platformType,
346  const API2::ExchangeAdapterDetails &exchangeAdapterDetails);
347  void initialize();
348 
349  UNSIGNED_LONG getConfirmationTimeSeconds() const { return _confirmationTimeSeconds; }
350  UNSIGNED_LONG getConfirmationTimeMicroSeconds() const { return _confirmationTimeMicroSeconds; }
351  UNSIGNED_CHARACTER getIsOffline() const {return _isOffline;}
352  UNSIGNED_LONG getSequenceNumber() const {return _sequenceNumber;}
353  const char* getTradeId() const {return getTradeIdCharPtr();}
354  const char* getExchangeOrderId() const {return getExchangeOrderIdCharPtr();}
355  UNSIGNED_INTEGER getReasonText() const {return _reasonText;}
356  UNSIGNED_CHARACTER getUnknownOrder() const{return _unknownOrder;}
357 
358  void setConfirmationTimeSeconds(UNSIGNED_LONG seconds) ;
359  void setConfirmationTimeMicroSeconds(UNSIGNED_LONG microSeconds) ;
360  void setIsOffline(UNSIGNED_CHARACTER isOffline);
361  void setSequenceNumber(UNSIGNED_LONG sequenceNumber);
362  void setReasonText(UNSIGNED_INTEGER reasonText);
363  void setUnknownOrder(UNSIGNED_CHARACTER unknownOrder);
364  void dumpCSV(std::ofstream &csvFile);
365  void dump() const;
366  std::string getString() const;
367  bool isVersionValid(){return true;}
368 #ifndef FRONTEND_COMPILATION
369  void dumpCSVTrades(std::ofstream &csvFile,
370  SG::SymbolStaticData &symbolData,
371  bool notFound,
372  int custFirm,
373  const std::string& accountId,
374  const std::string& settler,
375  const std::string& branchId,
376  const std::string& userId
377  );
378 
379  void dumpCSVDetailed(std::ofstream &csvFile,
380  SG::SymbolStaticData &symbolData,
381  bool notFound,
382  int custFirm,
383  const std::string& accountId,
384  const std::string& settler,
385  const std::string& branchId,
386  const std::string& userId
387  );
388 #endif
389 
390  std::string convertEpochToString(time_t rawtime);
391  std::string convertEpochToDate(time_t rawtime);
392  std::string convertEpochToTime(time_t rawtime);
393  int serialize(char* buf, short rc = ResponseCategory_ORDER_CONFIRMATION );
394  std::string getMonthFromNumber(int number);
395 
396  private:
397  void serializeAll(char* buf, int &bytes);
398  void serializeConfirmAndReplace(char* buf, int &bytes);
399  void serializeTrade(char* buf, int &bytes);
400  void serializeTradeModify(char* buf, int &bytes);
401  void serializeCancelAndCancelOfIoc(char* buf, int &bytes);
402  void serializeRejected(char* buf, int &bytes);
403  void serializeMktToLimitAndTriggered(char* buf, int &bytes);
404  void serializeRelay(char* buf, int &bytes);
405 
406  void deSerializeAll(const char* buf, int &offset);
407  void deSerializeConfirmAndReplace(const char* buf, int &offset);
408  void deSerializeTrade(const char* buf, int &offset);
409  void deSerializeTradeModify(const char* buf, int &offset);
410  void deSerializeCancelAndCancelOfIoc(const char* buf, int &offset);
411  void deSerializeRejected(const char* buf, int &offset);
412  void deSerializeMktToLimitAndTriggered(const char* buf, int &offset);
413  void deSerializeRelay(const char* buf, int &offset);
414 
415 
416  UNSIGNED_LONG _confirmationTimeSeconds;
417  UNSIGNED_LONG _confirmationTimeMicroSeconds;
418  UNSIGNED_CHARACTER _isOffline;
419  UNSIGNED_LONG _sequenceNumber;
420  UNSIGNED_INTEGER _reasonText;
421  UNSIGNED_CHARACTER _unknownOrder;
422 
423  CREATE_FIELD(UNSIGNED_CHARACTER,GiveupFlag);
424 
425 #ifdef FRONTEND_COMPILATION
426  CREATE_FIELD(UNSIGNED_LONG,TotalFillQuantity);
427  //CREATE_FIELD(UNSIGNED_CHARACTER,OrderType);
428 #endif
429 
430 #ifndef FRONTEND_COMPILATION
431  CREATE_FIELD(SIGNED_LONG, Price1);
432  CREATE_FIELD(SIGNED_LONG, Price2);
433 #endif
434 
435 #ifdef FRONTEND_COMPILATION
436 #ifdef ENABLE_DMS
437  public:
438  OrderConfirmation(const UT::PROTO::Order& protoOrder) ;
439 #endif
440 #endif
441 
442 };
443 }
444 #endif
445 #endif // SHAREDSTRUTURES_H
Definition: sharedStrutures.h:142
Definition: sharedStrutures.h:267
Definition: sharedStrutures.h:312
Definition: sharedStrutures.h:177
Definition: sharedStrutures.h:18
Definition: sharedStrutures.h:105
Definition: sharedStrutures.h:202
Definition: sharedStrutures.h:325