| | |
| | | #include "json.hpp" |
| | | #include "protocol.hpp" |
| | | |
| | | #include <cstdint> |
| | | #include <cstdlib> |
| | | #include <getopt.h> |
| | | #include <iostream> |
| | | #include <string> |
| | | #include <unordered_map> |
| | | |
| | | enum clickType { Buy, Sell, Flash, Delete }; |
| | |
| | | << "\t-p price" << std::endl |
| | | << "\t-v volume" << std::endl |
| | | << "\t-i id" << std::endl |
| | | << "\t-l loop count (default to 1)" << std::endl |
| | | << "Always need product, need side, price and volume for " |
| | | "adding/flash, need id for deleting" |
| | | << std::endl; |
| | |
| | | if (d->type == json::DELETED) { |
| | | std::cout << static_cast<json::DeletedMessage*>(d)->as_string() |
| | | << std::endl; |
| | | } else { |
| | | } else if (d->type == json::REJECT) { |
| | | std::cout << static_cast<json::RejectMessage*>(d)->as_string() |
| | | << std::endl; |
| | | } else if (d->type == json::ERROR) { |
| | | std::cout << static_cast<json::ErrorMessage*>(d)->as_string() << std::endl; |
| | | } |
| | | delete b; |
| | | delete d; |
| | |
| | | } else if (b->type == json::REJECT) { |
| | | std::cout << static_cast<json::RejectMessage*>(b)->as_string() |
| | | << std::endl; |
| | | } else { |
| | | } else if (b->type == json::ERROR) { |
| | | std::cout << static_cast<json::ErrorMessage*>(b)->as_string() |
| | | << std::endl; |
| | | } |
| | |
| | | double price; |
| | | clickType click, side; |
| | | uint64_t volume; |
| | | uint64_t times = 1; |
| | | initialise(); |
| | | if (argc == 1) { |
| | | usage(), exit(0); |
| | | } |
| | | while ((c = getopt(argc, argv, "a::t::s::p::v::i::")) != -1) { |
| | | while ((c = getopt(argc, argv, "a::t::s::p::v::i::l::")) != -1) { |
| | | switch (c) { |
| | | case 'a': |
| | | product = std::string(optarg); |
| | |
| | | case 'i': |
| | | id = std::string(optarg); |
| | | break; |
| | | case 'l': |
| | | times = std::stoll(optarg); |
| | | break; |
| | | case '?': |
| | | std::cout << "*1" << std::endl; |
| | | default: |
| | |
| | | exit(0); |
| | | } |
| | | } |
| | | for (std::uint64_t i = 0; i < times; i++) |
| | | { |
| | | switch (click) { |
| | | case Buy: |
| | | buy(product, price, volume); |
| | |
| | | break; |
| | | } |
| | | } |
| | | } |