Refactored.
This commit is contained in:
1 parent
939c6442be
commit
f177441d07
16 files changed
+66
-66
No files matched your search
@@ -42,14 +42,14 @@ PolyObserver::~PolyObserver() {}
|
||||
void PolyObserver::init(ISim &s, protos::SimRunOptions const &) {
|
||||
me->sim = &s;
|
||||
for (auto &p : s.polygons()) {
|
||||
auto descriptor = polygon_descriptor(p.second, s.instruments());
|
||||
auto descriptor = polygon_descriptor(p.second, s.securities());
|
||||
|
||||
auto buy_t = Target{
|
||||
p.first, p.second, descriptor, api::SIDE_BUY,
|
||||
polygon_product(p.second, s.instruments())};
|
||||
polygon_product(p.second, s.securities())};
|
||||
auto sell_t = Target{
|
||||
p.first, flip(p.second), descriptor, api::SIDE_SELL,
|
||||
polygon_product(p.second, s.instruments())};
|
||||
polygon_product(p.second, s.securities())};
|
||||
|
||||
me->targets.emplace_back(std::make_unique<Target>(buy_t));
|
||||
me->targets.emplace_back(std::make_unique<Target>(sell_t));
|
||||
@@ -82,7 +82,7 @@ void PolyObserver::eval() {
|
||||
t->mark_as_worthless();
|
||||
break;
|
||||
} else {
|
||||
auto cash = me->sim->get_sec(l.sec_id).to_cash(mkt[0].price);
|
||||
auto cash = me->sim->get_security(l.sec_id).to_cash(mkt[0].price);
|
||||
t->quantity.value() = qty;
|
||||
t->value += -l.ratio * cash;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ void SniperModel::on_replay_start(
|
||||
parse_poly_filter(get_param(me->options, "polys")), h, streak_id});
|
||||
|
||||
for (auto &p : me->sim->polygons()) {
|
||||
auto desc = polygon_descriptor(p.second, me->sim->instruments());
|
||||
auto desc = polygon_descriptor(p.second, me->sim->securities());
|
||||
|
||||
if (me->polys.size() && !me->polys.count(desc))
|
||||
continue;
|
||||
@@ -136,7 +136,7 @@ void SniperModel::on_replay_start(
|
||||
for (auto &pp : t->polygon.parts) {
|
||||
auto &dt = me->books[pp.sec_id];
|
||||
dt.book.security_id = pp.sec_id;
|
||||
dt.definition = me->sim->get_sec(pp.sec_id);
|
||||
dt.definition = me->sim->get_security(pp.sec_id);
|
||||
t->leg_sec_info.push_back(&dt);
|
||||
auto &dependencies = dt.dependencies;
|
||||
dependencies.push_back(t.get());
|
||||
@@ -148,7 +148,7 @@ void SniperModel::on_replay_start(
|
||||
auto it = me->books.find(mbp.security_id);
|
||||
if (it != me->books.end()) {
|
||||
me->sim->log(
|
||||
"book_at_replay_start", me->sim->get_sec(mbp.security_id).symbol(),
|
||||
"book_at_replay_start", me->sim->get_security(mbp.security_id).symbol(),
|
||||
mbp.mbp_buy[0].price.to_double(), mbp.mbp_buy[0].quantity.value(),
|
||||
mbp.mbp_sell[0].price.to_double(), mbp.mbp_sell[0].quantity.value());
|
||||
it->second.book = mbp;
|
||||
@@ -216,7 +216,7 @@ void SniperModel::on_order_update(
|
||||
all_fills.insert(
|
||||
all_fills.end(), these_fills.begin(), these_fills.end());
|
||||
}
|
||||
PandL pandl(me->sim->instruments());
|
||||
PandL pandl(me->sim->securities());
|
||||
auto cash = pandl.net_cash(all_fills);
|
||||
auto commission = pandl.commission_cost(all_fills);
|
||||
auto net = cash - commission;
|
||||
@@ -295,11 +295,11 @@ void SniperModel::maybe_force_fills() {
|
||||
if (order.order.quantity.value() > total_fills) {
|
||||
Price worst_price = order.order.price;
|
||||
if (order.order.side == api::SIDE_BUY)
|
||||
worst_price += me->sim->get_sec(order.order.security)
|
||||
worst_price += me->sim->get_security(order.order.security)
|
||||
.min_price_increment_int_price() *
|
||||
100;
|
||||
else
|
||||
worst_price -= me->sim->get_sec(order.order.security)
|
||||
worst_price -= me->sim->get_security(order.order.security)
|
||||
.min_price_increment_int_price() *
|
||||
100;
|
||||
order.change = OrderChange::updated_price;
|
||||
@@ -431,7 +431,7 @@ void SniperModel::fire(Shot const &s) {
|
||||
for (auto const &b : me->books) {
|
||||
auto const &mbp = b.second.book;
|
||||
me->sim->log(
|
||||
"book_at_shot_start", me->sim->get_sec(mbp.security_id).symbol(),
|
||||
"book_at_shot_start", me->sim->get_security(mbp.security_id).symbol(),
|
||||
mbp.mbp_buy[0].price.to_double(), mbp.mbp_buy[0].quantity.value(),
|
||||
mbp.mbp_sell[0].price.to_double(), mbp.mbp_sell[0].quantity.value());
|
||||
}
|
||||
@@ -455,11 +455,11 @@ void SniperModel::fire(Shot const &s) {
|
||||
}
|
||||
if (part_side == api::SIDE_BUY)
|
||||
worst_price +=
|
||||
me->sim->get_sec(p.sec_id).min_price_increment_int_price() *
|
||||
me->sim->get_security(p.sec_id).min_price_increment_int_price() *
|
||||
100;
|
||||
else
|
||||
worst_price -=
|
||||
me->sim->get_sec(p.sec_id).min_price_increment_int_price() *
|
||||
me->sim->get_security(p.sec_id).min_price_increment_int_price() *
|
||||
100;
|
||||
|
||||
auto order_change = SmallOrderChange{};
|
||||
@@ -482,7 +482,7 @@ void SniperModel::fire(Shot const &s) {
|
||||
|
||||
auto limit_price = book[0].price;
|
||||
auto pay_up_adj =
|
||||
me->sim->get_sec(p.sec_id).min_price_increment_int_price() *
|
||||
me->sim->get_security(p.sec_id).min_price_increment_int_price() *
|
||||
me->pay_up_ticks;
|
||||
|
||||
if (part_side == api::SIDE_BUY)
|
||||
@@ -499,7 +499,7 @@ void SniperModel::fire(Shot const &s) {
|
||||
order_change.order.key = me->sim->send(order_change);
|
||||
me->sim->log(
|
||||
"sent_order", api::Side_Name(part_side),
|
||||
me->sim->get_sec(p.sec_id).symbol(), book[0].price.to_double(),
|
||||
me->sim->get_security(p.sec_id).symbol(), book[0].price.to_double(),
|
||||
book[0].price.to_double(), book[0].quantity.value());
|
||||
shot.working[order_change.order.key].order = order_change;
|
||||
}
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@
|
||||
|
||||
// class TestSimServices : public bts::spartan::mdp3::ISimServices{
|
||||
// private:
|
||||
// InstrumentMap _instruments;
|
||||
// SecurityMap _instruments;
|
||||
// std::unordered_map<size_t,Polygon> _polygons;
|
||||
|
||||
// protected:
|
||||
@@ -36,7 +36,7 @@
|
||||
// :
|
||||
// key(0){
|
||||
// }
|
||||
// InstrumentMap const &instruments() const override{
|
||||
// SecurityMap const &instruments() const override{
|
||||
// bts_assert(false);
|
||||
// return _instruments;
|
||||
// }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "server/sparkd/cmds/spartan/domain/InstrumentMap.h"
|
||||
#include "server/sparkd/cmds/spartan/domain/SecurityMap.h"
|
||||
#include "server/sparkd/cmds/spartan/md/common/mdp3_common.h"
|
||||
#include "server/sparkd/cmds/spartan/md/utils/polygon_utils.h"
|
||||
|
||||
@@ -12,8 +12,8 @@ class ISim {
|
||||
|
||||
// Queries
|
||||
virtual PolygonMap const &polygons() const = 0;
|
||||
virtual InstrumentMap const &instruments() const = 0;
|
||||
virtual SecurityDefinition const &get_sec(SecurityID id) const = 0;
|
||||
virtual SecurityMap const &securities() const = 0;
|
||||
virtual SecurityDefinition const &get_security(SecurityID id) const = 0;
|
||||
virtual TimeStamp time() const = 0;
|
||||
|
||||
// Actions
|
||||
|
||||
@@ -85,7 +85,7 @@ struct Sim::AlgoCBFilter : IAlgoModel {
|
||||
struct Sim::PImpl {
|
||||
AlgoCBFilter algo;
|
||||
protos::SimRunOptions options;
|
||||
InstrumentMap const &instruments;
|
||||
SecurityMap const &instruments;
|
||||
IcebergMap const &ib_map;
|
||||
PolygonMap const &polygons;
|
||||
PCapEventGenerator &event_generator;
|
||||
@@ -110,7 +110,7 @@ struct Sim::PImpl {
|
||||
Sim::Sim(
|
||||
IAlgoModel &algo,
|
||||
protos::SimRunOptions const &options,
|
||||
InstrumentMap const &instruments,
|
||||
SecurityMap const &instruments,
|
||||
IcebergMap const &ice,
|
||||
PolygonMap const &polys,
|
||||
PCapEventGenerator &gen,
|
||||
@@ -277,13 +277,13 @@ void Sim::on_pcap_event_during_replay() {
|
||||
for (auto &c : changes) {
|
||||
sim_log(
|
||||
"presim_order", ev.transact_time.value(),
|
||||
change_name(c.change), get_sec(c.order.security).symbol(),
|
||||
change_name(c.change), get_security(c.order.security).symbol(),
|
||||
c.order.price.to_double(), c.order.quantity.value(),
|
||||
Side_Name(c.order.side), c.order.key.value(),
|
||||
c.order.key.value());
|
||||
}
|
||||
sim_log(
|
||||
"presim_book", get_sec(mbp.security_id).symbol(),
|
||||
"presim_book", get_security(mbp.security_id).symbol(),
|
||||
mbp.mbp_buy[0].price.to_double(),
|
||||
mbp.mbp_buy[0].quantity.value(),
|
||||
mbp.mbp_sell[0].price.to_double(),
|
||||
@@ -340,7 +340,7 @@ void Sim::on_pcap_event_during_simulation() {
|
||||
sim_log(
|
||||
"pcap_order", ev.transact_time.value(),
|
||||
change_name(corder.change),
|
||||
get_sec(corder.order.security).symbol(),
|
||||
get_security(corder.order.security).symbol(),
|
||||
corder.order.price.to_double(),
|
||||
corder.order.quantity.value(), Side_Name(corder.order.side),
|
||||
corder.order.key.value(), corder.original_key.value());
|
||||
@@ -365,7 +365,7 @@ void Sim::on_algo_action() {
|
||||
|
||||
sim_log(
|
||||
"algo_order", algo_action.transact_time.value(),
|
||||
change_name(change.change), get_sec(change.order.security).symbol(),
|
||||
change_name(change.change), get_security(change.order.security).symbol(),
|
||||
change.order.price.to_double(), change.order.quantity.value(),
|
||||
Side_Name(change.order.side), change.order.key.value(), 0);
|
||||
|
||||
@@ -398,7 +398,7 @@ void Sim::_start_simulation() {
|
||||
overloaded{
|
||||
[&](MBPUpdate &mbp) {
|
||||
sim_log(
|
||||
"sim_book_init", get_sec(mbp.security_id).symbol(),
|
||||
"sim_book_init", get_security(mbp.security_id).symbol(),
|
||||
mbp.mbp_buy[0].price.to_double(),
|
||||
mbp.mbp_buy[0].quantity.value(),
|
||||
mbp.mbp_sell[0].price.to_double(),
|
||||
@@ -467,7 +467,7 @@ void Sim::match_and_send_effects(
|
||||
[&](MBPUpdate const &mbp) {
|
||||
if (me->options.log_all_transactions())
|
||||
sim_log(
|
||||
"sim_book", get_sec(mbp.security_id).symbol(),
|
||||
"sim_book", get_security(mbp.security_id).symbol(),
|
||||
mbp.mbp_buy[0].price.to_double(),
|
||||
mbp.mbp_buy[0].quantity.value(),
|
||||
mbp.mbp_sell[0].price.to_double(),
|
||||
@@ -479,7 +479,7 @@ void Sim::match_and_send_effects(
|
||||
sim_log(
|
||||
"algo_fill", order_update.status_str(),
|
||||
Side_Name(order_update.side),
|
||||
get_sec(order_update.security_id).symbol(),
|
||||
get_security(order_update.security_id).symbol(),
|
||||
order_update.last_price.to_double(),
|
||||
order_update.last_fills.value(),
|
||||
order_update.key.value(), 0);
|
||||
@@ -490,7 +490,7 @@ void Sim::match_and_send_effects(
|
||||
sim_log(
|
||||
"fill", order_update.status_str(),
|
||||
Side_Name(order_update.side),
|
||||
get_sec(order_update.security_id).symbol(),
|
||||
get_security(order_update.security_id).symbol(),
|
||||
order_update.last_price.to_double(),
|
||||
order_update.last_fills.value(),
|
||||
order_update.key.value(),
|
||||
@@ -575,9 +575,9 @@ Sim::correct_pcap_order(OrderChange const &o, bool set_exact_ib_state) {
|
||||
|
||||
PolygonMap const &Sim::polygons() const { return me->polygons; }
|
||||
|
||||
InstrumentMap const &Sim::instruments() const { return me->instruments; }
|
||||
SecurityMap const &Sim::securities() const { return me->instruments; }
|
||||
|
||||
SecurityDefinition const &Sim::get_sec(SecurityID id) const {
|
||||
SecurityDefinition const &Sim::get_security(SecurityID id) const {
|
||||
auto it = me->instruments.find(id);
|
||||
bts_assert(it != me->instruments.end());
|
||||
return *it->second;
|
||||
@@ -600,7 +600,7 @@ double Sim::price_at_market(SecurityID id, Quantity qty, Side s) const {
|
||||
else {
|
||||
auto from_this_level = std::min(remaining_qty, l.quantity.value());
|
||||
cummulative_flow +=
|
||||
(from_this_level * get_sec(id).to_cash(l.price.to_double()));
|
||||
(from_this_level * get_security(id).to_cash(l.price.to_double()));
|
||||
remaining_qty -= from_this_level;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "server/sparkd/cmds/spartan/back_testing/sim/ISim.h"
|
||||
#include "server/sparkd/cmds/spartan/back_testing/sim/pandl/PandLSummary.h"
|
||||
#include "server/sparkd/cmds/spartan/md/channel_observers/IcebergFinder.h"
|
||||
#include "server/sparkd/cmds/spartan/domain/InstrumentMap.h"
|
||||
#include "server/sparkd/cmds/spartan/domain/SecurityMap.h"
|
||||
|
||||
namespace bts::spartan::mdp3 {
|
||||
struct EventHeader;
|
||||
@@ -25,7 +25,7 @@ class Sim : ISim {
|
||||
public:
|
||||
Sim(IAlgoModel &algo,
|
||||
protos::SimRunOptions const &,
|
||||
InstrumentMap const &im,
|
||||
SecurityMap const &im,
|
||||
IcebergMap const &,
|
||||
PolygonMap const &,
|
||||
PCapEventGenerator &,
|
||||
@@ -36,8 +36,8 @@ class Sim : ISim {
|
||||
private:
|
||||
// From ISim
|
||||
PolygonMap const &polygons() const override;
|
||||
InstrumentMap const &instruments() const override;
|
||||
SecurityDefinition const &get_sec(SecurityID id) const override;
|
||||
SecurityMap const &securities() const override;
|
||||
SecurityDefinition const &get_security(SecurityID id) const override;
|
||||
TimeStamp time() const override;
|
||||
void log_pandl() const override;
|
||||
OrderKey
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
namespace bts::spartan::mdp3 {
|
||||
|
||||
struct PandL::PImpl {
|
||||
InstrumentMap const &instruments;
|
||||
SecurityMap const &instruments;
|
||||
Pricer pricer;
|
||||
};
|
||||
|
||||
PandL::PandL(InstrumentMap const &m, Pricer const &p) : me(new PImpl{m, p}) {}
|
||||
PandL::PandL(SecurityMap const &m, Pricer const &p) : me(new PImpl{m, p}) {}
|
||||
PandL::~PandL() {}
|
||||
|
||||
double PandL::net_cash(std::vector<OrderUpdate> const &fills) const {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/os/os.h"
|
||||
#include "server/sparkd/cmds/spartan/domain/InstrumentMap.h"
|
||||
#include "server/sparkd/cmds/spartan/domain/SecurityMap.h"
|
||||
#include "server/sparkd/cmds/spartan/md/common/mdp3_common.h"
|
||||
|
||||
#include <cstdint>
|
||||
@@ -20,7 +20,7 @@ class PandL {
|
||||
using OutrightPosition = std::unordered_map<SecurityID, int64_t>;
|
||||
|
||||
PandL(
|
||||
InstrumentMap const &,
|
||||
SecurityMap const &,
|
||||
Pricer const & = [](auto, auto, auto) { return os::nan(); });
|
||||
~PandL();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ PCapEventSource::PCapEventSource(std::string const &pcap)
|
||||
|
||||
PCapEventSource::~PCapEventSource() {}
|
||||
|
||||
InstrumentMap const &PCapEventSource::instruments() const {
|
||||
SecurityMap const &PCapEventSource::instruments() const {
|
||||
return me->dc.ptr_result;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "server/sparkd/cmds/spartan/md/utils/polygon_utils.h"
|
||||
#include "server/sparkd/cmds/spartan/md/channel_observers/IcebergFinder.h"
|
||||
#include "server/sparkd/cmds/spartan/domain/SecurityDefinition.h"
|
||||
#include "server/sparkd/cmds/spartan/domain/InstrumentMap.h"
|
||||
#include "server/sparkd/cmds/spartan/domain/SecurityMap.h"
|
||||
|
||||
|
||||
namespace bts::spartan::mdp3 {
|
||||
@@ -24,7 +24,7 @@ class PCapEventSource {
|
||||
public:
|
||||
PCapEventSource(std::string const &pcap);
|
||||
~PCapEventSource();
|
||||
InstrumentMap const &instruments() const;
|
||||
SecurityMap const &instruments() const;
|
||||
std::unordered_map<size_t, Polygon> const &polygons() const;
|
||||
IcebergMap const &icebergs() const;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// //#include "lib/orderman/orders/algo/IBeforeLaunchAlgoServices.h"
|
||||
// //#include "../ISimServices.h"
|
||||
// #include "server/sparkd/cmds/spartan/md/common/SecurityDefinition.h"
|
||||
// #include "server/sparkd/cmds/spartan/md/common/InstrumentMap.h"
|
||||
// #include "server/sparkd/cmds/spartan/md/common/SecurityMap.h"
|
||||
// #include "server/sparkd/cmds/spartan/back_testing/simulator/AlgoEvent.h"
|
||||
// #include "lib/orderman/orderman_utils/Book.h"
|
||||
// #include "server/sparkd/cmds/spartan/md/common/mdp3_common.h"
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
// inline bts::api::Security convert_to_spark_security (
|
||||
// bts::spartan::mdp3::SecurityDefinition const* def_ptr,
|
||||
// const bts::spartan::mdp3::InstrumentMap& sec_map){
|
||||
// const bts::spartan::mdp3::SecurityMap& sec_map){
|
||||
// auto fill_common = [](const auto& def, auto out_sec){
|
||||
// out_sec.set_id(map_sec_key(def.security_id()).value());
|
||||
// out_sec.set_symbol(def.security_group());
|
||||
|
||||
+2
-2
@@ -5,11 +5,11 @@
|
||||
|
||||
namespace bts::spartan::mdp3 {
|
||||
class SecurityDefinition;
|
||||
using InstrumentMap =
|
||||
using SecurityMap =
|
||||
std::unordered_map<SecurityID, SecurityDefinition const *>;
|
||||
|
||||
inline SecurityDefinition const &
|
||||
get_sec(SecurityID id, InstrumentMap const &m) {
|
||||
get_sec(SecurityID id, SecurityMap const &m) {
|
||||
auto it = m.find(id);
|
||||
bts_assert(it != m.end());
|
||||
return *it->second;
|
||||
@@ -111,7 +111,7 @@ std::istream &operator>>(std::istream &in, PolygonValuation &v) {
|
||||
void poly_values_to_csv(
|
||||
std::vector<PolygonValuation> const &vals,
|
||||
PolygonMap &,
|
||||
InstrumentMap &,
|
||||
SecurityMap &,
|
||||
std::ofstream &poly_values) {
|
||||
for (auto &v : vals) {
|
||||
single_pv_to_csv(poly_values, v);
|
||||
@@ -122,7 +122,7 @@ void poly_values_to_csv(
|
||||
void poly_opportunities_to_csv(
|
||||
std::vector<PolygonOpportunity> const &ops,
|
||||
PolygonMap &pmap,
|
||||
InstrumentMap &imap,
|
||||
SecurityMap &imap,
|
||||
std::ofstream &out) {
|
||||
for (auto &op : ops) {
|
||||
out << op.opportunity_id << "," << op.polygon_id << ","
|
||||
@@ -268,7 +268,7 @@ struct PolygonOpportunityFinder::SnapshotRec {
|
||||
|
||||
struct PolygonOpportunityFinder::PImpl {
|
||||
PolygonMap const &all_polygons;
|
||||
InstrumentMap const &imap;
|
||||
SecurityMap const &imap;
|
||||
std::unordered_set<size_t> active_polygons = {};
|
||||
std::unordered_map<SecurityID, SnapshotRec> all_snapshots = {};
|
||||
std::unordered_map<SecurityID, std::vector<size_t>> dependencies = {};
|
||||
@@ -277,7 +277,7 @@ struct PolygonOpportunityFinder::PImpl {
|
||||
};
|
||||
|
||||
PolygonOpportunityFinder::PolygonOpportunityFinder(
|
||||
PolygonMap const &polys, InstrumentMap const &imap)
|
||||
PolygonMap const &polys, SecurityMap const &imap)
|
||||
: me(new PImpl{polys, imap}) {
|
||||
for (auto &[pid, p] : polys) {
|
||||
auto desc = polygon_descriptor(p, imap);
|
||||
|
||||
@@ -63,19 +63,19 @@ aggregate(std::vector<PolygonValuation> const &);
|
||||
void poly_values_to_csv(
|
||||
std::vector<PolygonValuation> const &,
|
||||
PolygonMap &,
|
||||
InstrumentMap &,
|
||||
SecurityMap &,
|
||||
std::ofstream &);
|
||||
|
||||
void poly_opportunities_to_csv(
|
||||
std::vector<PolygonOpportunity> const &,
|
||||
PolygonMap &,
|
||||
InstrumentMap &,
|
||||
SecurityMap &,
|
||||
std::ofstream &);
|
||||
|
||||
struct PolygonOpportunityFinder : IChannelObserver {
|
||||
std::vector<PolygonValuation> result;
|
||||
|
||||
PolygonOpportunityFinder(PolygonMap const &, InstrumentMap const &);
|
||||
PolygonOpportunityFinder(PolygonMap const &, SecurityMap const &);
|
||||
~PolygonOpportunityFinder();
|
||||
|
||||
private:
|
||||
|
||||
@@ -23,7 +23,7 @@ PolyInstrument make_outright(mdp3::SecurityID id) {
|
||||
}
|
||||
|
||||
const SecurityDefinition &
|
||||
find_instrument(const InstrumentMap &ins_map, SecurityID sec_id) {
|
||||
find_instrument(const SecurityMap &ins_map, SecurityID sec_id) {
|
||||
auto it = ins_map.find(sec_id);
|
||||
bts_assert(it != ins_map.end());
|
||||
bts_assert(it->second);
|
||||
@@ -235,7 +235,7 @@ std::vector<Polygon> find_polygons(
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t abs_contracts(const Polygon &polygon, const InstrumentMap &ins_map) {
|
||||
uint32_t abs_contracts(const Polygon &polygon, const SecurityMap &ins_map) {
|
||||
auto find_def = [&](SecurityID id) {
|
||||
auto it = ins_map.find(id);
|
||||
bts_assert(it != ins_map.end());
|
||||
@@ -264,7 +264,7 @@ uint32_t abs_contracts(const Polygon &polygon, const InstrumentMap &ins_map) {
|
||||
return static_cast<uint32_t>(rv);
|
||||
}
|
||||
|
||||
double tick_size(const Polygon &polygon, const InstrumentMap &ins_map) {
|
||||
double tick_size(const Polygon &polygon, const SecurityMap &ins_map) {
|
||||
double rv = 0;
|
||||
for (const InstrumentPart &p : polygon.parts) {
|
||||
auto price_inc = find_instrument(ins_map, p.sec_id).min_price_increment();
|
||||
@@ -351,7 +351,7 @@ clusterize(std::vector<PolyInstrument> const &universe) {
|
||||
}
|
||||
|
||||
std::string
|
||||
polygon_descriptor(Polygon const &p, InstrumentMap const &instruments) {
|
||||
polygon_descriptor(Polygon const &p, SecurityMap const &instruments) {
|
||||
|
||||
auto get_sec = [&instruments](SecurityID id) {
|
||||
auto it = instruments.find(id);
|
||||
@@ -400,7 +400,7 @@ polygon_descriptor(Polygon const &p, InstrumentMap const &instruments) {
|
||||
}
|
||||
|
||||
std::string
|
||||
polygon_product(Polygon const &polygon, InstrumentMap const &ins_map) {
|
||||
polygon_product(Polygon const &polygon, SecurityMap const &ins_map) {
|
||||
for (const InstrumentPart &p : polygon.parts) {
|
||||
const auto &ins = find_instrument(ins_map, p.sec_id);
|
||||
return std::string(ins.asset());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../common/mdp3_common.h"
|
||||
#include "server/sparkd/cmds/spartan/domain/InstrumentMap.h"
|
||||
#include "server/sparkd/cmds/spartan/domain/SecurityMap.h"
|
||||
#include <algorithm>
|
||||
#include <boost/container/small_vector.hpp>
|
||||
|
||||
@@ -21,17 +21,17 @@ make_spread(mdp3::SecurityID, std::initializer_list<InstrumentPart> legs);
|
||||
PolyInstrument make_outright(mdp3::SecurityID);
|
||||
|
||||
const SecurityDefinition &
|
||||
find_instrument(const InstrumentMap &map, SecurityID sec_id);
|
||||
find_instrument(const SecurityMap &map, SecurityID sec_id);
|
||||
struct Polygon {
|
||||
InstrumentParts parts;
|
||||
};
|
||||
|
||||
uint32_t abs_contracts(const Polygon &polygon, const InstrumentMap &ins_map);
|
||||
double tick_size(const Polygon &polygon, const InstrumentMap &ins_map);
|
||||
uint32_t abs_contracts(const Polygon &polygon, const SecurityMap &ins_map);
|
||||
double tick_size(const Polygon &polygon, const SecurityMap &ins_map);
|
||||
using PolygonMap = std::unordered_map<size_t, Polygon>;
|
||||
|
||||
std::string polygon_descriptor(Polygon const &, InstrumentMap const &);
|
||||
std::string polygon_product(Polygon const &, InstrumentMap const &);
|
||||
std::string polygon_descriptor(Polygon const &, SecurityMap const &);
|
||||
std::string polygon_product(Polygon const &, SecurityMap const &);
|
||||
|
||||
inline api::Side side_from_ratio(int ratio) {
|
||||
if (ratio > 0)
|
||||
|
||||
Reference in new issue
Block a user