nothing builds
This commit is contained in:
1 parent
d436dae7cd
commit
719fd03063
12 files changed
+191
-42
No files matched your search
@@ -38,14 +38,16 @@ class HandleIndex
|
||||
|
||||
public:
|
||||
typedef decltype( Key_Func(std::declval<MDConsumerHandle>()) ) KeyType;
|
||||
utils::LockBox<std::unordered_map<KeyType,MDConsumerHandle>> index;
|
||||
utils::LockBox<std::unordered_map<KeyType,MDConsumerHandle>> handle_index;
|
||||
utils::LockBox<std::unordered_map<KeyType,SecurityPtr>> security_index;
|
||||
|
||||
|
||||
HandleIndex(md::MDClient& client) :
|
||||
_client(client),
|
||||
_sub(0),
|
||||
_consumer(std::nullopt),
|
||||
index()
|
||||
handle_index(),
|
||||
security_index()
|
||||
{
|
||||
_sub = _client.on_consumer().subscribe([=](const MDConsumer& c) { on_consumer(c); });
|
||||
on_consumer( _client.current_consumer() );
|
||||
@@ -64,7 +66,8 @@ private:
|
||||
auto existing = _consumer ? _consumer->id() : 0;
|
||||
LOG(md,Info, "Updating HandleIndex MDConsumer. Old {} new {}", existing, temp.id());
|
||||
// clear the index
|
||||
index.lock([](auto& index) { index.clear(); });
|
||||
handle_index.lock([](auto& index) { index.clear(); });
|
||||
security_index.lock([](auto& index) { index.clear(); });
|
||||
// Swap to new consumer
|
||||
if (_consumer)
|
||||
{
|
||||
@@ -76,14 +79,18 @@ private:
|
||||
}
|
||||
// Subscribe to on_security
|
||||
auto id = _consumer->id();
|
||||
_consumer->on_security([this,id](const SecurityPtr&, MDConsumerHandle handle)
|
||||
_consumer->on_security([this,id](const SecurityPtr& sec, MDConsumerHandle handle)
|
||||
{
|
||||
if (_consumer->id() == id)
|
||||
{
|
||||
index.lock([this, handle](auto& index)
|
||||
handle_index.lock([this, handle](auto& index)
|
||||
{
|
||||
index[ Key_Func(handle) ] = handle;
|
||||
});
|
||||
security_index.lock([this, handle, sec](auto& index)
|
||||
{
|
||||
index[ Key_Func(handle) ] = sec;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ std::optional<uint32_t> search_orders(const ExchangeOrderKey oid, const std::vec
|
||||
}
|
||||
|
||||
bool update_position(const KeyHandleIndex& handles, ActiveOrder& order) {
|
||||
const auto& index = handles.index;
|
||||
const auto& index = handles.handle_index;
|
||||
auto handle = index.lock([id=order.security_id()](const auto& index) {
|
||||
auto iter = index.find(id);
|
||||
return iter != index.end() ? iter->second : MDConsumerHandle {};
|
||||
@@ -253,7 +253,7 @@ MBOServiceServer::~MBOServiceServer() { }
|
||||
void MBOServiceServer::get_orders_for_security(const MBOSecurityQuery& request, const api::Response<PositionData>& reply) {
|
||||
PositionData response;
|
||||
response.set_security_id(request.security_id());
|
||||
auto handle = _me->handle_index.index.lock([id=request.security_id()](const auto& index) {
|
||||
auto handle = _me->handle_index.handle_index.lock([id=request.security_id()](const auto& index) {
|
||||
auto iter = index.find(SecurityKey(id));
|
||||
return iter != index.end() ? iter->second : MDConsumerHandle {};
|
||||
});
|
||||
|
||||
@@ -18,6 +18,11 @@ target_include_directories( sparkd PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY
|
||||
|
||||
set_source_files_properties(exchange_sim/ExchangeSim.cpp PROPERTIES COMPILE_FLAGS --std=c++14)
|
||||
set_source_files_properties(exchange_sim/ExchangeSimApplication.cpp PROPERTIES COMPILE_FLAGS --std=c++14)
|
||||
set_source_files_properties(fix/FixInit.cpp PROPERTIES COMPILE_FLAGS --std=c++14)
|
||||
set_source_files_properties(fix/FixRouter.cpp PROPERTIES COMPILE_FLAGS --std=c++14)
|
||||
set_source_files_properties(fix/SessionBase.cpp PROPERTIES COMPILE_FLAGS --std=c++14)
|
||||
set_source_files_properties(fix/OrderSession.cpp PROPERTIES COMPILE_FLAGS --std=c++14)
|
||||
set_source_files_properties(fix/DropCopySession.cpp PROPERTIES COMPILE_FLAGS --std=c++14)
|
||||
|
||||
# linking
|
||||
target_link_libraries( sparkd
|
||||
|
||||
@@ -23,22 +23,22 @@ namespace bts
|
||||
{
|
||||
namespace fix
|
||||
{
|
||||
|
||||
|
||||
GCC_DIAG_OFF("-Wdeprecated")
|
||||
GCC_DIAG_OFF("-Wignored-qualifiers")
|
||||
|
||||
int FixInit::start_acceptor(bts::api::ServiceContext& sc, const md::MDClient& md, const std::string& settings_file, bool orders_allowed)
|
||||
|
||||
int FixInit::start_acceptor(bts::api::ServiceContext&, const md::MDClient& md, const std::string& settings_file, bool orders_allowed)
|
||||
{
|
||||
std::ifstream str{settings_file};
|
||||
FIX::SessionSettings settings( str );
|
||||
|
||||
FixRouter application(md, [=](IFixRouter& router, const auto& id)
|
||||
{
|
||||
if(orders_allowed)
|
||||
return std::shared_ptr<IFixSession>(new OrderSession(sc, router, id));
|
||||
else
|
||||
return std::shared_ptr<IFixSession>(new DropCopySession(sc, router, id));
|
||||
return std::shared_ptr<IFixSession>();
|
||||
// if(orders_allowed)
|
||||
// return std::shared_ptr<IFixSession>(new OrderSession(sc, router, id));
|
||||
// else
|
||||
// return std::shared_ptr<IFixSession>(new DropCopySession(sc, router, id));
|
||||
});
|
||||
FIX::FileStoreFactory storeFactory( settings );
|
||||
FIX::FileLogFactory logFactory( settings );
|
||||
|
||||
@@ -21,8 +21,6 @@ namespace bts
|
||||
namespace fix
|
||||
{
|
||||
|
||||
GCC_DIAG_OFF("-Wdeprecated")
|
||||
GCC_DIAG_OFF("-Wignored-qualifiers")
|
||||
|
||||
FixRouter::FixRouter(const md::MDClient& md,
|
||||
std::function< std::shared_ptr<IFixSession> (IFixRouter&, const FIX::SessionID&) > factory) :
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
|
||||
#include "IFixSession.h"
|
||||
#include "IFixRouter.h"
|
||||
#include "lib/md/HandleIndex.h"
|
||||
#include "SecurityIndex.h"
|
||||
#include "lib/md/MDConsumerHandle.h"
|
||||
|
||||
#include <quickfix/MessageCracker.h>
|
||||
#include <quickfix/Message.h>
|
||||
#include <quickfix/SessionID.h>
|
||||
|
||||
#include <boost/container/flat_map.hpp>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
@@ -16,16 +17,15 @@
|
||||
|
||||
#include "lib/utils/warn_ctrl.h"
|
||||
|
||||
GCC_DIAG_OFF("-Woverloaded-virtual")
|
||||
GCC_DIAG_OFF("-Wdeprecated")
|
||||
GCC_DIAG_OFF("-Wignored-qualifiers")
|
||||
|
||||
|
||||
namespace bts {
|
||||
namespace api { class ServiceContext; }
|
||||
namespace md { class MDClient; }
|
||||
namespace fix {
|
||||
|
||||
GCC_DIAG_OFF("-Wdeprecated")
|
||||
GCC_DIAG_OFF("-Wignored-qualifiers")
|
||||
|
||||
|
||||
class FixRouter : public IFixSession, public FIX::MessageCracker, public IFixRouter
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/domain_model/Security.pb.h"
|
||||
#include "lib/md/common.h"
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
@@ -20,15 +20,12 @@ namespace api
|
||||
}
|
||||
|
||||
namespace fix
|
||||
{
|
||||
typedef uint32_t security_key;
|
||||
const security_key invalid_security_key = 0;
|
||||
|
||||
{
|
||||
class IFixRouter
|
||||
{
|
||||
public:
|
||||
virtual std::vector<const api::Security*> get_securities() = 0;
|
||||
virtual const api::Security* lookup(security_key key) = 0;
|
||||
virtual const api::Security* lookup(md::security_key key) = 0;
|
||||
virtual const api::Security* lookup(const std::string& desc) = 0;
|
||||
|
||||
virtual void send(const FIX::Message& mess, const FIX::SessionID& sess) = 0;
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/utils/warn_ctrl.h"
|
||||
GCC_DIAG_OFF("-Woverloaded-virtual")
|
||||
GCC_DIAG_OFF("-Wdeprecated")
|
||||
GCC_DIAG_OFF("-Wignored-qualifiers")
|
||||
|
||||
#include <quickfix/Application.h>
|
||||
|
||||
namespace bts {
|
||||
namespace fix {
|
||||
|
||||
GCC_DIAG_OFF("-Wdeprecated")
|
||||
GCC_DIAG_OFF("-Wignored-qualifiers")
|
||||
|
||||
class IFixSession : public FIX::Application
|
||||
{
|
||||
};
|
||||
|
||||
}}
|
||||
}}
|
||||
@@ -0,0 +1,49 @@
|
||||
#include "SecurityIndex.h"
|
||||
|
||||
#include "lib/md/HandleIndex.h"
|
||||
|
||||
|
||||
namespace bts {
|
||||
namespace fix {
|
||||
|
||||
struct SecurityIndex::PImpl
|
||||
{
|
||||
md::DescHandleIndex index;
|
||||
PImpl(const md::MDClient& md) : index(md)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
SecurityIndex::SecurityIndex(const md::MDClient& md) : me(new PImpl(md))
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<md::SecurityPtr> SecurityIndex::get_securities()
|
||||
{
|
||||
std::vector<md::SecurityPtr> list;
|
||||
me->index.security_index.lock([&list] (const auto& secmap)
|
||||
{
|
||||
for(const auto& s : secmap)
|
||||
list.push_back(s.second);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
md::SecurityPtr SecurityIndex::lookup(const std::string& desc)
|
||||
{
|
||||
md::SecurityPtr ptr = nullptr;
|
||||
me->index.security_index.lock([&ptr, &desc] (const auto& secmap)
|
||||
{
|
||||
auto it = secmap.find(desc);
|
||||
if(it != secmap.end())
|
||||
ptr = it->second;
|
||||
});
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/md/common.h"
|
||||
#include "lib/md/SecurityPtr.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace bts {
|
||||
namespace api { class Security; }
|
||||
namespace md { class MDClient; }
|
||||
namespace fix {
|
||||
|
||||
//A Wrapper for HandleIndex that compiles in c++14 (because of Fix dynamic exception stuff)
|
||||
class SecurityIndex
|
||||
{
|
||||
public:
|
||||
SecurityIndex(const md::MDClient&);
|
||||
|
||||
std::vector<md::SecurityPtr> get_securities();
|
||||
md::SecurityPtr lookup(const std::string& desc);
|
||||
|
||||
private:
|
||||
struct PImpl;
|
||||
std::unique_ptr<PImpl> me;
|
||||
};
|
||||
|
||||
}}
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "lib/utils/AuthToken.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/utils/bts_assert.h"
|
||||
#include "lib/api/service_helpers/AdminServiceUtils.h"
|
||||
|
||||
|
||||
#include <quickfix/Message.h>
|
||||
@@ -99,47 +100,105 @@ FIX::SecurityType SessionBase::convert_security_type(bts::api::SecurityType btst
|
||||
switch (btstype)
|
||||
{
|
||||
case bts::api::SecurityType::SECURITYTYPE_FUTURE:
|
||||
return new QuickFix.Fields.SecurityType("FUT");
|
||||
case bts.api.SecurityType.Option:
|
||||
return new QuickFix.Fields.SecurityType("OPT");
|
||||
case bts.api.SecurityType.Spread:
|
||||
return new QuickFix.Fields.SecurityType("MLEG");
|
||||
case bts.api.SecurityType.Stock:
|
||||
return new QuickFix.Fields.SecurityType("CS");
|
||||
case bts.api.SecurityType.Synthetic:
|
||||
return new QuickFix.Fields.SecurityType("SYNTH");
|
||||
return FIX::SecurityType("FUT");
|
||||
case bts::api::SecurityType::SECURITYTYPE_OPTION:
|
||||
return FIX::SecurityType("OPT");
|
||||
case bts::api::SecurityType::SECURITYTYPE_SPREAD:
|
||||
return FIX::SecurityType("MLEG");
|
||||
case bts::api::SecurityType::SECURITYTYPE_STOCK:
|
||||
return FIX::SecurityType("CS");
|
||||
case bts::api::SecurityType::SECURITYTYPE_SYNTHETIC:
|
||||
return FIX::SecurityType("SYNTH");
|
||||
default:
|
||||
return new QuickFix.Fields.SecurityType();
|
||||
return FIX::SecurityType();
|
||||
}
|
||||
}
|
||||
|
||||
bts::api::SecurityType SessionBase::convert_security_type(FIX::SecurityType fixtype)
|
||||
{
|
||||
std::string s = std::string(fixtype.getValue());
|
||||
if(s == "FUT")
|
||||
return bts::api::SecurityType::SECURITYTYPE_FUTURE;
|
||||
else if(s == "OPT")
|
||||
return bts::api::SecurityType::SECURITYTYPE_OPTION;
|
||||
else if(s == "MLEG"))
|
||||
return bts::api::SecurityType::SECURITYTYPE_SPREAD;
|
||||
else if(s == "CS")
|
||||
return bts::api::SecurityType::SECURITYTYPE_STOCK;
|
||||
else if("SYNTH" == s)
|
||||
return bts::api::SecurityType::SECURITYTYPE_SYNTHETIC;
|
||||
else
|
||||
return bts::api::SecurityType::SECURITYTYPE_UNSET;
|
||||
}
|
||||
|
||||
bool SessionBase::exchanges_equal(bts::api::Venue btstype, FIX::SecurityExchange fixtype)
|
||||
{
|
||||
return btstype == convert_exchange(fixtype);
|
||||
}
|
||||
|
||||
FIX::SecurityExchange SessionBase::convert_exchange(bts::api::Venue btstype)
|
||||
{
|
||||
switch (btstype)
|
||||
{
|
||||
case bts::api::Venue::VENUE_BTS:
|
||||
return FIX::SecurityExchange("BTS");
|
||||
case bts::api::Venue::VENUE_CBOE:
|
||||
return FIX::SecurityExchange("XCBO");
|
||||
case bts::api::Venue::VENUE_CBOECFE:
|
||||
return FIX::SecurityExchange("XCBF");
|
||||
case bts::api::Venue::VENUE_GLBX:
|
||||
return FIX::SecurityExchange("XCME");
|
||||
case bts::api::Venue::VENUE_ICE:
|
||||
return FIX::SecurityExchange("IFUS");
|
||||
case bts::api::Venue::VENUE_SIM:
|
||||
return FIX::SecurityExchange("SIM");
|
||||
default:
|
||||
return FIX::SecurityExchange();
|
||||
}
|
||||
}
|
||||
|
||||
bts::api::Venue SessionBase::convert_exchange(FIX::SecurityExchange fixtype)
|
||||
{
|
||||
std::string s = std::string(fixtype.getValue());
|
||||
if("BTS" == s)
|
||||
return bts::api::Venue::VENUE_BTS;
|
||||
else if("XCBO" == s)
|
||||
return bts::api::Venue::VENUE_CBOE;
|
||||
else if("XCBF" == s)
|
||||
return bts::api::Venue::VENUE_CBOECFE;
|
||||
else if("GLBX" == s || "XCME" == s || "XCBT" == s || "XCEC" == s || "XNYM" == s)
|
||||
return bts::api::Venue::VENUE_GLBX;
|
||||
else if("IEPA" == s || "IFUS" == s || "IFEU" == s || "IFLL" == s || "IFCA" == s)
|
||||
return bts::api::Venue::VENUE_ICE;
|
||||
else if("SIM" == s)
|
||||
return bts::api::Venue::VENUE_SIM;
|
||||
else
|
||||
return bts::api::Venue::VENUE_UNSET;
|
||||
}
|
||||
}
|
||||
|
||||
FIX::OrdStatus SessionBase::translate_status(const bts::api::orderman::OrderStateImmutable& state,
|
||||
bts::api::orderman::NativeOrderStateImmutable* native)
|
||||
{
|
||||
return FIX::OrdStatus();
|
||||
}
|
||||
|
||||
uint SessionBase::lookup_account(const std::string& acct)
|
||||
{
|
||||
auto a = admin::AdminServiceUtils::find_account(_admin_data, acct);
|
||||
if(a)
|
||||
return a->id();
|
||||
else
|
||||
throw FIX::IncorrectTagValue(FIX::FIEILD::Account);
|
||||
}
|
||||
|
||||
uint SessionBase::lookup_user(const std::string& user)
|
||||
{
|
||||
auto u = admin::AdminServiceUtils::find_user(_admin_data, user);
|
||||
if(u)
|
||||
return u->id();
|
||||
else
|
||||
throw FIX::IncorrectTagValue(FIX::FIEILD::Username);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "lib/domain_model/Security.pb.h"
|
||||
|
||||
#include <quickfix/MessageCracker.h>
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
@@ -18,9 +19,6 @@
|
||||
|
||||
#include "lib/utils/warn_ctrl.h"
|
||||
|
||||
GCC_DIAG_OFF("-Woverloaded-virtual")
|
||||
GCC_DIAG_OFF("-Wdeprecated")
|
||||
GCC_DIAG_OFF("-Wignored-qualifiers")
|
||||
|
||||
namespace FIX
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user