-
Notifications
You must be signed in to change notification settings - Fork 0
/
snapshotRefresh.h
59 lines (54 loc) · 1.99 KB
/
snapshotRefresh.h
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
#ifndef SNAPSHOT_REFRESH_HEADER
#define SNAPSHOT_REFRESH_HEADER
#include<bits/stdc++.h>
#include"binaryConvertor.h"
#include "utils.h"
struct SnapShotRefreshGroup{
int64_t entry_px;
int32_t entry_sz;
int32_t num_orders;
int16_t price_level;
int16_t entry_type;
SnapShotRefreshGroup(const u_char* packet){
this->entry_px = convertBinaryToInt64(packet, 0, 8, true);
this->entry_sz = convertBinaryToInt64(packet, 8, 4, true);
this->num_orders = convertBinaryToInt64(packet, 12, 4, true);
this->price_level = convertBinaryToInt64(packet, 16, 1, true);
this->entry_type = convertBinaryToInt64(packet, 21, 1, true) - 48; // '0x30' is seen as 0.
}
};
struct SnapShotRefreshGroups{
//each group length
int16_t block_len;
int16_t group_cnt;
std::vector<SnapShotRefreshGroup> groups;
SnapShotRefreshGroups(){}
SnapShotRefreshGroups(const u_char* packet){
this->block_len = convertBinaryToInt64(packet, 0, 2, true);
this->group_cnt = convertBinaryToInt64(packet, 2, 1, true);
for(int i = 0; i < group_cnt; i++){
SnapShotRefreshGroup ssrg = SnapShotRefreshGroup(packet + 3 + i * this->block_len); // 3 for the header
groups.push_back(ssrg);
}
}
};
struct SnapShotFullRefresh{
int32_t lastmsgSeqNumProcessed;
int32_t security_id;
int32_t rpt_seq;
int64_t transact_time;
int64_t update_time;
SnapShotRefreshGroups ssrgs;
SnapShotFullRefresh(const u_char* packet){
this->lastmsgSeqNumProcessed = convertBinaryToInt64(packet, 0, 4, true);
this->security_id = convertBinaryToInt64(packet, 8, 4, true);
this->rpt_seq = convertBinaryToInt64(packet, 12, 4, true);
this->transact_time = convertBinaryToInt64(packet, 16, 8, true);
this->update_time = convertBinaryToInt64(packet, 24, 8, true);
this->ssrgs = SnapShotRefreshGroups(packet + 59);
}
// ~SnapShotFullRefresh(){
// delete ssrgs;
// }
};
#endif