From 128c6d51ec8c70e230dc86b100cb887ba3f0378d Mon Sep 17 00:00:00 2001
From: Joel Grunbaum <joelgrun@gmail.com>
Date: Thu, 20 Jan 2022 07:00:50 +0000
Subject: [PATCH] Secrets to macros and c string concat at compile time
---
strat.cpp | 6 +++---
secrets.hpp | 12 +++++-------
protocol.cpp | 19 ++++++++++---------
3 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/protocol.cpp b/protocol.cpp
index f336597..f3c637a 100644
--- a/protocol.cpp
+++ b/protocol.cpp
@@ -16,12 +16,14 @@
#include <string>
#include <unordered_map>
+using namespace std::literals;
+
namespace protocol
{
static std::unordered_map<json::MessageTypes, book::ProductTypeEnum>
mapAnnounce;
-std::string server = std::string(HOST) + ":" + std::string(PORT);
-httplib::Client cli("http://" + server);
+#define SERVER HOST ":" PORT
+httplib::Client cli("http://" SERVER);
std::unique_ptr<easywsclient::WebSocket> ws;
double lastime = 0;
@@ -40,7 +42,6 @@
// std::ifstream sampleFile("../data.test");
// std::stringstream ss;
// ss << sampleFile.rdbuf();
- httplib::Client cli("http://" + server);
auto res = cli.Get("/recover");
std::string l;
// l = ss.str();
@@ -61,8 +62,8 @@
void createWebSocket()
{
ws = std::unique_ptr<easywsclient::WebSocket>(
- easywsclient::WebSocket::pointer(easywsclient::WebSocket::from_url(
- "ws://" + server + "/information")));
+ easywsclient::WebSocket::pointer(
+ easywsclient::WebSocket::from_url("ws://" SERVER "/information")));
ws->poll();
}
@@ -242,10 +243,10 @@
httplib::MultipartFormDataItems a = {{"message", message, "", ""},
{"username", USER, "", ""},
{"password", PASS, "", ""}};
- auto res = cli.Post("/execution",
- "message=" + message + "&username=" + USER +
- "&password=" + PASS,
- "application/x-www-form-urlencoded");
+ auto res =
+ cli.Post("/execution",
+ "message=" + message + "&username=" USER "&password=" PASS,
+ "application/x-www-form-urlencoded");
std::string b = res->body;
std::queue<json::Message*> c = json::parse(b);
return c.front();
diff --git a/secrets.hpp b/secrets.hpp
index b8e4925..6b77f17 100644
--- a/secrets.hpp
+++ b/secrets.hpp
@@ -1,13 +1,11 @@
#pragma once
-#include <string>
-
-constexpr const char* HOST = "sytev070";
+#define HOST "sytev070"
#ifdef TEST_EXCHANGE
-constexpr const char* PORT = "9005";
+#define PORT "9005"
#else
-constexpr const char* PORT = "9000";
+#define PORT "9000"
#endif
-constexpr const char* USER = "jgrunbau";
-constexpr const char* PASS = "b7d630945a0854581d9f86ba147f34a5";
+#define USER "jgrunbau"
+#define PASS "b7d630945a0854581d9f86ba147f34a5"
diff --git a/strat.cpp b/strat.cpp
index fe26c2e..a4b5e5f 100644
--- a/strat.cpp
+++ b/strat.cpp
@@ -47,8 +47,8 @@
while (true) {
auto messages = protocol::catchUp(bs);
// bom::updateBom(bs);
- // printFeed(messages);
- dumbHit(messages);
+ printFeed(messages);
+ // dumbHit(messages);
freeMessages(messages);
}
}
@@ -107,7 +107,7 @@
for (auto& i : m) {
if (i->type == json::ADDED) {
json::AddedMessage* j = (json::AddedMessage*)i;
- if (j->owner == "nseow" || j->owner == "jgrunbau" || j->owner == "zoar" || j->owner == "aobrien") {
+ 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,
--
Gitblit v1.10.0