git cherry-pick add file
This commit is contained in:
1 parent
9011df884e
commit
39bf6ebaa5
8 files changed
+41
-7
No files matched your search
@@ -26,4 +26,8 @@ message OrdersSoftCleanup{
|
||||
|
||||
message ToastNotifications {
|
||||
optional bool enabled = 1 [default = false];
|
||||
}
|
||||
|
||||
message VolumeAtPrice{
|
||||
optional bool enabled = 1 [default = true];
|
||||
}
|
||||
@@ -21,8 +21,16 @@
|
||||
#include "lib/metrics/metrics.h"
|
||||
#include "lib/metrics/system_metrics.h"
|
||||
#include "server/sparkd/user/AdminServiceServer.h"
|
||||
#include "server/sparkd/md/MarketDataAuxiliaryServiceServer.h"
|
||||
#include "server/sparkd/user/UserServiceServer.h"
|
||||
#include "server/sparkd/position/PositionServiceServer.h"
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
#include "lib/orderman/order_factory/DynamicOrderRegistry.h"
|
||||
#include "lib/plugin/SparkServices.h"
|
||||
#include "lib/plugin/plugin.h"
|
||||
#include "lib/config/protos/toggles.pb.h"
|
||||
>>>>>>> 92c1508b... Put the VolumeAtPrice behind a toggle config
|
||||
|
||||
#include "lib/md/relay/QueryServer.h"
|
||||
|
||||
@@ -56,6 +64,8 @@ int Run::execute(std::vector<std::string> const &) {
|
||||
orderman::OrderServiceServer order_service_server(sc, synthetic_service,stats);
|
||||
support::ErrorReportServer error_report_service(sc);
|
||||
admin::AdminServiceServer admin_service(sc);
|
||||
if(config::get<config::toggles::VolumeAtPrice>().enabled())
|
||||
md::auxiliary::MarketDataAuxiliaryServiceServer md_aux_server(sc);
|
||||
position::PositionServiceServer position_service(sc);
|
||||
metrics::ShellLatencyServer shell_latency_service(sc, stats, utils::Dispatcher::background());
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ const VolumeAtPriceLevel& ChannelVolume::add_trade(const TradeMessage& m,
|
||||
int& record_id){
|
||||
auto price_map_it=_sec_map.find(m.key());
|
||||
if(price_map_it==_sec_map.end()){
|
||||
_sec_map[m.key()]=std::map<uint64_t,VolumeAtPriceLevel>();
|
||||
_sec_map[m.key()]=std::unordered_map<uint64_t,VolumeAtPriceLevel>();
|
||||
price_map_it=_sec_map.find(m.key());
|
||||
}
|
||||
auto& price_map=price_map_it->second;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "lib/api/services/MarketDataAuxiliaryService.pb.h"
|
||||
#include <unordered_map>
|
||||
|
||||
namespace bts{
|
||||
namespace co2 {class TradeMessage;class SecurityChannel;}
|
||||
@@ -11,7 +12,7 @@ namespace auxiliary{
|
||||
class ChannelVolume{
|
||||
private:
|
||||
bts::co2::SecurityChannel* const _channel;
|
||||
std::map<uint32_t,std::map<uint64_t,bts::api::md::auxiliary::VolumeAtPriceLevel>> _sec_map;
|
||||
std::unordered_map<uint32_t,std::unordered_map<uint64_t,bts::api::md::auxiliary::VolumeAtPriceLevel>> _sec_map;
|
||||
public:
|
||||
ChannelVolume(bts::co2::SecurityChannel* channel);
|
||||
// finds the VolumeAtPriceLevel for the <sec, price_level>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "lib/utils/Dispatcher.h"
|
||||
#include "lib/md/get_symbols.h"
|
||||
#include "VolumeAtPriceState.h"
|
||||
#include "lib/utils/bts_chrono.h"
|
||||
|
||||
namespace bts{
|
||||
namespace md{
|
||||
@@ -44,7 +45,7 @@ me(new PImpl(context,
|
||||
me->poll_period_ms,
|
||||
[this]() {
|
||||
me->relay_service.requestmd(me->state.md_req(),
|
||||
[this](const bts::api::Result<MDReply>& md_reply)
|
||||
[this](const bts::api::Result<MDReply>& md_reply)
|
||||
{
|
||||
if(md_reply.result()!=nullptr)
|
||||
_scan_trades(*md_reply.result());}
|
||||
@@ -54,8 +55,19 @@ me(new PImpl(context,
|
||||
}
|
||||
|
||||
void MarketDataAuxiliaryServiceServer::_scan_trades(const MDReply& md_reply){
|
||||
uint32_t n_trades=0, total_unique_levels=0;
|
||||
bts::TimeStamp t0=bts::Timer::now();
|
||||
for(const auto& cr : md_reply.channels())
|
||||
me->state.on_new_trades(cr,me->publisher);
|
||||
me->state.on_new_trades(cr,
|
||||
me->publisher,
|
||||
n_trades,
|
||||
total_unique_levels);
|
||||
bts::TimeStamp t1=bts::Timer::now();
|
||||
double usecs=static_cast<double>(us_diff (t1,t0));
|
||||
LOG(OrderMan,Info,"MarketDataAuxiliaryServiceServer::_scan_trades "
|
||||
"trades:{} tot_unique:{} usecs:{}",
|
||||
n_trades,total_unique_levels,usecs);
|
||||
me->publisher.flush();
|
||||
}
|
||||
|
||||
MarketDataAuxiliaryServiceServer::~MarketDataAuxiliaryServiceServer(){
|
||||
|
||||
@@ -11,7 +11,8 @@ namespace co2 {class MDReply;}
|
||||
namespace md{
|
||||
namespace auxiliary{
|
||||
|
||||
class MarketDataAuxiliaryServiceServer : public bts::api::md::auxiliary::MarketDataAuxiliaryServiceBase
|
||||
class MarketDataAuxiliaryServiceServer :
|
||||
public bts::api::md::auxiliary::MarketDataAuxiliaryServiceBase
|
||||
{
|
||||
private:
|
||||
struct PImpl;
|
||||
|
||||
@@ -41,13 +41,17 @@ ChannelVolume& VolumeAtPriceState::_update_or_add(const SecurityChannel& channel
|
||||
}
|
||||
|
||||
void VolumeAtPriceState::on_new_trades(const ChannelReply& reply,
|
||||
MarketDataAuxiliaryServiceBase::Volume_at_priceStatefulPublisher& publisher){
|
||||
MarketDataAuxiliaryServiceBase::Volume_at_priceStatefulPublisher& publisher,
|
||||
uint32_t& n_trades,
|
||||
uint32_t& total_unique_levels){
|
||||
ChannelVolume& channel_vol=_update_or_add(reply.channel());
|
||||
for(const TradeMessage& t : reply.trade_log()){
|
||||
const VolumeAtPriceLevel& sec_level_vol=channel_vol.add_trade(t,
|
||||
_record_id);
|
||||
publisher.add_or_update(sec_level_vol);
|
||||
n_trades++;
|
||||
}
|
||||
total_unique_levels = _record_id;
|
||||
}
|
||||
|
||||
const bts::co2::MDRequest& VolumeAtPriceState::md_req() const{
|
||||
|
||||
@@ -24,7 +24,9 @@ public:
|
||||
VolumeAtPriceState ();
|
||||
//encorporates the reply, and publishes it
|
||||
void on_new_trades(const bts::co2::ChannelReply& channel,
|
||||
bts::api::md::auxiliary::MarketDataAuxiliaryServiceBase::Volume_at_priceStatefulPublisher& publisher);
|
||||
bts::api::md::auxiliary::MarketDataAuxiliaryServiceBase::Volume_at_priceStatefulPublisher& publisher,
|
||||
uint32_t& n_trades,
|
||||
uint32_t& total_unique_levels);
|
||||
const bts::co2::MDRequest& md_req() const;
|
||||
};
|
||||
}}}
|
||||
Reference in new issue
Block a user