This new structure provides several benefits:
* Allows us to install multiple CMake projects in the same destination
dir (without include path conflicts).
- This makes shipping the trading algo sdk a trivial excercise. Simply
copy the lib and include dirs from the install dest. That's it!
* Puts us in a position to break up the monolithic libspark into smaller
modules, which are easier to manage.
96 lines
3.5 KiB
C++
96 lines
3.5 KiB
C++
#include "AdminReport.h"
|
|
|
|
#include "spark/api/public/ServiceContext.h"
|
|
#include "spark/config/config.h"
|
|
#include "spark/config/protos/logging.pb.h"
|
|
#include "spark/logging/logging.h"
|
|
#include "spark/quickbus/quickbus.h"
|
|
|
|
#include "spark/api/service_helpers/AdminServiceUtils.h"
|
|
#include "spark/api/services/AdminService.client.pb.h"
|
|
|
|
#include <algorithm>
|
|
#include <boost/algorithm/string.hpp>
|
|
#include <iostream>
|
|
#include <map>
|
|
|
|
namespace bts::cmds {
|
|
|
|
void md_report() {
|
|
auto cfg = config::get<config::Logging>();
|
|
cfg.mutable_console()->set_default_level("Fatal");
|
|
log::configure_logging(cfg);
|
|
|
|
std::map<api::CMEMics, std::string> mic_map;
|
|
mic_map[api::CMEMics::CME] = "XCME";
|
|
mic_map[api::CMEMics::COMEX] = "XCEC";
|
|
mic_map[api::CMEMics::CBT] = "XCBT";
|
|
mic_map[api::CMEMics::NYMEX] = "XNYM";
|
|
|
|
// config::QuickbusNodeCfg qb_cfg;
|
|
// auto& ports = config::get<config::Ports>();
|
|
// qb_cfg.set_my_port(ports.qbus_port());
|
|
// qbus::Quickbus quickbus();
|
|
api::ServiceContext sc; // for Eric
|
|
|
|
api::admin::AdminService admin = sc.locate<api::admin::AdminService>();
|
|
auto res = admin.get_admin_data(api::VoidMessage());
|
|
if (res.success()) {
|
|
const api::admin::AdminData &data = *res.value();
|
|
std::cout << "User,Fullname,Company,Exchange,MIC,Display,Pro/NonPro"
|
|
<< std::endl;
|
|
for (const auto &u : data.users()) {
|
|
if (u.name() == "bts")
|
|
continue;
|
|
const bts::api::admin::CMEUserData *cme =
|
|
admin::AdminServiceUtils::get_user_cme_data(u, data);
|
|
if (cme) {
|
|
for (const auto &md : cme->md_permissions()) {
|
|
if (!md.enabled())
|
|
continue;
|
|
std::string mic_string = bts::api::CMEMics_Name(md.mic());
|
|
auto it = mic_map.find(md.mic());
|
|
if (it != mic_map.end())
|
|
mic_string = it->second;
|
|
std::string disp_string = (cme->display_nondisplay() ==
|
|
api::admin::DisplayDesignation::
|
|
DISPLAYDESIGNATION_NONDISPLAY)
|
|
? "NONDISPLAY"
|
|
: "DISPLAY";
|
|
std::string pro_string =
|
|
(cme->pro_nonpro() == api::admin::ProfessionalDesignation::
|
|
PROFESSIONALDESIGNATION_NONPRO)
|
|
? "NONPRO"
|
|
: "PRO";
|
|
|
|
std::string name_string = u.name();
|
|
name_string.erase(
|
|
std::remove(name_string.begin(), name_string.end(), ','),
|
|
name_string.end());
|
|
std::string full_string = u.full_name();
|
|
full_string.erase(
|
|
std::remove(full_string.begin(), full_string.end(), ','),
|
|
full_string.end());
|
|
std::string co_string = u.company();
|
|
co_string.erase(
|
|
std::remove(co_string.begin(), co_string.end(), ','),
|
|
co_string.end());
|
|
|
|
std::cout << name_string << "," << full_string << ","
|
|
<< co_string << ",CMEGroup," << mic_string << ","
|
|
<< disp_string << "," << pro_string << std::endl;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
AdminReport::AdminReport()
|
|
: CLI::App(
|
|
"Write a market data entitlement report csv to stdout",
|
|
"admin-report") {
|
|
add_subcommand("md")->callback(md_report);
|
|
}
|
|
|
|
} // namespace bts::cmds
|