Bridge filling in
This commit is contained in:
1 parent
2f032def09
commit
2df07f446b
5 files changed
+101
-35
No files matched your search
@@ -7,7 +7,7 @@ class OrderBuilder;
|
||||
|
||||
class ChildTemplate {
|
||||
public:
|
||||
ChildTemplate();
|
||||
ChildTemplate(){};
|
||||
|
||||
private:
|
||||
ChildTemplate(OrderKey parent_key, api::orderman::OrderDefinition const &def,
|
||||
|
||||
+68
-21
@@ -1,6 +1,12 @@
|
||||
#include "lib/orderman/orders/algo/IAlgoOrder.h"
|
||||
#include "lib/orderman/orders/algo/IAlgoServices.h"
|
||||
// /#include "BeforeLaunchBridge.h"
|
||||
#include "server/sparkd/cmds/spartan/md/mdp3/back_testing/simulator/ISimServices.h"
|
||||
#include "AlgoServicesBridge.h"
|
||||
#include "lib/orderman/actors/order_manager/OrderBuilder.h"
|
||||
#include "lib/orderman/orders/algo/ChildTemplate.h"
|
||||
#include "lib/orderman/orderman_utils/Book.h"
|
||||
|
||||
|
||||
using namespace bts::spartan::mdp3;
|
||||
using namespace bts::api;
|
||||
@@ -10,11 +16,22 @@ namespace orderman {
|
||||
|
||||
struct AlgoServicesBridge::PImpl {
|
||||
std::vector<PositionUpdate> pos;
|
||||
PImpl(){
|
||||
IAlgoOrder& algo_order;
|
||||
ISimServices& sim_services;
|
||||
std::unordered_map<SecurityKey,Book> _book_map;
|
||||
PImpl(IAlgoOrder& algo_order,
|
||||
ISimServices& sim_services)
|
||||
:
|
||||
algo_order(algo_order),
|
||||
sim_services(sim_services){
|
||||
}
|
||||
};
|
||||
|
||||
AlgoServicesBridge::AlgoServicesBridge(){
|
||||
AlgoServicesBridge::AlgoServicesBridge(IAlgoOrder& algo_order,
|
||||
ISimServices& sim_services)
|
||||
:
|
||||
me(new PImpl(algo_order, sim_services))
|
||||
{
|
||||
}
|
||||
|
||||
Price AlgoServicesBridge::price() const{
|
||||
@@ -26,7 +43,7 @@ Quantity AlgoServicesBridge::quantity() const {
|
||||
}
|
||||
|
||||
Quantity AlgoServicesBridge::total_fills() const{
|
||||
return Quantity(0);
|
||||
return Quantity(0);
|
||||
}
|
||||
|
||||
bool AlgoServicesBridge::is_shutting_down() const {
|
||||
@@ -42,46 +59,62 @@ trace::CorID AlgoServicesBridge::get_correlation_id() const {
|
||||
return cid;
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::subscribe_book(SecurityKey) {
|
||||
void AlgoServicesBridge::subscribe_book(SecurityKey k) {
|
||||
if(me->_book_map.find(k) == me->_book_map.end())
|
||||
me->_book_map.insert({k,Book()});
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::unsubscribe_book(SecurityKey) {
|
||||
void AlgoServicesBridge::unsubscribe_book(SecurityKey k) {
|
||||
if(me->_book_map.find(k) != me->_book_map.end())
|
||||
me->_book_map.erase(k);
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::subscribe_settlement(SecurityKey) {
|
||||
void AlgoServicesBridge::subscribe_settlement(SecurityKey) {
|
||||
bts_assert_msg(false, "Not implemented");
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::unsubscribe_settlement(SecurityKey) {
|
||||
void AlgoServicesBridge::unsubscribe_settlement(SecurityKey) {
|
||||
bts_assert_msg(false, "Not implemented");
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::subscribe_child_change(OrderKey) {
|
||||
void AlgoServicesBridge::subscribe_child_change(OrderKey) {
|
||||
bts_assert_msg(false, "Not implemented");
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::unsubscribe_child_change(OrderKey) {
|
||||
void AlgoServicesBridge::unsubscribe_child_change(OrderKey) {
|
||||
bts_assert_msg(false, "Not implemented");
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::subscribe_timer() {
|
||||
void AlgoServicesBridge::subscribe_timer() {
|
||||
bts_assert_msg(false, "Not implemented");
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::unsubscribe_timer() {
|
||||
void AlgoServicesBridge::unsubscribe_timer() {
|
||||
bts_assert_msg(false, "Not implemented");
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::subscribe_ticker(SecurityKey) {
|
||||
void AlgoServicesBridge::subscribe_ticker(SecurityKey) {
|
||||
bts_assert_msg(false, "Not implemented");
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::unsubscribe_ticker(SecurityKey) {
|
||||
void AlgoServicesBridge::unsubscribe_ticker(SecurityKey) {
|
||||
bts_assert_msg(false, "Not implemented");
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::subscribe_status(SecurityKey) {
|
||||
void AlgoServicesBridge::subscribe_status(SecurityKey) {
|
||||
bts_assert_msg(false, "Not implemented");
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::unsubscribe_status(SecurityKey) {
|
||||
void AlgoServicesBridge::unsubscribe_status(SecurityKey) {
|
||||
bts_assert_msg(false, "Not implemented");
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::subscribe_position() {
|
||||
void AlgoServicesBridge::subscribe_position() {
|
||||
bts_assert_msg(false, "Not implemented");
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::unsubscribe_position() {
|
||||
void AlgoServicesBridge::unsubscribe_position() {
|
||||
bts_assert_msg(false, "Not implemented");
|
||||
}
|
||||
|
||||
OrderKey AlgoServicesBridge::launch_child(ChildTemplate &,
|
||||
@@ -111,26 +144,40 @@ void AlgoServicesBridge::cancel_child(OrderKey) {
|
||||
void AlgoServicesBridge::detach_child(OrderKey) {
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::detach_all_children() {
|
||||
void AlgoServicesBridge::detach_all_children() {
|
||||
bts_assert_msg(false, "Not implemented");
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::cancel(const std::string&) {
|
||||
void AlgoServicesBridge::cancel(const std::string&) {
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::terminate_error(const std::string&) {
|
||||
void AlgoServicesBridge::terminate_error(const std::string&) {
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::complete() {
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::set_ladder_visibility(bool) {
|
||||
void AlgoServicesBridge::set_ladder_visibility(bool) {
|
||||
bts_assert_msg(false, "Not implemented");
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::update_custom_state(const api::orderman::DynamicOrderState&) {
|
||||
bts_assert_msg(false, "Not implemented");
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::update_fill_state(Quantity, Price) {
|
||||
}
|
||||
|
||||
// IAlgoModel
|
||||
|
||||
void AlgoServicesBridge::init(bts::spartan::mdp3::ISimServices&,
|
||||
bts::spartan::protos::SimRunOptions const&){
|
||||
}
|
||||
|
||||
void AlgoServicesBridge::on_notification(
|
||||
const bts::spartan::mdp3::AlgoNotification&){
|
||||
}
|
||||
|
||||
|
||||
} // namespace orderman
|
||||
} // namespace bts
|
||||
+15
-5
@@ -2,21 +2,24 @@
|
||||
|
||||
#include "lib/orderman/orders/algo/IAlgoOrder.h"
|
||||
#include "lib/orderman/orders/algo/IAlgoServices.h"
|
||||
#include "server/sparkd/cmds/spartan/md/mdp3/back_testing/simulator/IAlgoModel.h"
|
||||
|
||||
namespace bts {namespace api {namespace orderman{class CustomOrderDefinition;}}}
|
||||
namespace bts {namespace spartan {namespace mdp3{class ISimServices;}}}
|
||||
|
||||
namespace bts::spartan::protos { class SimRunOptions; }
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
|
||||
class ChildTemplate;
|
||||
class IBeforeLaunchAlgoServices;
|
||||
struct SniperPolygon;
|
||||
struct SecData;
|
||||
class IAlgoOrder;
|
||||
class BeforeLaunchBridge;
|
||||
|
||||
class AlgoServicesBridge : public IAlgoServices{
|
||||
class AlgoServicesBridge : public IAlgoServices, public bts::spartan::mdp3::IAlgoModel{
|
||||
public:
|
||||
AlgoServicesBridge();
|
||||
AlgoServicesBridge(IAlgoOrder& algo_order,
|
||||
bts::spartan::mdp3::ISimServices&);
|
||||
~AlgoServicesBridge(){}
|
||||
|
||||
Price price() const override;
|
||||
@@ -83,6 +86,13 @@ class AlgoServicesBridge : public IAlgoServices{
|
||||
|
||||
void update_fill_state(Quantity total_fills, Price last_price) override;
|
||||
|
||||
// IAlgoModel
|
||||
|
||||
void init(bts::spartan::mdp3::ISimServices&,
|
||||
bts::spartan::protos::SimRunOptions const&) override;
|
||||
|
||||
void on_notification(bts::spartan::mdp3::AlgoNotification const&) override;
|
||||
|
||||
private:
|
||||
struct PImpl;
|
||||
std::unique_ptr<PImpl> me;
|
||||
|
||||
+16
-4
@@ -1,16 +1,25 @@
|
||||
#include "BeforeLaunchBridge.h"
|
||||
#include "../ISimServices.h"
|
||||
#include "BridgeCommon.h"
|
||||
#include "lib/orderman/actors/order_manager/OrderBuilder.h"
|
||||
#include "lib/orderman/orders/algo/ChildTemplate.h"
|
||||
|
||||
|
||||
namespace bts {
|
||||
namespace orderman {
|
||||
|
||||
using namespace bts::spartan::mdp3;
|
||||
using namespace bts::api::orderman;
|
||||
|
||||
typedef std::map<InstrumentDefinition const*, api::Security,
|
||||
std::function<bool(InstrumentDefinition const*,
|
||||
InstrumentDefinition const*)> > InsMap;
|
||||
|
||||
struct ChildTemplateBridge : public ChildTemplate{
|
||||
ChildTemplateBridge(){
|
||||
}
|
||||
};
|
||||
|
||||
struct BeforeLaunchBridge::PImpl {
|
||||
OrderKey ok;
|
||||
MDP3SecurityID sec_id;
|
||||
@@ -19,7 +28,8 @@ struct BeforeLaunchBridge::PImpl {
|
||||
ChildTemplate* child_temp = nullptr;
|
||||
api::Security security;
|
||||
TimeStamp ts;
|
||||
InsMap sec_map = InsMap([](const auto& a, const auto& b) {
|
||||
std::map<std::unique_ptr<ChildTemplate>,OrderDefinition> _child_temp_map;
|
||||
InsMap sec_map = InsMap([](const auto& a, const auto& b) {
|
||||
return a->security_id().value() < b->security_id().value();
|
||||
});
|
||||
|
||||
@@ -91,10 +101,12 @@ bool BeforeLaunchBridge::is_attaching() const{
|
||||
}
|
||||
|
||||
ChildTemplate& BeforeLaunchBridge::make_child_template(
|
||||
const api::orderman::OrderDefinition&,
|
||||
const api::orderman::OrderDefinition& d,
|
||||
size_t){
|
||||
// TODO
|
||||
return *me->child_temp;
|
||||
auto ret = me->_child_temp_map.insert(std::make_pair(std::make_unique<ChildTemplate>(),d));
|
||||
bts_assert(ret.second);
|
||||
const std::unique_ptr<ChildTemplate>& rv = ret.first->first;
|
||||
return *rv;
|
||||
}
|
||||
|
||||
// Get the current time
|
||||
|
||||
+1
-4
@@ -11,16 +11,13 @@ namespace bts {
|
||||
namespace orderman {
|
||||
|
||||
class ChildTemplate;
|
||||
class IBeforeLaunchAlgoServices;
|
||||
struct SniperPolygon;
|
||||
struct SecData;
|
||||
|
||||
class BeforeLaunchBridge : public IBeforeLaunchAlgoServices{
|
||||
public:
|
||||
BeforeLaunchBridge(
|
||||
bts::spartan::mdp3::ISimServices&,
|
||||
const api::orderman::OrderDefinition&);
|
||||
~BeforeLaunchBridge(){}
|
||||
virtual ~BeforeLaunchBridge(){}
|
||||
|
||||
// The OrderDefinition for this algo
|
||||
api::orderman::OrderDefinition const &definition() const override;
|
||||
|
||||
Reference in new issue
Block a user