MarketDataGateway still exists, but is greatly simplified. It creates several `IMarketDataProvider`s, each of which generates a list of `IMarketDataSource`s. The market data sources provide market data to an `IMarketDataListener`. * EmumbaMarketDataProvider * CCApiMarketDataProvider * PyMarketDataProvider * OnixsMarketDataProvider * ReplayMarketDataProvider As a side effect, individual py market data sources are now explicitly limited to a single venue (it probably should have been this way all along, since the shared memory writers do not expect updates to involve multiple venues).
51 lines
1.6 KiB
C++
51 lines
1.6 KiB
C++
#include "ReplayMarketDataProvider.h"
|
|
#include "spark/api/md/MarketDataConfig.pb.h"
|
|
#include "spark/api/md/MarketDataConfigUtils.h"
|
|
#include "spark/config/config.h"
|
|
#include "spark/domain/DomainSecurityUtils.h"
|
|
#include "spark/persistence/IDGenerator.h"
|
|
#include "sparkd/md/IMarketDataSource.h"
|
|
#include "sparkd/md/recording/MDReplayer.h"
|
|
|
|
namespace bts::md {
|
|
|
|
using bts::api::md::MarketDataConfig;
|
|
using bts::md::recording::MDReplayer;
|
|
using bts::persistence::IDGenerator;
|
|
using std::pair;
|
|
using std::shared_ptr;
|
|
using std::string;
|
|
using std::vector;
|
|
|
|
struct ReplayMarketDataProvider::PImpl {
|
|
MarketDataConfig config;
|
|
IDGenerator *sec_id_store;
|
|
vector<pair<api::domain::Venue, shared_ptr<IMarketDataSource>>> sources;
|
|
};
|
|
|
|
ReplayMarketDataProvider::ReplayMarketDataProvider()
|
|
: ReplayMarketDataProvider(
|
|
bts::config::get<MarketDataConfig>(), &IDGenerator::instance()) {}
|
|
|
|
ReplayMarketDataProvider::ReplayMarketDataProvider(
|
|
MarketDataConfig config, IDGenerator *sec_id_store)
|
|
: me_(std::make_unique<PImpl>()) {
|
|
me_->config = std::move(config);
|
|
me_->sec_id_store = sec_id_store;
|
|
}
|
|
|
|
ReplayMarketDataProvider::~ReplayMarketDataProvider() = default;
|
|
|
|
vector<pair<api::domain::Venue, shared_ptr<IMarketDataSource>>>
|
|
ReplayMarketDataProvider::get_sources() {
|
|
const auto replay_cfgs =
|
|
MarketDataConfigUtils::get_effective_replay_config(me_->config);
|
|
for (const auto &r : replay_cfgs) {
|
|
const auto v = domain::DomainSecurityUtils::convert(r.venue());
|
|
me_->sources.push_back({v, std::make_shared<MDReplayer>(r.venue())});
|
|
}
|
|
return me_->sources;
|
|
}
|
|
|
|
} // namespace bts::md
|