Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8fcd19034 | ||
|
|
993fe6697f | ||
|
|
fa18dcc6d4 | ||
|
|
5786f8eba1 |
No files matched your search
@@ -34,3 +34,5 @@ trace_data/
|
||||
/doc/user/public/*
|
||||
.ionide/*
|
||||
/.ignore
|
||||
/build
|
||||
/analysis_data
|
||||
@@ -1,12 +1,13 @@
|
||||
Session ID Access ID Secret Key Creation Date Expiration Date Environment
|
||||
Session ID Access ID Secret Key Creation Date Expiration Date Environment
|
||||
|
||||
M4D lLtjH74y1Kh5XUJTLyH2 f1K_tROQp2lTIplVp34WxKa7xDUgfFnIteolfik061o 2019-09-03 2020-09-03 CERT
|
||||
M4D lLtjH74y1Kh5XUJTLyH2 f1K_tROQp2lTIplVp34WxKa7xDUgfFnIteolfik061o 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC1 VEMlkDuLz74OVHSuacQB IuHyYT3b-9KUo3WsuXykt-fXsjzp7L-JOrdCSQZLNl0 2019-09-03 2020-09-03 CERT
|
||||
MC1 VEMlkDuLz74OVHSuacQB IuHyYT3b-9KUo3WsuXykt-fXsjzp7L-JOrdCSQZLNl0 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC5 77lzSUwPLlM9obaXh2mK z6aA9qfASDKfZkYTVKFqJd-78i0HZ2Q9ec3CKCYIqHg 2019-09-03 2020-09-03 CERT
|
||||
MC5 77lzSUwPLlM9obaXh2mK z6aA9qfASDKfZkYTVKFqJd-78i0HZ2Q9ec3CKCYIqHg 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC7 RphzI3rn71oGUEiYnX9e y6OvvPPyoyj2S8YAnE1gFduXT8v29HIMjO5EngYxSNg 2019-09-03 2020-09-03 CERT
|
||||
MC7 RphzI3rn71oGUEiYnX9e y6OvvPPyoyj2S8YAnE1gFduXT8v29HIMjO5EngYxSNg 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC8 PYBIm2TI9gFPIxmHbuYl 6o-ZolGH2DdeQOlGtJ5Zqoh_kg7VdbxkmjeOHmigKwU 2019-09-03 2020-09-03 CERT
|
||||
MC8 PYBIm2TI9gFPIxmHbuYl 6o-ZolGH2DdeQOlGtJ5Zqoh_kg7VdbxkmjeOHmigKwU 2019-09-03 2020-09-03 CERT
|
||||
|
||||
NGG 1OXPqNxPhbqbzm0kF92e qlUrwY1KG1Pyq-TcbJgMqYXmBTQoAi-wEEBERRDRZPE 2019-12-20 2020-12-20 NEWRELEASE
|
||||
@@ -1 +1 @@
|
||||
set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/service_helpers/PositionUtilities.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/BasePositionService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MBOService.proto;api/services/MarginService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/MoneyFileService.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/keycode.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/position_cfg.conf;config/defaults/span.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/sod.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/sample_fix.cpp;jetfix/tests/store_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MBOProcessor.cpp;md/MBOServiceServer.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityMapper.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/ice/ICEUtils.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/mbo_tests.cpp;md/test/md2_tests.cpp;md/test/md_test_utils.cpp;md/test/synthetic_book_merge_tests.cpp;md/vendor/OnixsUtils.cpp;mercury/actors/IPollableActor.cpp;mercury/broker/Broker.cpp;mercury/broker/BrokerProxy.cpp;mercury/broker/ILocalBroker.cpp;mercury/broker/IRemoteBroker.cpp;mercury/common/mercury_common.cpp;mercury/events/TimerEvent.cpp;mercury/executor/Executor.cpp;mercury/topics/Topic.cpp;metrics/metrics.cpp;metrics/system_metrics.cpp;orderman/actors/AsyncFactory.cpp;orderman/actors/FillStore.cpp;orderman/actors/GLBXExecutionGateway.cpLine truncated
|
||||
set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/service_helpers/PositionUtilities.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/BasePositionService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MBOService.proto;api/services/MarginService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/MoneyFileService.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/keycode.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/position_cfg.conf;config/defaults/span.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/sod.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/sample_fix.cpp;jetfix/tests/store_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MBOProcessor.cpp;md/MBOServiceServer.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityMapper.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/ice/ICEUtils.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/mbo_tests.cpp;md/test/md2_tests.cpp;md/test/md_test_utils.cpp;md/test/synthetic_book_merge_tests.cpp;md/vendor/OnixsUtils.cpp;mercury/actors/IPollableActor.cpp;mercury/broker/Broker.cpp;mercury/broker/BrokerProxy.cpp;mercury/broker/ILocalBroker.cpp;mercury/broker/IRemoteBroker.cpp;mercury/common/mercury_common.cpp;mercury/events/TimerEvent.cpp;mercury/executor/Executor.cpp;mercury/topics/Topic.cpp;metrics/metrics.cpp;metrics/system_metrics.cpp;orderman/actors/AsyncFactory.cpp;orderman/actors/FillStore.cpp;orderman/actors/GLBXExecutionGateway.cpLine truncated
|
||||
@@ -830,8 +830,8 @@ OutFIXPtr make_logon(uint32_t seq_num, uint32_t last_seq_num_processed,
|
||||
buffer.add<EncodedTextLen>(ld.access_key.size());
|
||||
buffer.add<EncodedText>(ld.access_key);
|
||||
buffer.add<EncryptedPasswordMethod>("CME-1-SHA-256");
|
||||
buffer.add<EncryptedPasswordLen>(ld.signature.size());
|
||||
buffer.add<EncryptedPassword>(ld.signature);
|
||||
buffer.add<EncryptedPasswordLen>(ld.signature_base64.size());
|
||||
buffer.add<EncryptedPassword>(ld.signature_base64);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@ bool in_session(datetime::PTime const &ref_date,
|
||||
return closest_earlier_end < closest_earlier_start;
|
||||
}
|
||||
|
||||
std::string
|
||||
SessionName
|
||||
session_name_from_ptime(datetime::PTime t,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::posix_time::time_duration time_of_day_end) {
|
||||
@@ -85,10 +85,10 @@ session_name_from_ptime(datetime::PTime t,
|
||||
(unsigned short)start_of_session.date().year(),
|
||||
start_of_session.date().month().as_number(),
|
||||
start_of_session.date().day().as_number());
|
||||
return result;
|
||||
return {result,t};
|
||||
}
|
||||
|
||||
std::string session_name(datetime::PTime const &ref_date,
|
||||
std::optional<SessionName> session_name(datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday_start,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::gregorian::greg_weekday weekday_end,
|
||||
@@ -100,25 +100,22 @@ std::string session_name(datetime::PTime const &ref_date,
|
||||
boost::posix_time::time_duration(0, 0, 0),
|
||||
boost::posix_time::time_duration(0, 0, 1));
|
||||
else
|
||||
return std::string();
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::string session_name(datetime::PTime const &ref_date,
|
||||
std::optional<SessionName> session_name(datetime::PTime const &ref_date,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::posix_time::time_duration time_of_day_end) {
|
||||
if (in_session(ref_date, time_of_day_start, time_of_day_end))
|
||||
return session_name_from_ptime(ref_date, time_of_day_start,
|
||||
time_of_day_end);
|
||||
else
|
||||
return "";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::string session_name(config::JetFIX::Connection const &session_cfg) {
|
||||
return session_name(datetime::local_now(), session_cfg);
|
||||
}
|
||||
std::optional<SessionName> session_name(config::JetFIX::Connection const &session_cfg) {
|
||||
auto now = datetime::local_now();
|
||||
|
||||
std::string session_name(datetime::PTime const&now,
|
||||
config::JetFIX::Connection const &session_cfg) {
|
||||
if (session_cfg.has_start_day()) {
|
||||
bts_assert(session_cfg.has_end_day());
|
||||
return session_name(now, parse_weekday(session_cfg.start_day()),
|
||||
@@ -193,8 +190,9 @@ SessionSpan session_span(datetime::PTime const &ref_date,
|
||||
}
|
||||
}
|
||||
|
||||
SessionSpan session_span(datetime::PTime const&now,config::JetFIX::Connection const&session_cfg)
|
||||
{
|
||||
SessionSpan session_span(config::JetFIX::Connection const &session_cfg) {
|
||||
auto now = datetime::local_now();
|
||||
|
||||
if (session_cfg.has_start_day()) {
|
||||
bts_assert(session_cfg.has_end_day());
|
||||
return session_span(now, parse_weekday(session_cfg.start_day()),
|
||||
@@ -206,10 +204,5 @@ SessionSpan session_span(datetime::PTime const&now,config::JetFIX::Connection co
|
||||
parse_time(session_cfg.end_time()));
|
||||
}
|
||||
|
||||
SessionSpan session_span(config::JetFIX::Connection const &session_cfg) {
|
||||
return session_span(datetime::local_now(), session_cfg);
|
||||
}
|
||||
|
||||
|
||||
} // namespace jetfix
|
||||
} // namespace bts
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "lib/utils/datetime.h"
|
||||
#include "lib/config/protos/jetfix.pb.h"
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <optional>
|
||||
|
||||
namespace boost {
|
||||
namespace gregorian {
|
||||
@@ -18,6 +19,11 @@ class time_duration;
|
||||
namespace bts {
|
||||
namespace jetfix {
|
||||
|
||||
struct SessionName {
|
||||
std::string name;
|
||||
datetime::PTime time;
|
||||
};
|
||||
|
||||
boost::gregorian::greg_weekday parse_weekday (std::string weekday_str);
|
||||
bool parse_time (std::string const &time_str,boost::posix_time::time_duration *out);
|
||||
|
||||
@@ -35,25 +41,22 @@ bool in_session (datetime::PTime const &ref_date,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
|
||||
std::string session_name (datetime::PTime const &ref_date,
|
||||
std::optional<SessionName> session_name (datetime::PTime const &ref_date,
|
||||
boost::gregorian::greg_weekday weekday_start,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::gregorian::greg_weekday weekday_end,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
|
||||
std::string session_name (datetime::PTime const &ref_date,
|
||||
std::optional<SessionName> session_name (datetime::PTime const &ref_date,
|
||||
boost::posix_time::time_duration time_of_day_start,
|
||||
boost::posix_time::time_duration time_of_day_end);
|
||||
|
||||
std::string session_name (config::JetFIX::Connection const &session_cfg);
|
||||
std::string session_name (datetime::PTime const &ref_date,
|
||||
config::JetFIX::Connection const &session_cfg);
|
||||
std::optional<SessionName> session_name (config::JetFIX::Connection const &session_cfg);
|
||||
|
||||
struct SessionSpan {
|
||||
datetime::PTime start;
|
||||
datetime::PTime stop;
|
||||
};
|
||||
SessionSpan session_span(config::JetFIX::Connection const&session_cfg);
|
||||
SessionSpan session_span(datetime::PTime const&local_now,config::JetFIX::Connection const&session_cfg);
|
||||
|
||||
}}
|
||||
@@ -92,7 +92,7 @@ size_t load_securities(
|
||||
api::Venue venue = (api::Venue)(int) select_stmt.getColumn("venue");
|
||||
auto type = (api::SecurityType)(int) select_stmt.getColumn("type");
|
||||
UserSymbol us(symbol, venue, type);
|
||||
if (symbols.empty() || symbols.find(us) != symbols.end()) {
|
||||
if (symbols.find(us) != symbols.end()) {
|
||||
auto blob = select_stmt.getColumn("security_blob");
|
||||
if (security.ParseFromArray(blob, blob.getBytes())) {
|
||||
apply_compatibilit_mutations(security);
|
||||
@@ -108,9 +108,6 @@ size_t load_securities(
|
||||
|
||||
return count;
|
||||
}
|
||||
size_t load_securities(const std::function<void(const api::Security&)>& callback) {
|
||||
return load_securities({}, callback);
|
||||
}
|
||||
|
||||
SecurityPtr find_security(SecurityKey key) {
|
||||
try {
|
||||
|
||||
@@ -27,7 +27,6 @@ struct SecurityDB;
|
||||
size_t load_securities(
|
||||
const std::set<UserSymbol>& symbols,
|
||||
const std::function<void(const api::Security&)>& callback);
|
||||
size_t load_securities(const std::function<void(const api::Security&)>& callback);
|
||||
|
||||
SecurityPtr find_security(SecurityKey);
|
||||
|
||||
|
||||
@@ -42,22 +42,18 @@ BeginString = FIX.4.2 8=FIX.4.2
|
||||
BodyLength = 271 9=271
|
||||
MsgType = NewOrderSingle 35=D
|
||||
MsgSeqNum = 8026 34=8026
|
||||
|
||||
SenderCompID = DT9238N 49=DT9238N
|
||||
SenderSubID = ROR 50=ROR
|
||||
SendingTime = 20161102-20:36:47.620 52=20161102-20:36:47.620
|
||||
TargetCompID = CME 56=CME
|
||||
|
||||
TargetSubID = 64 57=64
|
||||
SenderLocationID = US,IL 142=US,IL
|
||||
LastMsgSeqNumProcessed = 7374 369=7374
|
||||
Account = X8CM1 1=X8CM1
|
||||
|
||||
ClOrdID = 2KjMkw-1C22h9-001v8Q 11=2KjMkw-1C22h9-001v8Q
|
||||
HandlInst = 1 21=1
|
||||
OrderQty = 1 38=1
|
||||
OrdType = 2 40=2
|
||||
|
||||
Price = 209075 44=209075
|
||||
SecurityID = 2928 48=2928
|
||||
Side = 1 54=1
|
||||
|
||||
@@ -32,16 +32,12 @@ class Governor {
|
||||
return true;
|
||||
}
|
||||
|
||||
void record_sent(bool rate_limited, TimeStamp now = Timer::now()) {
|
||||
void record_sent(TimeStamp now = Timer::now()) {
|
||||
if (!in_window(now)) {
|
||||
_start_of_window = now;
|
||||
_msgs_in_window = 0;
|
||||
}
|
||||
_msgs_in_window += rate_limited;
|
||||
}
|
||||
|
||||
void record_sent(TimeStamp now = Timer::now()) {
|
||||
record_sent(true, now);
|
||||
_msgs_in_window++;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -72,6 +72,7 @@ OrderOpResult SplitterAlgo::do_before_launch(IBeforeLaunchAlgoServices& ibl) {
|
||||
void SplitterAlgo::do_launch(IAlgoServices& ias) {
|
||||
me->algo = &ias;
|
||||
me->target_qty = ias.quantity().value();
|
||||
ias.set_ladder_visibility(false);
|
||||
// launches initial child orders
|
||||
sync_orders();
|
||||
}
|
||||
|
||||
@@ -26,15 +26,26 @@ template <class Req> GW_Op_Ack make_ack(Req const &r) {
|
||||
struct Gateway::OrderRec {
|
||||
OrderRec() = default;
|
||||
OrderRec(OM_ID om_id, GW_BoundOrder const &order)
|
||||
: order(order), originator(om_id), last_ack(), routing_record(nullptr) {}
|
||||
: order(order), cancel_replace(nullptr), cancel(nullptr),
|
||||
originator(om_id) {}
|
||||
|
||||
GW_BoundOrder order;
|
||||
ICancelReplaceMsg *cancel_replace;
|
||||
ICancelMsg *cancel;
|
||||
OM_ID originator;
|
||||
GW_Op_Ack last_ack;
|
||||
api::orderman::RoutingRecord const *routing_record;
|
||||
|
||||
void clear_msgs() {
|
||||
cancel_replace = nullptr;
|
||||
cancel = nullptr;
|
||||
}
|
||||
|
||||
bool is_routable() const { return routing_record != nullptr; }
|
||||
void mark_non_routable() { routing_record = nullptr; }
|
||||
bool is_routable() const { return cancel_replace != nullptr; }
|
||||
|
||||
void set_msgs(ICancelReplaceMsg const &cr, ICancelMsg &can) {
|
||||
cancel_replace = &cr.clone();
|
||||
cancel = &can.clone();
|
||||
}
|
||||
};
|
||||
|
||||
class Gateway::OrderMap {
|
||||
@@ -45,7 +56,6 @@ class Gateway::OrderMap {
|
||||
return _store.make_and_index(bo.key.value, om_id, bo);
|
||||
}
|
||||
void remove(OrderKey k) { _store.remove(k.value); }
|
||||
|
||||
std::vector<OrderRec *> get_all() { return _store.get_all(); }
|
||||
|
||||
private:
|
||||
@@ -61,29 +71,27 @@ enum class Gateway::State {
|
||||
};
|
||||
|
||||
struct Gateway::Hot {
|
||||
using RoutingRecordsMap =
|
||||
std::unordered_map<UserAccountVenue, api::orderman::RoutingRecord,
|
||||
UserAccountVenueHash>;
|
||||
using MsgTemplatesMap =
|
||||
std::unordered_map<UserAccountVenue, MsgTemplates, UserAccountVenueHash>;
|
||||
|
||||
Hot(IVenue &v, ILimiter &l)
|
||||
: state(State::W_BOOTSTRAP), venue(v), limiter(l), working_orders(),
|
||||
routing_records() {}
|
||||
pending_msgs(), msg_templates() {}
|
||||
|
||||
State state;
|
||||
IVenue &venue;
|
||||
ILimiter &limiter;
|
||||
|
||||
// TODO: Separate orders that cannot be routed from working orders
|
||||
// to avoid the if is_routable() on order events
|
||||
// TODO: Separate ourders that cannot be routed from working orders to avoid
|
||||
// the if is_routable() on order events
|
||||
OrderMap working_orders;
|
||||
RoutingRecordsMap routing_records;
|
||||
boost::container::small_vector<IVenueMsg *, 8> pending_msgs;
|
||||
MsgTemplatesMap msg_templates;
|
||||
};
|
||||
|
||||
struct Gateway::Cold {
|
||||
Cold(IRouter &r, IClock &c, GatewayCfg const &cfg)
|
||||
: router(r), clock(c), admin_data(), cfg(cfg), start_of_pause(),
|
||||
current_exponential_backoff(0), bootstrap_orders(),
|
||||
interned_strings() {}
|
||||
current_exponential_backoff(0), bootstrap_orders(), interned_strings () {}
|
||||
|
||||
IRouter &router;
|
||||
IClock &clock;
|
||||
@@ -143,7 +151,6 @@ void Gateway::do_slow_work() {
|
||||
case State::W_LOGON:
|
||||
break;
|
||||
}
|
||||
me->hot.venue.do_work();
|
||||
}
|
||||
|
||||
void Gateway::on_om_bootstrap_orders(OM_BootstrapOrders const &orders) {
|
||||
@@ -158,7 +165,7 @@ void Gateway::on_om_bootstrap_orders(OM_BootstrapOrders const &orders) {
|
||||
|
||||
void Gateway::on_gw_ops(const GW_Op_Batch &op_batch) {
|
||||
op_batch.visit(*this);
|
||||
me->hot.venue.send_queued_msgs();
|
||||
send_pending_msgs();
|
||||
}
|
||||
|
||||
void Gateway::on_account_pnl(const AccountPnLUpdate &pnl) {
|
||||
@@ -176,14 +183,13 @@ void Gateway::on_excess_liquidity(const ExcessLiquidityUpdate &l) {
|
||||
void Gateway::on_admin_data(AdminDataUpdate const &admin) {
|
||||
me->hot.limiter.update(*me->cold.admin_data);
|
||||
me->cold.router.update(*me->cold.admin_data);
|
||||
me->hot.routing_records.clear();
|
||||
|
||||
switch (me->hot.state) {
|
||||
case State::W_BOOTSTRAP:
|
||||
me->cold.admin_data = admin.admin_data;
|
||||
break;
|
||||
default:
|
||||
rebuild_routing_records();
|
||||
rebuild_msg_templates();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +201,7 @@ void Gateway::on_venue_login_success(std::vector<ExecReport> const &recovered) {
|
||||
bts_assert(me->hot.state == State::W_LOGON);
|
||||
me->cold.current_exponential_backoff = 0;
|
||||
transition(State::READY);
|
||||
for (auto const &er : recovered)
|
||||
for (auto const &er : recovered)
|
||||
on_venue_exe_report(er);
|
||||
}
|
||||
|
||||
@@ -203,9 +209,10 @@ void Gateway::on_venue_login_failure() {
|
||||
bts_assert(me->hot.state == State::W_LOGON);
|
||||
|
||||
if (in_active_schedule()) {
|
||||
me->cold.current_exponential_backoff++;
|
||||
me->cold.current_exponential_backoff ++;
|
||||
transition(State::PAUSED);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
me->cold.current_exponential_backoff = 0;
|
||||
transition(State::W_SCHEDULE);
|
||||
}
|
||||
@@ -240,8 +247,8 @@ void Gateway::on_venue_exe_report(const ExecReport &report) {
|
||||
on_order_report(make_order_report(r));
|
||||
} else if (report.status == OrderStatus::WORKING) {
|
||||
auto sec = me->hot.venue.resolve_security(report);
|
||||
if (sec)
|
||||
on_unknown_native_order_update({sec, me->cold.cfg.my_id, report});
|
||||
if (sec)
|
||||
on_unknown_native_order_update ( {sec,me->cold.cfg.my_id,report});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,12 +288,20 @@ void Gateway::on_gw_op(OM_ID om_id, const GW_OrderCreate &create) {
|
||||
case State::READY: {
|
||||
|
||||
// Validate route
|
||||
auto it = me->hot.routing_records.find(order.uav);
|
||||
if (it == me->hot.routing_records.end()) {
|
||||
auto &msg_templates = me->hot.msg_templates;
|
||||
INewOrderSingleMsg *new_order_single;
|
||||
auto it = msg_templates.find(order.uav);
|
||||
if (it == msg_templates.end()) {
|
||||
ack.result = GW_OP_Result::ERROR_NO_ROUTE;
|
||||
break;
|
||||
} else
|
||||
gw_rec->routing_record = &it->second;
|
||||
}
|
||||
|
||||
// TODO: Replace the chained ifs with the accumulate error flags
|
||||
// and check them once.
|
||||
|
||||
// Set msgs in order record
|
||||
new_order_single = &it->second.new_order->clone();
|
||||
gw_rec->set_msgs(*it->second.cancel_replace, *it->second.cancel);
|
||||
|
||||
// Validate risk limit
|
||||
auto lqt = me->hot.limiter.can_send_new_order(
|
||||
@@ -303,12 +318,10 @@ void Gateway::on_gw_op(OM_ID om_id, const GW_OrderCreate &create) {
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: Replace the chained ifs with accumulated error flags
|
||||
// and check them once, to avoid pressure on the branch
|
||||
// predictor.
|
||||
|
||||
// All is good. Queue for send.
|
||||
me->hot.venue.queue_send(gw_rec->order, *gw_rec->routing_record);
|
||||
// All is good. Copy the order params to the order message and
|
||||
// queue the message for sending.
|
||||
new_order_single->set_order_params(order);
|
||||
me->hot.pending_msgs.push_back(new_order_single);
|
||||
|
||||
// For speed we do not send acks for the operation until we hear
|
||||
// from the exchange.
|
||||
@@ -345,12 +358,12 @@ void Gateway::on_gw_op(OM_ID om_id, const GW_OrderBind &bind) {
|
||||
auto &ack = gw_rec->last_ack;
|
||||
ack = make_ack(bind);
|
||||
|
||||
// Find the routing record for this order
|
||||
auto it = me->hot.routing_records.find(order.uav);
|
||||
if (it == me->hot.routing_records.end())
|
||||
// Find the message templates for this UAV and clone them for this
|
||||
// order
|
||||
auto &msg_templates = me->hot.msg_templates;
|
||||
auto it = msg_templates.find(order.uav);
|
||||
if (it == msg_templates.end())
|
||||
ack.result = GW_OP_Result::ERROR_NO_ROUTE;
|
||||
else
|
||||
gw_rec->routing_record = &it->second;
|
||||
|
||||
// In this case we have to send a reply to the bind operation
|
||||
// because there is no guarantee that we will be able to piggy back
|
||||
@@ -401,7 +414,8 @@ void Gateway::on_gw_op(OM_ID, const GW_OrderQuickUpdate &quick_update) {
|
||||
}
|
||||
order.price = quick_update.price;
|
||||
order.quantity = quick_update.quantity;
|
||||
me->hot.venue.queue_update(gw_rec->order, *gw_rec->routing_record);
|
||||
gw_rec->cancel_replace->update(order);
|
||||
me->hot.pending_msgs.push_back(gw_rec->cancel_replace);
|
||||
|
||||
// We do not send out a order report for performance
|
||||
// reasons. Instead we delay the report until the exchange
|
||||
@@ -422,9 +436,9 @@ void Gateway::on_gw_op(OM_ID, const GW_OrderQuickUpdate &quick_update) {
|
||||
}
|
||||
|
||||
// The difference between a full update and a quick update is that in
|
||||
// a full update we allow for any change including the account/user
|
||||
// associated with the order. This could change the routing of the
|
||||
// order so we need to retrieve a (possibly new) routing record.
|
||||
// a full update we allow for the account / user to change. In this
|
||||
// case we have to re-create the messages for cancel and update since
|
||||
// these messages embed in them account and user specific information.
|
||||
void Gateway::on_gw_op(OM_ID om_id, const GW_OrderFullUpdate &full_update) {
|
||||
auto gw_rec = me->hot.working_orders.lookup(full_update.order_key);
|
||||
auto &ack = gw_rec->last_ack;
|
||||
@@ -446,13 +460,13 @@ void Gateway::on_gw_op(OM_ID om_id, const GW_OrderFullUpdate &full_update) {
|
||||
}
|
||||
|
||||
auto &order = gw_rec->order;
|
||||
auto it = me->hot.routing_records.find(order.uav);
|
||||
if (it == me->hot.routing_records.end()) {
|
||||
gw_rec->mark_non_routable();
|
||||
auto &msg_templates = me->hot.msg_templates;
|
||||
auto it = msg_templates.find(order.uav);
|
||||
if (it == msg_templates.end()) {
|
||||
ack.result = GW_OP_Result::ERROR_NO_ROUTE;
|
||||
gw_rec->clear_msgs();
|
||||
break;
|
||||
} else
|
||||
gw_rec->routing_record = &it->second;
|
||||
}
|
||||
|
||||
// Update existing record with the non quick parts of the full
|
||||
// order update. There is a bit of inconsistency here. We are
|
||||
@@ -460,8 +474,8 @@ void Gateway::on_gw_op(OM_ID om_id, const GW_OrderFullUpdate &full_update) {
|
||||
// fields below, even though the quick update might later fail
|
||||
// to set the quantity and price. This could leave the order in
|
||||
// a half-updated half not-updated state. This should be rare
|
||||
// and benign enough so we live with it to avoid duplicating the
|
||||
// update logic from quick update here.
|
||||
// and benign enough so we live with it.
|
||||
gw_rec->set_msgs(*it->second.cancel_replace, *it->second.cancel);
|
||||
gw_rec->order.uav = full_update.uav;
|
||||
gw_rec->order.moi = full_update.moi;
|
||||
gw_rec->order.tif = full_update.tif;
|
||||
@@ -507,7 +521,10 @@ void Gateway::on_gw_op(OM_ID, const GW_OrderCancel &cancel) {
|
||||
break;
|
||||
}
|
||||
|
||||
me->hot.venue.queue_cancel(gw_rec->order, *gw_rec->routing_record);
|
||||
auto &order = gw_rec->order;
|
||||
gw_rec->cancel->update(order);
|
||||
me->hot.pending_msgs.push_back(gw_rec->cancel);
|
||||
|
||||
// We do not send out a order report yet for performance
|
||||
// reasons. Instead we delay the report until the exchange
|
||||
// reponds to our cancel
|
||||
@@ -526,8 +543,18 @@ void Gateway::on_gw_op(OM_ID, const GW_OrderCancel &cancel) {
|
||||
on_order_report(make_order_report(gw_rec));
|
||||
}
|
||||
|
||||
const char *Gateway::intern_string(std::string const &str) {
|
||||
return me->cold.interned_strings.insert(str).first->data();
|
||||
const char* Gateway::intern_string(std::string const&str) {
|
||||
auto [it,_] = me->cold.interned_strings.insert(str);
|
||||
(void)_;
|
||||
return it->data();
|
||||
}
|
||||
|
||||
void Gateway::send_pending_msgs() {
|
||||
auto &pending = me->hot.pending_msgs;
|
||||
// TODO: Need to make sure that there is no danger of reentrancy
|
||||
// here, in the case that venue calls us back from the send call
|
||||
me->hot.venue.send(pending.data(), (pending.data() + pending.size()));
|
||||
pending.clear();
|
||||
}
|
||||
|
||||
bool Gateway::has_bootstrap_data() const {
|
||||
@@ -536,7 +563,7 @@ bool Gateway::has_bootstrap_data() const {
|
||||
}
|
||||
|
||||
bool Gateway::in_active_schedule() const {
|
||||
auto now = me->cold.clock.ptime_local_now();
|
||||
auto now = me->cold.clock.ptime_now();
|
||||
return now >= me->cold.session_span.start &&
|
||||
now < me->cold.session_span.stop;
|
||||
}
|
||||
@@ -547,27 +574,29 @@ void Gateway::transition(State state) {
|
||||
me->hot.state = state;
|
||||
}
|
||||
|
||||
void Gateway::rebuild_routing_records() {
|
||||
void Gateway::rebuild_msg_templates() {
|
||||
// First just rebuild our template cache
|
||||
me->hot.routing_records.clear();
|
||||
|
||||
me->hot.msg_templates.clear();
|
||||
auto all_uav = me->hot.limiter.get_all_user_account_venue();
|
||||
for (auto const &uav : all_uav) {
|
||||
auto rq = me->cold.router.get_route(uav);
|
||||
if (rq.has_route)
|
||||
me->hot.routing_records[uav] = rq.routing_record;
|
||||
if (rq.has_route) {
|
||||
me->hot.msg_templates[uav] =
|
||||
me->hot.venue.get_msg_templates(rq.routing_record);
|
||||
}
|
||||
}
|
||||
|
||||
// Now go through every order and update its messages
|
||||
auto working = me->hot.working_orders.get_all();
|
||||
for (auto &orec : working) {
|
||||
if (auto it = me->hot.routing_records.find(orec->order.uav);
|
||||
it != me->hot.routing_records.end()) {
|
||||
orec->routing_record = &it->second;
|
||||
orec->clear_msgs();
|
||||
if (auto it = me->hot.msg_templates.find(orec->order.uav);
|
||||
it != me->hot.msg_templates.end()) {
|
||||
orec->set_msgs(*it->second.cancel_replace, *it->second.cancel);
|
||||
} else {
|
||||
LOG(OrderMan, Error, "Order {} can no longer be routed. {}",
|
||||
orec->order.key, orec->order.uav.to_str());
|
||||
orec->mark_non_routable();
|
||||
orec->clear_msgs();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class Gateway : public Actor, ISlowWorker, IGW_Op_Visitor, IVenueObserver {
|
||||
bool has_bootstrap_data() const;
|
||||
bool in_active_schedule() const;
|
||||
void transition(State);
|
||||
void rebuild_routing_records();
|
||||
void rebuild_msg_templates();
|
||||
void setup_bootstrap_orders();
|
||||
GW_OrderReport make_order_report(OrderRec *);
|
||||
static log::CharPtrWrapper state_name(State);
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
namespace bts {
|
||||
namespace api {
|
||||
class Security;
|
||||
namespace orderman {
|
||||
class RoutingRecord;
|
||||
namespace orderman { class RoutingRecord;}
|
||||
}
|
||||
} // namespace api
|
||||
|
||||
namespace orderman_v2 {
|
||||
|
||||
@@ -19,13 +17,19 @@ class IVenueMsg;
|
||||
class IVenueObserver;
|
||||
class ExecReport;
|
||||
class VenueCheckpoint;
|
||||
struct GW_BoundOrder;
|
||||
|
||||
struct MsgTemplates {
|
||||
INewOrderSingleMsg* new_order;
|
||||
ICancelReplaceMsg* cancel_replace;
|
||||
ICancelMsg* cancel;
|
||||
};
|
||||
|
||||
struct SessionSpan {
|
||||
datetime::PTime start;
|
||||
datetime::PTime stop;
|
||||
};
|
||||
|
||||
|
||||
class IVenue {
|
||||
public:
|
||||
// call this before any of the below
|
||||
@@ -36,34 +40,31 @@ class IVenue {
|
||||
virtual SessionSpan get_current_session_span() = 0;
|
||||
|
||||
// Logon to the venue. This can only be called if the caller knows that the
|
||||
// venue is in the idle state.
|
||||
// venue is in the idle state.
|
||||
virtual void login() = 0;
|
||||
|
||||
// Build new order, cancel replace and cancel messages appropriate
|
||||
// for this venue and using the information in the passed routing
|
||||
// record
|
||||
virtual MsgTemplates
|
||||
get_msg_templates(api::orderman::RoutingRecord const &) = 0;
|
||||
|
||||
// Check to to see if the venue is currently able to receive new
|
||||
// messages without breaching messaging limits
|
||||
virtual bool under_messaging_limit() = 0;
|
||||
|
||||
virtual void queue_send(GW_BoundOrder const &,
|
||||
api::orderman::RoutingRecord const &) = 0;
|
||||
virtual void queue_update(GW_BoundOrder const &,
|
||||
api::orderman::RoutingRecord const &) = 0;
|
||||
virtual void queue_cancel(GW_BoundOrder const &,
|
||||
api::orderman::RoutingRecord const &) = 0;
|
||||
virtual void send_queued_msgs() = 0;
|
||||
// Send the passed messages to the venue. It is only legal to call
|
||||
// this if the venue is idle or ready.
|
||||
virtual void send(IVenueMsg**begin, IVenueMsg**end) = 0;
|
||||
|
||||
// Resolved the security in the execution report. This is only
|
||||
// needed for disaster recovery. Null should be returned in case of
|
||||
// failure.
|
||||
virtual api::Security const *resolve_security(ExecReport const &) = 0;
|
||||
virtual api::Security const * resolve_security (ExecReport const&) = 0;
|
||||
|
||||
// Tell the venue the last message that had its effects commited to
|
||||
// disk
|
||||
virtual void set_checkpoint(VenueCheckpoint const &) = 0;
|
||||
|
||||
// call this periodically to allow the venue to process its
|
||||
// internal timers
|
||||
virtual void do_work() = 0;
|
||||
// Tell the venue what was the last message which had its effects
|
||||
// commited to disk
|
||||
virtual void set_checkpoint(VenueCheckpoint const&) = 0;
|
||||
};
|
||||
|
||||
} // namespace orderman_v2
|
||||
} // namespace bts
|
||||
}}
|
||||
@@ -6,6 +6,7 @@ namespace orderman_v2 {
|
||||
|
||||
class IVenueMsg {
|
||||
public:
|
||||
virtual void dispatch() = 0;
|
||||
virtual ~IVenueMsg() {}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
#include "FIXVenue.h"
|
||||
// #include "VenueCheckpoint.h"
|
||||
// #include "lib/jetfix/store/session_name.h"
|
||||
// #include "lib/orderman_v2/common.h"
|
||||
// #include "lib/utils/bts_assert.h"
|
||||
// #include "lib/orderman_v2/actors/gateway/IVenueMsg.h"
|
||||
|
||||
// #include <set>
|
||||
|
||||
// namespace bts {
|
||||
// namespace orderman_v2 {
|
||||
|
||||
// enum class FIXVenue::State {
|
||||
// IDLE,
|
||||
// W_CON,
|
||||
// W_LOGON,
|
||||
// W_TR,
|
||||
// RECOVER,
|
||||
// READY,
|
||||
// W_DCON
|
||||
// };
|
||||
|
||||
// struct FIXVenue::Hot {
|
||||
// Hot(IFIXStore &store, IClock &clock, VenueCheckpoint const &checkpoint)
|
||||
// : state(State::IDLE), our_seqnum(0), store(store), observer(nullptr),
|
||||
// clock(clock), seqnum(0), checkpoint(checkpoint) {}
|
||||
|
||||
// State state;
|
||||
// uint32_t our_seqnum;
|
||||
// IFIXStore &store;
|
||||
// IVenueObserver *observer;
|
||||
// IClock &clock;
|
||||
// uint32_t seqnum;
|
||||
// VenueCheckpoint checkpoint;
|
||||
// };
|
||||
|
||||
// struct FIXVenue::Cold {
|
||||
// Cold(config::JetFIX::Connection const &cfg) : cfg(cfg), interned_strings() {}
|
||||
// config::JetFIX::Connection const cfg;
|
||||
// std::set<std::string> interned_strings;
|
||||
// };
|
||||
|
||||
// struct FIXVenue::PImpl {
|
||||
// PImpl(config::JetFIX::Connection const &cfg,
|
||||
// VenueCheckpoint const &initial_checkpoint, IClock &clock,
|
||||
// IFIXStore &store)
|
||||
// : hot(store, clock, initial_checkpoint), cold(cfg) {}
|
||||
|
||||
// Hot hot;
|
||||
// Cold cold;
|
||||
// };
|
||||
|
||||
// FIXVenue::FIXVenue(config::JetFIX::Connection const &cfg,
|
||||
// VenueCheckpoint const &initial_checkpoint, IClock &clock,
|
||||
// IFIXStore &store)
|
||||
// : me(new PImpl(cfg, initial_checkpoint, clock, store)) {}
|
||||
|
||||
// FIXVenue::~FIXVenue() {}
|
||||
|
||||
// void FIXVenue::set_observer(IVenueObserver &observer) {
|
||||
// bts_assert(!me->hot.observer);
|
||||
// me->hot.observer = &observer;
|
||||
// }
|
||||
|
||||
// SessionSpan FIXVenue::get_current_session_span() {
|
||||
// auto span =
|
||||
// jetfix::session_span(me->hot.clock.ptime_local_now(), me->cold.cfg);
|
||||
// return {span.start, span.stop};
|
||||
// }
|
||||
|
||||
// void FIXVenue::login() {
|
||||
// switch (me->hot.state) {
|
||||
// case State::IDLE: {
|
||||
// auto session_name =
|
||||
// jetfix::session_name(me->hot.clock.ptime_local_now(), me->cold.cfg);
|
||||
// if (session_name != me->hot.checkpoint.session_uid)
|
||||
// start_new_session(session_name);
|
||||
// transition(State::W_CON);
|
||||
// break;
|
||||
// }
|
||||
// case State::W_CON:
|
||||
// case State::W_LOGON:
|
||||
// case State::W_TR:
|
||||
// case State::RECOVER:
|
||||
// case State::READY:
|
||||
// case State::W_DCON:
|
||||
// bts_assert(false);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// MsgTemplates FIXVenue::get_msg_templates(api::orderman::RoutingRecord const &) {
|
||||
// return {};
|
||||
// }
|
||||
|
||||
// bool FIXVenue::under_messaging_limit()
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// void FIXVenue::send(IVenueMsg **begin, IVenueMsg **end) {
|
||||
// switch (me->hot.state) {
|
||||
// case State::READY:
|
||||
// // visit messages, accumulating FIX, the dispatching at the end
|
||||
// for (auto m = begin; m != end; m++)
|
||||
// (*m)->dispatch();
|
||||
// internal_send();
|
||||
// break;
|
||||
// case State::W_DCON:
|
||||
// case State::IDLE:
|
||||
// break;
|
||||
// case State::W_CON:
|
||||
// case State::W_LOGON:
|
||||
// case State::W_TR:
|
||||
// case State::RECOVER:
|
||||
// bts_assert(false);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// void FIXVenue::transition(State)
|
||||
// {
|
||||
// }
|
||||
|
||||
// void FIXVenue::start_new_session(std::string const&session_name)
|
||||
// {
|
||||
// me->hot.checkpoint.session_uid =
|
||||
// me->cold.interned_strings.insert(session_name).first->c_str();
|
||||
// me->hot.checkpoint.seq_number = 0;
|
||||
// me->hot.seqnum = 0;
|
||||
// }
|
||||
|
||||
// } // namespace orderman_v2
|
||||
// } // namespace bts
|
||||
@@ -0,0 +1 @@
|
||||
#include "lib/orderman_v2/actors/gateway/fix/FIXVenueCtx.h"
|
||||
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/config/protos/jetfix.pb.h"
|
||||
#include "lib/jetfix/codec/FIXEncodingStream.h"
|
||||
#include "lib/orderman/governor/Governor.h"
|
||||
|
||||
#include "VenueCheckpoint.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman_v2 {
|
||||
|
||||
class IFIXStore {};
|
||||
class IClock;
|
||||
class IConnectionController;
|
||||
class IVenueObserver;
|
||||
|
||||
class FIXVenueCtx {
|
||||
public:
|
||||
FIXVenueCtx(config::JetFIX::Connection const &cfg,
|
||||
VenueCheckpoint const &last_processed_msg, IClock &clock,
|
||||
IFIXStore &store)
|
||||
: controller(), venue_observer(), store(store), clock(clock),
|
||||
out_buffer(cfg, 1), cfg(cfg), last_processed_msg(last_processed_msg) {}
|
||||
|
||||
IConnectionController *controller;
|
||||
IVenueObserver *venue_observer;
|
||||
IFIXStore &store;
|
||||
IClock &clock;
|
||||
jetfix::FIXEncodingStream out_buffer;
|
||||
orderman::Governor governor;
|
||||
config::JetFIX::Connection cfg;
|
||||
VenueCheckpoint last_processed_msg;
|
||||
}; // namespace orderman_v2
|
||||
|
||||
} // namespace orderman_v2
|
||||
} // namespace bts
|
||||
@@ -0,0 +1,16 @@
|
||||
#include "FIXVenueIdle.h"
|
||||
#include "FIXVenueCtx.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman_v2 {
|
||||
|
||||
FIXVenueIdle::PImpl (FIXVenueCtx &,FIXVenueWConnect &) {
|
||||
FIXVenueCtx &ctx;
|
||||
FIX
|
||||
|
||||
};
|
||||
|
||||
FIXVenueIdle::FIXVenueIdle() : me (new PImpl()) {}
|
||||
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,14 @@
|
||||
// #include "FIXVenueIdle.h"
|
||||
// #include "FIXVenueCtx.h"
|
||||
|
||||
// namespace bts {
|
||||
// namespace orderman_v2 {
|
||||
|
||||
// FIXVenueIdle::PImpl (FIXVenueCtx &,FIXVenueWConnect &) {
|
||||
// FIXVenueCtx &ctx;
|
||||
// };
|
||||
|
||||
// FIXVenueIdle::FIXVenueIdle() : me (new PImpl()) {}
|
||||
|
||||
|
||||
// }}
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "IFIXVenueState.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman_v2 {
|
||||
|
||||
class WConnect;
|
||||
class FIXVenueCtx;
|
||||
|
||||
class FIXVenueIdle : public IFIXVenueState {
|
||||
public:
|
||||
void init(FIXVenueCtx &,WConnect&);
|
||||
void send(IVenueMsg **, IVenueMsg**) override {};
|
||||
const char*name() override {return "FIXVenueIdle";}
|
||||
|
||||
void enter() override;
|
||||
void login() override;
|
||||
private:
|
||||
struct PImpl;
|
||||
std::unique_ptr<PImpl> me;
|
||||
};
|
||||
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
#include "lib/utils/bts_assert.h"
|
||||
|
||||
namespace bts {
|
||||
namespace jetfix {class InMsgBuffer;}
|
||||
namespace orderman_v2 {
|
||||
class IVenueMsg;
|
||||
|
||||
class IFIXVenueState {
|
||||
public:
|
||||
virtual void enter() = 0;
|
||||
virtual void login() {bts_assert(false);}
|
||||
virtual void send(IVenueMsg **, IVenueMsg**) {bts_assert(false);}
|
||||
virtual void on_connect_success() {bts_assert(false);}
|
||||
virtual void on_connect_fail() {bts_assert(false);}
|
||||
virtual void on_disconnect() {bts_assert(false);}
|
||||
virtual void on_msg(jetfix::InMsgBuffer const&) {bts_assert(false);}
|
||||
virtual const char* name() = 0;
|
||||
};
|
||||
}}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
#pragma once
|
||||
|
||||
namespace bts {
|
||||
namespace orderman_v2 {
|
||||
|
||||
const char* translate_business_reject_reason(int reason) {
|
||||
switch(reason) {
|
||||
case 0: return "Other";
|
||||
case 1: return "Unknown ID (unknown PartyDetailsListReqID being referenced in business message)";
|
||||
case 2: return "Unknown Security";
|
||||
case 3: return "Unsupported Message Type (for example using messages specific to cash markets for futures)";
|
||||
case 5: return "Required Field Missing";
|
||||
case 6: return "Not Authorized";
|
||||
case 8: return "Throttle Limit Exceeded (volume controls)";
|
||||
case 100: return "Value is incorrect (out of range) for this tag (for example using a value outside defined range of integer) ";
|
||||
case 101: return "Incorrect data format for value (for example using ASCII character outside 32-126 in string field)";
|
||||
case 102: return "Rejected due to Kill Switch";
|
||||
case 103: return "Rejected due to Risk Management API";
|
||||
case 104: return "Rejected due to Globex Credit Controls";
|
||||
case 105: return "Not Authorized to trade Deliverable Swap Futures";
|
||||
case 106: return "Not Authorized to trade Interest Rate Swap Futures";
|
||||
case 107: return "Rejected due to Inline Credit Controls";
|
||||
case 108: return "Invalid PartyDetailsListReqID (reusing already existing PartyDetailsListReqID while creating Party Details Definition Request)";
|
||||
case 109: return "Incoming message could not be decoded";
|
||||
case 110: return "Same repeating group entry appears more than once";
|
||||
case 111: return "Exceeded maximum number of allowable Party Details Definition Requests";
|
||||
case 112: return "Technical Error in Registering Party Details";
|
||||
case 113: return "Rejected due to Cross Venue Risk";
|
||||
case 114: return "Order Status Not Available";
|
||||
case 115: return "Enum Not Supported";
|
||||
case 116: return "Order Status Not Found";
|
||||
case 117: return "Mass Order Status Cannot be Completed";
|
||||
case 118: return "Exceeded Maximum Number of Allowable RequestingPartyID's in Party Details List Request";
|
||||
case 119: return "Duplicate Order Threshold Exceeded";
|
||||
case 120: return "On-Demand Message Rejected Due to Preceding Party Details Definition Request Being Rejected";
|
||||
case 121: return "Message Rejected Since PartyDetailsListReqID Does Not Match with Immediately Preceding Party Details Definition Request sent to MSGW when using On-demand administrative information";
|
||||
case 122: return "Party Details Definition Request sent to MSGW Being Rejected Due to Corresponding Business Message Being Rejected";
|
||||
case 123: return "Another Message Sent in Between Party Details Definition Request and Business Message when using On-demand administrative information";
|
||||
case 124: return "Cannot Have More Than One In-Flight Mass Order Status Request in Progress";
|
||||
case 125: return "Exceeded Maximum Number of In-Flight Order Status Requests";
|
||||
case 126: return "Cannot Have More Than One In-Flight Party Details List Request in Progress";
|
||||
case 127: return "Party Details List Request is Missing Requesting Party ID and Party ID";
|
||||
case 128: return "Party Details List Request cannot contain both RequestingPartyID and PartyID";
|
||||
case 129: return "Party Details Definition Request Being Rejected Since Another Message was sent in Between On-Demand Message";
|
||||
case 130: return "Buy Side Firm ID Does Not Match Sell Side Firm ID in New Order Cross";
|
||||
case 131: return "Message Type Not Supported on Backup Instance";
|
||||
case 132: return "New Order Cross Does Not Contain Buy Side Followed by Sell Side";
|
||||
}
|
||||
return "Unknown or invalid business reject reason.";
|
||||
}
|
||||
|
||||
const char* translate_negotiation_reject(int reason) {
|
||||
// https://www.cmegroup.com/confluence/display/EPICSANDBOX/Negotiation+Reject
|
||||
// 01/13/2020
|
||||
switch(reason) {
|
||||
case 0: return "HMACNotAuthenticated: failed authentication because identity is not recognized";
|
||||
case 1: return "HMACNotAvailable: HMAC component is not responding (5sec)";
|
||||
case 2: return "InvalidUUID: UUID is not greater than the one last used or value sent by the client is out of acceptable range (MIN, MAX)";
|
||||
case 3: return "InvalidTimestamp: Timestamp is not greater than the one last used or value sent by the client is out of acceptable range (MIN, MAX)";
|
||||
case 4: return "RequiredHMACSignatureMissing: empty bytes in HMACSignature field";
|
||||
case 5: return "RequiredAccessKeyIDMissing: empty bytes in AccessKeyID field";
|
||||
case 6: return "RequiredSessionMissing: empty bytes in Session field";
|
||||
case 7: return "RequiredFirmMissing: empty bytes in Firm field";
|
||||
case 8: return "RequiredUUIDMisssing: null value in UUID field";
|
||||
case 9: return "RequiredRequestTimestampMissing: null value in RequestTimestamp field";
|
||||
case 10: return "SessionBlocked: session and firm are not authorized for this port";
|
||||
case 12: return "InvalidAccessKeyID: contains non-printable ASCII character";
|
||||
case 13: return "InvalidSession: contains non-printable ASCII character";
|
||||
case 14: return "InvalidFirm: contains non-printable ASCII character";
|
||||
case 15: return "Volume Controls - exceeding TPS limit as defined for volume controls (reject action)";
|
||||
case 16: return "SplitMessageRejected - Messages queued due to split message penalty being rejected because of logout or disconnect";
|
||||
case 17: return "SplitMessageQueue - Reached threshold of messages queued due to split message penalty";
|
||||
case 27: return "DesignatedBackup - Using Designated backup before designated primary not allowed";
|
||||
}
|
||||
return "Unknown or invalid Negotiate reject reason.";
|
||||
}
|
||||
|
||||
const char* translate_establish_reject(int reason) {
|
||||
switch(reason) {
|
||||
case 0: return "HMACNotAuthenticated: failed authentication because identity is not recognized";
|
||||
case 1: return "HMACNotAvailable: HMAC component is not responding (5sec)";
|
||||
case 2: return "InvalidUUID: UUID is not greater than the one last used or value sent by the client is out of acceptable range (MIN, MAX)";
|
||||
case 3: return "InvalidTimestamp: Timestamp is not greater than the one last used or value sent by the client is out of acceptable range (MIN, MAX)";
|
||||
case 4: return "RequiredHMACSignatureMissing: empty bytes in HMACSignature field";
|
||||
case 5: return "RequiredAccessKeyIDMissing: empty bytes in AccessKeyID field";
|
||||
case 6: return "RequiredSessionMissing: empty bytes in Session field";
|
||||
case 7: return "RequiredFirmMissing: empty bytes in Firm field";
|
||||
case 8: return "RequiredUUIDMisssing: null value in UUID field";
|
||||
case 9: return "RequiredRequestTimestampMissing: null value in RequestTimestamp field";
|
||||
case 10: return "SessionBlocked: session and firm are not authorized for this port";
|
||||
case 11: return "InvalidKeepAliveInterval: value is out of acceptable range (MIN, MAX)";
|
||||
case 12: return "InvalidAccessKeyID: contains non-printable ASCII character";
|
||||
case 13: return "InvalidSession: contains non-printable ASCII character";
|
||||
case 14: return "InvalidFirm: contains non-printable ASCII character";
|
||||
case 15: return "Volume Controls - exceeding TPS limit as defined for volume controls (reject action)";
|
||||
case 16: return "SplitMessageRejected - Messages queued due to split message penalty being rejected because of logout or disconnect";
|
||||
case 17: return "SplitMessageQueue - Reached threshold of messages queued due to split message penalty";
|
||||
case 18: return "RequiredTradingSystemNameMissing: empty bytes in TradingSystemName";
|
||||
case 19: return "RequiredTradingSystemVersionMissing: empty bytes in TradingSystemVersion";
|
||||
case 20: return "RequiredTradingSystemVendorMissing: empty bytes in TradingSystemVendor";
|
||||
case 21: return "RequiredKeepAliveIntervalMissing: null value in KeepAliveInterval field";
|
||||
case 22: return "RequiredNextSeqNoMissing: empty bytes in NextSeqNo field";
|
||||
case 23: return "InvalidTradingSystemName: contains non-prinatable ASCII character";
|
||||
case 24: return "InvalidTradingSystemVersion: contains non-prinatable ASCII character";
|
||||
case 25: return "InvalidTradingSystemVendor: contains non-prinatable ASCII character";
|
||||
case 26: return "DesignatedBackup - Using Designated backup before designated primary not allowed";
|
||||
case 27: return "DesignatedBackup - Using Designated backup before designated primary not allowed";
|
||||
}
|
||||
return "Unknown or invalid Establish reject reason.";
|
||||
}
|
||||
|
||||
}}//namespace
|
||||
@@ -0,0 +1,294 @@
|
||||
#include "ILink3Venue.h"
|
||||
#include "ILink3Utils.h"
|
||||
#include "lib/utils/bts_assert.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/utils/datetime.h"
|
||||
#include "lib/orderman_v2/actors/gateway/IVenueObserver.h"
|
||||
#include "lib/orderman_v2/actors/network/IConnectionController.h"
|
||||
#include "lib/utils/SecureLogon.h"
|
||||
|
||||
#include "generated/MessageHeader.h"
|
||||
#include "generated/Negotiate500.h"
|
||||
#include "generated/NegotiationResponse501.h"
|
||||
#include "generated/NegotiationReject502.h"
|
||||
#include "generated/Establish503.h"
|
||||
#include "generated/NewOrderSingle514.h"
|
||||
#include "generated/BusinessReject521.h"
|
||||
|
||||
// high pri
|
||||
#include "generated/ExecutionReportNew522.h"
|
||||
#include "generated/ExecutionReportModify531.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <variant>
|
||||
#include <tuple>
|
||||
#include <fstream>
|
||||
|
||||
namespace bts {
|
||||
namespace orderman_v2 {
|
||||
|
||||
typedef unsigned char byte;
|
||||
struct FramingHeader {
|
||||
uint16_t message_size;
|
||||
// always 0xCAFE
|
||||
uint16_t encoding_type;
|
||||
};
|
||||
|
||||
|
||||
template <class Msg, size_t Data=0, size_t Sz=4+iLinkBinary::MessageHeader::encodedLength()+Msg::sbeBlockLength()>
|
||||
std::array<char,Sz+Data> mkbuffer() {
|
||||
static_assert(sizeof(FramingHeader) == 4);
|
||||
return std::array<char,Sz+Data> {};
|
||||
}
|
||||
|
||||
template <class Msg, size_t Sz>
|
||||
Msg frame_message(std::array<char,Sz>& buffer) {
|
||||
static_assert(Sz >= 4+iLinkBinary::MessageHeader::encodedLength()+Msg::sbeBlockLength());
|
||||
static_assert(sizeof(FramingHeader) == 4);
|
||||
FramingHeader* fhead = reinterpret_cast<FramingHeader*>(&buffer[0]);
|
||||
fhead->message_size = buffer.size();
|
||||
fhead->encoding_type = 0xCAFE;
|
||||
Msg msg;
|
||||
msg.wrapAndApplyHeader((char*)&buffer, sizeof(FramingHeader), buffer.size());
|
||||
return msg;
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// States
|
||||
//
|
||||
|
||||
struct Idle {};
|
||||
struct Connecting {
|
||||
enum class Step {
|
||||
EstablishSocket,
|
||||
Negotiate, // initiates a new session
|
||||
Establish, // binds to an existing session
|
||||
Transfer, // negotate sequence number?
|
||||
};
|
||||
Step step;
|
||||
int failover_count;
|
||||
};
|
||||
struct Connected {};
|
||||
struct Disconnected {};
|
||||
|
||||
using State = std::variant<Idle,Connecting,Connected,Disconnected>;
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
struct ILink3Venue::PImpl {
|
||||
PImpl():
|
||||
session(determine_session()),
|
||||
sequence(0),
|
||||
sequence_cme(0),
|
||||
state(Idle{}),
|
||||
observer(default_venue_observer()),
|
||||
connection(nullptr)
|
||||
{ }
|
||||
|
||||
uint64_t session;
|
||||
uint64_t sequence;
|
||||
uint64_t sequence_cme;
|
||||
State state;
|
||||
IVenueObserver& observer;
|
||||
IConnectionController* connection;
|
||||
|
||||
template<class T>
|
||||
void assert_state() {
|
||||
bts_assert(std::holds_alternative<T>(state));
|
||||
}
|
||||
|
||||
uint64_t determine_session() {
|
||||
// this is fairly complex
|
||||
// see session_name.h
|
||||
return utils::TimeStamp::now().to_uint64();
|
||||
}
|
||||
|
||||
|
||||
// CME messages
|
||||
void do_negotiate() {
|
||||
// add 2 bytes for empty 'credentials' (39008) length
|
||||
auto buffer = mkbuffer<iLinkBinary::Negotiate500,2>();
|
||||
auto msg = frame_message<iLinkBinary::Negotiate500>(buffer);
|
||||
|
||||
// msg.customerFlow(); // constant
|
||||
// msg.hMACVersion(); // constant
|
||||
msg.uUID(this->session);
|
||||
msg.requestTimestamp(datetime::unix_nano_now());
|
||||
msg.putSession("NGG");
|
||||
// sets the length of the credential block to ushort 00
|
||||
msg.putCredentials("");
|
||||
// pad with 0 at the front *and* null at the back
|
||||
const std::string_view firm = "004";
|
||||
// this must use the std::string_view overload
|
||||
// the char* overload does not pad correctly
|
||||
msg.putFirm(firm);
|
||||
const auto ld = glbx::calculate_hmac(
|
||||
msg.getSessionAsString(),
|
||||
std::to_string(msg.requestTimestamp()),
|
||||
std::to_string(msg.uUID()),
|
||||
msg.getSessionAsString(),
|
||||
firm.data()
|
||||
);
|
||||
msg.putAccessKeyID(ld.access_key);
|
||||
msg.putHMACSignature(ld.signature);
|
||||
|
||||
connection->send({ buffer.data(), buffer.size() });
|
||||
}
|
||||
|
||||
void do_establish() {
|
||||
// add 2 bytes for empty 'credentials' (39008) length
|
||||
// auto buffer = mkbuffer<iLinkBinary::Establish503,2>();
|
||||
// auto msg = frame_message<iLinkBinary::Establish503>(buffer);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void log(const T& t) {
|
||||
std::stringstream buf;
|
||||
buf << t;
|
||||
LOG(OrderMan, Warn, "{}", buf.str());
|
||||
}
|
||||
template <class T, class D> void log(const T& t, int errcode, D decode) {
|
||||
std::stringstream buf;
|
||||
buf << t;
|
||||
LOG(OrderMan, Warn, "Error: {}\n{}", std::string(decode(errcode)), buf.str());
|
||||
}
|
||||
|
||||
void handle_negotiate_response(const iLinkBinary::NegotiationResponse501& msg) {
|
||||
log(msg);
|
||||
}
|
||||
|
||||
void handle_negotiate_reject(const iLinkBinary::NegotiationReject502& msg) {
|
||||
log(msg, msg.errorCodes(), translate_negotiation_reject);
|
||||
}
|
||||
|
||||
void handle_business_reject(const iLinkBinary::BusinessReject521& msg) {
|
||||
log(msg, msg.businessRejectReason(), translate_business_reject_reason);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// Interface methods
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
ILink3Venue::ILink3Venue() : me(std::make_unique<PImpl>())
|
||||
{
|
||||
}
|
||||
|
||||
ILink3Venue::~ILink3Venue() {}
|
||||
|
||||
//
|
||||
// IConnectionHandler
|
||||
//
|
||||
|
||||
void ILink3Venue::init_handler(IConnectionController& c) {
|
||||
me->connection = &c;
|
||||
}
|
||||
void ILink3Venue::on_connect_success() {
|
||||
auto& state = std::get<Connecting>(me->state);
|
||||
bts_assert(state.step == Connecting::Step::EstablishSocket);
|
||||
state.step = Connecting::Step::Negotiate;
|
||||
me->do_negotiate();
|
||||
}
|
||||
void ILink3Venue::on_connect_fail() {
|
||||
me->assert_state<Connecting>();
|
||||
me->connection->failover();
|
||||
auto& state = std::get<Connecting>(me->state);
|
||||
//todo: config this
|
||||
if (state.failover_count < 16) {
|
||||
state.failover_count += 1;
|
||||
me->connection->connect();
|
||||
}
|
||||
else {
|
||||
LOG(OrderMan,Error, "ilink3 connection exceeded failover count");
|
||||
me->observer.on_venue_login_failure();
|
||||
}
|
||||
}
|
||||
void ILink3Venue::on_disconnect() {
|
||||
LOG(OrderMan, Warn, "Disconnected");
|
||||
me->state = Disconnected {};
|
||||
}
|
||||
void ILink3Venue::on_data(const std::string_view& message) {
|
||||
// decode message and dispatch to handler function
|
||||
auto fh = reinterpret_cast<const FramingHeader*>(message.data());
|
||||
bts_assert_d(fh->encoding_type == 0xCAFE);
|
||||
iLinkBinary::MessageHeader header((char*)message.data()+4, message.size());
|
||||
constexpr size_t offset = sizeof(FramingHeader) + iLinkBinary::MessageHeader::encodedLength();
|
||||
char* buffer = (char*)message.data() + offset;
|
||||
size_t size = message.size() - offset;
|
||||
|
||||
// TODO: Docs seem to say there will only be one SBE message per packet so we're
|
||||
// going with that for now. If we miss a message it should shake out in certification
|
||||
|
||||
// TODO: For the sake of performance we should split the switch in 2 high priority messages are served first
|
||||
switch(header.templateId()) {
|
||||
case iLinkBinary::NegotiationResponse501::sbeTemplateId():
|
||||
me->handle_negotiate_response({ buffer, size });
|
||||
break;
|
||||
|
||||
case iLinkBinary::NegotiationReject502::sbeTemplateId():
|
||||
me->handle_negotiate_reject({ buffer, size });
|
||||
break;
|
||||
|
||||
case iLinkBinary::BusinessReject521::sbeTemplateId():
|
||||
me->handle_business_reject({buffer,size});
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG(OrderMan, Warn,
|
||||
"Unrecognized iLink3 template templateId={} schemaId={} version={}",
|
||||
header.templateId(),
|
||||
header.schemaId(),
|
||||
header.version()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// IVenue
|
||||
//
|
||||
|
||||
void ILink3Venue::set_observer(IVenueObserver& o) {
|
||||
me->observer = o;
|
||||
}
|
||||
|
||||
SessionSpan ILink3Venue::get_current_session_span() {
|
||||
bts_assert(false);
|
||||
return SessionSpan{};
|
||||
}
|
||||
|
||||
void ILink3Venue::login() {
|
||||
if (me->connection == nullptr) {
|
||||
LOG(OrderMan, Error, "Cannot log in ILink3 session without connection");
|
||||
me->observer.on_venue_login_failure();
|
||||
}
|
||||
me->state = Connecting { Connecting::Step::EstablishSocket, 0 };
|
||||
me->connection->connect();
|
||||
}
|
||||
|
||||
MsgTemplates ILink3Venue::get_msg_templates(const api::orderman::RoutingRecord&) {
|
||||
return {};
|
||||
}
|
||||
|
||||
bool ILink3Venue::under_messaging_limit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void ILink3Venue::send(IVenueMsg**begin, IVenueMsg**end) {
|
||||
(void)begin;
|
||||
(void)end;
|
||||
}
|
||||
|
||||
const api::Security* ILink3Venue::resolve_security (const ExecReport&) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ILink3Venue::set_checkpoint(const VenueCheckpoint&) {
|
||||
}
|
||||
|
||||
|
||||
}} //namespace
|
||||
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
#include "lib/orderman_v2/actors/gateway/IVenue.h"
|
||||
#include "lib/orderman_v2/actors/network/IConnectionHandler.h"
|
||||
|
||||
namespace bts {
|
||||
namespace orderman_v2 {
|
||||
|
||||
class ILink3Venue :
|
||||
public IVenue,
|
||||
public IConnectionHandler
|
||||
{
|
||||
struct PImpl;
|
||||
std::unique_ptr<PImpl> me;
|
||||
|
||||
public:
|
||||
ILink3Venue();
|
||||
~ILink3Venue();
|
||||
|
||||
// IConnectionHandler
|
||||
|
||||
void init_handler(IConnectionController &) override;
|
||||
void on_connect_success() override;
|
||||
void on_connect_fail() override;
|
||||
void on_disconnect() override;
|
||||
void on_data(const std::string_view& data) override;
|
||||
|
||||
// IVenue
|
||||
|
||||
void set_observer(IVenueObserver &) override;
|
||||
SessionSpan get_current_session_span() override;
|
||||
void login() override;
|
||||
MsgTemplates get_msg_templates(const api::orderman::RoutingRecord &) override;
|
||||
bool under_messaging_limit() override;
|
||||
void send(IVenueMsg**begin, IVenueMsg**end) override;
|
||||
const api::Security* resolve_security (const ExecReport&) override;
|
||||
void set_checkpoint(const VenueCheckpoint&) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}} //namespace
|
||||
@@ -0,0 +1,32 @@
|
||||
// { type:state }
|
||||
(start) [Login] -> (Negotiate 500)
|
||||
// Negotiate sets the session ID, receives the last sent sequence #
|
||||
// https://www.cmegroup.com/confluence/display/EPICSANDBOX/Negotiate
|
||||
(Negotiate 500) Response501 -> (ExaminePrevSequence)
|
||||
(ExaminePrevSequence) >0 -> (Replay)
|
||||
(ExaminePrevSequence) 0 -> (Establish 503)
|
||||
(Negotiate 500) Reject502 -> (NegotiateFailed)
|
||||
// DesignatedBackup = Trying to use backup when should be using primary
|
||||
(NegotiateFailed) DesignatedBackup -> (Failover)
|
||||
// InvalidUUID = UUID too low
|
||||
(NegotiateFailed) InvalidUUID -> (start)
|
||||
(NegotiateFailed) _ -> (Unrecoverable)
|
||||
(Negotiate 500) BusinessReject521 -> (Unrecoverable)
|
||||
// Set the next customer->cme sequence #
|
||||
// https://www.cmegroup.com/confluence/display/EPICSANDBOX/Establish
|
||||
(Establish 503) Ack -> (Established)
|
||||
(Establish 503) Nack -> (Unrecoverable)
|
||||
(Failover) -> (start)
|
||||
// Set expected CME seq #
|
||||
(Replay) -> (RetransmitRequest508)
|
||||
// send current and last uuid
|
||||
(RetransmitRequest508) Ack -> (HandleRetransmission)
|
||||
(RetransmitRequest508) Nack -> (Unrecoverable)
|
||||
(HandleRetransmission) -> (Establish 503)
|
||||
(HandleSequence) heartbeat -> (Established)
|
||||
(HandleSequence) KeepAliveElapsed -> (Established)
|
||||
(HandleSequence) Failover -> (Failover)
|
||||
|
||||
// Steady state
|
||||
(Established) Sequence -> (HandleSequence)
|
||||
(Established) NotApplied -> (??)
|
||||
@@ -0,0 +1,99 @@
|
||||
#include "../ILink3Venue.h"
|
||||
#include "lib/orderman_v2/actors/network/Reactor.h"
|
||||
|
||||
// #include "../generated/NewOrderSingle514.h"
|
||||
#include "lib/utils/Dispatcher.h"
|
||||
#include "lib/orderman_v2/actors/gateway/IVenueObserver.h"
|
||||
|
||||
// IP Market Segment ID Market Segment Description
|
||||
// 69.50.112.184 12
|
||||
// 69.50.112.202 50
|
||||
// 69.50.112.181 52
|
||||
// 69.50.112.191 54
|
||||
// 69.50.112.174 56
|
||||
// 69.50.112.172 58
|
||||
// 69.50.112.195 60
|
||||
// 69.50.112.177 64
|
||||
// 69.50.112.168 68
|
||||
// 69.50.112.183 70
|
||||
// 69.50.112.189 72
|
||||
// 69.50.112.197 74
|
||||
// 69.50.112.204 76
|
||||
// 69.50.112.167 78
|
||||
// 69.50.112.187 80
|
||||
// 69.50.112.179 82
|
||||
// 69.50.112.198 84
|
||||
// 69.50.112.169 88
|
||||
// 69.50.112.199 99
|
||||
// IP Market Segment ID Market Segment Description
|
||||
// 69.50.112.185 12
|
||||
// 69.50.112.201 50
|
||||
// 69.50.112.180 52
|
||||
// 69.50.112.190 54
|
||||
// 69.50.112.173 56
|
||||
// 69.50.112.171 58
|
||||
// 69.50.112.194 60
|
||||
// 69.50.112.176 64
|
||||
// 69.50.112.170 68
|
||||
// 69.50.112.182 70
|
||||
// 69.50.112.188 72
|
||||
// 69.50.112.196 74
|
||||
// 69.50.112.203 76
|
||||
// 69.50.112.166 78
|
||||
// 69.50.112.186 80
|
||||
// 69.50.112.178 82
|
||||
// 69.50.112.200 84
|
||||
// 69.50.112.175 88
|
||||
// 69.50.112.205 99
|
||||
|
||||
|
||||
namespace bts {
|
||||
namespace orderman_v2 {
|
||||
namespace test {
|
||||
|
||||
struct Observer : public IVenueObserver {
|
||||
void on_venue_login_success(std::vector<ExecReport> const &) override {
|
||||
std::cout << "IVenueObserver::" << __func__;
|
||||
}
|
||||
void on_venue_login_failure() override {
|
||||
std::cout << "IVenueObserver::" << __func__;
|
||||
}
|
||||
void on_venue_disconnect() override {
|
||||
std::cout << "IVenueObserver::" << __func__;
|
||||
}
|
||||
void on_venue_exe_report(const ExecReport &) override {
|
||||
std::cout << "IVenueObserver::" << __func__;
|
||||
}
|
||||
void on_venue_error(VenueError const &) override {
|
||||
std::cout << "IVenueObserver::" << __func__;
|
||||
}
|
||||
};
|
||||
|
||||
void test_ilink3() {
|
||||
// create reactor
|
||||
Reactor reactor;
|
||||
|
||||
// create ilink3 session
|
||||
ILink3Venue venue;
|
||||
|
||||
Observer observer;
|
||||
venue.set_observer(observer);
|
||||
|
||||
// register it with the reactor
|
||||
reactor.register_connection_handler({
|
||||
{"69.50.112.184", 64530},
|
||||
{"69.50.112.185", 64530},
|
||||
}, venue);
|
||||
|
||||
// try to login
|
||||
venue.login();
|
||||
|
||||
utils::DispatcherTimer timer(utils::Dispatcher::current(), 10, [&]() {
|
||||
reactor.do_work();
|
||||
});
|
||||
timer.start();
|
||||
utils::Dispatcher::current().run();
|
||||
}
|
||||
|
||||
|
||||
}}}
|
||||
@@ -4,13 +4,13 @@
|
||||
#include <fcntl.h>
|
||||
#include <fstream>
|
||||
#include <netinet/tcp.h>
|
||||
#include <queue>
|
||||
#include <stdlib.h>
|
||||
#include <sys/epoll.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <unistd.h>
|
||||
#include <queue>
|
||||
|
||||
#include "IConnectionController.h"
|
||||
#include "IConnectionHandler.h"
|
||||
@@ -21,11 +21,11 @@ namespace orderman_v2 {
|
||||
|
||||
struct Reactor::Connection : IConnectionController {
|
||||
|
||||
Connection(int epoll_fd, std::vector<TCPEndpoint> const &end_points,
|
||||
Connection(int epoll_fd, std::vector<TCPEndpoint> const&end_points,
|
||||
IConnectionHandler &handler)
|
||||
: epoll_fd(epoll_fd), fd(0), is_connected(false), handler(&handler),
|
||||
end_points(
|
||||
std::deque<TCPEndpoint>{end_points.begin(), end_points.end()}) {}
|
||||
end_points(std::deque<TCPEndpoint> {end_points.begin(), end_points.end()})
|
||||
{}
|
||||
|
||||
~Connection() {
|
||||
if (is_connected)
|
||||
@@ -50,7 +50,7 @@ struct Reactor::Connection : IConnectionController {
|
||||
auto end_point = current_end_point();
|
||||
auto host = end_point.host;
|
||||
auto port = end_point.port;
|
||||
|
||||
|
||||
serv_addr.sin_family = AF_INET;
|
||||
serv_addr.sin_port = htons(port);
|
||||
result = inet_pton(AF_INET, host.c_str(), &serv_addr.sin_addr);
|
||||
@@ -86,42 +86,32 @@ struct Reactor::Connection : IConnectionController {
|
||||
handler->on_disconnect();
|
||||
}
|
||||
|
||||
void send(std::string_view const &dt) override {
|
||||
if (!is_connected)
|
||||
return;
|
||||
auto result = ::write(fd, dt.data(), dt.size());
|
||||
if (result < 0) {
|
||||
auto er = errno;
|
||||
char msg[256];
|
||||
auto host = current_end_point().host;
|
||||
auto port = current_end_point().port;
|
||||
LOG(OrderMan, Warn, "Could not write to reactor connection. {}:{}",
|
||||
std::string(strerror_r(er, msg, sizeof(msg))), host, port);
|
||||
disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void send(std::vector<std::string_view> const &dt) override {
|
||||
if (!is_connected)
|
||||
return;
|
||||
|
||||
iovec *iv = (iovec *)alloca(sizeof(iovec) * dt.size());
|
||||
for (size_t i = 0; i < dt.size(); i++) {
|
||||
iv[i].iov_base = (void *)dt[i].data();
|
||||
iovec *iv = (iovec*)alloca(sizeof(iovec)*dt.size());
|
||||
for (size_t i = 0; i < dt.size();i++) {
|
||||
iv[i].iov_base = (void*)dt[i].data();
|
||||
iv[i].iov_len = dt[i].size();
|
||||
}
|
||||
auto result = ::writev(fd, iv, dt.size());
|
||||
auto result = ::writev(fd,iv,dt.size());
|
||||
if (result < 0) {
|
||||
auto er = errno;
|
||||
char msg[256];
|
||||
auto host = current_end_point().host;
|
||||
auto port = current_end_point().port;
|
||||
LOG(OrderMan, Warn, "Could not write to reactor connection. {}:{}",
|
||||
std::string(strerror_r(er, msg, sizeof(msg))), host, port);
|
||||
std::string(strerror_r(er, msg, sizeof(msg))),host,port);
|
||||
disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void send(std::string_view const& sv) override {
|
||||
//TODO: make me fast
|
||||
send(std::vector<std::string_view>{sv});
|
||||
}
|
||||
|
||||
void failover() override {
|
||||
bts_assert(!is_connected);
|
||||
next_end_point();
|
||||
@@ -132,8 +122,12 @@ struct Reactor::Connection : IConnectionController {
|
||||
handler->on_data(data);
|
||||
}
|
||||
|
||||
TCPEndpoint current_end_point() { return end_points.front(); }
|
||||
|
||||
|
||||
TCPEndpoint current_end_point()
|
||||
{
|
||||
return end_points.front();
|
||||
}
|
||||
|
||||
void next_end_point() {
|
||||
auto next = end_points.front();
|
||||
end_points.pop();
|
||||
@@ -158,9 +152,10 @@ Reactor::Reactor() : me(new PImpl()) {
|
||||
}
|
||||
|
||||
void Reactor::register_connection_handler(
|
||||
std::vector<TCPEndpoint> const &end_points, IConnectionHandler &handler) {
|
||||
std::vector<TCPEndpoint> const&end_points,
|
||||
IConnectionHandler &handler) {
|
||||
me->connections.emplace_back(
|
||||
std::make_unique<Connection>(me->epoll_fd, end_points, handler));
|
||||
std::make_unique<Connection>(me->epoll_fd, end_points,handler));
|
||||
handler.init_handler(*me->connections.back());
|
||||
}
|
||||
|
||||
|
||||
@@ -45,11 +45,6 @@ std::ostream &operator<<(std::ostream &s, Value<Tag, V> const &v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
struct ExchangeCorID {
|
||||
std::array<char,4> channel;
|
||||
uint32_t sn;
|
||||
};
|
||||
|
||||
using BookSide = std::array<md::PriceSize, 5>;
|
||||
using OrderKey = Value<struct OrderKeyTag, uint32_t>;
|
||||
using Price = Value<struct PriceTag, double>;
|
||||
@@ -62,7 +57,6 @@ using UserID = Value<struct UserIDTag, uint16_t>;
|
||||
using AccountID = Value<struct AccountIDTag, uint16_t>;
|
||||
using SecurityKey = Value<struct SecurityKeyTag, uint32_t>;
|
||||
using Side = Value<struct SideTag, uint8_t>;
|
||||
using OrderType = Value<struct OrderTypeTag, uint8_t>;
|
||||
using ManualOrderIndicator = Value<struct ManualOrderIndicatorTag, uint8_t>;
|
||||
using TimeInForce = Value<struct TimeInForceTag, uint8_t>;
|
||||
|
||||
@@ -124,7 +118,7 @@ class Book {
|
||||
class IClock {
|
||||
public:
|
||||
virtual TimeStamp now() = 0;
|
||||
virtual datetime::PTime ptime_local_now() = 0;
|
||||
virtual datetime::PTime ptime_now() = 0;
|
||||
};
|
||||
|
||||
} // namespace orderman_v2
|
||||
|
||||
@@ -77,27 +77,22 @@ BeginString = FIX.4.2 8=FIX.4.2
|
||||
BodyLength = 000257 9=000257
|
||||
MsgType = NewOrderSingle 35=D
|
||||
MsgSeqNum = 000000113 34=000000113
|
||||
|
||||
LastMsgSeqNumProcessed = 000000110 369=000000110
|
||||
SendingTime = 20190804-22:11:06.602 52=20190804-22:11:06.602
|
||||
SenderCompID = DE7534N 49=DE7534N
|
||||
TargetCompID = CME 56=CME
|
||||
|
||||
TargetSubID = 80 57=80
|
||||
SenderSubID = DO3BTSJGR 50=DO3BTSJGR
|
||||
SenderLocationID = US,IL 142=US,IL
|
||||
Account = CLX60635 1=CLX60635
|
||||
|
||||
Side = 2 54=2
|
||||
TimeInForce = 0 59=0
|
||||
1028 = N 1028=N
|
||||
CustomerOrFirm = 0 204=0
|
||||
|
||||
9702 = 1 9702=1
|
||||
SecurityDesc = HOU9-HOX9 107=HOU9-HOX9
|
||||
ClOrdID = 00000101730000432660 11=00000101730000432660
|
||||
7928 = 6935102 7928=6935102
|
||||
|
||||
TransactTime = 20190804-22:11:06.592 60=20190804-22:11:06.592
|
||||
OrderQty = 000001 38=000001
|
||||
OrdType = 2 40=2
|
||||
@@ -141,26 +136,3 @@ Gateways will wait until they have:
|
||||
READY->W_SCHEDULE [label="on_venue_disconnect"]
|
||||
}
|
||||
#+END_SRC
|
||||
* FIX
|
||||
|-----------------+-----+-----+--------+-----+------------|
|
||||
| Field | New | C/R | Cancel | UAV | Fixed Size |
|
||||
|-----------------+-----+-----+--------+-----+------------|
|
||||
| sender sub id | X | X | X | X | N |
|
||||
| sender location | X | X | X | X | |
|
||||
| account | X | X | X | X | |
|
||||
| side | X | X | X | | |
|
||||
| tif | X | X | X | | |
|
||||
| moi | X | X | X | | |
|
||||
| secdesc | X | X | X | | |
|
||||
| clordid | X | X | X | | |
|
||||
| transact time | X | X | X | | |
|
||||
| cof | X | X | | X | |
|
||||
| Cti | X | X | | X | |
|
||||
| smpid | X | X | | X | |
|
||||
| quantity | X | X | | | |
|
||||
| price | X | X | | | |
|
||||
| ordetype | X | X | | | |
|
||||
| inflightmit | | X | | | |
|
||||
| corclorid | | X | X | | |
|
||||
| origclordid | | X | X | | |
|
||||
|-----------------+-----+-----+--------+-----+------------|
|
||||
@@ -145,10 +145,6 @@ struct GW_BoundOrder {
|
||||
ManualOrderIndicator moi;
|
||||
TimeInForce tif;
|
||||
Side side;
|
||||
OrderType order_type;
|
||||
ExchangeCorID corid;
|
||||
Price stop_price;
|
||||
Quantity display_quantity;
|
||||
};
|
||||
|
||||
struct GW_OrderCreate {
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
// #include "lib/orderman_v2/fix/FIXVenue.h"
|
||||
// #include "lib/jetfix/common/OutFIX.h"
|
||||
// #include "lib/jetfix/store/session_name.h"
|
||||
// #include "lib/orderman/governor/Governor.h"
|
||||
// #include "lib/orderman_v2/actors/gateway/IVenueMsg.h"
|
||||
// #include "lib/orderman_v2/actors/network/IConnectionController.h"
|
||||
// #include "lib/orderman_v2/common.h"
|
||||
// #include "lib/utils/bts_assert.h"
|
||||
|
||||
// #include <map>
|
||||
|
||||
// namespace bts {
|
||||
// namespace orderman_v2 {
|
||||
|
||||
// class FIXVenueConfig {};
|
||||
|
||||
// struct InMsg {
|
||||
// std::string_view data;
|
||||
// };
|
||||
|
||||
// struct VenueCheckPoint {
|
||||
// std::string session;
|
||||
// uint32_t sequence_number;
|
||||
// };
|
||||
|
||||
// class IFIXStore {
|
||||
// public:
|
||||
// };
|
||||
|
||||
// struct FIXVenue::PImpl {
|
||||
|
||||
// PImpl(config::JetFIX::Connection const &cfg,
|
||||
// VenueCheckPoint const &last_processed_msg, IClock &clock,
|
||||
// IFIXStore &store)
|
||||
// : controller(), venue_observer(), store(store), clock(clock),
|
||||
// out_buffer(cfg, 1), cfg(cfg),
|
||||
// last_processed_msg(last_processed_msg) {}
|
||||
// IConnectionController *controller;
|
||||
// IVenueObserver *venue_observer;
|
||||
// IFIXStore &store;
|
||||
// IClock &clock;
|
||||
// TimeStamp now;
|
||||
// jetfix::FIXEncodingStream out_buffer;
|
||||
// orderman::Governor governor;
|
||||
// config::JetFIX::Connection cfg;
|
||||
// VenueCheckPoint last_processed_msg;
|
||||
// };
|
||||
|
||||
// FIXVenue::FIXVenue(config::JetFIX::Connection const &cfg,
|
||||
// VenueCheckPoint const &check_point, IClock &clock,
|
||||
// IFIXStore &store)
|
||||
// : me(new PImpl(cfg, check_point, clock, store)) {}
|
||||
|
||||
// void FIXVenue::set_observer(IVenueObserver &obs) {
|
||||
// bts_assert(!me->venue_observer);
|
||||
// me->venue_observer = &obs;
|
||||
// }
|
||||
|
||||
// SessionSpan FIXVenue::get_current_session_span() {
|
||||
// jetfix::SessionSpan ss = jetfix::session_span(me->cfg);
|
||||
// return {ss.start, ss.stop};
|
||||
// }
|
||||
|
||||
// void FIXVenue::login() {
|
||||
// bts_assert(is_initialized());
|
||||
|
||||
// }
|
||||
|
||||
// void FIXVenue::send(IVenueMsg **begin, IVenueMsg **end) {
|
||||
// me->now = me->clock.now();
|
||||
// for (auto msg = begin; msg != end; msg++)
|
||||
// (*msg)->dispatch();
|
||||
// internal_send();
|
||||
// }
|
||||
|
||||
// void FIXVenue::init_handler(IConnectionController &ctrl) {
|
||||
// bts_assert(!me->controller);
|
||||
// me->controller = &ctrl;
|
||||
// }
|
||||
|
||||
// void FIXVenue::on_connect_success() {
|
||||
// switch (me->state) {
|
||||
// case State::IDLE:
|
||||
// prepare_logon(&me->out_buffer);
|
||||
// transition(State::W_LOGON);
|
||||
// internal_send();
|
||||
// break;
|
||||
// case State::W_LOGON:
|
||||
// case State::WTR_REPLY:
|
||||
// case State::READY:
|
||||
// case State::RECOVER:
|
||||
// case State::W_CONNECT:
|
||||
// bts_assert(false);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// void FIXVenue::dispatch_new_order(jetfix::FIXFragment const &fix) {
|
||||
// me->governor.record_sent(me->now);
|
||||
// me->out_buffer.new_msg(jetfix::MessageTypes::NewOrderSingle).append(fix);
|
||||
// }
|
||||
|
||||
// void FIXVenue::dispatch_cancel_replace(jetfix::FIXFragment const &fix) {
|
||||
// me->governor.record_sent(me->now);
|
||||
// me->out_buffer.new_msg(jetfix::MessageTypes::CancelReplace).append(fix);
|
||||
// }
|
||||
|
||||
// void FIXVenue::dispatch_cancel(jetfix::FIXFragment const &fix) {
|
||||
// me->out_buffer.new_msg(jetfix::MessageTypes::Cancel).append(fix);
|
||||
// }
|
||||
|
||||
// bool FIXVenue::is_initialized() const {
|
||||
// return me->controller && me->venue_observer;
|
||||
// }
|
||||
|
||||
// } // namespace orderman_v2
|
||||
// } // namespace bts
|
||||
+21
-22
@@ -15,48 +15,47 @@ namespace orderman_v2 {
|
||||
class IClock;
|
||||
class IFIXStore;
|
||||
class FIXVenueConfig;
|
||||
class VenueCheckpoint;
|
||||
struct VenueCheckpoint;
|
||||
|
||||
class FIXVenue : public IVenue, public IConnectionHandler {
|
||||
public:
|
||||
FIXVenue(config::JetFIX::Connection const &cfg,
|
||||
VenueCheckpoint const &initial_checkpoint, IClock &, IFIXStore &);
|
||||
~FIXVenue();
|
||||
FIXVenue(config::JetFIX::Connection const &cfg, VenueCheckPoint const &,
|
||||
IClock &, IFIXStore &);
|
||||
|
||||
// IVenue
|
||||
void set_observer(IVenueObserver &) override;
|
||||
SessionSpan get_current_session_span() override;
|
||||
void login() override;
|
||||
bool under_messaging_limit() override;
|
||||
void queue_send(GW_BoundOrder const &,
|
||||
api::orderman::RoutingRecord const &) override;
|
||||
void queue_update(GW_BoundOrder const &,
|
||||
api::orderman::RoutingRecord const &) override;
|
||||
void queue_cancel(GW_BoundOrder const &,
|
||||
api::orderman::RoutingRecord const &) override;
|
||||
void send_queued_msgs() override;
|
||||
api::Security const *resolve_security(ExecReport const &) override;
|
||||
void set_checkpoint(VenueCheckpoint const &) override;
|
||||
void do_work() override;
|
||||
MsgTemplates
|
||||
get_msg_templates(api::orderman::RoutingRecord const &) override;
|
||||
|
||||
// IConnectionHandler
|
||||
void login() override;
|
||||
void send(IVenueMsg **begin, IVenueMsg **end) override;
|
||||
|
||||
// IConnectionHandler
|
||||
void init_handler(IConnectionController &) override;
|
||||
|
||||
void on_connect_success() override;
|
||||
void on_connect_fail() override;
|
||||
void on_disconnect() override;
|
||||
void on_data(std::string_view const &data) override;
|
||||
|
||||
protected:
|
||||
virtual void prepare_logon(jetfix::FIXEncodingStream *out) = 0;
|
||||
|
||||
private:
|
||||
friend class FIXNewOrderSingle;
|
||||
friend class FIXCancelReplace;
|
||||
friend class FIXCancel;
|
||||
void dispatch_new_order(jetfix::FIXFragment const &fix);
|
||||
void dispatch_cancel_replace(jetfix::FIXFragment const &fix);
|
||||
void dispatch_cancel(jetfix::FIXFragment const &fix);
|
||||
|
||||
struct PImpl;
|
||||
struct Hot;
|
||||
struct Cold;
|
||||
enum class State;
|
||||
std::unique_ptr<PImpl> me;
|
||||
|
||||
bool is_initialized() const;
|
||||
void prepare_logout(jetfix::FIXEncodingStream *out);
|
||||
void internal_send();
|
||||
void transition(State);
|
||||
void start_new_session(std::string const &session_name);
|
||||
};
|
||||
|
||||
} // namespace orderman_v2
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "FieldsHelpers.h"
|
||||
#include "lib/jetfix/codec/i32_toa.h"
|
||||
#include "lib/utils/bts_assert.h"
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
@@ -28,8 +27,6 @@ using CtiCode = BaseFIXField<9702, 1>;
|
||||
using SelfMatchPreventionID = BaseFIXField<7928, 12>;
|
||||
using OrdType = BaseFIXField<40, 1>;
|
||||
|
||||
using HandlInst = BaseFIXField<21, 1>;
|
||||
using CustOrderHandlingInst = BaseFIXField<1031, 1>;
|
||||
using TransactTime = BaseFIXField<60, 21>;
|
||||
using ClOrdID = BaseFIXField<11, 20>;
|
||||
using Side = BaseFIXField<54, 1>;
|
||||
@@ -56,7 +53,7 @@ struct Encoding {
|
||||
}
|
||||
};
|
||||
|
||||
template <class... Fs> class FIXFragment {
|
||||
template<class... Fs> class FIXFragment {
|
||||
public:
|
||||
FIXFragment()
|
||||
: sealed_crc(0), hole_crc(0), current_offset(0),
|
||||
@@ -79,23 +76,6 @@ template <class... Fs> class FIXFragment {
|
||||
sealed_crc += F::tag_info.crc + 1;
|
||||
}
|
||||
|
||||
template <class F> void add_value(int32_t v, int pad = 0) {
|
||||
static_assert(find_type<F, Fs...>() >= 0);
|
||||
bts_assert_d(current_offset + F::max_sz < buffer.size());
|
||||
bts_assert_d(!is_sealed);
|
||||
|
||||
memcpy(buffer.data() + current_offset, F::tag_info.str, F::tag_info.sz);
|
||||
current_offset += F::tag_info.sz;
|
||||
auto start_of_text = current_offset;
|
||||
auto len_of_text =
|
||||
i32_toa(v, (char *)(buffer.data() + current_offset), pad);
|
||||
current_offset += len_of_text;
|
||||
buffer[current_offset] = 1;
|
||||
current_offset++;
|
||||
sealed_crc +=
|
||||
sum_bytes((char *)(buffer.data() + start_of_text), len_of_text);
|
||||
sealed_crc += F::tag_info.crc + 1;
|
||||
}
|
||||
struct Hole {
|
||||
size_t offset;
|
||||
size_t size;
|
||||
@@ -138,12 +118,6 @@ template <class... Fs> class FIXFragment {
|
||||
memcpy(buffer.data() + h.offset, dt.data(), dt.size());
|
||||
}
|
||||
|
||||
void fill_hole(Hole const &h, int32_t v) {
|
||||
bts_assert_d(is_sealed);
|
||||
i32_toa(v, (char *)(buffer.data() + h.offset), h.size);
|
||||
hole_crc += sum_bytes((char*)(buffer.data() + h.offset), h.size);
|
||||
}
|
||||
|
||||
void fill_hole(Hole const &h, int crc, std::string_view const &dt) {
|
||||
bts_assert_d(is_sealed);
|
||||
bts_assert_d(dt.size() == h.size);
|
||||
@@ -163,18 +137,7 @@ template <class... Fs> class FIXFragment {
|
||||
sealed_crc + hole_crc};
|
||||
}
|
||||
|
||||
FIXFragment &operator=(const FIXFragment &src) = default;
|
||||
|
||||
void reset() {
|
||||
current_offset = 0;
|
||||
sealed_crc = 0;
|
||||
hole_crc = 0;
|
||||
is_sealed = false;
|
||||
}
|
||||
|
||||
uint8_t crc() { return (sealed_crc + hole_crc) % 256; }
|
||||
|
||||
uint32_t size() { return current_offset; }
|
||||
FIXFragment& operator=(const FIXFragment&src) = default;
|
||||
|
||||
private:
|
||||
uint64_t sealed_crc;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <fstream>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <fstream>
|
||||
// #include "catch/catch.hpp"
|
||||
|
||||
@@ -95,11 +96,8 @@ std::tuple<string, string> load_session_keys(const string& session) {
|
||||
}
|
||||
|
||||
LogonData calculate_hmac(const std::string& session_id, const std::vector<std::string>& values) {
|
||||
string canonical;
|
||||
for (const auto& v : values) {
|
||||
canonical += v;
|
||||
canonical += '\n';
|
||||
}
|
||||
string canonical = boost::algorithm::join(values, "\n");
|
||||
|
||||
|
||||
string secret_key, access_id;
|
||||
std::tie(access_id, secret_key) = load_session_keys(session_id);
|
||||
@@ -117,7 +115,7 @@ LogonData calculate_hmac(const std::string& session_id, const std::vector<std::s
|
||||
string encoded_hmac;
|
||||
StringSource(calculated_hmac, true, new Base64URLEncoder(new StringSink(encoded_hmac)));
|
||||
|
||||
return { access_id, encoded_hmac, canonical};
|
||||
return LogonData { access_id, encoded_hmac, calculated_hmac, canonical};
|
||||
}
|
||||
catch(const Exception& e) {
|
||||
bts_assert_msg(false, e.what());
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace glbx {
|
||||
|
||||
struct LogonData {
|
||||
std::string access_key;
|
||||
// Signature is base64 encoded for FIX
|
||||
std::string signature_base64;
|
||||
std::string signature;
|
||||
std::string canonical;
|
||||
};
|
||||
|
||||
@@ -44,6 +44,17 @@ LLDateTime ll_local_now() {
|
||||
long unix_now() {
|
||||
return (boost::posix_time::microsec_clock::universal_time() - PTime(anchor)).total_microseconds() / (long)1E6;
|
||||
}
|
||||
#ifndef _WIN32
|
||||
uint64_t unix_nano_now() {
|
||||
struct timespec ts;
|
||||
// CLOCK_REALTIME is already anchored at the unix epoch
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
return
|
||||
static_cast<int64_t>(1000000000UL)*
|
||||
static_cast<int64_t>(ts.tv_sec) +
|
||||
static_cast<int64_t>(ts.tv_nsec);
|
||||
}
|
||||
#endif
|
||||
|
||||
std::chrono::system_clock::time_point utc_ll_to_timepoint(unsigned long long ll) {
|
||||
auto us_since_epoch = ((ll & ticks_mask) - anchor_ticks) / ticks_per_micro;
|
||||
|
||||
@@ -41,6 +41,7 @@ extern "C" BTS_EXPORT LLDateTime ll_local_now ();
|
||||
extern "C" BTS_EXPORT double OA_date_from_ll (LLDateTime ll);
|
||||
extern "C" BTS_EXPORT LLDateTime ll_from_OA_date (double oa_date);
|
||||
extern "C" BTS_EXPORT long unix_now();
|
||||
uint64_t unix_nano_now();
|
||||
|
||||
BTS_EXPORT std::chrono::system_clock::time_point utc_ll_to_timepoint(unsigned long long ll) ;
|
||||
BTS_EXPORT PTime now ();
|
||||
|
||||
@@ -201,7 +201,7 @@ std::string make_logon(int seqnum, int last_seq_num_processed,
|
||||
"57={}\001",
|
||||
seq_num_str, last_seq_num_str, time_str,
|
||||
ld.access_key.size(), ld.access_key,
|
||||
ld.signature.size(), ld.signature, target_subid);
|
||||
ld.signature_base64.size(), ld.signature_base64, target_subid);
|
||||
|
||||
return body;
|
||||
}
|
||||
@@ -240,7 +240,7 @@ std::string make_cgw_logon(int seqnum, int last_seq_num_processed) {
|
||||
"57=G\001",
|
||||
seq_num_str, last_seq_num_str, time_str,
|
||||
ld.access_key.size(), ld.access_key,
|
||||
ld.signature.size(), ld.signature);
|
||||
ld.signature_base64.size(), ld.signature_base64);
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
@@ -18,61 +18,45 @@
|
||||
|
||||
#include "lib/utils/bts_assert.h"
|
||||
#include "lib/utils/bts_chrono.h"
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
namespace bts {
|
||||
namespace orderman_v2 { namespace test { void test_ilink3(); } }
|
||||
namespace cmd {
|
||||
|
||||
using namespace orderman_v2;
|
||||
|
||||
int QuickTest::execute(std::vector<std::string> const &) {
|
||||
std::ifstream f("/home/ppinto/Dropbox/20191120-MBO_xnym_cl_fut_1-eth");
|
||||
std::string line;
|
||||
size_t lines = 0;
|
||||
std::vector<std::string_view> strs;
|
||||
while (std::getline(f,line)) {
|
||||
lines ++;
|
||||
auto start = 0;
|
||||
for (size_t i= 0; i < line.size();i++)
|
||||
if (line[i] ==1 ) {
|
||||
strs.push_back (std::string_view {line.data()+start, i-start+1});
|
||||
start = i;
|
||||
}
|
||||
struct MyHandler : IConnectionHandler {
|
||||
void init_handler(IConnectionController &c) override {
|
||||
c.connect();
|
||||
}
|
||||
void on_connect_success() override {
|
||||
std::cout << "Connected " << this << "\n";
|
||||
}
|
||||
void on_connect_fail() override {
|
||||
std::cout << "Connection failed " << this << "\n";
|
||||
}
|
||||
void on_disconnect() override {
|
||||
std::cout << "Disconnected " << this << "\n";
|
||||
}
|
||||
void on_data(std::string_view const &data) override {
|
||||
std::cout << "Got: " << data << " " << this << "\n";
|
||||
}
|
||||
};
|
||||
int QuickTest::execute(std::vector<std::string> const &args) {
|
||||
if (std::find(args.begin(), args.end(), "ilink") != args.end()) {
|
||||
test::test_ilink3();
|
||||
return 1;
|
||||
}
|
||||
Reactor r;
|
||||
MyHandler h1;
|
||||
MyHandler h2;
|
||||
r.register_connection_handler({{args[0],3000}},h1);
|
||||
r.register_connection_handler({{args[0],3001}},h2);
|
||||
while (true) {
|
||||
r.do_work();
|
||||
}
|
||||
std::cout << lines << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// struct MyHandler : IConnectionHandler {
|
||||
// void init_handler(IConnectionController &c) override {
|
||||
// c.connect();
|
||||
// }
|
||||
// void on_connect_success() override {
|
||||
// std::cout << "Connected " << this << "\n";
|
||||
// }
|
||||
// void on_connect_fail() override {
|
||||
// std::cout << "Connection failed " << this << "\n";
|
||||
// }
|
||||
// void on_disconnect() override {
|
||||
// std::cout << "Disconnected " << this << "\n";
|
||||
// }
|
||||
// void on_data(std::string_view const &data) override {
|
||||
// std::cout << "Got: " << data << " " << this << "\n";
|
||||
// }
|
||||
// };
|
||||
|
||||
// int QuickTest::execute(std::vector<std::string> const &args) {
|
||||
// Reactor r;
|
||||
// MyHandler h1;
|
||||
// MyHandler h2;
|
||||
// r.register_connection_handler({{args[0],3000}},h1);
|
||||
// r.register_connection_handler({{args[0],3001}},h2);
|
||||
// while (true) {
|
||||
// r.do_work();
|
||||
// }
|
||||
// }
|
||||
|
||||
// int connect(std::string const &host, int port) {
|
||||
// auto fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
// int flag = 1;
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
#include <benchmark/benchmark.h>
|
||||
|
||||
#include "lib/api/services/OrderService.pb.h"
|
||||
#include "lib/domain_model/Security.pb.h"
|
||||
#include "lib/jetfix/codec/FIXEncodingStream.h"
|
||||
#include "lib/jetfix/codec/FIXFragment.h"
|
||||
#include "lib/jetfix/codec/FieldDefinitions.h"
|
||||
#include "lib/jetfix/codec/f_toa.h"
|
||||
#include "lib/jetfix/codec/i32_toa.h"
|
||||
#include "lib/orderman_v2/fix/Fields.h"
|
||||
@@ -42,65 +37,19 @@ inline int my_u32_toa(uint32_t v, unsigned char *buffer, int pad) {
|
||||
}
|
||||
}
|
||||
|
||||
using NewOrderSingle =
|
||||
FIXFragment<fix::BeginString, fix::BodyLength, fix::MessageType,
|
||||
fix::MsgSeqNum, fix::LastMsgSeqNumProcessed, fix::SendingTime,
|
||||
fix::SenderCompID, fix::TargetCompID, fix::TargetSubID,
|
||||
fix::SenderSubID, fix::SenderLocationID, fix::Account,
|
||||
fix::Side, fix::TimeInForce, fix::ManualOrderIndicator,
|
||||
fix::CustomerOrFirm, fix::CtiCode, fix::SecurityDesc,
|
||||
fix::ClOrdID, fix::SelfMatchPreventionID, fix::TransactTime,
|
||||
fix::OrderQty, fix::OrdType, fix::Price, fix::Checksum>;
|
||||
using NewOrderSingle = FIXFragment<
|
||||
fix::BeginString, fix::BodyLength, fix::MessageType, fix::MsgSeqNum,
|
||||
fix::TargetCompID, fix::TargetSubID, fix::SenderCompID,
|
||||
fix::SenderLocationID, fix::SenderSubID, fix::SendingTime, fix::Account,
|
||||
fix::CtiCode, fix::ManualOrderIndicator, fix::CustomerOrFirm,
|
||||
fix::SelfMatchPreventionID, fix::LastMsgSeqNumProcessed, fix::Checksum,
|
||||
fix::TransactTime, fix::SecurityDesc, fix::Side, fix::TimeInForce,
|
||||
fix::ClOrdID, fix::OrderQty, fix::OrdType, fix::Price>;
|
||||
|
||||
static void new_order_single_hybrid(benchmark::State &state) {
|
||||
NewOrderSingle no;
|
||||
using namespace fix;
|
||||
|
||||
for (auto _ : state) {
|
||||
no.reset();
|
||||
|
||||
no.add_value<BeginString>("FIX.4.2");
|
||||
auto body_length = no.add_hole<BodyLength>();
|
||||
no.add_value<MessageType>("D");
|
||||
no.add_value<MsgSeqNum>(12345);
|
||||
|
||||
no.add_value<LastMsgSeqNumProcessed>("1");
|
||||
no.add_value<SendingTime>("20190804-22:11:06.602");
|
||||
no.add_value<SenderCompID>("DE7534N");
|
||||
no.add_value<TargetCompID>("CME");
|
||||
|
||||
no.add_value<TargetSubID>("80");
|
||||
no.add_value<SenderSubID>("DO3BTSJGR");
|
||||
no.add_value<SenderLocationID>("US,IL");
|
||||
no.add_value<Account>("CLX60635");
|
||||
|
||||
no.add_value<Side>("1");
|
||||
no.add_value<TimeInForce>("1");
|
||||
no.add_value<ManualOrderIndicator>("1");
|
||||
no.add_value<CustomerOrFirm>("1");
|
||||
|
||||
no.add_value<CtiCode>("1");
|
||||
no.add_value<SecurityDesc>("CH01");
|
||||
no.add_value<ClOrdID>(88412);
|
||||
no.add_value<SelfMatchPreventionID>("6935102");
|
||||
|
||||
no.add_value<TransactTime>("20190804-22:11:06.602");
|
||||
no.add_value<OrderQty>(12);
|
||||
no.add_value<OrdType>("2");
|
||||
no.add_value<Price>("17");
|
||||
|
||||
no.add_value<Checksum>(123);
|
||||
no.fill_hole(body_length,232);
|
||||
}
|
||||
std::cout << "fix: " << no.encode().human_str() << " crc: " << (int) no.crc()
|
||||
<< " sz: " << no.size() << "\n";
|
||||
}
|
||||
BENCHMARK(new_order_single_hybrid);
|
||||
|
||||
static void new_order_single_no_jetfixt(benchmark::State &state) {
|
||||
NewOrderSingle no;
|
||||
using namespace fix;
|
||||
|
||||
no.add_value<BeginString>("FIX.4.2");
|
||||
auto body_length = no.add_hole<BodyLength>();
|
||||
no.add_value<MessageType>("D");
|
||||
@@ -156,90 +105,48 @@ static void new_order_single_no_jetfixt(benchmark::State &state) {
|
||||
}
|
||||
std::cout << no.encode().human_str() << "\n";
|
||||
}
|
||||
BENCHMARK(new_order_single_no_jetfixt);
|
||||
BENCHMARK(new_order_single_hybrid);
|
||||
|
||||
// static void fragment_copy(benchmark::State &state) {
|
||||
// NewOrderSingle no;
|
||||
// using namespace fix;
|
||||
static void fragment_copy(benchmark::State &state) {
|
||||
NewOrderSingle no;
|
||||
using namespace fix;
|
||||
|
||||
// no.add_value<BeginString>("FIX.4.2");
|
||||
// no.add_hole<BodyLength>();
|
||||
// no.add_value<MessageType>("D");
|
||||
// no.add_hole<MsgSeqNum>();
|
||||
// no.add_hole<LastMsgSeqNumProcessed>();
|
||||
// no.add_hole<SendingTime>();
|
||||
no.add_value<BeginString>("FIX.4.2");
|
||||
no.add_hole<BodyLength>();
|
||||
no.add_value<MessageType>("D");
|
||||
no.add_hole<MsgSeqNum>();
|
||||
no.add_hole<LastMsgSeqNumProcessed>();
|
||||
no.add_hole<SendingTime>();
|
||||
|
||||
// no.add_value<SenderCompID>("DE7534N");
|
||||
// no.add_value<TargetCompID>("CME");
|
||||
// no.add_value<TargetSubID>("80");
|
||||
// no.add_value<SenderLocationID>("US,IL");
|
||||
// no.add_value<SelfMatchPreventionID>("6935102");
|
||||
// no.add_value<SenderSubID>("DO3BTSJGR");
|
||||
// no.add_value<Account>("CLX60635");
|
||||
// no.add_value<CtiCode>("1");
|
||||
// no.add_value<CustomerOrFirm>("1");
|
||||
// no.add_value<OrdType>("2");
|
||||
no.add_value<SenderCompID>("DE7534N");
|
||||
no.add_value<TargetCompID>("CME");
|
||||
no.add_value<TargetSubID>("80");
|
||||
no.add_value<SenderLocationID>("US,IL");
|
||||
no.add_value<SelfMatchPreventionID>("6935102");
|
||||
no.add_value<SenderSubID>("DO3BTSJGR");
|
||||
no.add_value<Account>("CLX60635");
|
||||
no.add_value<CtiCode>("1");
|
||||
no.add_value<CustomerOrFirm>("1");
|
||||
no.add_value<OrdType>("2");
|
||||
|
||||
// no.add_hole<TransactTime>();
|
||||
// no.add_hole<ClOrdID>(9);
|
||||
// no.add_hole<fix::Side>();
|
||||
// no.add_hole<fix::TimeInForce>();
|
||||
// no.add_hole<fix::ManualOrderIndicator>();
|
||||
// no.add_hole<OrderQty>();
|
||||
// no.add_hole<fix::Price>(17);
|
||||
// no.add_hole<SecurityDesc>(9);
|
||||
// no.add_hole<Checksum>();
|
||||
no.add_hole<TransactTime>();
|
||||
no.add_hole<ClOrdID>(9);
|
||||
no.add_hole<fix::Side>();
|
||||
no.add_hole<fix::TimeInForce>();
|
||||
no.add_hole<fix::ManualOrderIndicator>();
|
||||
no.add_hole<OrderQty>();
|
||||
no.add_hole<fix::Price>(17);
|
||||
no.add_hole<SecurityDesc>(9);
|
||||
no.add_hole<Checksum>();
|
||||
|
||||
// no.seal();
|
||||
|
||||
// NewOrderSingle no2;
|
||||
// for (auto _ : state) {
|
||||
// benchmark::DoNotOptimize(no2 = no);
|
||||
// }
|
||||
// }
|
||||
// BENCHMARK(fragment_copy);
|
||||
|
||||
static void jetfix_gen_new_order(benchmark::State &state) {
|
||||
config::JetFIX::Connection cfg;
|
||||
cfg.set_socket_connect_host_ip("69.50.112.199");
|
||||
cfg.set_socket_connect_port(61922);
|
||||
cfg.set_sender_compid("MC5004N");
|
||||
cfg.set_target_compid("CME");
|
||||
cfg.set_target_subid("99");
|
||||
cfg.set_cme_market_segment_id(99);
|
||||
cfg.set_start_time("00:30:00");
|
||||
cfg.set_end_time("23:30:00");
|
||||
cfg.set_start_day("sunday");
|
||||
cfg.set_end_day("friday");
|
||||
cfg.set_sender_compid("BTS");
|
||||
cfg.set_raw_data("S4PMA");
|
||||
cfg.set_auto_fix_seq_num(true);
|
||||
jetfix::FIXEncodingStream stream(cfg);
|
||||
auto ts = std::string("20121204-14:44:02.000");
|
||||
no.seal();
|
||||
|
||||
NewOrderSingle no2;
|
||||
for (auto _ : state) {
|
||||
// stream.new_msg(jetfix::MessageTypes::NewOrderSingle);
|
||||
// frag.add<jetfix::fix::SenderSubID>("pedro");
|
||||
// frag.add<jetfix::fix::SenderLocationID>("NC,US");
|
||||
// frag.add<jetfix::fix::Account>("pp_account");
|
||||
// frag.add<jetfix::fix::Side>(api::SIDE_BUY);
|
||||
// frag.add<jetfix::fix::TimeInForce>(api::orderman::TIME_IN_FORCE_DAY);
|
||||
// frag.add<jetfix::fix::ManualOrderIndicator>(api::orderman::MANUAL_ORDER_INDICATOR_NO);
|
||||
// frag.add<jetfix::fix::CustomerOrFirm>(api::orderman::CUSTOMER_OR_FIRM_CUSTOMER);
|
||||
// frag.add<jetfix::fix::CtiCode>(api::orderman::CTI_CODE_UNDEFINED);
|
||||
// frag.add<jetfix::fix::SecurityDesc>("CH07");
|
||||
// frag.add<jetfix::fix::ClOrdID>("1234567890");
|
||||
// frag.add<jetfix::fix::SelfMatchPreventionID>("1234");
|
||||
// frag.add<jetfix::fix::TransactTimeStr>("20121204-14:44:02.000");
|
||||
// frag.add<jetfix::fix::OrderQty>(123);
|
||||
// frag.add<jetfix::fix::Price>(12.0,7,17);
|
||||
// frag.add<jetfix::fix::OrdType>(api::orderman::NATIVE_ORDER_TYPE_LIMIT);
|
||||
// stream.close();
|
||||
// stream.stamp(1,1,ts);
|
||||
stream.reset();
|
||||
benchmark::DoNotOptimize(no2 = no);
|
||||
}
|
||||
}
|
||||
BENCHMARK(jetfix_gen_new_order);
|
||||
BENCHMARK(fragment_copy);
|
||||
|
||||
// size_t create_order = 0;
|
||||
// size_t update_order = 0;
|
||||
@@ -278,53 +185,54 @@ BENCHMARK(jetfix_gen_new_order);
|
||||
// }
|
||||
// BENCHMARK(gw_op_serialize);
|
||||
|
||||
static void new_order_single_raw_gen(benchmark::State &state) {
|
||||
// static void new_order_single_raw_gen(benchmark::State &state) {
|
||||
|
||||
std::string msg =
|
||||
"8=FIX.4.2\\019=000257\\0135=D\\0134=000000113\\01369=000000110\\0152="
|
||||
"20190804-22:11:06.602\\0149=DE7534N\\0156=CME\\0157=80\\0150="
|
||||
"DO3BTSJGR\\01142=US,IL\\011=CLX60635\\0154=2\\0159=0\\011028=N\\01204="
|
||||
"0\\019702=1\\01107=HOU9-HOX9\\0111=00000101730000432660\\017928="
|
||||
"6935102\\0160=20190804-22:11:06.592\\0138=000001\\0140=2\\0144=-"
|
||||
"0000093."
|
||||
"00000000\\0110=018\\01";
|
||||
// std::string msg =
|
||||
// "8=FIX.4.2\\019=000257\\0135=D\\0134=000000113\\01369=000000110\\0152="
|
||||
// "20190804-22:11:06.602\\0149=DE7534N\\0156=CME\\0157=80\\0150="
|
||||
// "DO3BTSJGR\\01142=US,IL\\011=CLX60635\\0154=2\\0159=0\\011028=N\\01204="
|
||||
// "0\\019702=1\\01107=HOU9-HOX9\\0111=00000101730000432660\\017928="
|
||||
// "6935102\\0160=20190804-22:11:06.592\\0138=000001\\0140=2\\0144=-"
|
||||
// "0000093."
|
||||
// "00000000\\0110=018\\01";
|
||||
|
||||
auto sn_index = msg.find("000000113");
|
||||
auto lsn_index = msg.find("000000110");
|
||||
auto st_index = msg.find("20190804-22:11:06.602");
|
||||
auto tt_index = msg.find("20190804-22:11:06.592");
|
||||
auto qty_index = msg.find("000001");
|
||||
auto p_index = msg.find("-0000093.00000000");
|
||||
// auto sn_index = msg.find("000000113");
|
||||
// auto lsn_index = msg.find("000000110");
|
||||
// auto st_index = msg.find("20190804-22:11:06.602");
|
||||
// auto tt_index = msg.find("20190804-22:11:06.592");
|
||||
// auto qty_index = msg.find("000001");
|
||||
// auto p_index = msg.find("-0000093.00000000");
|
||||
|
||||
char buffer[1024];
|
||||
memcpy(buffer, msg.data(), msg.size());
|
||||
uint64_t cb = 0;
|
||||
// char buffer[1024];
|
||||
// memcpy(buffer, msg.data(), msg.size());
|
||||
// uint64_t cb = 0;
|
||||
|
||||
memcpy(buffer, msg.data(), msg.size());
|
||||
for (auto _ : state) {
|
||||
// memcpy(buffer, msg.data(), msg.size());
|
||||
// for (auto _ : state) {
|
||||
|
||||
memcpy(buffer + sn_index, "000000113", sizeof("000000113") - 1);
|
||||
cb += sum_bytes(buffer + sn_index, sizeof("000000113") - 1);
|
||||
// memcpy(buffer + sn_index, "000000113", sizeof("000000113") - 1);
|
||||
// cb += sum_bytes(buffer + sn_index, sizeof("000000113") - 1);
|
||||
|
||||
memcpy(buffer + lsn_index, "000000113", sizeof("000000113") - 1);
|
||||
cb += sum_bytes(buffer + lsn_index, sizeof("000000113") - 1);
|
||||
// memcpy(buffer + lsn_index, "000000113", sizeof("000000113") - 1);
|
||||
// cb += sum_bytes(buffer + lsn_index, sizeof("000000113") - 1);
|
||||
|
||||
memcpy(buffer + st_index, "20190804-22:11:06.592",
|
||||
sizeof("20190804-22:11:06.592") - 1);
|
||||
// memcpy(buffer + st_index, "20190804-22:11:06.592",
|
||||
// sizeof("20190804-22:11:06.592") - 1);
|
||||
|
||||
memcpy(buffer + tt_index, "20190804-22:11:06.592",
|
||||
sizeof("20190804-22:11:06.592") - 1);
|
||||
// memcpy(buffer + tt_index, "20190804-22:11:06.592",
|
||||
// sizeof("20190804-22:11:06.592") - 1);
|
||||
|
||||
memcpy(buffer + qty_index, "000001", sizeof("000001") - 1);
|
||||
cb += sum_bytes(buffer + qty_index, sizeof("000001") - 1);
|
||||
// memcpy(buffer + qty_index, "000001", sizeof("000001") - 1);
|
||||
// cb += sum_bytes(buffer + qty_index, sizeof("000001") - 1);
|
||||
|
||||
memcpy(buffer + p_index, "-0000093.00000000",
|
||||
sizeof("-0000093.00000000") - 1);
|
||||
benchmark::DoNotOptimize(
|
||||
cb += sum_bytes(buffer + p_index, sizeof("-0000093.00000000") - 1));
|
||||
}
|
||||
}
|
||||
BENCHMARK(new_order_single_raw_gen);
|
||||
// memcpy(buffer + p_index, "-0000093.00000000",
|
||||
// sizeof("-0000093.00000000") - 1);
|
||||
// benchmark::DoNotOptimize(
|
||||
// cb += sum_bytes(buffer + p_index, sizeof("-0000093.00000000") -
|
||||
// 1));
|
||||
// }
|
||||
// }
|
||||
// BENCHMARK(new_order_single_raw_gen);
|
||||
|
||||
} // namespace cmd
|
||||
} // namespace bts
|
||||
@@ -3,5 +3,5 @@ if [ -f /.dockerenv ]; then
|
||||
ninja
|
||||
else
|
||||
cid=`docker ps | grep -P "emacs_ide|bluetradingsystems/linux_docker" | awk '{print $1}'`
|
||||
docker exec $cid /bin/bash -c "cd build/clang_debug/ && ninja"
|
||||
docker exec $cid /bin/bash -c "cd /home/ppinto/temp/spark_build/clang_debug && ninja"
|
||||
fi
|
||||
+15
-17
@@ -1,23 +1,21 @@
|
||||
#/bin/bash
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
mkdir -p $DIR/../build/
|
||||
cd $DIR/../build/
|
||||
SRC_ROOT=$DIR/../
|
||||
mkdir -p $SRC_ROOT/build/
|
||||
BUILD_ROOT=`readlink -f $SRC_ROOT/build`
|
||||
|
||||
rm -rf clang_debug
|
||||
mkdir clang_debug
|
||||
cd clang_debug
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_CXX_COMPILER=/usr/lib/ccache/clang++ ../..
|
||||
cd ..
|
||||
rm -rf $BUILD_ROOT/clang_debug
|
||||
mkdir $BUILD_ROOT/clang_debug
|
||||
cd $BUILD_ROOT/clang_debug
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_CXX_COMPILER=/usr/lib/ccache/clang++ $SRC_ROOT
|
||||
|
||||
rm -rf ninja_debug
|
||||
mkdir ninja_debug
|
||||
cd ninja_debug
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++ ../..
|
||||
cd ..
|
||||
rm -rf $BUILD_ROOT/ninja_debug
|
||||
mkdir $BUILD_ROOT/ninja_debug
|
||||
cd $BUILD_ROOT/ninja_debug
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++ $SRC_ROOT
|
||||
|
||||
rm -rf ninja_release
|
||||
mkdir ninja_release
|
||||
cd ninja_release
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_CXX_COMPILER=g++ ../..
|
||||
cd ..
|
||||
rm -rf $BUILD_ROOT/ninja_release
|
||||
mkdir $BUILD_ROOT/ninja_release
|
||||
cd $BUILD_ROOT/ninja_release
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_CXX_COMPILER=g++ $SRC_ROOT
|
||||
|
||||
Reference in new issue
Block a user