Also rename files in snake_case (standard naming convention for protos) https://protobuf.dev/programming-guides/style/
52 lines
1.6 KiB
C++
52 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<domain::protobufs::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<domain::protobufs::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
|