Libannhoo_md_sdk  1.6.1
for index, tick(entrust and trade), and snapshot with solar flare
 All Classes Namespaces Files Functions Variables Pages
ah_md_spi_inl.cpp
Go to the documentation of this file.
1 
7 #include "ah_md_spi_inl.h"
8 
9 #include <arpa/inet.h>
10 #include <endian.h>
11 #include <fcntl.h>
12 #include <sys/stat.h>
13 #include <sys/time.h>
14 #include <sys/types.h>
15 #include <unistd.h>
16 
17 #include <iostream>
18 #define TEST_VERSION
19 
20 // #include"StrLiteral.h"
21 
22 namespace annhoo {
23 #define CSV_TABLE \
24  X(CSV_INDEX, \
25  "MsgType,ExchangeID,MDStreamID(SZ),OrigTime/TradeTime,ChannelNo(SZ),TradingPhaseCode(SZ),SecurityID,LastIndex,PreCloseIndex,OpenIndex," \
26  "HighIndex,LowIndex,CloseIndex,TotalVolumeTrade,TotalValueTrade,NumTrades\n") \
27  X(CSV_ENTRUST, \
28  "MsgType,MsgLength,ExchangeID,MsgID,MDStreamID,ChannelNo,ApplSeqNum,SecurityID,Price,OrderQty,Side," \
29  "TransactTime,OrdType\n") \
30  X(CSV_TRADE, \
31  "MsgType,MsgLength,ExchangeID,MsgID,MDStreamID,ChannelNo,ApplSeqNum,BidApplSeqNum,OfferApplSeqNum,SecurityID," \
32  "LastPx,LastQty,ExecType,TransactTime\n") \
33  X(CSV_SNAP_SHOT, \
34  "MsgType,ExchangeID,MDStreamID(SZ),OrigTime,ChannelNo,SecurityID,TradingPhaseCode,BidPrice[0]," \
35  "BidPrice[1],BidPrice[2],BidPrice[3],BidPrice[4],BidPrice[5],BidPrice[6],BidPrice[7],BidPrice[8],BidPrice[9]," \
36  "AskPrice[0],AskPrice[1],AskPrice[2],AskPrice[3],AskPrice[4],AskPrice[5],AskPrice[6],AskPrice[7],AskPrice[8]," \
37  "AskPrice[9],BidVolume[0],BidVolume[1],BidVolume[2],BidVolume[3],BidVolume[4],BidVolume[5],BidVolume[6]," \
38  "BidVolume[7],BidVolume[8],BidVolume[9],AskVolume[0],AskVolume[1],AskVolume[2],AskVolume[3],AskVolume[4]," \
39  "AskVolume[5],AskVolume[6],AskVolume[7],AskVolume[8],AskVolume[9],PrevClosePx,OpenPrice,HighPrice,LowPrice," \
40  "LastPrice,NumTrades,TotalVolumeTrade,TotalValueTrade,OpenInterest,LastSubPrevClosePrice,LastSubPrevLastPrice," \
41  "TotalBidVolume,TotalAskVolume,MaBidPrice,MaAskPrice,PreIOPV,IOPV,UpperLimitPrice,LowerLimitPrice\n")
42 
43 #define X(a, b) a,
44 enum CSV_HEADER { CSV_TABLE };
45 #undef X
46 
47 #define X(a, b) [a] = b,
48 const char* CsvHeaderTableStr[] = {CSV_TABLE};
49 #undef X
50 
51 inline static bool FileExists(const std::string& name, struct stat* st)
52 {
53  return (stat(name.c_str(), st) == 0);
54 }
55 
56 static inline int64_t GetTimeStampNano(void)
57 {
58  struct timespec ts;
59  clock_gettime(CLOCK_REALTIME, &ts);
60 
61  return ts.tv_sec * 1000000000 + ts.tv_nsec;
62 }
63 
64 AHMdSpiInl::AHMdSpiInl(const std::string& index_file, const std::string& tick_file, const std::string& snapshot_file,
65  const char* delimiter, const char* suffix)
66 {
67  this->delimiter = delimiter;
68  this->suffix = suffix;
69  struct stat st;
70  if (FileExists(index_file, &st)) {
71  // index_fd = open(index_file.c_str(), O_WRONLY |O_APPEND, S_IRUSR | S_IWUSR);
72  index_fd = open(index_file.c_str(), O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR);
73  if (index_fd < 0) {
74  int err = errno;
75  fprintf(stderr, "open index file: %s, errmsg: %s", index_file.c_str(), strerror(err));
76  return;
77  }
78  } else {
79  index_fd = open(index_file.c_str(), O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
80  }
81  // write(index_fd, CsvHeaderTableStr[CSV_INDEX], strlen(CsvHeaderTableStr[CSV_INDEX]));
82 
83  if (FileExists(snapshot_file, &st)) {
84  snapshot_fd = open(snapshot_file.c_str(), O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR);
85  if (snapshot_fd < 0) {
86  int err = errno;
87  fprintf(stderr, "open snap_shot file: %s, errmsg: %s", snapshot_file.c_str(), strerror(err));
88  return;
89  }
90  } else {
91  snapshot_fd = open(snapshot_file.c_str(), O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
92  }
93  // write(snapshot_fd, CsvHeaderTableStr[CSV_SNAP_SHOT], strlen(CsvHeaderTableStr[CSV_SNAP_SHOT]));
94 }
95 
96 AHMdSpiInl::~AHMdSpiInl()
97 {
98  close(index_fd);
99  close(snapshot_fd);
100 }
101 
103 {
104  static const char* sz_format = "%d%s%c%c%s" // header
105  "%s%s" // MDStreamID
106  "%lld%s" // OrigTime
107  "%d%s" // ChannelNo
108  "%c%c%s" // TradingPhaseCode
109  "%c%c%c%c%c%c%c%c%s" // SecurityID
110  "%lld%s" // LastIndex
111  "%lld%s" // PreCloseIndex
112  "%lld%s" // OpenIndex
113  "%lld%s" // HighIndex
114  "%lld%s" // LowIndex
115  "%lld%s" // CloseIndex
116  "%lld%s" // TotalVolumeTrade
117  "%lld%s" // TotalValueTrade
118  "%lld%s"; // NumTrades
119 
120  static const char* sh_format = "%d%s%c%c%s" // header
121  "%lld%s" // TradeTime
122  "%c%c%c%c%c%c%c%c%s" // SecurityID
123  "%lld%s" // LastIndex
124  "%lld%s" // PreCloseIndex
125  "%lld%s" // OpenIndex
126  "%lld%s" // HighIndex
127  "%lld%s" // LowIndex
128  "%lld%s" // CloseIndex
129  "%lld%s" // TotalVolumeTrade
130  "%lld%s"; // TotalValueTrade
131  if (index->header.ExchangeID[1] == 'Z') {
132  dprintf(index_fd, sz_format,
133  index->header.MsgType, delimiter.c_str(),
134  index->header.ExchangeID[0], index->header.ExchangeID[1], delimiter.c_str(),
135  index->MDStreamID, delimiter.c_str(),
136  index->OrigTime, delimiter.c_str(),
137  index->ChannelNo, delimiter.c_str(),
138  index->TradingPhaseCode[0], index->TradingPhaseCode[1], delimiter.c_str(),
139  index->SecurityID[0], index->SecurityID[1], index->SecurityID[2], index->SecurityID[3],
140  index->SecurityID[4], index->SecurityID[5], index->SecurityID[6], index->SecurityID[7], delimiter.c_str(),
141  index->LastIndex, delimiter.c_str(),
142  index->PreCloseIndex, delimiter.c_str(),
143  index->OpenIndex, delimiter.c_str(),
144  index->HighIndex, delimiter.c_str(),
145  index->LowIndex, delimiter.c_str(),
146  index->CloseIndex, delimiter.c_str(),
147  index->TotalVolumeTrade, delimiter.c_str(),
148  index->TotalValueTrade, delimiter.c_str(),
149  index->NumTrades, suffix.c_str());
150  } else {
151  dprintf(index_fd, sh_format,
152  index->header.MsgType, delimiter.c_str(),
153  index->header.ExchangeID[0], index->header.ExchangeID[1], delimiter.c_str(),
154  index->TradeTime, delimiter.c_str(),
155  index->SecurityID[0], index->SecurityID[1], index->SecurityID[2], index->SecurityID[3],
156  index->SecurityID[4], index->SecurityID[5], index->SecurityID[6], index->SecurityID[7], delimiter.c_str(),
157  index->LastIndex, delimiter.c_str(),
158  index->PreCloseIndex, delimiter.c_str(),
159  index->OpenIndex, delimiter.c_str(),
160  index->HighIndex, delimiter.c_str(),
161  index->LowIndex, delimiter.c_str(),
162  index->CloseIndex, delimiter.c_str(),
163  index->TotalVolumeTrade, delimiter.c_str(),
164  index->TotalValueTrade, suffix.c_str());
165  }
166 }
167 
168 void AHMdSpiInl::OnTickCB(AHTick* tick, uint16_t type)
169 {
170  static const char* sz_entrust_format = "%d%s%c%c%s" // Header
171  "%s%s" // MDStreamID
172  "%d%s" // ChannelNo
173  "%c%s" // Side
174  "%c%s" // OrdType
175  "%lld%s" // ApplSeqNum
176  "%c%c%c%c%c%c%c%c%s" // SecurityID
177  "%lld%s" // Price
178  "%lld%s" // orderQty
179  "%lld%s"; // TransactTime
180 
181  static const char* sh_entrust_format = "%d%s%c%c%s" // Header
182  "%d%s" // OrderIndex
183  "%d%s" // Channel
184  "%c%s" // OrderBSFlag
185  "%c%s" // OrderType
186  "%lld%s" // BizIndex
187  "%c%c%c%c%c%c%c%c%s" // SecurityID
188  "%lld%s" // OrderPrice
189  "%lld%s" // Balance
190  "%lld%s" // OrderTime
191  "%lld%s"; // OrderNo
192 
193  static const char* sz_trade_format = "%d%s%c%c%s" // Header
194  "%s%s" // MDStreamID
195  "%d%s" // ChannelNo
196  "%c%s" // ExecType
197  "%lld%s" // ApplSeqNum
198  "%c%c%c%c%c%c%c%c%s" // SecurityID
199  "%lld%s" // LastPx
200  "%lld%s" // LastQty
201  "%lld%s" // TransactTime
202  "%lld%s" // BidApplSeqNum
203  "%lld%s"; // OfferApplSeqNum
204 
205  static const char* sh_trade_format = "%d%s%c%c%s" // Header
206  "%d%s" // TradeIndex
207  "%d%s" // TradeChannel
208  "%c%s" // TradeBSFlag
209  "%lld%s" // BizIndex
210  "%c%c%c%c%c%c%c%c%s" // SecurityID
211  "%lld%s" // TradePrice
212  "%lld%s" // TradeQty
213  "%lld%s" // TradeTime
214  "%lld%s" // TradeBuyNo
215  "%lld%s" // TradeSellNo
216  "%lld%s"; // TradeMony
217  if (type == AHType::ENTRUST) {
218  // int64_t* ptime = (int64_t*)((char*)entrust + sizeof(AHEntrust));
219  if (tick->header.ExchangeID[1] == 'Z') {
220  fprintf(stderr, sz_entrust_format, tick->header.MsgType, delimiter.c_str(),
221  tick->header.ExchangeID[0], tick->header.ExchangeID[1], delimiter.c_str(),
222  tick->MDStreamID, delimiter.c_str(),
223  tick->ChannelNo, delimiter.c_str(),
224  tick->Side, delimiter.c_str(),
225  tick->OrdType, delimiter.c_str(),
226  tick->ApplSeqNum, delimiter.c_str(),
227  tick->SecurityID[0], tick->SecurityID[1], tick->SecurityID[2], tick->SecurityID[3],
228  tick->SecurityID[4], tick->SecurityID[5], tick->SecurityID[6], tick->SecurityID[7], delimiter.c_str(),
229  tick->Price, delimiter.c_str(),
230  tick->OrderQty, delimiter.c_str(),
231  tick->TransactTime, suffix.c_str());
232  } else {
233  fprintf(stderr, sh_entrust_format, tick->header.MsgType, delimiter.c_str(),
234  tick->header.ExchangeID[0], tick->header.ExchangeID[1], delimiter.c_str(),
235  tick->OrderIndex, delimiter.c_str(),
236  tick->Channel, delimiter.c_str(),
237  tick->OrderBSFlag, delimiter.c_str(),
238  tick->OrderType, delimiter.c_str(),
239  tick->BizIndex, delimiter.c_str(),
240  tick->SecurityID[0], tick->SecurityID[1], tick->SecurityID[2], tick->SecurityID[3],
241  tick->SecurityID[4], tick->SecurityID[5], tick->SecurityID[6], tick->SecurityID[7], delimiter.c_str(),
242  tick->OrderPrice, delimiter.c_str(),
243  tick->Balance, delimiter.c_str(),
244  tick->OrderTime, delimiter.c_str(),
245  tick->OrderNO, suffix.c_str());
246  }
247  } else {
248  if (tick->header.ExchangeID[1] == 'Z') {
249  fprintf(stderr, sz_trade_format, tick->header.MsgType, delimiter.c_str(),
250  tick->header.ExchangeID[0], tick->header.ExchangeID[1], delimiter.c_str(),
251  tick->MDStreamID, delimiter.c_str(),
252  tick->ChannelNo, delimiter.c_str(),
253  tick->ExecType, delimiter.c_str(),
254  tick->ApplSeqNum, delimiter.c_str(),
255  tick->SecurityID[0], tick->SecurityID[1], tick->SecurityID[2], tick->SecurityID[3],
256  tick->SecurityID[4], tick->SecurityID[5], tick->SecurityID[6], tick->SecurityID[7], delimiter.c_str(),
257  tick->LastPx, delimiter.c_str(),
258  tick->LastQty, delimiter.c_str(),
259  tick->TransactTime, delimiter.c_str(),
260  tick->BidApplSeqNum, delimiter.c_str(),
261  tick->OfferApplSeqNum, suffix.c_str());
262  } else {
263  fprintf(stderr, sh_trade_format, tick->header.MsgType, delimiter.c_str(),
264  tick->header.ExchangeID[0], tick->header.ExchangeID[1], delimiter.c_str(),
265  tick->TradeIndex, delimiter.c_str(),
266  tick->TradeChannel, delimiter.c_str(),
267  tick->TradeBSFlag, delimiter.c_str(),
268  tick->BizIndex, delimiter.c_str(),
269  tick->SecurityID[0], tick->SecurityID[1], tick->SecurityID[2], tick->SecurityID[3],
270  tick->SecurityID[4], tick->SecurityID[5], tick->SecurityID[6], tick->SecurityID[7], delimiter.c_str(),
271  tick->TradePrice, delimiter.c_str(),
272  tick->TradeQty, delimiter.c_str(),
273  tick->TradeTime, delimiter.c_str(),
274  tick->TradeBuyNo, delimiter.c_str(),
275  tick->TradeSellNo, delimiter.c_str(),
276  tick->TradeMony, suffix.c_str());
277  }
278  }
279 }
280 
282 {
283  static const char* sz_format = "%d%s%c%c%s" // header
284  "%s%s" // MDStreamID
285  "%lld%s" // OrigTime
286  "%d%s" // ChannelNo
287  "%c%c%c%c%s" // TradingPhaseCode
288  "%c%c%c%c%c%c%c%c%s" // SecurityID
289  "%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s" // BidPrice
290  "%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s" // AskPrice
291  "%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s" // BidVolume
292  "%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s" // AskVolume
293  "%lld%s" // PrevClosePx
294  "%lld%s" // OpenPx
295  "%lld%s" // HighPx
296  "%lld%s" // LowPx
297  "%lld%s" // LastPx
298  "%lld%s" // ClosePx
299  "%lld%s" // NumTrades
300  "%lld%s" // TotalVolumeTrade
301  "%lld%s" // TotalValueTrade
302  "%lld%s" // TotalBidQty
303  "%lld%s" // WeightedAvgBidPx
304  "%lld%s" // TotalOfferQty
305  "%lld%s" // WeightedAvgOfferPx
306  "%lld%s" // IOPV
307  "%lld%s" // LPV
308  "%lld%s" // UpperLimitPrice
309  "%lld%s" // LowerLimitPrice
310  "%lld%s" // OpenInterest
311  "%lld%s" // LastSubPrevClosePrice
312  "%lld%s"; // LastSubPrevLastPrice
313 
314  static const char* sh_format = "%d%s%c%c%s" // header
315  "%lld%s" // TradeTime
316  "%c%c%s" // InstrumentStatus
317  "%c%c%c%c%s" // TradingPhaseCode
318  "%c%c%c%c%c%c%c%c%s" // SecurityID
319  "%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s" // BidPrice
320  "%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s" // AskPrice
321  "%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s" // BidVolume
322  "%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s%lld%s" // AskVolume
323  "%lld%s" // PrevClosePx
324  "%lld%s" // OpenPx
325  "%lld%s" // HighPx
326  "%lld%s" // LowPx
327  "%lld%s" // LastPx
328  "%lld%s" // ClosePx
329  "%lld%s" // NumTrades
330  "%lld%s" // TotalVolumeTrade
331  "%lld%s" // TotalValueTrade
332  "%lld%s" // TotalBidQty
333  "%lld%s" // WeightedAvgBidPx
334  "%lld%s" // TotalOfferQty
335  "%lld%s" // WeightedAvgOfferPx
336  "%lld%s"; // IOPV
337 
338  if (snapshot->header.ExchangeID[1] == 'Z') {
339  dprintf(snapshot_fd, sz_format,
340  snapshot->header.MsgType, delimiter.c_str(),
341  snapshot->header.ExchangeID[0], snapshot->header.ExchangeID[1], delimiter.c_str(),
342  snapshot->MDStreamID, delimiter.c_str(),
343  snapshot->OrigTime, delimiter.c_str(),
344  snapshot->ChannelNo, delimiter.c_str(),
345  snapshot->TradingPhaseCode[0], snapshot->TradingPhaseCode[1],
346  snapshot->TradingPhaseCode[2], snapshot->TradingPhaseCode[3], delimiter.c_str(),
347  snapshot->SecurityID[0], snapshot->SecurityID[1], snapshot->SecurityID[2], snapshot->SecurityID[3],
348  snapshot->SecurityID[4], snapshot->SecurityID[5], snapshot->SecurityID[6], snapshot->SecurityID[7], delimiter.c_str(),
349  snapshot->BidPrice[0], delimiter.c_str(),
350  snapshot->BidPrice[1], delimiter.c_str(),
351  snapshot->BidPrice[2], delimiter.c_str(),
352  snapshot->BidPrice[3], delimiter.c_str(),
353  snapshot->BidPrice[4], delimiter.c_str(),
354  snapshot->BidPrice[5], delimiter.c_str(),
355  snapshot->BidPrice[6], delimiter.c_str(),
356  snapshot->BidPrice[7], delimiter.c_str(),
357  snapshot->BidPrice[8], delimiter.c_str(),
358  snapshot->BidPrice[9], delimiter.c_str(),
359  snapshot->AskPrice[0], delimiter.c_str(),
360  snapshot->AskPrice[1], delimiter.c_str(),
361  snapshot->AskPrice[2], delimiter.c_str(),
362  snapshot->AskPrice[3], delimiter.c_str(),
363  snapshot->AskPrice[4], delimiter.c_str(),
364  snapshot->AskPrice[5], delimiter.c_str(),
365  snapshot->AskPrice[6], delimiter.c_str(),
366  snapshot->AskPrice[7], delimiter.c_str(),
367  snapshot->AskPrice[8], delimiter.c_str(),
368  snapshot->AskPrice[9], delimiter.c_str(),
369  snapshot->BidVolume[0], delimiter.c_str(),
370  snapshot->BidVolume[1], delimiter.c_str(),
371  snapshot->BidVolume[2], delimiter.c_str(),
372  snapshot->BidVolume[3], delimiter.c_str(),
373  snapshot->BidVolume[4], delimiter.c_str(),
374  snapshot->BidVolume[5], delimiter.c_str(),
375  snapshot->BidVolume[6], delimiter.c_str(),
376  snapshot->BidVolume[7], delimiter.c_str(),
377  snapshot->BidVolume[8], delimiter.c_str(),
378  snapshot->BidVolume[9], delimiter.c_str(),
379  snapshot->AskVolume[0], delimiter.c_str(),
380  snapshot->AskVolume[1], delimiter.c_str(),
381  snapshot->AskVolume[2], delimiter.c_str(),
382  snapshot->AskVolume[3], delimiter.c_str(),
383  snapshot->AskVolume[4], delimiter.c_str(),
384  snapshot->AskVolume[5], delimiter.c_str(),
385  snapshot->AskVolume[6], delimiter.c_str(),
386  snapshot->AskVolume[7], delimiter.c_str(),
387  snapshot->AskVolume[8], delimiter.c_str(),
388  snapshot->AskVolume[9], delimiter.c_str(),
389  snapshot->PrevClosePx, delimiter.c_str(),
390  snapshot->OpenPx, delimiter.c_str(),
391  snapshot->HighPx, delimiter.c_str(),
392  snapshot->LowPx, delimiter.c_str(),
393  snapshot->LastPx, delimiter.c_str(),
394  snapshot->ClosePx, delimiter.c_str(),
395  snapshot->NumTrades, delimiter.c_str(),
396  snapshot->TotalVolumeTrade, delimiter.c_str(),
397  snapshot->TotalValueTrade, delimiter.c_str(),
398  snapshot->TotalBidQty, delimiter.c_str(),
399  snapshot->WeightedAvgBidPx, delimiter.c_str(),
400  snapshot->TotalOfferQty, delimiter.c_str(),
401  snapshot->WeightedAvgOfferPx, delimiter.c_str(),
402  snapshot->IOPV, delimiter.c_str(),
403  snapshot->LPV, delimiter.c_str(),
404  snapshot->UpperLimitPrice, delimiter.c_str(),
405  snapshot->LowerLimitPrice, delimiter.c_str(),
406  snapshot->OpenInterest, delimiter.c_str(),
407  snapshot->LastSubPrevClosePrice, delimiter.c_str(),
408  snapshot->LastSubPrevLastPrice, suffix.c_str());
409  } else {
410  dprintf(snapshot_fd, sh_format,
411  snapshot->header.MsgType, delimiter.c_str(),
412  snapshot->header.ExchangeID[0], snapshot->header.ExchangeID[1], delimiter.c_str(),
413  snapshot->TradeTime, delimiter.c_str(),
414  snapshot->InstrumentStatus[0], snapshot->InstrumentStatus[1], delimiter.c_str(),
415  snapshot->TradingPhaseCode[0], snapshot->TradingPhaseCode[1],
416  snapshot->TradingPhaseCode[2], snapshot->TradingPhaseCode[3], delimiter.c_str(),
417  snapshot->SecurityID[0], snapshot->SecurityID[1], snapshot->SecurityID[2], snapshot->SecurityID[3],
418  snapshot->SecurityID[4], snapshot->SecurityID[5], snapshot->SecurityID[6], snapshot->SecurityID[7], delimiter.c_str(),
419  snapshot->BidPrice[0], delimiter.c_str(),
420  snapshot->BidPrice[1], delimiter.c_str(),
421  snapshot->BidPrice[2], delimiter.c_str(),
422  snapshot->BidPrice[3], delimiter.c_str(),
423  snapshot->BidPrice[4], delimiter.c_str(),
424  snapshot->BidPrice[5], delimiter.c_str(),
425  snapshot->BidPrice[6], delimiter.c_str(),
426  snapshot->BidPrice[7], delimiter.c_str(),
427  snapshot->BidPrice[8], delimiter.c_str(),
428  snapshot->BidPrice[9], delimiter.c_str(),
429  snapshot->AskPrice[0], delimiter.c_str(),
430  snapshot->AskPrice[1], delimiter.c_str(),
431  snapshot->AskPrice[2], delimiter.c_str(),
432  snapshot->AskPrice[3], delimiter.c_str(),
433  snapshot->AskPrice[4], delimiter.c_str(),
434  snapshot->AskPrice[5], delimiter.c_str(),
435  snapshot->AskPrice[6], delimiter.c_str(),
436  snapshot->AskPrice[7], delimiter.c_str(),
437  snapshot->AskPrice[8], delimiter.c_str(),
438  snapshot->AskPrice[9], delimiter.c_str(),
439  snapshot->BidVolume[0], delimiter.c_str(),
440  snapshot->BidVolume[1], delimiter.c_str(),
441  snapshot->BidVolume[2], delimiter.c_str(),
442  snapshot->BidVolume[3], delimiter.c_str(),
443  snapshot->BidVolume[4], delimiter.c_str(),
444  snapshot->BidVolume[5], delimiter.c_str(),
445  snapshot->BidVolume[6], delimiter.c_str(),
446  snapshot->BidVolume[7], delimiter.c_str(),
447  snapshot->BidVolume[8], delimiter.c_str(),
448  snapshot->BidVolume[9], delimiter.c_str(),
449  snapshot->AskVolume[0], delimiter.c_str(),
450  snapshot->AskVolume[1], delimiter.c_str(),
451  snapshot->AskVolume[2], delimiter.c_str(),
452  snapshot->AskVolume[3], delimiter.c_str(),
453  snapshot->AskVolume[4], delimiter.c_str(),
454  snapshot->AskVolume[5], delimiter.c_str(),
455  snapshot->AskVolume[6], delimiter.c_str(),
456  snapshot->AskVolume[7], delimiter.c_str(),
457  snapshot->AskVolume[8], delimiter.c_str(),
458  snapshot->AskVolume[9], delimiter.c_str(),
459  snapshot->PrevClosePx, delimiter.c_str(),
460  snapshot->OpenPx, delimiter.c_str(),
461  snapshot->HighPx, delimiter.c_str(),
462  snapshot->LowPx, delimiter.c_str(),
463  snapshot->LastPx, delimiter.c_str(),
464  snapshot->ClosePx, delimiter.c_str(),
465  snapshot->NumTrades, delimiter.c_str(),
466  snapshot->TotalVolumeTrade, delimiter.c_str(),
467  snapshot->TotalValueTrade, delimiter.c_str(),
468  snapshot->TotalBidQty, delimiter.c_str(),
469  snapshot->WeightedAvgBidPx, delimiter.c_str(),
470  snapshot->TotalOfferQty, delimiter.c_str(),
471  snapshot->WeightedAvgOfferPx, delimiter.c_str(),
472  snapshot->IOPV, suffix.c_str());
473  }
474 }
475 }; // namespace annhoo
virtual void OnIndexCB(AHIndex *index) override
Callback for AHIndex.
int64_t PreCloseIndex
Definition: ah_md_common.h:53
int64_t AskPrice[10]
Definition: ah_md_common.h:81
int64_t TotalVolumeTrade
Definition: ah_md_common.h:91
int64_t BidApplSeqNum
Definition: ah_md_common.h:169
int64_t TradeSellNo
Definition: ah_md_common.h:175
int64_t TransactTime
Definition: ah_md_common.h:162
int64_t WeightedAvgBidPx
Definition: ah_md_common.h:95
int64_t LowIndex
Definition: ah_md_common.h:56
uint16_t TradeIndex
Definition: ah_md_common.h:119
int64_t TradeMony
Definition: ah_md_common.h:178
AHDataHeader header
Definition: ah_md_common.h:68
int64_t TotalVolumeTrade
Definition: ah_md_common.h:58
int64_t ApplSeqNum
Definition: ah_md_common.h:141
AHDataHeader header
Definition: ah_md_common.h:41
char MDStreamID[4]
Definition: ah_md_common.h:42
int64_t OrderPrice
Definition: ah_md_common.h:149
int64_t CloseIndex
Definition: ah_md_common.h:57
uint16_t ChannelNo
Definition: ah_md_common.h:48
int64_t NumTrades
Definition: ah_md_common.h:60
int64_t TradePrice
Definition: ah_md_common.h:151
int64_t BizIndex
Definition: ah_md_common.h:142
int64_t TradeBuyNo
Definition: ah_md_common.h:170
int64_t TradeTime
Definition: ah_md_common.h:45
int64_t OrderTime
Definition: ah_md_common.h:163
int64_t BidPrice[10]
Definition: ah_md_common.h:80
int64_t OrderQty
Definition: ah_md_common.h:155
char SecurityID[8]
Definition: ah_md_common.h:145
int64_t AskVolume[10]
Definition: ah_md_common.h:83
int64_t LastIndex
Definition: ah_md_common.h:52
int64_t TotalValueTrade
Definition: ah_md_common.h:92
int64_t OfferApplSeqNum
Definition: ah_md_common.h:174
uint16_t ChannelNo
Definition: ah_md_common.h:123
int64_t HighIndex
Definition: ah_md_common.h:55
int64_t TotalValueTrade
Definition: ah_md_common.h:59
char SecurityID[8]
Definition: ah_md_common.h:51
int64_t TradeQty
Definition: ah_md_common.h:158
uint16_t OrderIndex
Definition: ah_md_common.h:118
int64_t LastSubPrevLastPrice
Definition: ah_md_common.h:106
AHDataHeader header
Definition: ah_md_common.h:115
int64_t BidVolume[10]
Definition: ah_md_common.h:82
uint16_t Channel
Definition: ah_md_common.h:124
int64_t TradeTime
Definition: ah_md_common.h:164
Contains data defined for index.
Definition: ah_md_common.h:40
char TradingPhaseCode[4]
Definition: ah_md_common.h:77
virtual void OnSnapshotCB(AHSnapshot *snap_shot) override
Callback for AHSnapshot.
int64_t OrigTime
Definition: ah_md_common.h:44
Contains data defined for snapshot.
Definition: ah_md_common.h:67
char InstrumentStatus[2]
Definition: ah_md_common.h:76
int64_t LastSubPrevClosePrice
Definition: ah_md_common.h:105
virtual void OnTickCB(AHTick *tick, uint16_t type) override
Callback for AHEntrust or AHTrade.
uint16_t TradeChannel
Definition: ah_md_common.h:125
int64_t WeightedAvgOfferPx
Definition: ah_md_common.h:97
char MDStreamID[4]
Definition: ah_md_common.h:117
int64_t OpenIndex
Definition: ah_md_common.h:54
char TradingPhaseCode[2]
Definition: ah_md_common.h:49