Spark-608 - get the simulator to send markets down to the shell.

This commit is contained in:
Eric Harding committed 2018-03-09 17:16:20 -05:00
1 parent 1653671764
commit e652435890
8 files changed
+45 -34

No files matched your search

+5
View File
@@ -7,6 +7,11 @@ MarketDataConfig {
use_replay: true
}
}
PlatformMap {
value {
glbx_platform: "PLATFORM_MDP3ONIXS"
}
}
PublisherNamespace {
value {
+7
View File
@@ -5,6 +5,13 @@ message MarketDataConfig {
optional bool use_replay = 1 [default=true];
}
message PlatformMap
{
// PLATFORM_MDP3ONIXS
optional string glbx_platform = 1 [default = "PLATFORM_SIM"];
}
//
// Options that apply to market data server
//
+6
View File
@@ -154,6 +154,12 @@ MDProducerChannel MDProducer::get_channel(const char* symbol, SecurityType type,
return MDProducerChannel(get_producer(symbol, type, exchange));
}
void MDProducer::heartbeat() {
for (auto& impl : _producers) {
impl->heartbeat();
}
}
//
// MDProducerChannel
//
+3
View File
@@ -31,6 +31,9 @@ public:
// A Producer Channel holds data shared between the
MDProducerChannel get_channel(const char* symbol, SecurityType type, Venue exchange);
// Heartbeat all channels
void heartbeat();
private:
BTS_NO_COPY(MDProducer);
+6 -22
View File
@@ -129,28 +129,12 @@ size_t get_system_md_symbols(const md::PlatformConfig& config, std::set<UserSymb
}
extern "C" BTS_EXPORT Platform platform_for_exchange(Venue) {
return co2::PLATFORM_MDP3ONIXS;
// using namespace bts::md;
// const auto& pmap = config::get<PlatformMap>();
// const PlatformMap::PlatformProps platforms[] = {
// pmap.sim(), pmap.srlabs(), pmap.spryware(), pmap.csm(), pmap.cme(), pmap.ice(), pmap.replay(), pmap.activ(), pmap.mdp3(), pmap.csm_onixs(), pmap.blue()
// };
// const Platform types[] = {
// PLATFORM_SIM, PLATFORM_SRLABS, PLATFORM_SPRYWARE, PLATFORM_CSM, PLATFORM_CME, PLATFORM_ICE, PLATFORM_REPLAY, PLATFORM_ACTIV, PLATFORM_MDP3ONIXS, PLATFORM_CSM_ONIXS, PLATFORM_BLUE
// };
// static_assert(BTS_ARRAYSIZE(platforms) == BTS_ARRAYSIZE(types),"Platforms should be the same size as types");
// for (size_t x = 0; x < BTS_ARRAYSIZE(platforms); x++)
// {
// for (int y = 0; y < platforms[x].exchange_size(); ++y) {
// if (platforms[x].exchange(y) == exchange) {
// return types[x];
// }
// }
// }
// return PLATFORM_UNSET;
const auto& pmap = config::get<PlatformMap>();
co2::Platform platform;
if (co2::Platform_Parse(pmap.glbx_platform(), &platform)) {
return platform;
}
return PLATFORM_UNSET;
}
+12 -9
View File
@@ -39,7 +39,7 @@ namespace test {
using namespace api;
using namespace co2;
Platform TEST_PLATFORM = PLATFORM_MDP3ONIXS;
Platform TEST_PLATFORM = PLATFORM_SIM;
//
// Helper functions for Producer/Consumer tests
@@ -148,6 +148,11 @@ class Co2Tests
public:
void setup() {
config::internal::initialize_for_test(
"PlatformMap {"
" value {"
" glbx_platform: 'PLATFORM_SIM'"
" }"
"}"
"PublisherOptions {"
" value {"
" heartbeat_ms: 100"
@@ -1202,14 +1207,12 @@ struct Co2IndexTests {
struct Co2RelayTests {
void setup() {
// config::internal::initialize_for_test(
// "PlatformMap {"
// " value {"
// " sim {"
// " exchange: TESTEXCHANGE"
// " }"
// " }"
// "}");
config::internal::initialize_for_test(
"PlatformMap {"
" value {"
" glbx_platform: 'PLATFORM_SIM'"
" }"
"}");
}
void teardown() {}
@@ -315,7 +315,8 @@ ExchangeSimApplication::convert(const FIX::ManualOrderIndicator &moi) {
ExchangeSimApplication::ExchangeSimApplication() :
producer(co2::PLATFORM_SIM),
handles()
handles(),
timer(utils::Dispatcher::background(), 200, [=](){ producer.heartbeat(); })
{
std::set<md::UserSymbol> symbols;
md::get_system_md_symbols(symbols);
@@ -324,10 +325,10 @@ ExchangeSimApplication::ExchangeSimApplication() :
md::with_security_like(s,[this,s] (auto &fs) {
auto new_s = s;
*new_s.mutable_glbx()->mutable_security_desc() = std::string("sim:") + s.glbx().security_desc();
*new_s.mutable_symbol() = std::string("sim:") + s.symbol();
*new_s.mutable_symbol() = s.symbol();
md::convert_security(new_s, fs, true);
md::MDProducerHandle handle = producer.add_security(fs);
auto sec_desc = securities::descriptor(s);
auto sec_desc = securities::descriptor(new_s);
handles.insert(make_pair(sec_desc, handle));
});
}});
@@ -32,6 +32,7 @@ GCC_DIAG_OFF("-Wignored-qualifiers")
#include "OrderMatcher.h"
#include "Order.h"
#include "lib/md/MDProducer.h"
#include "lib/utils/Dispatcher.h"
#include <queue>
#include <iostream>
@@ -108,6 +109,7 @@ private:
IDGenerator m_generator;
md::MDProducer producer;
std::map<std::string,md::MDProducerHandle> handles;
utils::DispatcherTimer timer;
public:
void update_md(std::string const&sec_desc);
const OrderMatcher& orderMatcher() { return m_orderMatcher; }