Added new spartan command to clean up pcaps to just what we need.

This commit is contained in:
Pedro Pinto committed 2020-08-19 16:29:49 -04:00
1 parent 86ca092f18
commit 5c5bc243d2
14 files changed
+398 -190

No files matched your search

+19 -10
View File
@@ -2,15 +2,26 @@
#include "server/sparkd/cmds/spartan/algo/RunTAS.h"
#include "server/sparkd/cmds/spartan/analysis/RunAnalysis.h"
#include "server/sparkd/cmds/spartan/md/mdp3/common/InstrumentSnapshot.h"
#include "server/sparkd/cmds/spartan/md/mdp3/feed_control/IFeedController.h"
#include "server/sparkd/cmds/spartan/md/mdp3/handler/IChannelObserver.h"
#include "server/sparkd/cmds/spartan/md/mdp3/utils/mdp3_utils.h"
#include "server/sparkd/cmds/spartan/util/PCapReader.h"
#include "server/sparkd/cmds/spartan/md/mdp3/feed_control/AB_Arbitrageur.h"
#include "server/sparkd/cmds/spartan/md/mdp3/handler/ChannelHandler.h"
#include "server/sparkd/cmds/spartan/md/mdp3/feed_control/PickedFeed.h"
#include <fmt/format.h>
#include <fstream>
#include <iostream>
#include <Pcap++/PcapFileDevice.h>
namespace bts {
namespace cmd {
int slim_pcap(std::string const &file, std::string const &out_dir) {
return !spartan::mdp3::slim_down_pcap(file, out_dir);
}
int export_tables(std::string const &file, std::string const &out_dir) {
using namespace bts::spartan::mdp3;
@@ -25,15 +36,12 @@ int export_tables(std::string const &file, std::string const &out_dir) {
"first_st,last_st"
<< std::endl;
event_items
<< "eid, t_time,sid,status,type,"
"change,ok,side,"
"pri,price,qty,tid,agg"
<< std::endl;
event_items << "eid, t_time,sid,status,type,"
"change,ok,side,"
"pri,price,qty,tid,agg"
<< std::endl;
securities
<< "sid,symbol,group,asset,last_t"
<< std::endl;
securities << "sid,symbol,group,asset,last_t" << std::endl;
}
std::ofstream events;
@@ -155,8 +163,6 @@ int export_tables(std::string const &file, std::string const &out_dir) {
<< std::endl;
if (s->security_id().value() == 12181 && event_id == 1065)
std::cout << "There is" << std::endl;
auto deduced_order = s->deduced_order_change();
if (deduced_order) {
event_items << event_id << ","
@@ -211,6 +217,8 @@ int Spartan::execute(std::vector<std::string> const &args) {
error = spartan::convert_pcap_to_json(args);
else if (args[0] == "pcap_to_tables")
error = export_tables(args[1], args[2]);
else if (args[0] == "slim_pcap")
error = slim_pcap(args[1],args[2]);
}
if (error)
std::cout << help();
@@ -220,6 +228,7 @@ int Spartan::execute(std::vector<std::string> const &args) {
std::string Spartan::help() {
return fmt::format("\tpcap_to_msgs pcap_file\n"
"\tpcap_to_json pcap_file\n"
"\tslim_pcap in_pcap out_pcap\n"
"\tpcap_to_tables pcap_file output_dir\n");
}