Filling in the bridge 1

This commit is contained in:
Taha Afzal committed 2020-11-05 16:31:22 -05:00
1 parent 89d9585ad8
commit 74267bbba9
2 files changed
+49 -6

No files matched your search

@@ -1,32 +1,57 @@
#include "BeforeLaunchBridge.h"
#include "../ISimServices.h"
#include "BridgeCommon.h"
namespace bts {
namespace orderman {
using namespace bts::spartan::mdp3;
typedef std::map<InstrumentDefinition const*, api::Security,
std::function<bool(InstrumentDefinition const*,
InstrumentDefinition const*)> > InsMap;
struct BeforeLaunchBridge::PImpl {
OrderKey ok;
MDP3SecurityID sec_id;
ISimServices& sim_services;
const api::orderman::OrderDefinition& order_def;
ChildTemplate* child_temp = nullptr;
api::Security security;
TimeStamp ts;
InsMap sec_map = InsMap([](const auto& a, const auto& b) {
return a->security_id().value() < b->security_id().value();
});
PImpl(
OrderKey ok,
MDP3SecurityID sec_id,
ISimServices& sim_services,
const api::orderman::OrderDefinition& order_def)
:
ok(ok),
sec_id(sec_id),
sim_services(sim_services),
order_def(order_def) {
}
};
// TODO:
// order def translation (ex sniper)
// security translation (in BridgeCommon)
// ChildTemplate
// timestamp
BeforeLaunchBridge::BeforeLaunchBridge(
ISimServices& sim_services,
const api::orderman::OrderDefinition& order_def)
:
me(new PImpl(sim_services, order_def))
{
me(new PImpl(OrderKey(0),MDP3SecurityID(0),sim_services,order_def)){
for (const auto& p : me->sim_services.instruments()){
auto mdp3_sec_ptr = p.second;
api::Security sec = convert_to_spark_security(mdp3_sec_ptr);
me->sec_map.insert({mdp3_sec_ptr,sec});
}
}
const api::orderman::OrderDefinition& BeforeLaunchBridge::definition() const{
@@ -38,19 +63,25 @@ const api::Security& BeforeLaunchBridge::security() const{
}
OrderKey BeforeLaunchBridge::order_key() const{
return OrderKey(0);
return me->ok;
}
OrderKey BeforeLaunchBridge::parent_order_key() const{
return OrderKey(0);
// not supported in spartan sim
return order_key();
}
api::Security const * BeforeLaunchBridge::lookup_security(SecurityKey) const{
api::Security const* BeforeLaunchBridge::lookup_security(SecurityKey k) const{
for (const auto& p : me->sec_map)
if(p.second.id() == k.value())
return &p.second;
return nullptr;
}
std::vector<api::Security const*> BeforeLaunchBridge::known_securities() const{
std::vector<api::Security const*> rv;
for (const auto& p : me->sec_map)
rv.push_back(&p.second);
return rv;
}
@@ -61,13 +92,14 @@ bool BeforeLaunchBridge::is_attaching() const{
ChildTemplate& BeforeLaunchBridge::make_child_template(
const api::orderman::OrderDefinition&,
size_t){
// TODO
return *me->child_temp;
}
// Get the current time
TimeStamp BeforeLaunchBridge::get_time() const{
// TODO
return me->ts;
}
}}
@@ -0,0 +1,11 @@
#include "lib/orderman/orders/algo/IAlgoOrder.h"
#include "lib/orderman/orders/algo/IBeforeLaunchAlgoServices.h"
#include "../ISimServices.h"
#include "server/sparkd/cmds/spartan/md/mdp3/common/InstrumentDefinition.h"
bts::api::Security convert_to_spark_security (
bts::spartan::mdp3::InstrumentDefinition const*){
// TODO
bts::api::Security sec;
return sec;
}