Moved ouput messages to log.
This commit is contained in:
1 parent
41ec7fb668
commit
112c78e50b
4 files changed
+43
-40
No files matched your search
@@ -36,6 +36,7 @@ namespace bts {
|
||||
Plugin,
|
||||
Sdk,
|
||||
Http,
|
||||
Spartan,
|
||||
// Please keep this list in sync with logging.h/logging.cpp
|
||||
}
|
||||
|
||||
|
||||
@@ -120,6 +120,7 @@ void configure_logging(bts::config::Logging const&cfg, bts::config::ThreadGroupC
|
||||
{log::Plugin,"Plugin"},
|
||||
{log::Sdk,"Sdk"},
|
||||
{log::Http,"Http"},
|
||||
{log::Spartan,"Spartan"},
|
||||
};
|
||||
|
||||
real_cfg.sinks["console"] =
|
||||
|
||||
@@ -46,6 +46,7 @@ constexpr log::Subsystem DataFlow {Latency.ordinal+1 };
|
||||
constexpr log::Subsystem Plugin {DataFlow.ordinal+1 };
|
||||
constexpr log::Subsystem Sdk {Plugin.ordinal+1 };
|
||||
constexpr log::Subsystem Http {Sdk.ordinal+1 };
|
||||
constexpr log::Subsystem Spartan {Http.ordinal+1 };
|
||||
|
||||
struct LoggerHandle {
|
||||
LoggerHandle(LoggerHandle const&) = delete;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "lib/api/service_helpers/AdminServiceUtils.h"
|
||||
#include "lib/config/config.h"
|
||||
#include "lib/config/protos/spartan.pb.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/md/cme/MDP3Utils.h"
|
||||
#include "server/sparkd/cmds/spartan_tas/algo/TASOrderReactor.h"
|
||||
#include "server/sparkd/cmds/spartan_tas/algo/TASTriggerDef.h"
|
||||
@@ -42,21 +43,21 @@ build_trigger_defs(SecurityDB &db, config::SpartanTASCfg const &cfg) {
|
||||
auto const &sym = t.future_symbol();
|
||||
auto sec = db.query_single([&sym](auto const &sec) {
|
||||
return sec.has_glbx() && sec.has_future() &&
|
||||
securities::descriptor(sec) == sym;
|
||||
securities::descriptor(sec) == sym;
|
||||
});
|
||||
bts_assert(sec);
|
||||
admin::AdminServiceOperationResult result;
|
||||
auto rr = admin::AdminServiceUtils::get_routing_record(
|
||||
admin.value(), account, user_name, *sec, result);
|
||||
admin.value(), account, user_name, *sec, result);
|
||||
bts_assert_msg(result.is_success(), result.error_text());
|
||||
|
||||
auto sec_trigger = TASTriggerDef::SecTrigger{*sec, rr, {}};
|
||||
sec_trigger.side.set(
|
||||
api::Side::SIDE_BUY,
|
||||
TASTriggerDef::Side{t.buy().quantity(), t.buy().ticks_away()});
|
||||
api::Side::SIDE_BUY,
|
||||
TASTriggerDef::Side{t.buy().quantity(), t.buy().ticks_away()});
|
||||
sec_trigger.side.set(
|
||||
api::Side::SIDE_SELL,
|
||||
TASTriggerDef::Side{t.sell().quantity(), t.sell().ticks_away()});
|
||||
api::Side::SIDE_SELL,
|
||||
TASTriggerDef::Side{t.sell().quantity(), t.sell().ticks_away()});
|
||||
auto trigger = get_trigger(sec->glbx().cme_symbol());
|
||||
trigger->sec_triggers.push_back(sec_trigger);
|
||||
}
|
||||
@@ -102,31 +103,31 @@ validate_trigger_defs(std::vector<TASTriggerDef> const &defs) {
|
||||
|
||||
std::vector<TASTriggerDef> build_and_validate_triggers(SecurityDB &db) {
|
||||
auto triggers = build_trigger_defs(db, config::get<config::SpartanTASCfg>());
|
||||
std::cout << "TAS Trigger layout: "
|
||||
<< "\n";
|
||||
std::cout << "-----------------------------------------------------------"
|
||||
"---------------------\n";
|
||||
LOG(Spartan,Info, "TAS Trigger layout: \n"
|
||||
"-----------------------------------------------------------"
|
||||
"---------------------");
|
||||
for (auto const &t : triggers)
|
||||
std::cout << t;
|
||||
std::cout << "-----------------------------------------------------------"
|
||||
"---------------------\n\n";
|
||||
LOG(Spartan,Info,"{}",t);
|
||||
|
||||
LOG(Spartan,Info,"-----------------------------------------------------------"
|
||||
"---------------------");
|
||||
|
||||
auto valid = validate_trigger_defs(triggers);
|
||||
if (std::holds_alternative<std::string>(valid)) {
|
||||
std::cerr << "Invalid TAS trigger definition in config: "
|
||||
<< std::get<std::string>(valid) << "\n";
|
||||
LOG(Spartan, Error, "Invalid TAS trigger definition in config: {}",
|
||||
std::get<std::string>(valid));
|
||||
std::exit(-1);
|
||||
}
|
||||
return triggers;
|
||||
}
|
||||
|
||||
std::set<md::UserSymbol> get_symbols(SecurityDB &db,
|
||||
config::SpartanTASCfg const &cfg) {
|
||||
config::SpartanTASCfg const &cfg) {
|
||||
std::set<md::UserSymbol> result;
|
||||
for (auto const &t : cfg.tas_trigger()) {
|
||||
auto sec = db.query_single([&t](auto const &sec) {
|
||||
return sec.has_glbx() && sec.has_future() &&
|
||||
securities::descriptor(sec) == t.future_symbol();
|
||||
securities::descriptor(sec) == t.future_symbol();
|
||||
});
|
||||
bts_assert(sec);
|
||||
|
||||
@@ -142,19 +143,19 @@ std::vector<md::CMEConnection> get_connections(SecurityDB &db) {
|
||||
|
||||
std::vector<md::CMEConnection> result;
|
||||
auto find_inc_feed_connection =
|
||||
[](std::map<std::string, md::CMEConnection> const &m)
|
||||
-> md::CMEConnection {
|
||||
for (auto const &p : m) {
|
||||
if (p.second.feed_type == "I" && p.second.feed == 'A')
|
||||
return p.second;
|
||||
}
|
||||
bts_assert(false);
|
||||
return {};
|
||||
};
|
||||
[](std::map<std::string, md::CMEConnection> const &m)
|
||||
-> md::CMEConnection {
|
||||
for (auto const &p : m) {
|
||||
if (p.second.feed_type == "I" && p.second.feed == 'A')
|
||||
return p.second;
|
||||
}
|
||||
bts_assert(false);
|
||||
return {};
|
||||
};
|
||||
|
||||
auto channels = md::get_configured_cme_channels();
|
||||
for (auto const &c : channels) {
|
||||
for (auto const &sym :cme_symbols) {
|
||||
for (auto const &sym : cme_symbols) {
|
||||
if (c.symbols.count(sym))
|
||||
result.push_back(find_inc_feed_connection(c.connections));
|
||||
}
|
||||
@@ -170,27 +171,26 @@ int Spartan::run_from_mcast(std::vector<std::string> const &args) {
|
||||
auto triggers = build_and_validate_triggers(db);
|
||||
auto connections = get_connections(db);
|
||||
if (connections.empty()) {
|
||||
std::cerr << "Could not find connections for selected TAS symbols\n";
|
||||
LOG(Spartan, Error,
|
||||
"Could not find connections for selected TAS symbols");
|
||||
std::exit(1);
|
||||
}
|
||||
for (auto &c : connections) {
|
||||
std::cout << "Listening on " << c << "\n";
|
||||
LOG(Spartan,Info,"Listening on {}",c);
|
||||
}
|
||||
|
||||
|
||||
boost::asio::io_service io;
|
||||
utils::MDPParser parser;
|
||||
utils::MDPWriter writer(std::cout, parser);
|
||||
TASOrderReactor reactor(triggers);
|
||||
|
||||
parser.set_handler<mktdata::SecurityStatus30>(
|
||||
[&reactor](auto const &sec_status) {
|
||||
reactor.on_security_status(sec_status);
|
||||
});
|
||||
|
||||
[&reactor](auto const &sec_status) {
|
||||
reactor.on_security_status(sec_status);
|
||||
});
|
||||
std::vector<std::unique_ptr<utils::MCastReceiver>> mc_receivers;
|
||||
for (auto const &c : connections) {
|
||||
auto receiver =
|
||||
std::make_unique<utils::MCastReceiver>(io, "0.0.0.0", c.ip, c.port);
|
||||
std::make_unique<utils::MCastReceiver>(io, "0.0.0.0", c.ip, c.port);
|
||||
receiver->on_receive() = [&parser](auto const &bytes) {
|
||||
parser.on_bytes(bytes);
|
||||
};
|
||||
@@ -216,9 +216,9 @@ int Spartan::run_from_pcap(std::vector<std::string> const &args) {
|
||||
utils::MDPParser parser;
|
||||
|
||||
parser.set_handler<mktdata::SecurityStatus30>(
|
||||
[&reactor](auto const &sec_status) {
|
||||
reactor.on_security_status(sec_status);
|
||||
});
|
||||
[&reactor](auto const &sec_status) {
|
||||
reactor.on_security_status(sec_status);
|
||||
});
|
||||
|
||||
pcap_reader.on_packet() = [&parser](auto const &bytes) {
|
||||
parser.on_bytes(bytes);
|
||||
@@ -238,7 +238,7 @@ int Spartan::parse_pcap(std::vector<std::string> const &args) {
|
||||
utils::MDPParser parser;
|
||||
utils::MDPWriter writer(std::cout, parser);
|
||||
utils::PCapReader pcap_reader(
|
||||
args[1], args.size() == 3 ? std::string("net ") + args[2] : "");
|
||||
args[1], args.size() == 3 ? std::string("net ") + args[2] : "");
|
||||
|
||||
pcap_reader.on_packet() = [&parser](auto const &bytes) {
|
||||
if (parser.on_bytes(bytes))
|
||||
|
||||
Reference in new issue
Block a user