commit | author | age
|
16b655
|
1 |
#include "book.hpp" |
JG |
2 |
#include "json.hpp" |
|
3 |
#include "protocol.hpp" |
|
4 |
|
|
5 |
#include <cstdlib> |
|
6 |
#include <getopt.h> |
|
7 |
#include <iostream> |
|
8 |
#include <unordered_map> |
|
9 |
|
|
10 |
enum clickType { Buy, Sell, Flash }; |
|
11 |
|
|
12 |
static std::unordered_map<std::string, clickType> mapClick; |
|
13 |
|
|
14 |
void initialise() |
|
15 |
{ |
|
16 |
mapClick = {{"BUY", Buy}, {"SELL", Sell}, {"FLASH", Flash}, |
|
17 |
{"b", Buy}, {"s", Sell}, {"f", Flash}, |
|
18 |
{"B", Buy}, {"S", Sell}, {"F", Flash}}; |
|
19 |
} |
|
20 |
|
|
21 |
void usage() |
|
22 |
{ |
|
23 |
std::cout << "DESCRIPTION" << std::endl |
|
24 |
<< "Click trader using same algs" << std::endl |
|
25 |
<< std::endl |
|
26 |
<< "USAGE" << std::endl |
|
27 |
<< "\t-a product" << std::endl |
|
28 |
<< "\t-t click type (buy, sell, flash)" << std::endl |
|
29 |
<< "\t-p price" << std::endl |
|
30 |
<< "\t-v volume" << std::endl |
|
31 |
<< "\t-i id" << std::endl |
|
32 |
<< "Always need product, need side, price and volume for " |
|
33 |
"adding/flash, need id for deleting" |
|
34 |
<< std::endl; |
|
35 |
} |
|
36 |
|
|
37 |
int main(int argc, char** argv) |
|
38 |
{ |
|
39 |
int c; |
|
40 |
std::string product, id; |
|
41 |
double price; |
|
42 |
clickType click; |
|
43 |
uint64_t volume; |
|
44 |
initialise(); |
|
45 |
if (argc == 1) { |
|
46 |
usage(), exit(0); |
|
47 |
} |
|
48 |
while ((c = getopt(argc, argv, "a::t::p::v::i::")) != -1) { |
|
49 |
switch (c) { |
|
50 |
case 'a': |
|
51 |
product = std::string(optarg); |
|
52 |
break; |
|
53 |
case 's': |
|
54 |
click = mapClick[optarg]; |
|
55 |
break; |
|
56 |
case 'p': |
|
57 |
price = std::stod(optarg); |
|
58 |
break; |
|
59 |
case 'v': |
|
60 |
volume = std::stoll(optarg); |
|
61 |
break; |
|
62 |
case 'i': |
|
63 |
id = std::string(optarg); |
|
64 |
break; |
|
65 |
case '?': |
|
66 |
default: |
|
67 |
usage(); |
|
68 |
exit(0); |
|
69 |
} |
|
70 |
} |
|
71 |
switch (click) { |
|
72 |
case Buy: |
|
73 |
case Sell: |
|
74 |
case Flash:; |
|
75 |
} |
|
76 |
} |