Added some sql tools, added order deduction

This commit is contained in:
Pedro Pinto committed 2020-08-18 07:51:16 -04:00
1 parent 81bb5404cb
commit 7489d70c95
10 files changed
+463 -137

No files matched your search

+54 -28
View File
@@ -6,6 +6,7 @@
#include "lib/tracing/PerfLog.h"
#include "lib/utils/datetime.h"
#include "lib/config/protos/logging.pb.h"
#include "lib/domain_model/sod.h"
#include "lib/logging/logging.h"
#include "lib/utils/datetime.h"
@@ -30,55 +31,80 @@ namespace bts {
namespace cmd {
using namespace bts::orderman;
using namespace spartan::mdp3;
using namespace spartan;
void dump_snapshots() {
using namespace bts::spartan::mdp3;
using namespace bts::spartan;
struct TimeWriter {
mdp3::MDP3PacketView packet;
void on_begin_packet(mdp3::MDP3PacketView const &p) { packet = p; }
void on_end_packet() {
std::cout << packet.sending_time() << std::endl;
}
auto file = "/home/ppinto/es_md/es_all.pcap";
auto feed_map = guess_feed_map(file);
template <class M> void operator()(M const &) {
}
};
void print_times(std::string const &file) {
struct PacketBuffers {
spartan::mdp3::MDP3Packet i;
spartan::mdp3::MDP3Packet n;
};
auto feed_map = spartan::mdp3::guess_feed_map(file);
bts_assert(feed_map);
auto reader = PCapReader{file};
struct JSON_Writer {
mdp3::MDP3PacketView packet;
void on_begin_packet(mdp3::MDP3PacketView const &p) { packet = p; }
void on_end_packet() {}
mdp3::AB_Arbitrageur ab;
void operator()(::mdp3::SnapshotFullRefresh52 const &m) {
if (m.securityID() == 15234)
std::cout << "{\"SeqNum\": " << packet.seq_num() << ", "
<< " \"SendTime\": " << packet.sending_time() << ", "
<< " \"Size\": " << packet.size() << ","
<< " \"Msg\": " << m << "}\n";
reader.on_packet() = [&](auto const &info, auto const &payload) {
if ((info.dst_ip == feed_map.incremental[0].ip &&
info.dst_port == feed_map.incremental[0].port)) {
TimeWriter tw;
parse_packet(MDP3PacketView {payload},tw);
}
};
JSON_Writer writer;
reader.on_packet() = [&](auto const &, auto const &payload) {
parse_packet(mdp3::MDP3PacketView{payload}, writer);
return true;
};
while (reader.read_next())
;
}
int QuickTest::execute(std::vector<std::string> const &) {
// dump_snapshots();
int QuickTest::execute(std::vector<std::string> const &args) {
auto cfg = config::get<config::Logging>();
cfg.mutable_console()->set_default_level("Fatal");
log::configure_logging(cfg);
auto file = args[0];
print_times(file);
return 0;
using namespace bts::spartan::mdp3;
struct Obs : IChannelObserver {
void on_recovery_complete(
std::vector<InstrumentSnapshot const *> const &) override {}
std::vector<InstrumentSnapshot const *> const &secs) override {
for (auto s : secs) {
std::cout << "Bootstrap -----------------------------------------"
"------------------------------"
<< std::endl;
std::cout << "Symbol: " << s->definition().symbol() << std::endl
<< "Status: " << s->trading_status() << std::endl
<< "Orders:\n"
<< s->orders();
}
}
void on_real_time_event(MDP3Event const &ev) override {
for (auto s : ev.affected_securities) {
if (s->order_changes().size() || s->fills().size()) {
std::cout << "symbol: " << s->definition().symbol() << "\n"
<< "seq_num: " << ev.first_packet_sn << " to "
<< ev.last_packet_sn << "\n"
<< "changes:\n"
std::cout << "Event " << ev.transact_time
<< " -----------------------------" << std::endl;
std::cout << "Symbol: " << s->definition().symbol() << std::endl
<< "Status: " << s->trading_status() << std::endl
<< "Seq Num: " << ev.first_packet_sn << " to "
<< ev.last_packet_sn << std::endl
<< "Orders:\n"
<< s->order_changes() << "Fills:\n"
<< s->fills();
}
@@ -89,7 +115,7 @@ int QuickTest::execute(std::vector<std::string> const &) {
}
} obs;
spartan::observe_channel("/home/ppinto/es_md/es_all.pcap", obs);
spartan::observe_channel(file, obs);
return 0;
}