.gitignore | ●●●●● patch | view | raw | blame | history | |
bom.cpp | ●●●●● patch | view | raw | blame | history | |
book.cpp | ●●●●● patch | view | raw | blame | history | |
book.hpp | patch | view | raw | blame | history | |
click.cpp | ●●●●● patch | view | raw | blame | history | |
json.cpp | patch | view | raw | blame | history | |
test.cpp | ●●●●● patch | view | raw | blame | history |
.gitignore
@@ -10,3 +10,4 @@ build test click bom_data.xml bom.cpp
@@ -45,9 +45,11 @@ for (auto &i : bs) { if (i.second.stationId == bom_id) { // Should be apparent temp i.second.bomPrice = std::stod(n->first_node()->first_node()->first_node()->first_node()->value()); std::cout << i.second.product << ", " << i.second.stationId << ", " << i.second.bomPrice << std::endl; break; i.second.bomPrice = std::stod(n->first_node() ->first_node() ->first_node() ->first_node() ->value()); } } } book.cpp
@@ -92,8 +92,7 @@ void Book::ask(Order& order) { auto a = this->askSide.emplace(order.id, order); auto a = this->askSide.emplace(order.id, order); if (!a.second) { std::cout << order.id << "already exists" << std::endl; } @@ -101,8 +100,7 @@ void Book::bid(Order& order) { auto a = this->bidSide.emplace(order.id, order); auto a = this->bidSide.emplace(order.id, order); if (!a.second) { std::cout << order.id << "already exists" << std::endl; } @@ -112,7 +110,8 @@ { std::cout << "Sell side: " << this->askSide.size() << std::endl; std::vector<Level> askCopy; for (auto i : this->askSide) askCopy.push_back(i.second); for (auto i : this->askSide) askCopy.push_back(i.second); std::size_t count = 0; std::sort(askCopy.begin(), askCopy.end()); for (auto i = askCopy.rbegin(); i != askCopy.rend(); i++) { @@ -122,7 +121,8 @@ } std::cout << "Buy side: " << this->bidSide.size() << std::endl; std::vector<Level> bidCopy; for (auto i : this->bidSide) bidCopy.push_back(i.second); for (auto i : this->bidSide) bidCopy.push_back(i.second); count = 0; std::sort(bidCopy.begin(), bidCopy.end()); for (auto i = bidCopy.rbegin(); i != bidCopy.rend(); i++) { book.hpp
click.cpp
@@ -38,27 +38,32 @@ 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) { @@ -83,7 +88,8 @@ 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; } } json.cpp
test.cpp
@@ -1,8 +1,9 @@ #include "bom.hpp" #include "book.hpp" #include "json.hpp" #include "protocol.hpp" #include "bom.hpp" #include <chrono> #include <iostream> #include <unistd.h> #include <unordered_map> @@ -19,4 +20,10 @@ bom::initialise(); bom::updateBom(bs); bom::destroy(); protocol::catchUp(bs); std::cout << bs.size() << std::endl; for (auto& i : bs) { std::cout << i.first << ", " << i.second.bomPrice << std::endl; i.second.printBook(); } }