-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
67 lines (50 loc) · 2.21 KB
/
Copy pathmain.cpp
File metadata and controls
67 lines (50 loc) · 2.21 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
#include <iostream>
#include "include/enums.hpp"
#include "include/order.hpp"
#include "include/orderbook.hpp"
#include "include/helpers.hpp"
using namespace std;
int main() {
OrderBook ob;
cout << "Hello" << endl;
while(true) {
int action;
cout << "Options\n————————————————————\n|1. Print Orderbook|\n|2. Submit order |\n ————————————————————\nYour choice: ";
cin >> action;
cout << "\n";
if(action == 1) {
} else {
int orderTypeInput;
int tranSideInput;
Volume volume;
cout << "Enter order type:\n0. Limit order\n1. Market order\nYour choice: ";
cin >> orderTypeInput;
OrderType orderType = static_cast<OrderType>(orderTypeInput);
cout << "\nEnter side:\n0. Buy\n1. Sell\nYour choice: ";
cin >> tranSideInput;
TranSide tranSide = static_cast<TranSide>(tranSideInput);
cout << "\nEnter order volume: ";
cin >> volume;
if(orderType == OrderType::Market) {
cout << "\nSubmitting " << ((tranSide == TranSide::Buy) ? "buying":"selling")
<< " market order for " << volume << " units." << "\n";
TimeStamp startTime = getUnixTime();
std::pair<Price, Volume> report = ob.handleNewOrder(orderType, tranSide, volume);
TimeStamp endTime = getUnixTime();
// printReport(report, startTime, endTime);
} else if (orderType == OrderType::Limit) {
Price price;
cout << "\nEnter price: ";
cin >> price;
cout << "\nSubmitting " << ((tranSide == TranSide::Buy) ? "buying":"selling")
<< " limit order for " << volume << " units." << "\n";
TimeStamp startTime = getUnixTime();
std::pair<Price, Volume> report = ob.handleNewOrder(orderType, tranSide, volume, price);
TimeStamp endTime = getUnixTime();
// printReport(report, startTime, endTime);
}
}
cout << "\n";
}
return 0;
}