| | |
| | | void buy(std::string& product, double price, uint64_t volume) |
| | | { |
| | | json::AddMessage a(json::ADD, product, price, book::Buy, volume); |
| | | json::AddedMessage* b = static_cast<json::AddedMessage*>(protocol::addOrder(a)); |
| | | json::AddedMessage* b = |
| | | static_cast<json::AddedMessage*>(protocol::addOrder(a)); |
| | | std::cout << b->as_string() << std::endl; |
| | | } |
| | | |
| | | void sell(std::string& product, double price, uint64_t volume) |
| | | { |
| | | json::AddMessage a(json::ADD, product, price, book::Sell, volume); |
| | | json::AddedMessage* b = static_cast<json::AddedMessage*>(protocol::addOrder(a)); |
| | | json::AddedMessage* b = |
| | | static_cast<json::AddedMessage*>(protocol::addOrder(a)); |
| | | std::cout << b->as_string() << std::endl; |
| | | delete b; |
| | | } |
| | | |
| | | void flash(std::string& product, double price, uint64_t volume, book::OrderSideEnum side) |
| | | void flash(std::string& product, double price, uint64_t volume, |
| | | book::OrderSideEnum side) |
| | | { |
| | | json::AddMessage a(json::ADD, product, price, side, volume); |
| | | json::Message* b = static_cast<json::Message*>(protocol::addOrder(a)); |
| | | if (b->type == json::ERROR) { |
| | | std::cout << static_cast<json::ErrorMessage*>(b)->as_string() << std::endl; |
| | | std::cout << static_cast<json::ErrorMessage*>(b)->as_string() |
| | | << std::endl; |
| | | return; |
| | | } |
| | | json::DeleteMessage c(json::DELETE, product, static_cast<json::AddedMessage*>(b)->id); |
| | | json::DeleteMessage c(json::DELETE, product, |
| | | static_cast<json::AddedMessage*>(b)->id); |
| | | json::Message* d = protocol::deleteOrder(c); |
| | | std::cout << static_cast<json::AddedMessage*>(b)->as_string() << std::endl; |
| | | if (d->type == json::DELETED) { |
| | |
| | | std::cout << static_cast<json::RejectMessage*>(b)->as_string() |
| | | << std::endl; |
| | | } else { |
| | | std::cout << static_cast<json::ErrorMessage*>(b)->as_string() << std::endl; |
| | | std::cout << static_cast<json::ErrorMessage*>(b)->as_string() |
| | | << std::endl; |
| | | } |
| | | } |
| | | |