This repository was archived by the owner on Jun 17, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
73 lines (55 loc) · 2.31 KB
/
Copy pathmain.cpp
File metadata and controls
73 lines (55 loc) · 2.31 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
#include "OrderBookWriter.h"
#include "OrderBookReader.h"
using namespace da_order_book;
template<typename K, typename V, typename C>
void printMap(const std::map<K, V, C> &m) {
for (const auto &[key, value]: m) {
std::cout << "Price: " << key << ", Entry: { Price: " << value.price << ", Vol: " << value.vol << ", Num: "
<< value.num << " }\n";
}
}
int main() {
MetaData metaData = {1};
Header header = {1, "Test Instrument", 1000000000, 1000000001};
Snapshot snapshot;
snapshot.timestamp_local = 1627654321;
snapshot.timestamp_exchange = 1627654000;
snapshot.depth = 5;
snapshot.asks.emplace(10, Entry{10, 50, 1});
snapshot.asks.emplace(11, Entry{11, 55, 2});
snapshot.asks.emplace(12, Entry{12, 60, 3});
snapshot.asks.emplace(13, Entry{13, 65, 4});
snapshot.asks.emplace(14, Entry{16, 70, 5});
snapshot.bids.emplace(9, Entry{9, 45, 1});
snapshot.bids.emplace(8, Entry{8, 40, 2});
snapshot.bids.emplace(7, Entry{7, 35, 3});
snapshot.bids.emplace(6, Entry{6, 30, 4});
snapshot.bids.emplace(5, Entry{5, 25, 5});
MetaData metaData2 = {1};
Header header2 = {1, "Test Instrument", 1000000002, 1000000003};
Snapshot secondSnapshot;
secondSnapshot.timestamp_local = 2630654331;
secondSnapshot.timestamp_exchange = 2630654010;
secondSnapshot.depth = 5;
secondSnapshot.asks.emplace(8, Entry{10, 50, 1});
secondSnapshot.asks.emplace(9, Entry{12, 55, 2});
secondSnapshot.asks.emplace(10, Entry{14, 60, 3});
secondSnapshot.asks.emplace(12, Entry{20, 65, 4});
secondSnapshot.asks.emplace(15, Entry{10, 50, 1});
secondSnapshot.bids.emplace(7, Entry{7, 35, 1});
secondSnapshot.bids.emplace(6, Entry{6, 30, 2});
secondSnapshot.bids.emplace(5, Entry{5, 25, 3});
secondSnapshot.bids.emplace(4, Entry{4, 20, 4});
secondSnapshot.bids.emplace(3, Entry{3, 15, 5});
OrderBook testOrderBook(metaData, header, snapshot);
OrderBook testOrderBook2(metaData2, header2, secondSnapshot);
OrderBookWriter ob_writer("../test.txt");
ob_writer.write(testOrderBook);
ob_writer.write(testOrderBook2);
OrderBookReader ob_reader("../test.txt");
OrderBookHistory obh = ob_reader.read();
printMap(obh.snapshots[0].asks);
printMap(obh.snapshots[0].bids);
return 0;
}