From e8c910e52d1807e2fcca3b43d80a9df6acac5387 Mon Sep 17 00:00:00 2001
From: Joel Grunbaum <joelgrun@gmail.com>
Date: Wed, 12 Jan 2022 06:26:46 +0000
Subject: [PATCH] write price level to each book

---
 json.cpp |   39 ++++++++++++++++++++-------------------
 1 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/json.cpp b/json.cpp
index ea1016a..dfcbbf4 100644
--- a/json.cpp
+++ b/json.cpp
@@ -48,7 +48,8 @@
 	mapOrder = {{"BUY", book::Buy}, {"SELL", book::Sell}};
 
 	mapTrade = {{"BUY_AGGRESSOR", BUY_AGGRESSOR},
-	            {"SELL_AGGRESSOR", SELL_AGGRESSOR}};
+	            {"SELL_AGGRESSOR", SELL_AGGRESSOR},
+	            {"BROKER_TRADE", BROKER_TRADE}};
 
 	mapOrderSide = {{book::Buy, "BUY"}, {book::Sell, "SELL"}};
 }
@@ -278,9 +279,9 @@
 {
 	if (mapOrderSide.empty()) initialise();
 	return "{\"type\": \"ADD\", \"product\": \"" + this->product +
-	       "\", \"price\": " + std::to_string(this->price) + ", \"side\": \"" +
-	       mapOrderSide[this->side] +
-	       "\", \"volume\": " + std::to_string(this->volume) + "}";
+		   "\", \"price\": " + std::to_string(this->price) + ", \"side\": \"" +
+		   mapOrderSide[this->side] +
+		   "\", \"volume\": " + std::to_string(this->volume) + "}";
 }
 
 AddedMessage::AddedMessage(MessageTypes type, std::string product,
@@ -295,13 +296,13 @@
 std::string AddedMessage::as_string()
 {
 	return "{\"type\": \"ADDED\", \"product\": \"" + this->product +
-	       "\", \"product\": \"" + this->id + "\" \"side\": \"" +
-	       mapOrderSide[this->side] +
-	       "\", \"price\": " + std::to_string(this->price) +
-	       "\"filled\": " + std::to_string(this->filled) +
-	       ", \"resting\": " + std::to_string(this->resting) +
-	       ", \"sequence\": " + std::to_string(this->sequence) +
-	       ", \"timestamp\":" + std::to_string(this->timestamp) + "}";
+		   "\", \"product\": \"" + this->id + "\" \"side\": \"" +
+		   mapOrderSide[this->side] +
+		   "\", \"price\": " + std::to_string(this->price) +
+		   "\"filled\": " + std::to_string(this->filled) +
+		   ", \"resting\": " + std::to_string(this->resting) +
+		   ", \"sequence\": " + std::to_string(this->sequence) +
+		   ", \"timestamp\":" + std::to_string(this->timestamp) + "}";
 }
 
 DeleteMessage::DeleteMessage(MessageTypes type, std::string product,
@@ -314,7 +315,7 @@
 {
 	if (mapOrderSide.empty()) initialise();
 	return "{\"type\": \"DELETE\", \"product\": \"" + this->product +
-	       "\", \"id\": \"" + this->id + "\"}";
+		   "\", \"id\": \"" + this->id + "\"}";
 }
 
 DeletedMessage::DeletedMessage(MessageTypes type, std::string product,
@@ -327,10 +328,10 @@
 std::string DeletedMessage::as_string()
 {
 	return "{\"type\": \"DELETED\", \"product\": \"" + this->product +
-	       "\", \"product\": \"" + this->id + "\" \"side\": \"" +
-	       mapOrderSide[this->side] +
-	       ", \"sequence\": " + std::to_string(this->sequence) +
-	       ", \"timestamp\":" + std::to_string(this->timestamp) + "}";
+		   "\", \"product\": \"" + this->id + "\" \"side\": \"" +
+		   mapOrderSide[this->side] +
+		   ", \"sequence\": " + std::to_string(this->sequence) +
+		   ", \"timestamp\":" + std::to_string(this->timestamp) + "}";
 }
 
 RejectMessage::RejectMessage(MessageTypes type, std::string product,
@@ -343,9 +344,9 @@
 std::string RejectMessage::as_string()
 {
 	return "{\"type\": \"REJECT\", \"product\": \"" + this->product =
-	           "\", \"error\": \"" + this->error +
-	           "\", \"sequence\": " + std::to_string(this->sequence) +
-	           ", \"timestamp\": " + std::to_string(this->timestamp) + "}";
+			   "\", \"error\": \"" + this->error +
+			   "\", \"sequence\": " + std::to_string(this->sequence) +
+			   ", \"timestamp\": " + std::to_string(this->timestamp) + "}";
 }
 
 TradeMessage::TradeMessage(MessageTypes type, std::string product, double price,

--
Gitblit v1.9.3