More refactoring.
This commit is contained in:
1 parent
f5b83efade
commit
7e2001744c
11 files changed
+160
-89
No files matched your search
@@ -1 +1 @@
|
||||
set(sources algo/AlgoDefinitionServiceServer.cpp;cmds/AdminReport.cpp;cmds/AutoCert.cpp;cmds/Benchmark.cpp;cmds/CMECertCmd.cpp;cmds/CmdRegistry.cpp;cmds/ConfigCheck.cpp;cmds/FIXSim.cpp;cmds/Help.cpp;cmds/KeyCode.cpp;cmds/Md.cpp;cmds/ParseHistoricalFIX.cpp;cmds/PrintHedgeOrders.cpp;cmds/QuickTest.cpp;cmds/Run.cpp;cmds/Span.cpp;cmds/Spartan.cpp;cmds/Test.cpp;cmds/Web.cpp;cmds/spartan/algo/RunTAS.cpp;cmds/spartan/algo/TASOrderReactor.cpp;cmds/spartan/algo/TASTriggerDef.cpp;cmds/spartan/analysis/ActionableEventAnalyzer.cpp;cmds/spartan/analysis/RunAnalysis.cpp;cmds/spartan/md/mdp3/BookRecoveryStrategy.cpp;cmds/spartan/md/mdp3/IFeedController.cpp;cmds/spartan/md/mdp3/MDP3FeedHandler.cpp;cmds/spartan/md/mdp3/OldBookSnapshot.cpp;cmds/spartan/md/mdp3/RealTimeFeedParser.cpp;cmds/spartan/md/mdp3/Snapshot.cpp;cmds/spartan/md/mdp3/SnapshotBuilder.cpp;cmds/spartan/md/mdp3/common/InstrumentSnapshot.cpp;cmds/spartan/md/mdp3/recovery/BookSnapshot.cpp;cmds/spartan/md/mdp3/recovery/DefinitionSnapshot.cpp;cmds/spartan/md/mdp3/recovery/IncrementalQueue.cpp;cmds/spartan/md/mdp3/tests/snapshot_builder_tests.cpp;cmds/spartan/util/MCastReceiver.cpp;cmds/spartan/util/PCapReader.cpp;cmds/spartan/util/SecurityDB.cpp;dspark/mirage/quick_queue/quick_queue.cpp;exchange_sim/ExchangeSim.cpp;exchange_sim/ExchangeSimApplication.cpp;exchange_sim/book/Book.cpp;exchange_sim/book/ExchangeSim.proto;exchange_sim/book/Order.cpp;exchange_sim/book/OrderMatcher.cpp;exchange_sim/book/book_transform.cpp;exchange_sim/tests/test_book_transform.cpp;http/ApiGateway.cpp;http/MultipartFormDecoder.cpp;http/WebServer.cpp;http/tests/MultiPartFormTests.cpp;main.cpp;md/ChannelVolume.cpp;md/MarketDataAuxiliaryServiceServer.cpp;md/VolumeAtPriceState.cpp;md/platforms/IMDPlatform.cpp;md/platforms/ice_onixs/ICEListener.cpp;md/platforms/ice_onixs/ICEMain.cpp;md/platforms/ice_onixs/tests/ice_tests.cpp;md/platforms/mdp3_onixs/MDP3Listener.cpp;md/platforms/mdp3_onixs/MDP3Main.cpp;md/platforms/mdp3_onixs/tests/mdp3_tests.cpp;md/run_md.cpp;position/IPositionObserver.cpp;position/MarginServiceCore.cpp;position/MarginServiceServer.cpp;position/PositionAggregator.cpp;position/PositionMap.cpp;position/PositionServicePNLHelper.cpp;position/PositionServiceServer.cpp;position/import/BasePositionServiceServer.cpp;position/import/DownloadCommonStateMachine.cpp;position/import/DownloadWindow.cpp;position/import/MoneyFileServiceServer.cpp;position/import/parsing/gmi_parser.cpp;position/import/parsing/money_parser.cpp;position/import/parsing/parser_common.cpp;position/tests/PositionTests.cpp;position/tests/position_tests_internal.cpp;subprocess/SubProcessRunner.cpp;support/ErrorReportService.cpp;support/ShellLatencyServer.cpp;user/AdminServiceDB.cpp;user/AdminServiceServer.cpp;user/AuthServiceServer.cpp;user/tests/admin_service_tests.cpp)
|
||||
set(sources algo/AlgoDefinitionServiceServer.cpp;cmds/AdminReport.cpp;cmds/AutoCert.cpp;cmds/Benchmark.cpp;cmds/CMECertCmd.cpp;cmds/CmdRegistry.cpp;cmds/ConfigCheck.cpp;cmds/FIXSim.cpp;cmds/Help.cpp;cmds/KeyCode.cpp;cmds/Md.cpp;cmds/ParseHistoricalFIX.cpp;cmds/PrintHedgeOrders.cpp;cmds/QuickTest.cpp;cmds/Run.cpp;cmds/Span.cpp;cmds/Spartan.cpp;cmds/Test.cpp;cmds/Web.cpp;cmds/spartan/algo/RunTAS.cpp;cmds/spartan/algo/TASOrderReactor.cpp;cmds/spartan/algo/TASTriggerDef.cpp;cmds/spartan/analysis/ActionableEventAnalyzer.cpp;cmds/spartan/analysis/RunAnalysis.cpp;cmds/spartan/md/mdp3/BookRecoveryStrategy.cpp;cmds/spartan/md/mdp3/IFeedController.cpp;cmds/spartan/md/mdp3/MDP3FeedHandler.cpp;cmds/spartan/md/mdp3/OldBookSnapshot.cpp;cmds/spartan/md/mdp3/Snapshot.cpp;cmds/spartan/md/mdp3/SnapshotBuilder.cpp;cmds/spartan/md/mdp3/common/InstrumentSnapshot.cpp;cmds/spartan/md/mdp3/realtime/RealtimeHandler.cpp;cmds/spartan/md/mdp3/recovery/BookSnapshot.cpp;cmds/spartan/md/mdp3/recovery/DefinitionSnapshot.cpp;cmds/spartan/md/mdp3/recovery/IncrementalQueue.cpp;cmds/spartan/md/mdp3/tests/snapshot_builder_tests.cpp;cmds/spartan/util/MCastReceiver.cpp;cmds/spartan/util/PCapReader.cpp;cmds/spartan/util/SecurityDB.cpp;dspark/mirage/quick_queue/quick_queue.cpp;exchange_sim/ExchangeSim.cpp;exchange_sim/ExchangeSimApplication.cpp;exchange_sim/book/Book.cpp;exchange_sim/book/ExchangeSim.proto;exchange_sim/book/Order.cpp;exchange_sim/book/OrderMatcher.cpp;exchange_sim/book/book_transform.cpp;exchange_sim/tests/test_book_transform.cpp;http/ApiGateway.cpp;http/MultipartFormDecoder.cpp;http/WebServer.cpp;http/tests/MultiPartFormTests.cpp;main.cpp;md/ChannelVolume.cpp;md/MarketDataAuxiliaryServiceServer.cpp;md/VolumeAtPriceState.cpp;md/platforms/IMDPlatform.cpp;md/platforms/ice_onixs/ICEListener.cpp;md/platforms/ice_onixs/ICEMain.cpp;md/platforms/ice_onixs/tests/ice_tests.cpp;md/platforms/mdp3_onixs/MDP3Listener.cpp;md/platforms/mdp3_onixs/MDP3Main.cpp;md/platforms/mdp3_onixs/tests/mdp3_tests.cpp;md/run_md.cpp;position/IPositionObserver.cpp;position/MarginServiceCore.cpp;position/MarginServiceServer.cpp;position/PositionAggregator.cpp;position/PositionMap.cpp;position/PositionServicePNLHelper.cpp;position/PositionServiceServer.cpp;position/import/BasePositionServiceServer.cpp;position/import/DownloadCommonStateMachine.cpp;position/import/DownloadWindow.cpp;position/import/MoneyFileServiceServer.cpp;position/import/parsing/gmi_parser.cpp;position/import/parsing/money_parser.cpp;position/import/parsing/parser_common.cpp;position/tests/PositionTests.cpp;position/tests/position_tests_internal.cpp;subprocess/SubProcessRunner.cpp;support/ErrorReportService.cpp;support/ShellLatencyServer.cpp;user/AdminServiceDB.cpp;user/AdminServiceServer.cpp;user/AuthServiceServer.cpp;user/tests/admin_service_tests.cpp)
|
||||
@@ -52,7 +52,7 @@ InstrumentDefinition InstrumentSnapshot::definition() const {
|
||||
return me->definition;
|
||||
}
|
||||
|
||||
void InstrumentSnapshot::set_instrument_definition(
|
||||
void InstrumentSnapshot::set_definition(
|
||||
InstrumentDefinition const &def) {
|
||||
me->definition = def;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class InstrumentSnapshot {
|
||||
// Definition
|
||||
MDP3SecurityID security_id() const;
|
||||
InstrumentDefinition definition() const;
|
||||
void set_instrument_definition(InstrumentDefinition const&);
|
||||
void set_definition(InstrumentDefinition const&);
|
||||
|
||||
// Trading status
|
||||
::mdp3::SecurityTradingStatus::Value trading_status() const;
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ namespace bts::spartan::mdp3 {
|
||||
|
||||
class MDP3EventInfo;
|
||||
|
||||
class IRealTimeFeedObserver {
|
||||
class IRealTimeObserver {
|
||||
public:
|
||||
virtual void on_event(MDP3EventInfo const&) = 0;
|
||||
};
|
||||
+11
-17
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/mdp3_common.h"
|
||||
#include "../common/mdp3_common.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@@ -23,7 +23,7 @@ class SecurityStatus30;
|
||||
namespace bts::spartan::mdp3 {
|
||||
|
||||
class InstrumentSnapshot;
|
||||
class IRealTimeFeedObserver;
|
||||
class IRealTimeObserver;
|
||||
class MDP3PacketHeader;
|
||||
|
||||
// Updates a set of instruments snapshots with the incremental changes
|
||||
@@ -34,12 +34,12 @@ class MDP3PacketHeader;
|
||||
// snapshot. In addition to updating the passed snapshots this class
|
||||
// will also create new snapshots for any new securities discovered
|
||||
// through the real time incremental feed.
|
||||
class RealTimeFeedParser {
|
||||
class RealTimeHandler {
|
||||
public:
|
||||
RealTimeFeedParser();
|
||||
~RealTimeFeedParser();
|
||||
RealTimeHandler();
|
||||
~RealTimeHandler();
|
||||
|
||||
void set_observer(IRealTimeFeedObserver &);
|
||||
void set_observer(IRealTimeObserver &);
|
||||
|
||||
// Add a snapshot, including the instrument definition and its book
|
||||
// to the list of updated snapshots. Ownership of the passed
|
||||
@@ -49,23 +49,17 @@ class RealTimeFeedParser {
|
||||
// the one the snapshot expects. Additionally, callers must ensure
|
||||
// that no snapshots are added while this class is in the middle of
|
||||
// processing a multi message event, that is while
|
||||
// is_processing_multi_message_event() returns true. Note that if
|
||||
// this class observes a security definition message for a security
|
||||
// that has not been previously added through add_snapshot() it
|
||||
// will assume that the instrument was just created and has an
|
||||
// empty book. Subsquent incremental update messages for that
|
||||
// snapshot must be consistent with an initially empty book.
|
||||
// is_processing_multi_message_event() returns true.
|
||||
void add_snapshot(std::unique_ptr<InstrumentSnapshot> snapshot);
|
||||
|
||||
// Returns wheter this class is in the middle of processing a multi
|
||||
// message event. Discrete exchange events like a single order
|
||||
// entry are sometimes described by multiple MDP3 messages,
|
||||
// possibly over multiple network packets. Messages describing a
|
||||
// single event have to be processed together as a unit and so
|
||||
// while processing a multi event message the snapshots maintained
|
||||
// by this class can be in an inconsistent state. For that reason
|
||||
// this class does not allow adding or removing snapshots during
|
||||
// event processing.
|
||||
// single event have to be processed together as a unit and it is
|
||||
// possible for snapshots to be in inconsistent state while in
|
||||
// middle of a multi message event. For that reason this class does
|
||||
// not allow adding or removing snapshots during event processing.
|
||||
bool is_processing_multi_message_event() const;
|
||||
|
||||
// Stop processing incremental udpates and transfer ownership of
|
||||
+62
-50
@@ -1,17 +1,14 @@
|
||||
#include "RealTimeFeedParser.h"
|
||||
#include "IMDP3FeedObserver.h"
|
||||
#include "IRealTimeFeedObserver.h"
|
||||
#include "common/InstrumentSnapshot.h"
|
||||
#include "common/mdp3_common.h"
|
||||
#include "parsing/MDP3Parser.h"
|
||||
|
||||
#include "mdp3_gen/MDIncrementalRefreshBook46.h"
|
||||
|
||||
#include "RealTimeHandler.h"
|
||||
#include "IRealTimeObserver.h"
|
||||
#include "../common/InstrumentSnapshot.h"
|
||||
#include "../common/mdp3_common.h"
|
||||
#include "../mdp3_gen/MDIncrementalRefreshBook46.h"
|
||||
#include "../parsing/MDP3Parser.h"
|
||||
#include <unordered_map>
|
||||
|
||||
namespace bts::spartan::mdp3 {
|
||||
|
||||
struct RealTimeFeedParser::TradeSummary {
|
||||
struct RealTimeHandler::TradeSummary {
|
||||
::mdp3::MDUpdateAction::Value update_action;
|
||||
InstrumentSnapshot *security;
|
||||
md::IntPrice price;
|
||||
@@ -20,12 +17,12 @@ struct RealTimeFeedParser::TradeSummary {
|
||||
MDP3TradeEntryID trade_entry_id;
|
||||
};
|
||||
|
||||
struct RealTimeFeedParser::TradeOrderDetail {
|
||||
struct RealTimeHandler::TradeOrderDetail {
|
||||
MDP3OrderKey order_id;
|
||||
MDP3Quantity quantity;
|
||||
};
|
||||
|
||||
struct RealTimeFeedParser::PImpl {
|
||||
struct RealTimeHandler::PImpl {
|
||||
|
||||
PImpl()
|
||||
: instruments(), current_packet_send_time(MDP3TimeStamp{0}),
|
||||
@@ -40,19 +37,19 @@ struct RealTimeFeedParser::PImpl {
|
||||
uint32_t current_packet_sn;
|
||||
MDP3EventInfo current_event;
|
||||
|
||||
IRealTimeFeedObserver &observer;
|
||||
IRealTimeObserver &observer;
|
||||
std::vector<TradeSummary> pending_ts;
|
||||
std::vector<TradeOrderDetail> pending_order_detail;
|
||||
struct NullObserver : public IRealTimeFeedObserver {
|
||||
struct NullObserver : public IRealTimeObserver {
|
||||
void on_event(MDP3EventInfo const &) {}
|
||||
} null_observer;
|
||||
bool terminated;
|
||||
};
|
||||
|
||||
struct RealTimeFeedParser::EventGuard {
|
||||
struct RealTimeHandler::EventGuard {
|
||||
|
||||
template <class M>
|
||||
EventGuard(RealTimeFeedParser &owner, M &m) : owner(owner) {
|
||||
EventGuard(RealTimeHandler &owner, M &m) : owner(owner) {
|
||||
bts_assert_d(!owner.me->terminated);
|
||||
auto &info = owner.me->current_event;
|
||||
if (info.transact_time == MDP3TimeStamp{0}) {
|
||||
@@ -73,7 +70,7 @@ struct RealTimeFeedParser::EventGuard {
|
||||
}
|
||||
}
|
||||
|
||||
EventGuard(RealTimeFeedParser &owner, InstrumentDefinition &def)
|
||||
EventGuard(RealTimeHandler &owner, InstrumentDefinition &def)
|
||||
: owner(owner) {
|
||||
bts_assert_d(!owner.me->terminated);
|
||||
auto &info = owner.me->current_event;
|
||||
@@ -114,18 +111,18 @@ struct RealTimeFeedParser::EventGuard {
|
||||
info.affected_securities.push_back(s);
|
||||
}
|
||||
|
||||
RealTimeFeedParser &owner;
|
||||
RealTimeHandler &owner;
|
||||
};
|
||||
|
||||
RealTimeFeedParser::RealTimeFeedParser() : me(new PImpl()) {}
|
||||
RealTimeHandler::RealTimeHandler() : me(new PImpl()) {}
|
||||
|
||||
RealTimeFeedParser::~RealTimeFeedParser() {}
|
||||
RealTimeHandler::~RealTimeHandler() {}
|
||||
|
||||
void RealTimeFeedParser::set_observer(IRealTimeFeedObserver &o) {
|
||||
void RealTimeHandler::set_observer(IRealTimeObserver &o) {
|
||||
me->observer = o;
|
||||
}
|
||||
|
||||
void RealTimeFeedParser::add_snapshot(
|
||||
void RealTimeHandler::add_snapshot(
|
||||
std::unique_ptr<InstrumentSnapshot> snapshot) {
|
||||
bts_assert(!is_processing_multi_message_event());
|
||||
bts_assert(!me->terminated);
|
||||
@@ -133,12 +130,12 @@ void RealTimeFeedParser::add_snapshot(
|
||||
me->instruments[snapshot->security_id()] = std::move(snapshot);
|
||||
}
|
||||
|
||||
bool RealTimeFeedParser::is_processing_multi_message_event() const {
|
||||
bool RealTimeHandler::is_processing_multi_message_event() const {
|
||||
return me->current_event.transact_time != MDP3TimeStamp{};
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<InstrumentSnapshot>>
|
||||
RealTimeFeedParser::remove_all_securities_and_terminate() {
|
||||
RealTimeHandler::remove_all_securities_and_terminate() {
|
||||
bts_assert(!me->terminated);
|
||||
|
||||
std::vector<std::unique_ptr<InstrumentSnapshot>> result;
|
||||
@@ -147,12 +144,12 @@ RealTimeFeedParser::remove_all_securities_and_terminate() {
|
||||
return result;
|
||||
}
|
||||
|
||||
void RealTimeFeedParser::on_begin_packet(MDP3PacketHeader const &h) {
|
||||
void RealTimeHandler::on_begin_packet(MDP3PacketHeader const &h) {
|
||||
me->current_packet_sn = h.msg_seq_num;
|
||||
me->current_packet_send_time = MDP3TimeStamp{h.sending_time};
|
||||
}
|
||||
|
||||
void RealTimeFeedParser::on_end_packet() {}
|
||||
void RealTimeHandler::on_end_packet() {}
|
||||
|
||||
api::Side convert_side(::mdp3::MDEntryTypeBook::Value v) {
|
||||
switch (v) {
|
||||
@@ -168,7 +165,7 @@ api::Side convert_side(::mdp3::MDEntryTypeBook::Value v) {
|
||||
}
|
||||
}
|
||||
|
||||
void RealTimeFeedParser::operator()(::mdp3::MDIncrementalRefreshBook46 &m) {
|
||||
void RealTimeHandler::operator()(::mdp3::MDIncrementalRefreshBook46 &m) {
|
||||
EventGuard ev(*this, m);
|
||||
|
||||
m.noMDEntries().forEach([&ev, this](auto &md_entry) {
|
||||
@@ -257,7 +254,7 @@ void RealTimeFeedParser::operator()(::mdp3::MDIncrementalRefreshBook46 &m) {
|
||||
});
|
||||
}
|
||||
|
||||
void RealTimeFeedParser::operator()(
|
||||
void RealTimeHandler::operator()(
|
||||
::mdp3::MDIncrementalRefreshDailyStatistics49 &m) {
|
||||
EventGuard ev(*this, m);
|
||||
|
||||
@@ -289,7 +286,7 @@ void RealTimeFeedParser::operator()(
|
||||
});
|
||||
}
|
||||
|
||||
void RealTimeFeedParser::operator()(
|
||||
void RealTimeHandler::operator()(
|
||||
::mdp3::MDIncrementalRefreshLimitsBanding50 &m) {
|
||||
EventGuard ev(*this, m);
|
||||
|
||||
@@ -311,7 +308,7 @@ void RealTimeFeedParser::operator()(
|
||||
});
|
||||
}
|
||||
|
||||
void RealTimeFeedParser::operator()(
|
||||
void RealTimeHandler::operator()(
|
||||
::mdp3::MDIncrementalRefreshOrderBook47 &m) {
|
||||
EventGuard ev(*this, m);
|
||||
|
||||
@@ -346,7 +343,7 @@ void RealTimeFeedParser::operator()(
|
||||
});
|
||||
}
|
||||
|
||||
void RealTimeFeedParser::operator()(
|
||||
void RealTimeHandler::operator()(
|
||||
::mdp3::MDIncrementalRefreshSessionStatistics51 &m) {
|
||||
|
||||
EventGuard ev(*this, m);
|
||||
@@ -406,7 +403,7 @@ void RealTimeFeedParser::operator()(
|
||||
});
|
||||
}
|
||||
|
||||
void RealTimeFeedParser::operator()(
|
||||
void RealTimeHandler::operator()(
|
||||
::mdp3::MDIncrementalRefreshTradeSummary48 &m) {
|
||||
EventGuard ev(*this, m);
|
||||
|
||||
@@ -436,7 +433,7 @@ void RealTimeFeedParser::operator()(
|
||||
});
|
||||
}
|
||||
|
||||
void RealTimeFeedParser::operator()(::mdp3::MDIncrementalRefreshVolume37 &m) {
|
||||
void RealTimeHandler::operator()(::mdp3::MDIncrementalRefreshVolume37 &m) {
|
||||
EventGuard ev(*this, m);
|
||||
m.noMDEntries().forEach([&ev, this](auto &md_entry) {
|
||||
auto sid = MDP3SecurityID{md_entry.securityID()};
|
||||
@@ -449,39 +446,54 @@ void RealTimeFeedParser::operator()(::mdp3::MDIncrementalRefreshVolume37 &m) {
|
||||
});
|
||||
}
|
||||
|
||||
template <class Def> void RealTimeFeedParser::on_instrument_definition(Def &d) {
|
||||
template <class Def>
|
||||
void RealTimeHandler::on_instrument_definition(Def &d) {
|
||||
InstrumentDefinition def{d};
|
||||
EventGuard ev(*this, def);
|
||||
|
||||
auto sid = MDP3SecurityID{d.securityID()};
|
||||
auto iptr = find_instrument(sid);
|
||||
if (!iptr) {
|
||||
auto new_snapshot = std::make_unique<InstrumentSnapshot>(d);
|
||||
iptr = new_snapshot.get();
|
||||
me->instruments[sid] = std::move(new_snapshot);
|
||||
if (auto iptr = find_instrument(sid); !iptr) {
|
||||
// We only add instruments if we observe them being created
|
||||
// because otherwise we cannot guarantee that the incremental
|
||||
// book updates we receive can be applied to the instrument.
|
||||
if (d.securityUpdateAction() == ::mdp3::SecurityUpdateAction::Add) {
|
||||
auto new_snapshot = std::make_unique<InstrumentSnapshot>(d);
|
||||
iptr = new_snapshot.get();
|
||||
me->instruments[sid] = std::move(new_snapshot);
|
||||
ev.record_security_change(iptr);
|
||||
}
|
||||
else {
|
||||
// We have not observed the instrument creation so it will be
|
||||
// someone else's responsability to build a snapshot for this
|
||||
// instrument and add it via add_snapshot()
|
||||
}
|
||||
}
|
||||
else {
|
||||
iptr->set_definition(d);
|
||||
ev.record_security_change(iptr);
|
||||
}
|
||||
ev.record_security_change(iptr);
|
||||
|
||||
iptr->set_instrument_definition(def);
|
||||
}
|
||||
|
||||
void RealTimeFeedParser::operator()(::mdp3::MDInstrumentDefinitionFuture54 &d) {
|
||||
void RealTimeHandler::operator()(
|
||||
::mdp3::MDInstrumentDefinitionFuture54 &d) {
|
||||
on_instrument_definition(d);
|
||||
}
|
||||
|
||||
void RealTimeFeedParser::operator()(::mdp3::MDInstrumentDefinitionOption55 &d) {
|
||||
void RealTimeHandler::operator()(
|
||||
::mdp3::MDInstrumentDefinitionOption55 &d) {
|
||||
on_instrument_definition(d);
|
||||
}
|
||||
|
||||
void RealTimeFeedParser::operator()(::mdp3::MDInstrumentDefinitionSpread56 &d) {
|
||||
void RealTimeHandler::operator()(
|
||||
::mdp3::MDInstrumentDefinitionSpread56 &d) {
|
||||
on_instrument_definition(d);
|
||||
}
|
||||
|
||||
void RealTimeFeedParser::operator()(::mdp3::QuoteRequest39 &qr) {
|
||||
void RealTimeHandler::operator()(::mdp3::QuoteRequest39 &qr) {
|
||||
EventGuard ev(*this, qr);
|
||||
}
|
||||
|
||||
void RealTimeFeedParser::operator()(::mdp3::SecurityStatus30 &ss) {
|
||||
void RealTimeHandler::operator()(::mdp3::SecurityStatus30 &ss) {
|
||||
EventGuard ev(*this, ss);
|
||||
|
||||
// This applies only to the security
|
||||
@@ -524,13 +536,13 @@ void RealTimeFeedParser::operator()(::mdp3::SecurityStatus30 &ss) {
|
||||
}
|
||||
}
|
||||
|
||||
void RealTimeFeedParser::operator()(::mdp3::ChannelReset4 &r) {
|
||||
void RealTimeHandler::operator()(::mdp3::ChannelReset4 &r) {
|
||||
EventGuard ev(*this, r);
|
||||
for (auto &p : me->instruments)
|
||||
p.second->reset_books();
|
||||
}
|
||||
|
||||
void RealTimeFeedParser::on_end_of_event() {
|
||||
void RealTimeHandler::on_end_of_event() {
|
||||
// trade summary messages have to be processed together once all of
|
||||
// them have been received. We do this here, because we know the
|
||||
// event is over and therefore so are the trade summaries
|
||||
@@ -568,7 +580,7 @@ void RealTimeFeedParser::on_end_of_event() {
|
||||
me->observer.on_event(me->current_event);
|
||||
}
|
||||
|
||||
InstrumentSnapshot *RealTimeFeedParser::find_instrument(MDP3SecurityID id) {
|
||||
InstrumentSnapshot *RealTimeHandler::find_instrument(MDP3SecurityID id) {
|
||||
auto it = me->instruments.find(id);
|
||||
if (it == me->instruments.end())
|
||||
return nullptr;
|
||||
@@ -21,14 +21,16 @@ class BookSnapshot {
|
||||
BookSnapshot();
|
||||
~BookSnapshot();
|
||||
|
||||
void on_begin_packet(MDP3PacketHeader const&);
|
||||
void on_end_packet();
|
||||
void operator()(::mdp3::SnapshotFullRefresh52 &);
|
||||
void operator()(::mdp3::SnapshotFullRefreshOrderBook53 &);
|
||||
|
||||
void reset();
|
||||
bool is_complete() const;
|
||||
std::vector<InstrumentBookSnapshot> get_books_and_reset();
|
||||
|
||||
void on_begin_packet(MDP3PacketHeader const&);
|
||||
void on_end_packet();
|
||||
|
||||
void operator()(::mdp3::SnapshotFullRefresh52 &);
|
||||
void operator()(::mdp3::SnapshotFullRefreshOrderBook53 &);
|
||||
|
||||
|
||||
private:
|
||||
void check_completion();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "../common/InstrumentDefinition.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "../common/InstrumentDefinition.h"
|
||||
|
||||
namespace mdp3 {
|
||||
class MDInstrumentDefinitionFuture54;
|
||||
@@ -18,21 +18,23 @@ class DefinitionSnapshot {
|
||||
public:
|
||||
DefinitionSnapshot();
|
||||
~DefinitionSnapshot();
|
||||
|
||||
void on_begin_packet(MDP3PacketHeader const&);
|
||||
|
||||
bool is_complete() const;
|
||||
void reset();
|
||||
std::vector<InstrumentDefinition> get_definitions_and_reset();
|
||||
|
||||
void on_begin_packet(MDP3PacketHeader const &);
|
||||
void on_end_packet();
|
||||
|
||||
void operator()(::mdp3::MDInstrumentDefinitionFuture54 &);
|
||||
void operator()(::mdp3::MDInstrumentDefinitionOption55 &);
|
||||
void operator()(::mdp3::MDInstrumentDefinitionSpread56 &);
|
||||
void on_end_packet();
|
||||
void reset();
|
||||
bool is_complete() const;
|
||||
std::vector<InstrumentDefinition> get_definitions_and_reset();
|
||||
|
||||
|
||||
private:
|
||||
enum class State;
|
||||
struct PImpl;
|
||||
std::unique_ptr<PImpl> me;
|
||||
template<class D> void on_definition(D &);
|
||||
template <class D> void on_definition(D &);
|
||||
};
|
||||
|
||||
} // namespace bts::spartan::mdp3
|
||||
@@ -30,11 +30,11 @@ bool IncrementalQueue::is_consistent() const {
|
||||
me->state == State::CONSISTENT;
|
||||
}
|
||||
|
||||
size_t IncrementalQueue::first_packet_seq_num() const {
|
||||
MDP3PacketHeader IncrementalQueue::first_packet() const {
|
||||
if (me->queue.size())
|
||||
return me->queue[0].packet_header.msg_seq_num;
|
||||
return me->queue[0].packet_header;
|
||||
else
|
||||
return 0;
|
||||
return {0,0};
|
||||
}
|
||||
|
||||
void IncrementalQueue::reset() {
|
||||
|
||||
@@ -34,13 +34,14 @@ class IncrementalQueue {
|
||||
// - The last message in the queue is also the last message in a packet
|
||||
// - The last message in the queue is also the last message in an event
|
||||
bool is_consistent() const;
|
||||
MDP3PacketHeader first_packet () const;
|
||||
|
||||
size_t first_packet_seq_num() const;
|
||||
void reset();
|
||||
std::vector<SequencedMDP3MsgWrapper> get_queued_messages_and_reset();
|
||||
|
||||
void on_begin_packet(MDP3PacketHeader const&);
|
||||
void on_end_packet();
|
||||
|
||||
void operator()(::mdp3::ChannelReset4&);
|
||||
void operator()(::mdp3::MDIncrementalRefreshBook46&);
|
||||
void operator()(::mdp3::MDIncrementalRefreshDailyStatistics49&);
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
namespace bts::spartan::mdp3 {
|
||||
|
||||
class RecoveryHandler {
|
||||
public:
|
||||
|
||||
class InstrumentFeedHandler {
|
||||
public:
|
||||
void on_begin_packet(MDP3PacketHeader const &);
|
||||
void on_end_packet();
|
||||
void operator()(::mdp3::MDInstrumentDefinitionFuture54 &);
|
||||
void operator()(::mdp3::MDInstrumentDefinitionOption55 &);
|
||||
void operator()(::mdp3::MDInstrumentDefinitionSpread56 &);
|
||||
private:
|
||||
InstrumentFeedHandler(RecoveryHandler&);
|
||||
RecoveryHandler owner;
|
||||
} on_instrument_feed;
|
||||
|
||||
class SnapshotFeedHandler {
|
||||
public:
|
||||
SnapshotFeedHandler(RecoveryHandler&);
|
||||
void on_begin_packet(MDP3PacketHeader const &);
|
||||
void on_end_packet();
|
||||
void operator()(::mdp3::SnapshotFullRefresh52 &);
|
||||
void operator()(::mdp3::SnapshotFullRefreshOrderBook53 &);
|
||||
private:
|
||||
SnapshotFeedHandler(RecoveryHandler&);
|
||||
RecoveryHandler owner;
|
||||
} on_snapshot_feed;
|
||||
|
||||
class IncrementalFeedHandler {
|
||||
void on_begin_packet(MDP3PacketHeader const &);
|
||||
void on_end_packet();
|
||||
void operator()(::mdp3::MDIncrementalRefreshBook46 &);
|
||||
void operator()(::mdp3::MDIncrementalRefreshDailyStatistics49 &);
|
||||
void operator()(::mdp3::MDIncrementalRefreshLimitsBanding50 &);
|
||||
void operator()(::mdp3::MDIncrementalRefreshOrderBook47 &);
|
||||
void operator()(::mdp3::MDIncrementalRefreshSessionStatistics51 &);
|
||||
void operator()(::mdp3::MDIncrementalRefreshTradeSummary48 &);
|
||||
void operator()(::mdp3::MDIncrementalRefreshVolume37 &);
|
||||
void operator()(::mdp3::MDInstrumentDefinitionFuture54 &);
|
||||
void operator()(::mdp3::MDInstrumentDefinitionOption55 &);
|
||||
void operator()(::mdp3::MDInstrumentDefinitionSpread56 &);
|
||||
void operator()(::mdp3::QuoteRequest39 &);
|
||||
void operator()(::mdp3::SecurityStatus30 &);
|
||||
void operator()(::mdp3::ChannelReset4 &);
|
||||
private:
|
||||
IncrementalFeedHandler(RecoveryHandler&);
|
||||
RecoveryHandler owner;
|
||||
} on_incremental_feed;
|
||||
|
||||
|
||||
private:
|
||||
struct PImpl;
|
||||
std::unique_ptr<PImpl> me;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user