FIX Venue

This commit is contained in:
Pedro Pinto committed 2019-12-26 11:49:02 -05:00
1 parent 874f655b55
commit bf8369fca8
20 files changed
+286 -290

No files matched your search

+1 -1
View File
@@ -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
+11 -4
View File
@@ -114,8 +114,11 @@ std::string session_name(datetime::PTime const &ref_date,
}
std::string session_name(config::JetFIX::Connection const &session_cfg) {
auto now = datetime::local_now();
return session_name(datetime::local_now(), session_cfg);
}
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()),
@@ -190,9 +193,8 @@ SessionSpan session_span(datetime::PTime const &ref_date,
}
}
SessionSpan session_span(config::JetFIX::Connection const &session_cfg) {
auto now = datetime::local_now();
SessionSpan session_span(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_span(now, parse_weekday(session_cfg.start_day()),
@@ -204,5 +206,10 @@ SessionSpan session_span(config::JetFIX::Connection const &session_cfg) {
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
+3
View File
@@ -46,11 +46,14 @@ std::string session_name (datetime::PTime const &ref_date,
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);
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);
}}
+6 -2
View File
@@ -32,12 +32,16 @@ class Governor {
return true;
}
void record_sent(TimeStamp now = Timer::now()) {
void record_sent(bool rate_limited, TimeStamp now = Timer::now()) {
if (!in_window(now)) {
_start_of_window = now;
_msgs_in_window = 0;
}
_msgs_in_window++;
_msgs_in_window += rate_limited;
}
void record_sent(TimeStamp now = Timer::now()) {
record_sent(true, now);
}
private:
@@ -151,6 +151,7 @@ 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) {
@@ -544,8 +545,7 @@ void Gateway::on_gw_op(OM_ID, const GW_OrderCancel &cancel) {
}
const char* Gateway::intern_string(std::string const&str) {
auto [it,there] = me->cold.interned_strings.insert(str);
return it->data();
return me->cold.interned_strings.insert(str).first->data();
}
void Gateway::send_pending_msgs() {
@@ -562,7 +562,7 @@ bool Gateway::has_bootstrap_data() const {
}
bool Gateway::in_active_schedule() const {
auto now = me->cold.clock.ptime_now();
auto now = me->cold.clock.ptime_local_now();
return now >= me->cold.session_span.start &&
now < me->cold.session_span.stop;
}
@@ -65,6 +65,10 @@ class IVenue {
// Tell the venue what was the last message which 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;
};
}}
@@ -6,7 +6,6 @@ namespace orderman_v2 {
class IVenueMsg {
public:
virtual void dispatch() = 0;
virtual ~IVenueMsg() {}
};
@@ -0,0 +1,134 @@
// #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
@@ -15,47 +15,45 @@ namespace orderman_v2 {
class IClock;
class IFIXStore;
class FIXVenueConfig;
struct VenueCheckpoint;
class VenueCheckpoint;
class FIXVenue : public IVenue, public IConnectionHandler {
public:
FIXVenue(config::JetFIX::Connection const &cfg, VenueCheckPoint const &,
IClock &, IFIXStore &);
FIXVenue(config::JetFIX::Connection const &cfg,
VenueCheckpoint const &initial_checkpoint, IClock &, IFIXStore &);
~FIXVenue();
// IVenue
void set_observer(IVenueObserver &) override;
SessionSpan get_current_session_span() override;
void login() override;
MsgTemplates
get_msg_templates(api::orderman::RoutingRecord const &) override;
void login() override;
bool under_messaging_limit() override;
void send(IVenueMsg **begin, IVenueMsg **end) override;
// IConnectionHandler
api::Security const *resolve_security(ExecReport const &) override;
void set_checkpoint(VenueCheckpoint const &) override;
void do_work () 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;
protected:
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 +0,0 @@
#include "lib/orderman_v2/actors/gateway/fix/FIXVenueCtx.h"
@@ -1,36 +0,0 @@
#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
@@ -1,16 +0,0 @@
#include "FIXVenueIdle.h"
#include "FIXVenueCtx.h"
namespace bts {
namespace orderman_v2 {
FIXVenueIdle::PImpl (FIXVenueCtx &,FIXVenueWConnect &) {
FIXVenueCtx &ctx;
FIX
};
FIXVenueIdle::FIXVenueIdle() : me (new PImpl()) {}
}}
@@ -1,14 +0,0 @@
// #include "FIXVenueIdle.h"
// #include "FIXVenueCtx.h"
// namespace bts {
// namespace orderman_v2 {
// FIXVenueIdle::PImpl (FIXVenueCtx &,FIXVenueWConnect &) {
// FIXVenueCtx &ctx;
// };
// FIXVenueIdle::FIXVenueIdle() : me (new PImpl()) {}
// }}
@@ -1,24 +0,0 @@
#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;
};
}}
@@ -1,23 +0,0 @@
#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;
};
}}
+1 -1
View File
@@ -118,7 +118,7 @@ class Book {
class IClock {
public:
virtual TimeStamp now() = 0;
virtual datetime::PTime ptime_now() = 0;
virtual datetime::PTime ptime_local_now() = 0;
};
} // namespace orderman_v2
@@ -136,3 +136,26 @@ 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 | | |
|-----------------+-----+-----+--------+-----+------------|
-117
View File
@@ -1,117 +0,0 @@
// #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
+46 -26
View File
@@ -18,41 +18,61 @@
#include "lib/utils/bts_assert.h"
#include "lib/utils/bts_chrono.h"
#include <boost/algorithm/string.hpp>
namespace bts {
namespace cmd {
using namespace orderman_v2;
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 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;
}
}
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,5 +1,9 @@
#include <benchmark/benchmark.h>
#include "lib/api/services/OrderService.pb.h"
#include "lib/domain_model/Security.pb.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"
@@ -148,6 +152,37 @@ static void fragment_copy(benchmark::State &state) {
}
BENCHMARK(fragment_copy);
static void jetfix_gen_new_order(benchmark::State &state) {
jetfix::FIXFragment frag;
for (auto _ : state) {
frag.reset();
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<fix::TimeInForce>(api::TIME_IN_FORCE_DAY);
}
// frag.add<fix::TimeInForce>(def.time_in_force());
// frag.add<fix::ManualOrderIndicator>(def.manual_order_indicator());
// frag.add<fix::CustomerOrFirm>(rr.customer_or_firm());
// frag.add<fix::CtiCode>(rr.cti_code());
// frag.add<fix::SecurityDesc>(sec.glbx().security_desc());
// frag.add<fix::ClOrdID>(clordid);
// frag.add<fix::SelfMatchPreventionID>(rr.smp_id());
// frag.add<fix::SelfMatchPreventionInstruction>(
// rr.smp_instruction());
// }
// me->create_transact_time_bm = frag.add<fix::TransactTimeStr>(
// datetime::FIX_timestamp(datetime::now()));
// me->create_quantity_bm =
// frag.add<fix::OrderQty>(0, quantity_sz());
// me->create_corid_bm =
// frag.add<fix::Text>(std::string(corid_sz(), ' '));
}
BENCHMARK(jetfix_gen_new_order);
// size_t create_order = 0;
// size_t update_order = 0;
// size_t cancel_order = 0;