From 0bef191acd5a77544852e6a3daae2df05bd34a31 Mon Sep 17 00:00:00 2001 From: Joel Grunbaum <joelgrun@gmail.com> Date: Wed, 19 Jan 2022 11:20:45 +0000 Subject: [PATCH] Reformat and change send to x-www-form-urlencoded --- strat.cpp | 43 +++++++++++++++++++++++++++---------------- 1 files changed, 27 insertions(+), 16 deletions(-) diff --git a/strat.cpp b/strat.cpp index 2856c1a..a25ca17 100644 --- a/strat.cpp +++ b/strat.cpp @@ -46,7 +46,8 @@ while (true) { auto messages = protocol::catchUp(bs); // bom::updateBom(bs); - printFeed(messages); + // printFeed(messages); + dumbHit(messages); freeMessages(messages); } } @@ -102,20 +103,30 @@ void dumbHit(std::deque<json::Message*>& m) { - for (auto& i : m) { - if (i->type == json::ADDED) { - json::AddedMessage* j = (json::AddedMessage*) i; - if (j->owner == "nseow") { - book::OrderSideEnum s = j->side == book::Buy ? book::Sell : book::Buy; - json::AddMessage a(json::ADD, j->product, j->price, s, j->resting); - auto b = protocol::addOrder(a); - if (b->type == json::ADDED) { - json::DeleteMessage d(json::DELETE, j->product, ((json::AddedMessage*) b)->id); - delete protocol::deleteOrder(d); - } - delete b; - } - } - } + for (auto& i : m) { + if (i->type == json::ADDED) { + json::AddedMessage* j = (json::AddedMessage*)i; + if (j->owner == "jgrunbau") { + book::OrderSideEnum s = + j->side == book::Buy ? book::Sell : book::Buy; + json::AddMessage a(json::ADD, j->product, j->price, s, + j->resting); + auto b = protocol::addOrder(a); + if (b->type == json::ADDED && + ((json::AddedMessage*)b)->resting > 0) { + json::DeleteMessage d(json::DELETE, j->product, + ((json::AddedMessage*)b)->id); + delete protocol::deleteOrder(d); + } + if (b->type == json::ADDED) { + std::cout << "Hit " << j->owner << " for " + << ((json::AddedMessage*)b)->filled + << ", resting " + << ((json::AddedMessage*)b)->resting << std::endl; + } + delete b; + } + } + } } } // namespace strat -- Gitblit v1.9.3