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 |
int index; |
|
41 |
std::string product, id; |
|
42 |
double price; |
|
43 |
clickType click; |
|
44 |
uint64_t volume; |
|
45 |
initialise(); |
|
46 |
if (argc == 1) { |
|
47 |
usage(), exit(0); |
|
48 |
} |
|
49 |
while ((c = getopt(argc, argv, "a::t::p::v::i::")) != -1) { |
|
50 |
switch (c) { |
|
51 |
case 'a': |
|
52 |
product = std::string(optarg); |
|
53 |
break; |
|
54 |
case 's': |
|
55 |
click = mapClick[optarg]; |
|
56 |
break; |
|
57 |
case 'p': |
|
58 |
price = std::stod(optarg); |
|
59 |
break; |
|
60 |
case 'v': |
|
61 |
volume = std::stoll(optarg); |
|
62 |
break; |
|
63 |
case 'i': |
|
64 |
id = std::string(optarg); |
|
65 |
break; |
|
66 |
case '?': |
|
67 |
default: |
|
68 |
usage(); |
|
69 |
exit(0); |
|
70 |
} |
|
71 |
} |
|
72 |
switch (click) { |
|
73 |
case Buy: |
|
74 |
case Sell: |
|
75 |
case Flash:; |
|
76 |
} |
|
77 |
} |