CCMarketDataListener now listens to CC and writes data to shared memory

This commit is contained in:
Taha Afzal committed 2022-10-19 13:55:52 -04:00
1 parent dd84ec6720
commit 32d1714cf6
24 files changed
+994 -612

No files matched your search

+1 -1
View File
@@ -1 +1 @@
set(sources api/analytics/ExpirationDriver.proto;api/analytics/TimeWeightedInterpolatedDriver.proto;api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/domain/Currency.proto;api/domain/SecurityCriteria.proto;api/domain/SecurityCriteriaClause.proto;api/domain/SecurityExpiration.proto;api/domain/SecurityMetadata.proto;api/domain/SecurityMetadataCollection.proto;api/domain/SecurityMetadataItem.proto;api/domain/SecurityType.proto;api/domain/TickDisplaySettings.proto;api/domain/TickFactors.proto;api/domain/Venue.proto;api/io/URL.proto;api/md/MarketDataSubscriptionParams.proto;api/md/binance/BinanceDepthStreamParams.proto;api/md/binance/BinanceMarketDataSubscriptionParams.proto;api/md/deribit/DeribitMarketDataSubscriptionParams.proto;api/md/ftx/FTXDepthStreamParams.proto;api/md/ftx/FTXMarketDataSubscriptionParams.proto;api/md/glbx/GlbxMarketDataSubscriptionParams.proto;api/md/huobi/HuobiMarketDataSubscriptionParams.proto;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/AnalyticsService.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/MarketDataService.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;communincation/websockets/tests/WebsocketSyncClientTests.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/SecurityMetadataCollection.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/algo_types.proto;config/protos/cme_reference_data.proto;config/protos/exchange_sim_cfg.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/market_data.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/ports.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spartan.proto;config/protos/spreader.proto;config/protos/subprocess.proto;config/protos/symbols.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/protos/ui.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain/AggressorSide.cpp;domain/NewOrder.cpp;domain/OrderDefinition.cpp;domain/OrderStatus.cpp;domain/OrderUpdate.cpp;domain/Side.cpp;domain/TimeInForce.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;io/QueryParams.cpp;io/URL.cpp;io/http/CurlHandle.cpp;io/http/HTTPClient.cpp;io/http/HTTPHeaders.cpp;io/http/HTTPRequest.cpp;io/http/HTTPResponse.cpp;io/websocket/WebsocketClient.cpp;io/websocket/WebsocketClientConfiguration.cpp;io/websocket/WebsocketError.cpp;io/websocket/WebsocketMessage.cpp;io/websocket/WebsocketSSLClientInternal.cpp;io/websocket/tests/WebsocketClientTests.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/JetFIXGatLine truncated
set(sources api/analytics/ExpirationDriver.proto;api/analytics/TimeWeightedInterpolatedDriver.proto;api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/domain/Currency.proto;api/domain/SecurityCriteria.proto;api/domain/SecurityCriteriaClause.proto;api/domain/SecurityExpiration.proto;api/domain/SecurityMetadata.proto;api/domain/SecurityMetadataCollection.proto;api/domain/SecurityMetadataItem.proto;api/domain/SecurityType.proto;api/domain/TickDisplaySettings.proto;api/domain/TickFactors.proto;api/domain/Venue.proto;api/io/URL.proto;api/md/MarketDataSubscriptionParams.proto;api/md/binance/BinanceDepthStreamParams.proto;api/md/binance/BinanceMarketDataSubscriptionParams.proto;api/md/deribit/DeribitMarketDataSubscriptionParams.proto;api/md/ftx/FTXDepthStreamParams.proto;api/md/ftx/FTXMarketDataSubscriptionParams.proto;api/md/glbx/GlbxMarketDataSubscriptionParams.proto;api/md/huobi/HuobiMarketDataSubscriptionParams.proto;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/AnalyticsService.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/MarketDataService.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;communincation/websockets/tests/WebsocketSyncClientTests.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/SecurityMetadataCollection.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/algo_types.proto;config/protos/cme_reference_data.proto;config/protos/exchange_sim_cfg.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/market_data.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/ports.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spartan.proto;config/protos/spreader.proto;config/protos/subprocess.proto;config/protos/symbols.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/protos/ui.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain/AggressorSide.cpp;domain/NewOrder.cpp;domain/OrderDefinition.cpp;domain/OrderStatus.cpp;domain/OrderUpdate.cpp;domain/Side.cpp;domain/TimeInForce.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;io/QueryParams.cpp;io/URL.cpp;io/http/CurlHandle.cpp;io/http/HTTPClient.cpp;io/http/HTTPHeaders.cpp;io/http/HTTPRequest.cpp;io/http/HTTPResponse.cpp;io/websocket/WebsocketClient.cpp;io/websocket/WebsocketClientConfiguration.cpp;io/websocket/WebsocketError.cpp;io/websocket/WebsocketMessage.cpp;io/websocket/WebsocketSSLClientInternal.cpp;io/websocket/tests/WebsocketClientTests.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/JetFIXGatLine truncated
@@ -52,6 +52,7 @@ bool AdminServiceUtils::has_exchange(
rv = conn.has_ice_connection();
break;
case api::Venue::VENUE_DERIBIT: // TODO
case api::Venue::VENUE_FTX:
case api::Venue::VENUE_BTS:
case api::Venue::VENUE_CBOE:
case api::Venue::VENUE_CBOECFE:
@@ -161,6 +162,7 @@ AdminServiceUtils::resolve_connection(
rv = resolve_sim_connection(data, account, sec);
break;
case api::Venue::VENUE_DERIBIT:
case api::Venue::VENUE_FTX:
rv = resolve_sim_connection(data, account, sec);
break;
case api::Venue::VENUE_CBOE:
@@ -410,6 +412,7 @@ std::string AdminServiceUtils::find_account_exchange_account(
}
case api::Venue::VENUE_UNSET:
case api::Venue::VENUE_DERIBIT: // TODO
case api::Venue::VENUE_FTX: // TODO
case api::Venue::VENUE_BTS:
case api::Venue::VENUE_CBOE:
case api::Venue::VENUE_CBOECFE:
@@ -686,6 +689,7 @@ bts::api::orderman::RoutingRecord AdminServiceUtils::get_routing_record(
rv.set_customer_or_firm(sim_account_data->origin());
return rv;
} break;
case api::VENUE_FTX: // TODO
case api::Venue::VENUE_UNSET:
case api::Venue::VENUE_BTS:
case api::Venue::VENUE_CBOE:
@@ -1075,6 +1079,7 @@ std::string AdminServiceUtils::find_user_exchange_id(
break;
}
case api::Venue::VENUE_DERIBIT: // TODO
case api::Venue::VENUE_FTX: // TODO
case api::Venue::VENUE_UNSET:
case api::Venue::VENUE_BTS:
case api::Venue::VENUE_CBOE:
@@ -1103,6 +1108,7 @@ std::string AdminServiceUtils::find_user_company_id(
break;
}
case api::Venue::VENUE_DERIBIT:
case api::Venue::VENUE_FTX: // TODO
case api::Venue::VENUE_SIM:
case api::Venue::VENUE_SIMICE:
case api::Venue::VENUE_GLBX:
+12 -2
View File
@@ -19,7 +19,7 @@ SymbolList {
# symbol: "ES"
# symbol: "FYT"
# symbol: "FOB"
# symbol: "GC"
symbol: "GC"
# symbol: "GE"
# symbol: "HE"
# symbol: "HG"
@@ -37,7 +37,7 @@ SymbolList {
# symbol: "NUB"
# symbol: "RB"
# symbol: "RBT"
# symbol: "SI"
symbol: "SI"
# symbol: "SOM"
# symbol: "SR1"
# symbol: "SR3"
@@ -84,6 +84,11 @@ SymbolLists
key: "DERIBIT"
symbol: @SymbolList.symbol
}
list
{
key: "FTX"
symbol: @SymbolList.symbol
}
}
}
@@ -141,5 +146,10 @@ Symbols {
option: @SymbolLists.list[DERIBIT].symbol
spread: @SymbolLists.list[DERIBIT].symbol
}
ftx {
future: @SymbolLists.list[FTX].symbol
option: @SymbolLists.list[FTX].symbol
spread: @SymbolLists.list[FTX].symbol
}
}
}
+1
View File
@@ -23,4 +23,5 @@ message Symbols {
optional SecurityExchangeList ice = 30;
optional SecurityExchangeList simice = 40;
optional SecurityExchangeList deribit = 50;
optional SecurityExchangeList ftx = 60;
}
+6
View File
@@ -14,6 +14,7 @@ enum Venue {
VENUE_ICE = 306;
VENUE_SIMICE = 3;
VENUE_DERIBIT = 400;
VENUE_FTX = 410;
}
enum SecurityType {
@@ -102,6 +103,10 @@ message DeribitExchangeData {
int64 exchange_id = 10;
string security_desc = 20;
}
message FTXExchangeData {
int64 exchange_id = 10;
string security_desc = 20;
}
message CBOECFEExchangeData {
int64 exchange_id = 10;
string security_desc = 20;
@@ -198,6 +203,7 @@ message Security {
CBOECFEExchangeData cfe = 220;
ICEExchangeData ice = 230;
DeribitExchangeData deribit = 240;
FTXExchangeData ftx = 250;
}
}
message SecurityList {
+1 -1
View File
@@ -205,7 +205,7 @@ static const char *Message_Type_Name(ccapi::Message::Type t) {
bool CCApiListenerAdaptor::processEvent(
const ccapi::Event &event, ccapi::Session *) {
LOG(md, Error, "Received ccapi event: {}", event.toString());
LOG(md, Diag, "Received ccapi event: {}", event.toString());
const auto &msgs = event.getMessageList();
for (const auto &msg : msgs) {
const auto &corr_ids = msg.getCorrelationIdList();
+3 -3
View File
@@ -1,6 +1,4 @@
#ifdef SPARK_ENABLE_CCAPI
#include "lib/md/CCApiListenerAdaptor.h"
#include <ccapi_cpp/ccapi_macro.h>
#include "MarketDataGateway.h"
#include "MarketDataRegistration.h"
#include "lib/api/md/MarketDataSubscriptionParams.pb.h"
@@ -8,6 +6,7 @@
#include "lib/core/ProtoPrinter.h"
#include "lib/domain/Venue.h"
#include "lib/logging/logging.h"
#include "lib/md/CCApiListenerAdaptor.h"
#include "lib/md/CompositeMarketDataListener.h"
#include "lib/md/IMarketDataListener.h"
#include "lib/md/MarketDataListenerData.h"
@@ -17,6 +16,7 @@
#include "lib/md/binance/BinanceDiffDepthUpdate.h"
#include "lib/utils/ContainsKey.h"
#include "lib/utils/bts_assert.h"
#include <ccapi_cpp/ccapi_macro.h>
#include <ccapi_cpp/ccapi_session.h>
#include <optional>
#include <unordered_map>
@@ -125,7 +125,7 @@ struct MarketDataGateway::PImpl {
for (const auto &symbol : symbols) {
std::string corr_id = fmt::format("{}", listener_id);
ccapi::Subscription sub(
"binance", symbol, CCAPI_MARKET_DEPTH, opts, corr_id);
"ftx", symbol, CCAPI_MARKET_DEPTH, opts, corr_id);
ccapi_session().subscribe(sub);
}
}
+19
View File
@@ -235,6 +235,25 @@ size_t get_system_md_symbols(
&result);
}
}
{
if (exchange == api::VENUE_FTX || exchange == api::VENUE_UNSET) {
auto const &e = config::get<config::system_symbols::Symbols>().ftx();
if (type == api::SECURITYTYPE_FUTURE ||
type == api::SECURITYTYPE_UNSET) {
add_symbols_to_result(
e.future(), api::VENUE_FTX, api::SECURITYTYPE_FUTURE, &result);
}
if (type == api::SECURITYTYPE_OPTION ||
type == api::SECURITYTYPE_UNSET) {
add_symbols_to_result(
e.option(), api::VENUE_FTX, api::SECURITYTYPE_OPTION, &result);
}
if (type == api::SECURITYTYPE_SPREAD ||
type == api::SECURITYTYPE_UNSET)
add_symbols_to_result(
e.spread(), api::VENUE_FTX, api::SECURITYTYPE_SPREAD, &result);
}
}
for (const auto &u : result) {
LOG(md, Info, "get_system_md_symbols loaded sym: {} exch: {} type: {}",
u.symbol(), Venue_Name(u.exchange()), SecurityType_Name(u.type()));
+10
View File
@@ -190,6 +190,10 @@ void convert_security(const FixedSecurity &source, Security *presult) {
dest.mutable_deribit()->set_security_desc(source.security_desc());
dest.mutable_deribit()->set_exchange_id(source.numeric_id);
break;
case Venue::VENUE_FTX:
dest.mutable_ftx()->set_security_desc(source.security_desc());
dest.mutable_ftx()->set_exchange_id(source.numeric_id);
break;
case Venue::VENUE_BTS:
break;
default:
@@ -288,6 +292,8 @@ uint64_t exchange_id(const Security &security) {
return security.ice().exchange_id();
case Security::ExchangeDataCase::kDeribit:
return security.deribit().exchange_id();
case Security::ExchangeDataCase::kFtx:
return security.ftx().exchange_id();
// Debatable whether this should be an error or not.
// If is possible that we might create a spread with no exchange in the
// future and if we did this would be a runtime error.
@@ -338,6 +344,10 @@ void convert_security(
dest.numeric_id = src.deribit().exchange_id();
dest.security_desc(src.deribit().security_desc());
break;
case Security::ExchangeDataCase::kFtx:
dest.numeric_id = src.ftx().exchange_id();
dest.security_desc(src.ftx().security_desc());
break;
case Security::ExchangeDataCase::EXCHANGEDATA_NOT_SET:
break;
}
+51
View File
@@ -0,0 +1,51 @@
#include "CCDemoListener.h"
#include "lib/logging/logging.h"
#include "lib/md/MarketDataError.h"
#include <functional>
#include <iomanip>
#include <memory>
namespace bts::md {
struct CCDemoListener::PImpl {
size_t n_bk_updates = 0;
};
CCDemoListener::CCDemoListener() : me(std::make_unique<PImpl>()) {}
CCDemoListener::~CCDemoListener() {}
void CCDemoListener::on_securities(
const std::vector<const domain::Security *> &sec_v) {
LOG(md, Info, "CCDemoListener::on_securities sz: {}", sec_v.size());
}
void CCDemoListener::on_security_state(const domain::SecurityState &) {}
void CCDemoListener::on_security_statistics(
const domain::SecurityMarketDataStatistics &) {}
void CCDemoListener::on_book(const domain::Book &book) {
auto bids = book[domain::Side::Buy];
auto asks = book[domain::Side::Sell];
size_t idx = 0;
std::cout << "Book no: " << me->n_bk_updates++
<< " sec_id: " << book.security_id().value() << std::endl;
for (const auto &b : bids) {
std::cout << "idx: " << idx++ << " pr: " << b.price
<< " sz: " << b.total_quantity << std::endl;
}
for (const auto &a : asks) {
std::cout << "idx: " << idx++ << " pr: " << a.price
<< " sz: " << a.total_quantity << std::endl;
}
std::cout << "-----------------" << std::endl;
}
void CCDemoListener::on_trades(
const std::vector<domain::TradeRecord const *> &) {}
void CCDemoListener::on_rfqs(const std::vector<domain::RFQ const *> &) {}
void CCDemoListener::on_error(const MarketDataError &error) {
LOG(md, bts::Error, "MarketDataError: {}", error);
}
} // namespace bts::md
+26
View File
@@ -0,0 +1,26 @@
#pragma once
#include "lib/md/IMarketDataListener.h"
namespace bts::md {
class CCDemoListener : public IMarketDataListener {
public:
void on_securities(const std::vector<domain::Security const *>
&complete_security_list) override;
void on_security_state(const domain::SecurityState &security_state) override;
void on_security_statistics(
const domain::SecurityMarketDataStatistics &security_stats) override;
void on_book(const domain::Book &book) override;
void on_trades(
const std::vector<domain::TradeRecord const *> &trades) override;
void on_rfqs(const std::vector<domain::RFQ const *> &rfqs) override;
void on_error(const MarketDataError &error) override;
CCDemoListener();
virtual ~CCDemoListener();
private:
struct PImpl;
std::unique_ptr<PImpl> me;
};
} // namespace bts::md
+98
View File
@@ -0,0 +1,98 @@
#include "CCMain.h"
#include "lib/api/md/MarketDataSubscriptionParams.pb.h"
#include "lib/config/config.h"
#include "lib/config/protos/market_data.pb.h"
#include "lib/core/ProtoReader.h"
#include "lib/logging/logging.h"
#include "lib/md/MDProducer.h"
#include "lib/md/MarketDataGateway.h"
#include "lib/md/MarketDataRegistration.h"
#include "lib/md/MarketDataSubscription.h"
#include "lib/md/SecurityDB.h"
#include "lib/md/SecurityIDRecorder.h"
#include "lib/md/ccApi/CCDemoListener.h"
#include "lib/md/ccApi/CCMarketDataListener.h"
#include "lib/md/ccApi/CCSecurityIndex.h"
#include "lib/md/coconut2.h"
#include "lib/md/common.h"
#include "lib/md/protos/co2.pb.h"
#include "lib/os/os.h"
#include "lib/utils/Dispatcher.h"
#include "lib/utils/PBUtils.h"
#include "lib/utils/bts_assert.h"
#include "lib/utils/bts_chrono.h"
#include "lib/utils/proto_helper.h"
#include "lib/utils/thread_manager.h"
#include "server/sparkd/cmds/crypto/DeribitDemoConfiguration.h"
#include <emumba-deribit-connector/deribit_listener.h>
#include "lib/md/ccApi/CCSecurityIndex.h"
#include <boost/filesystem.hpp>
#include <memory>
#include <optional>
#include <set>
using namespace std;
namespace bts::md {
struct CCMain::PImpl {
CCSecurityIndex sec_index;
SecurityIDRecorder recorder;
MDProducer producer;
bts::md::MarketDataGateway gw;
CCMarketDataListener cc_listener;
PImpl()
: sec_index(), recorder(
{utils::Dispatcher::current(),
[=](ExchangeKey k) {
return SecurityKey(sec_index.get_key(k.value()));
}}),
producer(bts::co2::PLATFORM_SIM, recorder),
cc_listener(sec_index, producer) {}
};
CCMain::CCMain()
: // me(std::make_unique<PImpl>()) {
me(new PImpl()) {
LOG(md, Info, "CCMain::CCMain constructed on t_id: {} t_name: {}",
bts::os::get_thread_id(), bts::os::get_thread_name());
}
void CCMain::send_heartbeats() {}
CCMain::~CCMain() {}
void CCMain::run() {
LOG(md, Info, "Run::run_ccapi t_id:{} t_name:{}", os::get_thread_id(),
os::get_thread_name());
std::string conf_file = "/home/taha/sparkdata/conf/ftx.json";
std::optional<api::md::MarketDataSubscriptionParams> subscriptions =
core::ProtoReader::read_proto<api::md::MarketDataSubscriptionParams>(
conf_file);
if (!subscriptions.has_value()) {
LOG(md, bts::Error,
"run_ccapi Unable to parse MarketDataSubscriptionParams from file: "
"'{}'",
conf_file);
return;
}
LOG(md, Info, "run_ccapi read proto: {}",
bts::utils::pb::to_string(subscriptions.value()));
bts::md::MarketDataSubscription md_sub{subscriptions.value()};
char ssl_cert_file[] = "SSL_CERT_FILE=/etc/ssl/cert/ca-certificates.crt";
putenv(ssl_cert_file);
me->gw.subscribe(md_sub, &me->cc_listener);
size_t n = 0;
while (true) {
std::cout << "Main loop iter " << n + 1 << std::endl << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(1));
}
std::cout << "Exiting run_ccapi" << std::endl;
}
} // namespace bts::md
+21
View File
@@ -0,0 +1,21 @@
#pragma once
#include "server/sparkd/md/platforms/IMDPlatform.h"
#include <memory>
namespace bts::md {
class CCMain : public IMDPlatform {
public:
CCMain();
virtual ~CCMain();
// IMDPlatform implementation
void send_heartbeats() override;
void run();
private:
struct PImpl;
std::unique_ptr<PImpl> me;
};
} // namespace bts::md
+125 -30
View File
@@ -1,3 +1,10 @@
#include "lib/api/domain/Currency.pb.h"
#include "lib/api/domain/Venue.pb.h"
#include "lib/core/TimeStamp.h"
#include "lib/md/MDProducerHandle.h"
#include "lib/md/Shm/MDStructure.h"
#include "lib/orderman/actors/SODPosition.h"
#include "lib/utils/TimeStamp.h"
#ifdef SPARK_ENABLE_CCAPI
#include "CCMarketDataListener.h"
#include "lib/api/domain/SecurityType.pb.h"
@@ -25,7 +32,11 @@
#include "lib/utils/PBUtils.h"
#include "lib/utils/bts_assert.h"
#include <bits/stdint-uintn.h>
#include <google/protobuf/timestamp.pb.h>
#include <google/protobuf/util/time_util.h>
#include <sstream>
#include <string>
#include <sys/time.h>
namespace bts::md {
@@ -47,13 +58,17 @@ struct SecSearchResult {
};
struct CCMarketDataListener::PImpl {
const bool use_cc_id_as_bts_id = true;
const std::string cc_name_prefix = "cc_security";
size_t n_bk_updates = 0;
bts::persistence::IDGenerator id_gen = {};
CCSecurityIndex &index;
MDProducer &md_producer;
// map of logical key (venue + exchange key) to id
std::unordered_map<std::string, SecurityAuxData> sec_map = {};
// std::unordered_map<std::string, SecurityAuxData> sec_map = {};
// this is the map of cc api transient sec id's to bts permenant id's
// (a flag is used to tell if bts::domain::SecurityID can be used as bts id
// as well)
std::unordered_map<bts::domain::SecurityID, uint64_t> cc_sec_id_map = {};
MDArray bids = {};
MDArray asks = {};
@@ -63,15 +78,14 @@ struct CCMarketDataListener::PImpl {
// stateless util functions ///////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
std::string get_logical_Key(const bts::domain::Security &sec) {
std::string get_logical_key(const bts::domain::Security &sec) {
return bts::api::domain::Venue_Name(sec.security_common.venue) + "_" +
sec.security_common.exchange_sec_id;
}
void get_date_from_epoch_nanos(
long int epoch_nanosecs, uint32_t &year, uint32_t &month, uint32_t &day) {
// timezone)
long int epoch_secs = epoch_nanosecs / 1000 * 1000 * 1000;
long int epoch_secs = epoch_nanosecs / (1000 * 1000 * 1000);
time_t ts_tt(epoch_secs);
struct tm *ptm = gmtime(&ts_tt);
year = ptm->tm_year + 1900;
@@ -79,6 +93,18 @@ void get_date_from_epoch_nanos(
day = ptm->tm_mday;
}
core::TimeStamp get_ts_from_date(uint32_t yy, uint32_t mm, uint32_t dd) {
struct tm t;
t.tm_year = yy - 1900; // Year - 1900
t.tm_mon = mm - 1; // Month, where 0 = jan
t.tm_mday = dd; // Day of the month
t.tm_hour = t.tm_min = t.tm_sec = 0;
t.tm_isdst = -1; // Is DST on? 1 = yes, 0 = no, -1 = unknown
time_t t_of_day = mktime(&t);
auto nanos = (double)t_of_day * 1000 * 1000 * 1000;
return core::TimeStamp(nanos);
}
bts::md::IntPrice convert_price(bts::domain::Price p) {
return bts::md::IntPrice(p.mantissa(), p.exponent());
}
@@ -168,7 +194,9 @@ void CCMarketDataListener::on_security_state(const domain::SecurityState &) {}
void CCMarketDataListener::on_security_statistics(
const domain::SecurityMarketDataStatistics &sec_stats) {
auto handle = _find_handle(sec_stats.security_id);
bts_assert(handle != nullptr);
bts_assert_msg(
handle != nullptr,
"CCMarketDataListener::on_security_statistics null handle");
auto now = utils::TimeStamp::now();
bts::datetime::Date date_temp = {};
handle->handle.update_session_low(now, sec_stats.low.to_double());
@@ -180,11 +208,29 @@ void CCMarketDataListener::on_security_statistics(
}
void CCMarketDataListener::on_book(const bts::domain::Book &book) {
_temp_add_security();
me->n_bk_updates++;
auto handle = _find_handle(book.security_id());
bts_assert(handle != nullptr);
bts_assert_msg(
handle != nullptr, "CCMarketDataListener::on_book null handle");
copy_books(book, me->bids, bts::domain::Side::Value::Buy);
copy_books(book, me->asks, bts::domain::Side::Value::Sell);
handle->handle.update_direct(utils::TimeStamp::now(), me->bids, me->asks);
auto bids = book[domain::Side::Buy];
auto asks = book[domain::Side::Sell];
size_t idx = 0;
std::cout << "Book no: " << me->n_bk_updates
<< " sec_id: " << book.security_id().value() << std::endl;
for (const auto &b : bids) {
std::cout << "idx: " << idx++ << " pr: " << b.price
<< " sz: " << b.total_quantity << std::endl;
}
for (const auto &a : asks) {
std::cout << "idx: " << idx++ << " pr: " << a.price
<< " sz: " << a.total_quantity << std::endl;
}
std::cout << "-----------------" << std::endl;
}
void CCMarketDataListener::on_trades(
@@ -210,29 +256,36 @@ void CCMarketDataListener::on_rfqs(const std::vector<domain::RFQ const *> &) {}
void CCMarketDataListener::on_error(const MarketDataError &) {}
CCMarketDataListener::~CCMarketDataListener() {}
// private members ////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
SecSearchResult CCMarketDataListener::_find_sec(
const bts::domain::Security &sec, bool add_if_absent) {
auto logical_key = get_logical_Key(sec);
auto sec_it = me->sec_map.find(logical_key);
if (sec_it != me->sec_map.end()) {
auto cc_id = sec.security_common.id;
auto sec_it = me->cc_sec_id_map.find(cc_id);
if (sec_it != me->cc_sec_id_map.end()) {
// exists already
auto key = sec_it->second.locked_key;
auto key = sec_it->second;
return {key, true, true};
} else {
// does not exist
if (add_if_absent) {
auto new_key_opt =
me->id_gen.get_id(me->cc_name_prefix, logical_key, true);
bts_assert(new_key_opt.has_value());
auto new_key = new_key_opt.value();
me->sec_map.insert({logical_key, {new_key}});
me->cc_sec_id_map.insert({sec.security_common.id, new_key});
LOG(md, Info, "Adding new sec logical_key: {} key: {}", logical_key,
new_key);
return {new_key, false, true};
uint64_t bts_id = cc_id.value();
if (!me->use_cc_id_as_bts_id) {
auto logical_key = get_logical_key(sec);
auto new_key_opt =
me->id_gen.get_id(me->cc_name_prefix, logical_key, true);
bts_assert(new_key_opt.has_value());
bts_id = new_key_opt.value();
}
me->cc_sec_id_map.insert({cc_id, {bts_id}});
LOG(md, Info,
"CCMarketDataListener::_find_sec adding new sec desc: {} cc_id: "
"{} bts_id: {}",
sec.security_common.desc, cc_id, bts_id);
return {bts_id, false, true};
} else {
return {0, false, false};
}
@@ -241,6 +294,8 @@ SecSearchResult CCMarketDataListener::_find_sec(
CCSecurityData *CCMarketDataListener::_find_handle(
bts::domain::SecurityID cc_id) {
// TODO: temp
cc_id = me->cc_sec_id_map.begin()->first;
auto it = me->cc_sec_id_map.find(cc_id);
if (it != me->cc_sec_id_map.end()) {
auto id = it->second;
@@ -255,11 +310,13 @@ void CCMarketDataListener::_add_future(const bts::domain::Security &sec) {
bts_assert(search_result.existed_before);
FixedFutureSecurity ff_sec;
_copy_security_common(sec, search_result.key, ff_sec);
ff_sec.type = api::SECURITYTYPE_FUTURE;
uint32_t year, month, day;
const auto &f_sec = std::get<bts::domain::FutureSecurity>(sec.security);
get_date_from_epoch_nanos(f_sec.expiration.nanos(), year, month, day);
LOG(md, Info, "CCMarketDataListener::_add_future yy: {} mm: {} dd:{ }", year,
month, day);
LOG(md, Info,
"CCMarketDataListener::_add_future nanos: {} yy: {} mm: {} dd: {}",
f_sec.expiration.nanos(), year, month, day);
ff_sec.expiration_year = year;
ff_sec.expiration_month = month;
ff_sec.expiration_day = day;
@@ -296,26 +353,64 @@ void CCMarketDataListener::_add_spot(const bts::domain::Security &sec) {
_commit_security(fs_sec);
}
void CCMarketDataListener::_commit_security(const FixedSecurity &fsec) {
void CCMarketDataListener::_commit_security(const FixedSecurity &sec) {
// Set up the shared memory for this security
bts_assert(fsec.numeric_id != 0);
auto handle = me->md_producer.add_security(fsec);
bts_assert(sec.numeric_id != 0);
auto handle = me->md_producer.add_security(sec);
// Add it to the index so it can receive messages
me->index.add_security(fsec.numeric_id, handle);
auto kp = me->index.add_security(sec.numeric_id, handle);
LOG(md, Info,
"CCMarketDataListener::_add_security_to_shm added sec: {} id: {} "
"num_id: {} n_secs: {}",
std::string(handle.security().security_desc()), kp->id,
handle.security().numeric_id, me->index.n_secs());
}
void CCMarketDataListener::_copy_security_common(
const bts::domain::Security &from, uint64_t key, FixedSecurity &to) const {
to.key = key; // key;
to.key = key;
to.numeric_id = key;
auto symbol = from.security_common.symbol;
to.symbol(symbol);
to.security_desc(from.security_common.desc);
to.exchange = Venue::VENUE_DERIBIT; // TODO: hc'ing to SIM
to.display_factor = 0.0;
double min_tick = from.security_common.min_price_increment.to_double();
to.low_tick = to.high_tick = min_tick;
to.exchange = Venue::VENUE_FTX;
to.display_factor = 1.0;
to.price_break = 0.0;
to.low_tick = to.high_tick =
from.security_common.min_price_increment_ammount;
}
// just adds the BTC perp
void CCMarketDataListener::_temp_add_security() {
if (!me->cc_sec_id_map.empty()) {
return;
}
bts::domain::Security sec = {};
// common
auto &scomm = sec.security_common;
scomm.venue = api::domain::FTX;
std::string desc = "BTC-PERPETUAL";
scomm.exchange_sec_id = desc;
auto id = me->id_gen.get_id(me->cc_name_prefix, desc, true);
bts_assert(id.has_value());
scomm.id = domain::SecurityID(id.value());
scomm.type = api::domain::SecurityType::FUTURE;
scomm.currency = api::domain::USD;
scomm.display_factor = 1;
scomm.cash_per_point = 1;
scomm.symbol = "BTC";
scomm.desc = scomm.exchange_sec_id;
scomm.min_price_increment_ammount = 0.01;
scomm.min_quantity_increment = 0.0001;
// future
bts::domain::FutureSecurity fs = {};
fs.expiration = // core::TimeStamp(0);
get_ts_from_date(2022, 12, 25);
sec.security = fs;
std::vector<domain::Security const *> temp_list;
temp_list.push_back(&sec);
on_securities(temp_list);
}
} // namespace bts::md
+4
View File
@@ -19,6 +19,7 @@ struct CCSecurityData;
namespace bts::md {
class CCMarketDataListener : public IMarketDataListener {
public:
CCMarketDataListener(CCSecurityIndex &index, MDProducer &md_producer);
void on_securities(const std::vector<domain::Security const *>
&complete_security_list) override;
@@ -30,12 +31,15 @@ class CCMarketDataListener : public IMarketDataListener {
const std::vector<domain::TradeRecord const *> &trades) override;
void on_rfqs(const std::vector<domain::RFQ const *> &rfqs) override;
void on_error(const MarketDataError &error) override;
virtual ~CCMarketDataListener();
private:
struct PImpl;
std::unique_ptr<PImpl> me;
private:
// temporary functions to get things going
void _temp_add_security();
SecSearchResult _find_sec(
const bts::domain::Security &sec, bool add_if_absent);
// given a cc id, returns the bts persisted id, if it can find one
+5 -2
View File
@@ -161,7 +161,9 @@ struct MDConsumerGroup {
channel.exchange() == api::VENUE_BTS ||
channel.exchange() == api::VENUE_UNSET) {
this->mic = "BTS";
} else if (channel.exchange() == api::VENUE_DERIBIT) {
} else if (
channel.exchange() == api::VENUE_DERIBIT ||
channel.exchange() == api::VENUE_FTX) {
this->mic = "DERIBIT";
} else
bts_assert_msg(false, "unknown venue in QueryServer");
@@ -602,7 +604,8 @@ struct MDRelayServer : bts::co2::AuthenticatedMarketDataRelayBase {
}
}
// disabling md entitlements
_db.query(request, preply, user_entitlement, true || bypass_entitlement);
_db.query(
request, preply, user_entitlement, true || bypass_entitlement);
reply(*preply);
#ifndef _WIN32
auto elapsed = (TimeStamp::now() - start);
+7 -1
View File
@@ -1,3 +1,4 @@
#include <string>
#ifndef _WIN32
#include "Sqlite_utils.h"
#include "bts_assert.h"
@@ -8,7 +9,12 @@ namespace sqlite {
void exec_nofail(sqlite3 *db, const char *sql) {
char *error_message = nullptr;
int result = sqlite3_exec(db, sql, nullptr, nullptr, &error_message);
bts_assert_msg(result == SQLITE_OK, error_message);
if (result != SQLITE_OK) {
std::string log_msg =
"error_message: " + std::string(error_message) +
" query: " + (sql != nullptr ? std::string(sql) : "NULL");
bts_assert_msg(false, log_msg);
}
}
void exec_nofail(sqlite3_ptr &db, const char *sql) {
+12
View File
@@ -3,6 +3,7 @@
#include "lib/config/protos/market_data.pb.h"
#include "lib/logging/logging.h"
#include "lib/md/UserSymbol.h"
#include "lib/md/ccApi/CCMain.h"
#include "lib/md/relay/RelayRecorder.h"
#include "lib/os/os.h"
#include "lib/utils/thread_manager.h"
@@ -97,6 +98,13 @@ static void run_emumba() {
em_main.run();
}
static void run_ccapi() {
LOG(md, Info, "Run::run_ccapi t_id:{} t_name:{}", os::get_thread_id(),
get_thread_name());
bts::md::CCMain cc_main = {};
cc_main.run();
}
void Run::run(
bts::md::MBOWriter *mbo_writer,
bts::md::TradeSummarySignalDispatcher *tss_dispatcher,
@@ -152,6 +160,10 @@ void Run::run(
sim::start_exchange_sim(api::Venue::VENUE_SIM, mbo_writer);
}).detach();
}
bool is_run_ccapi = true;
if (is_run_ccapi) {
threading::make_thread("CCAPI", []() { run_ccapi(); }).detach();
}
boot_sleep();
} else {
impl();
@@ -9,7 +9,8 @@ namespace bts::cmds::md {
EnumOptionNames<api::Venue> VenueOption::names() {
return {NAME_PAIR(api::VENUE_BTS), NAME_PAIR(api::VENUE_GLBX),
NAME_PAIR(api::VENUE_ICE), NAME_PAIR(api::VENUE_SIM),
NAME_PAIR(api::VENUE_SIMICE), NAME_PAIR(api::VENUE_DERIBIT)};
NAME_PAIR(api::VENUE_SIMICE), NAME_PAIR(api::VENUE_DERIBIT),
NAME_PAIR(api::VENUE_FTX)};
}
std::string VenueOption::name(api::Venue venue) {
@@ -26,6 +27,8 @@ std::string VenueOption::name(api::Venue venue) {
return "simice";
case api::VENUE_DERIBIT:
return "deribit";
case api::VENUE_FTX:
return "ftx";
default:
return std::to_string(static_cast<int32_t>(venue));
}
@@ -1,10 +1,10 @@
#include "FeedHandler.h"
#include "common/SpartanError.h"
#include "feed_handler/detail/AB_Arbitrageur.h"
#include "feed_handler/detail/FeedHandler_RealTime.h"
#include "feed_handler/detail/FeedHandler_Recovery.h"
#include "server/sparkd/cmds/spartan/domain/SecuritySnapshot.h"
#include "common/SpartanError.h"
namespace bts::spartan {
@@ -14,7 +14,7 @@ struct FeedHandler::PImpl {
State state = State::INIT;
mdp3::AB_Arbitrageur real_time_ab;
FeedHandler_RealTime real_time_handler;
mdp3::FeedHandler_Recovery recovery_handler;
// mdp3::FeedHandler_Recovery recovery_handler;
};
struct FeedHandler::RecoveryGuard {
@@ -40,12 +40,12 @@ void FeedHandler::run() {
start_recovery();
}
void FeedHandler::handle_instrument_packet(MDP3PacketView const &pv) {
void FeedHandler::handle_instrument_packet(MDP3PacketView const & /*pv*/) {
switch (me->state) {
case State::RECOVERY: {
RecoveryGuard g{*this};
mdp3::MDP3Parser::parse(
pv, me->recovery_handler.instrument_stream_handler);
// mdp3::MDP3Parser::parse(
// pv, me->recovery_handler.instrument_stream_handler);
break;
}
case State::REALTIME:
@@ -56,11 +56,12 @@ void FeedHandler::handle_instrument_packet(MDP3PacketView const &pv) {
}
}
void FeedHandler::handle_snapshot_packet(MDP3PacketView const &pv) {
void FeedHandler::handle_snapshot_packet(MDP3PacketView const & /*pv*/) {
switch (me->state) {
case State::RECOVERY: {
RecoveryGuard g{*this};
mdp3::MDP3Parser::parse(pv, me->recovery_handler.snapshot_stream_handler);
// mdp3::MDP3Parser::parse(pv,
// me->recovery_handler.snapshot_stream_handler);
break;
}
case State::REALTIME:
@@ -80,8 +81,8 @@ PickedFeed FeedHandler::handle_incremental_packet(
switch (action.action) {
case mdp3::AB_Arbitrageur::APPLY: {
RecoveryGuard g{*this};
mdp3::MDP3Parser::parse(
action.packet, me->recovery_handler.incremental_stream_handler);
// mdp3::MDP3Parser::parse(
// action.packet, me->recovery_handler.incremental_stream_handler);
}
case mdp3::AB_Arbitrageur::IGNORE:
break;
@@ -119,7 +120,7 @@ void FeedHandler::start_recovery() {
case State::RECOVERY:
LOG(Spartan, Info, "Restarting channel recovery.");
me->real_time_ab = {};
me->recovery_handler.reset();
// me->recovery_handler.reset();
break;
case State::REALTIME:
LOG(Spartan, Warn,
@@ -141,22 +142,22 @@ void FeedHandler::start_recovery() {
void FeedHandler::try_start_real_time() {
bts_assert(me->state == State::RECOVERY);
auto maybe_snaps = me->recovery_handler.try_build_snapshot_and_reset();
if (maybe_snaps) {
LOG(Spartan, Info, "Recovery complete. Starting real time feed");
me->state = State::REALTIME;
std::vector<SecuritySnapshot const *> snap_ptrs;
for (auto &p : maybe_snaps.value())
snap_ptrs.push_back(p.get());
me->real_time_handler.add_snapshots(maybe_snaps.value());
stop_instrument_stream();
stop_snapshot_stream();
on_snapshot(snap_ptrs);
for (auto s : snap_ptrs) {
const_cast<SecuritySnapshot *>(s)->clear_fills();
const_cast<SecuritySnapshot *>(s)->clear_order_changes();
}
}
// auto maybe_snaps = me->recovery_handler.try_build_snapshot_and_reset();
// if (maybe_snaps) {
// LOG(Spartan, Info, "Recovery complete. Starting real time feed");
// me->state = State::REALTIME;
// std::vector<SecuritySnapshot const *> snap_ptrs;
// for (auto &p : maybe_snaps.value())
// snap_ptrs.push_back(p.get());
// me->real_time_handler.add_snapshots(maybe_snaps.value());
// stop_instrument_stream();
// stop_snapshot_stream();
// on_snapshot(snap_ptrs);
// for (auto s : snap_ptrs) {
// const_cast<SecuritySnapshot *>(s)->clear_fills();
// const_cast<SecuritySnapshot *>(s)->clear_order_changes();
// }
// }
}
void FeedHandler::bind_realtime_handler() {
@@ -166,5 +167,4 @@ void FeedHandler::bind_realtime_handler() {
me->real_time_handler.on_trade_summary = on_trade_summary;
}
} // namespace bts::spartan
@@ -1,439 +1,450 @@
#include "FeedHandler_Recovery.h"
// #include "FeedHandler_Recovery.h"
#include "BookSnapshot.h"
#include "DefinitionSnapshot.h"
#include "IncrementalQueue.h"
#include "domain/SecuritySnapshot.h"
#include "feed_handler/detail/FeedHandler_RealTime.h"
// #include "BookSnapshot.h"
// #include "DefinitionSnapshot.h"
// #include "IncrementalQueue.h"
// #include "domain/SecuritySnapshot.h"
// #include "feed_handler/detail/FeedHandler_RealTime.h"
namespace bts::spartan::mdp3 {
// namespace bts::spartan::mdp3 {
// Helpers
inline spartan::Side convert_side(::mdp3::MDEntryType::Value v) {
switch (v) {
case ::mdp3::MDEntryType::Bid:
case ::mdp3::MDEntryType::ImpliedBid:
return Side::Buy;
case ::mdp3::MDEntryType::Offer:
case ::mdp3::MDEntryType::ImpliedOffer:
return Side::Sell;
default:
bts_assert(false);
return Side::Buy;
}
}
// // Helpers
// inline spartan::Side convert_side(::mdp3::MDEntryType::Value v) {
// switch (v) {
// case ::mdp3::MDEntryType::Bid:
// case ::mdp3::MDEntryType::ImpliedBid:
// return Side::Buy;
// case ::mdp3::MDEntryType::Offer:
// case ::mdp3::MDEntryType::ImpliedOffer:
// return Side::Sell;
// default:
// bts_assert(false);
// return Side::Buy;
// }
// }
inline spartan::Side convert_side(::mdp3::MDEntryTypeBook::Value v) {
switch (v) {
case ::mdp3::MDEntryTypeBook::Bid:
return Side::Buy;
case ::mdp3::MDEntryTypeBook::Offer:
return Side::Sell;
default:
bts_assert(false);
return Side::Buy;
}
}
// inline spartan::Side convert_side(::mdp3::MDEntryTypeBook::Value v) {
// switch (v) {
// case ::mdp3::MDEntryTypeBook::Bid:
// return Side::Buy;
// case ::mdp3::MDEntryTypeBook::Offer:
// return Side::Sell;
// default:
// bts_assert(false);
// return Side::Buy;
// }
// }
struct FeedHandler_Recovery::PImpl {
PImpl(FeedHandler_Recovery &owner)
: owner(owner),
// struct FeedHandler_Recovery::PImpl {
// PImpl(FeedHandler_Recovery &owner)
// : owner(owner),
book_snapshot(), definition_snapshot(), incremental_queue(),
// book_snapshot(), definition_snapshot(), incremental_queue(),
instrument_stream_handler(*this), snapshot_stream_handler(*this),
incremental_stream_handler(*this) {}
// instrument_stream_handler(*this), snapshot_stream_handler(*this),
// incremental_stream_handler(*this) {}
FeedHandler_Recovery &owner;
// FeedHandler_Recovery &owner;
BookSnapshot book_snapshot;
DefinitionSnapshot definition_snapshot;
IncrementalQueue incremental_queue;
// BookSnapshot book_snapshot;
// DefinitionSnapshot definition_snapshot;
// IncrementalQueue incremental_queue;
InstrumentStreamHandler instrument_stream_handler;
SnapshotStreamHandler snapshot_stream_handler;
IncrementalStreamHandler incremental_stream_handler;
};
// InstrumentStreamHandler instrument_stream_handler;
// SnapshotStreamHandler snapshot_stream_handler;
// IncrementalStreamHandler incremental_stream_handler;
// };
FeedHandler_Recovery::FeedHandler_Recovery()
: me(new PImpl(*this)),
instrument_stream_handler(me->instrument_stream_handler),
snapshot_stream_handler(me->snapshot_stream_handler),
incremental_stream_handler(me->incremental_stream_handler) {}
// FeedHandler_Recovery::FeedHandler_Recovery()
// : me(new PImpl(*this)),
// instrument_stream_handler(me->instrument_stream_handler),
// snapshot_stream_handler(me->snapshot_stream_handler),
// incremental_stream_handler(me->incremental_stream_handler) {}
FeedHandler_Recovery::~FeedHandler_Recovery() {}
// FeedHandler_Recovery::~FeedHandler_Recovery() {}
void FeedHandler_Recovery::reset() {
me->book_snapshot.reset();
me->definition_snapshot.reset();
me->incremental_queue.reset();
}
// void FeedHandler_Recovery::reset() {
// me->book_snapshot.reset();
// me->definition_snapshot.reset();
// me->incremental_queue.reset();
// }
FeedHandler_Recovery::MaybeSnapshot
FeedHandler_Recovery::try_build_snapshot_and_reset() {
if (!me->book_snapshot.is_complete())
return {};
if (!me->definition_snapshot.is_complete())
return {};
if (!me->incremental_queue.is_consistent())
return {};
// FeedHandler_Recovery::MaybeSnapshot
// FeedHandler_Recovery::try_build_snapshot_and_reset() {
// if (!me->book_snapshot.is_complete())
// return {};
// if (!me->definition_snapshot.is_complete())
// return {};
// if (!me->incremental_queue.is_consistent())
// return {};
// Do we have definitions for every book?
auto &books = me->book_snapshot.get_books();
auto &definitions_ref = me->definition_snapshot.get_definitions();
std::unordered_set<SecurityID> definition_ids;
for (auto &d : definitions_ref)
definition_ids.insert(d.security_id());
for (auto &b : books)
if (definition_ids.count(SecurityID{b.book->securityID()}) == 0) {
// We are missing a definition for one of the books so we
// need to start over and get a new round of definitions
LOG(Spartan, Info,
"Missed instrument definition for security {}. Recoverying "
"instruments again",
b.book->securityID());
me->definition_snapshot.reset();
return {};
}
// // Do we have definitions for every book?
// auto &books = me->book_snapshot.get_books();
// auto &definitions_ref = me->definition_snapshot.get_definitions();
// std::unordered_set<SecurityID> definition_ids;
// for (auto &d : definitions_ref)
// definition_ids.insert(d.security_id());
// for (auto &b : books)
// if (definition_ids.count(SecurityID{b.book->securityID()}) == 0) {
// // We are missing a definition for one of the books so we
// // need to start over and get a new round of definitions
// LOG(Spartan, Info,
// "Missed instrument definition for security {}. Recoverying "
// "instruments again",
// b.book->securityID());
// me->definition_snapshot.reset();
// return {};
// }
// Does our incremental queue have events that preced every book
// snapshot? If so we can be sure that we can catch up the
// snapshots to the current incremental feed by applying the queued
// events.
if (me->book_snapshot.oldest_snapshot_seq_num() <=
me->incremental_queue.oldest_packet_seq_num()) {
// Our queue is not guaranteed to contain all the events that
// follow all the snapshots so we need to get a new round of
// snapshots.
LOG(Spartan, Info,
"First packet in incremental queue ({}) is more recent than oldest "
"last processed packet in snapshot ({}). Snapshot is too old, will "
"try getting a new one.",
me->incremental_queue.oldest_packet_seq_num(),
me->book_snapshot.oldest_snapshot_seq_num());
me->book_snapshot.reset();
return {};
}
// // Does our incremental queue have events that preced every book
// // snapshot? If so we can be sure that we can catch up the
// // snapshots to the current incremental feed by applying the queued
// // events.
// if (me->book_snapshot.oldest_snapshot_seq_num() <=
// me->incremental_queue.oldest_packet_seq_num()) {
// // Our queue is not guaranteed to contain all the events that
// // follow all the snapshots so we need to get a new round of
// // snapshots.
// LOG(Spartan, Info,
// "First packet in incremental queue ({}) is more recent than oldest
// " "last processed packet in snapshot ({}). Snapshot is too old,
// will " "try getting a new one.",
// me->incremental_queue.oldest_packet_seq_num(),
// me->book_snapshot.oldest_snapshot_seq_num());
// me->book_snapshot.reset();
// return {};
// }
// Does the queue extend beyond the newest event of each snapshot? If
// if does not then we could run the risk of applying an event to a
// snapshot that already has it.
if (me->book_snapshot.newest_snapshot_seq_num() >
me->incremental_queue.newest_packet_seq_num()) {
// Accumulate a few more
LOG(Spartan, Info,
"Most recent packet in incremental queue ({}) is older than most "
"recent last processed packet in snapshot ({}). Will acumulate a "
"few more packets in incremental queue.",
me->incremental_queue.newest_packet_seq_num(),
me->book_snapshot.newest_snapshot_seq_num());
return {};
}
// // Does the queue extend beyond the newest event of each snapshot? If
// // if does not then we could run the risk of applying an event to a
// // snapshot that already has it.
// if (me->book_snapshot.newest_snapshot_seq_num() >
// me->incremental_queue.newest_packet_seq_num()) {
// // Accumulate a few more
// LOG(Spartan, Info,
// "Most recent packet in incremental queue ({}) is older than most "
// "recent last processed packet in snapshot ({}). Will acumulate a "
// "few more packets in incremental queue.",
// me->incremental_queue.newest_packet_seq_num(),
// me->book_snapshot.newest_snapshot_seq_num());
// return {};
// }
// We are ready to build our instrument snapshots. We will want
// them in order of last processed sequence number so that we can
// ensure that only messages they haven't seen will be replayed.
struct SortableSnapshot {
SecuritySnapshotPtr snapshot;
uint32_t last_processed_sn;
bool operator<(SortableSnapshot const &other) const {
return last_processed_sn < other.last_processed_sn;
}
};
std::vector<SortableSnapshot> sortable_snapshots;
sortable_snapshots.reserve(definitions_ref.size());
// // We are ready to build our instrument snapshots. We will want
// // them in order of last processed sequence number so that we can
// // ensure that only messages they haven't seen will be replayed.
// struct SortableSnapshot {
// SecuritySnapshotPtr snapshot;
// uint32_t last_processed_sn;
// bool operator<(SortableSnapshot const &other) const {
// return last_processed_sn < other.last_processed_sn;
// }
// };
// std::vector<SortableSnapshot> sortable_snapshots;
// sortable_snapshots.reserve(definitions_ref.size());
auto definition_snaps = me->definition_snapshot.move_definitions_and_reset();
auto book_snaps = me->book_snapshot.move_books_and_reset();
// auto definition_snaps =
// me->definition_snapshot.move_definitions_and_reset(); auto book_snaps =
// me->book_snapshot.move_books_and_reset();
// Index books so we can join them with the definitions
std::unordered_map<SecurityID, InstrumentBookSnapshot *> book_snaps_idx;
for (auto &bs : book_snaps)
book_snaps_idx[SecurityID{bs.book->securityID()}] = &bs;
// // Index books so we can join them with the definitions
// std::unordered_map<SecurityID, InstrumentBookSnapshot *> book_snaps_idx;
// for (auto &bs : book_snaps)
// book_snaps_idx[SecurityID{bs.book->securityID()}] = &bs;
// Now iterate over all definitions, locate the corresponding book
// and if successfull use both to build a SecuritySnapshot
// instance.
for (auto &d : definition_snaps) {
auto instrument_snapshot =
std::make_unique<SecuritySnapshot>(std::move(d));
auto this_book_snap = book_snaps_idx[instrument_snapshot->security_id()];
uint32_t last_processed_sn = 0;
if (this_book_snap) {
last_processed_sn = this_book_snap->book->lastMsgSeqNumProcessed();
auto book_snap_msg = *(this_book_snap->book);
update_book_in_snapshot(*instrument_snapshot, book_snap_msg);
for (auto &bchunk : this_book_snap->book_chunks) {
auto chunk_msg = *bchunk;
update_book_chunk_in_snapshot(*instrument_snapshot, chunk_msg);
}
instrument_snapshot->set_books_from_orders();
}
sortable_snapshots.push_back(
{std::move(instrument_snapshot), last_processed_sn});
}
std::sort(sortable_snapshots.begin(), sortable_snapshots.end());
// // Now iterate over all definitions, locate the corresponding book
// // and if successfull use both to build a SecuritySnapshot
// // instance.
// for (auto &d : definition_snaps) {
// auto instrument_snapshot =
// std::make_unique<SecuritySnapshot>(std::move(d));
// auto this_book_snap =
// book_snaps_idx[instrument_snapshot->security_id()]; uint32_t
// last_processed_sn = 0; if (this_book_snap) {
// last_processed_sn = this_book_snap->book->lastMsgSeqNumProcessed();
// auto book_snap_msg = *(this_book_snap->book);
// update_book_in_snapshot(*instrument_snapshot, book_snap_msg);
// for (auto &bchunk : this_book_snap->book_chunks) {
// auto chunk_msg = *bchunk;
// update_book_chunk_in_snapshot(*instrument_snapshot, chunk_msg);
// }
// instrument_snapshot->set_books_from_orders();
// }
// sortable_snapshots.push_back(
// {std::move(instrument_snapshot), last_processed_sn});
// }
// std::sort(sortable_snapshots.begin(), sortable_snapshots.end());
// Now we have a a set of snapshots, one for each instrument,
// ordered by the last sequence number that was considered in
// building the respective book. We can now apply our queued
// messages, ensuring that we only add an instrument when the next
// event in the queue has not yet been seen by the snapshot.
FeedHandler_RealTime rt_handler;
auto pending_packets = me->incremental_queue.get_queued_packets_and_reset();
auto current_snapshot = sortable_snapshots.begin();
uint32_t last_applied_packet = 0;
for (auto &p : pending_packets) {
auto pv = p.view();
// // Now we have a a set of snapshots, one for each instrument,
// // ordered by the last sequence number that was considered in
// // building the respective book. We can now apply our queued
// // messages, ensuring that we only add an instrument when the next
// // event in the queue has not yet been seen by the snapshot.
// FeedHandler_RealTime rt_handler;
// auto pending_packets =
// me->incremental_queue.get_queued_packets_and_reset(); auto
// current_snapshot = sortable_snapshots.begin(); uint32_t
// last_applied_packet = 0; for (auto &p : pending_packets) {
// auto pv = p.view();
// First add all the snapshots that are ready to see the next packet
for (; current_snapshot != sortable_snapshots.end(); current_snapshot++) {
auto &this_snapshot = *current_snapshot;
if (this_snapshot.last_processed_sn == 0 ||
this_snapshot.last_processed_sn + 1 == pv.seq_num()) {
LOG(Spartan, Diag,
"Added snapshot with last update time {} for security {} with "
"last processed sn {}",
this_snapshot.snapshot->last_update_time().value(),
this_snapshot.snapshot->security_id().value(),
this_snapshot.last_processed_sn);
rt_handler.add_snapshot(std::move(this_snapshot.snapshot));
} else
break;
}
// // First add all the snapshots that are ready to see the next packet
// for (; current_snapshot != sortable_snapshots.end();
// current_snapshot++) {
// auto &this_snapshot = *current_snapshot;
// if (this_snapshot.last_processed_sn == 0 ||
// this_snapshot.last_processed_sn + 1 == pv.seq_num()) {
// LOG(Spartan, Diag,
// "Added snapshot with last update time {} for security {} with
// " "last processed sn {}",
// this_snapshot.snapshot->last_update_time().value(),
// this_snapshot.snapshot->security_id().value(),
// this_snapshot.last_processed_sn);
// rt_handler.add_snapshot(std::move(this_snapshot.snapshot));
// } else
// break;
// }
// Now parse the next packet
// // Now parse the next packet
LOG(Spartan, Diag, "Appplying queued packet with sequence number {}",
pv.seq_num());
MDP3Parser::parse(pv, rt_handler);
last_applied_packet = pv.seq_num();
}
// LOG(Spartan, Diag, "Appplying queued packet with sequence number {}",
// pv.seq_num());
// MDP3Parser::parse(pv, rt_handler);
// last_applied_packet = pv.seq_num();
// }
for (; current_snapshot != sortable_snapshots.end(); current_snapshot++) {
auto &this_snapshot = *current_snapshot;
bts_assert(this_snapshot.last_processed_sn == last_applied_packet);
LOG(Spartan, Diag,
"Added snapshot with last update time {} for security {} with "
"last processed sn {}",
this_snapshot.snapshot->last_update_time().value(),
this_snapshot.snapshot->security_id().value(),
this_snapshot.last_processed_sn);
rt_handler.add_snapshot(std::move(this_snapshot.snapshot));
}
// for (; current_snapshot != sortable_snapshots.end(); current_snapshot++) {
// auto &this_snapshot = *current_snapshot;
// bts_assert(this_snapshot.last_processed_sn == last_applied_packet);
// LOG(Spartan, Diag,
// "Added snapshot with last update time {} for security {} with "
// "last processed sn {}",
// this_snapshot.snapshot->last_update_time().value(),
// this_snapshot.snapshot->security_id().value(),
// this_snapshot.last_processed_sn);
// rt_handler.add_snapshot(std::move(this_snapshot.snapshot));
// }
bts_assert(current_snapshot == sortable_snapshots.end());
// bts_assert(current_snapshot == sortable_snapshots.end());
// At this point we are caught up and all the instrument snapshots
// have been shown the incremental messages that have occurred
// since their books were recovered from the snapshot feed. We are
// ready to go
auto result = rt_handler.move_all_securities_and_reset();
reset();
return result;
}
// // At this point we are caught up and all the instrument snapshots
// // have been shown the incremental messages that have occurred
// // since their books were recovered from the snapshot feed. We are
// // ready to go
// auto result = rt_handler.move_all_securities_and_reset();
// reset();
// return result;
// }
// Instrument feed -------------------------------------------
void FeedHandler_Recovery::InstrumentStreamHandler::packet_begin(
MDP3PacketView const &p) {
me.definition_snapshot.packet_begin(p);
}
// // Instrument feed -------------------------------------------
// void FeedHandler_Recovery::InstrumentStreamHandler::packet_begin(
// MDP3PacketView const &p) {
// me.definition_snapshot.packet_begin(p);
// }
void FeedHandler_Recovery::InstrumentStreamHandler::packet_end(
MDP3PacketView const &mvp) {
me.definition_snapshot.packet_end(mvp);
}
// void FeedHandler_Recovery::InstrumentStreamHandler::packet_end(
// MDP3PacketView const &mvp) {
// me.definition_snapshot.packet_end(mvp);
// }
void FeedHandler_Recovery::InstrumentStreamHandler::operator()(
::mdp3::MDInstrumentDefinitionFuture54 &d) {
me.definition_snapshot(d);
}
// void FeedHandler_Recovery::InstrumentStreamHandler::operator()(
// ::mdp3::MDInstrumentDefinitionFuture54 &d) {
// me.definition_snapshot(d);
// }
void FeedHandler_Recovery::InstrumentStreamHandler::operator()(
::mdp3::MDInstrumentDefinitionOption55 &d) {
me.definition_snapshot(d);
}
// void FeedHandler_Recovery::InstrumentStreamHandler::operator()(
// ::mdp3::MDInstrumentDefinitionOption55 &d) {
// me.definition_snapshot(d);
// }
void FeedHandler_Recovery::InstrumentStreamHandler::operator()(
::mdp3::MDInstrumentDefinitionSpread56 &d) {
me.definition_snapshot(d);
}
// void FeedHandler_Recovery::InstrumentStreamHandler::operator()(
// ::mdp3::MDInstrumentDefinitionSpread56 &d) {
// me.definition_snapshot(d);
// }
// Snapshot feed -------------------------------------------
void FeedHandler_Recovery::SnapshotStreamHandler::packet_begin(
MDP3PacketView const &p) {
me.book_snapshot.packet_begin(p);
}
// // Snapshot feed -------------------------------------------
// void FeedHandler_Recovery::SnapshotStreamHandler::packet_begin(
// MDP3PacketView const &p) {
// me.book_snapshot.packet_begin(p);
// }
void FeedHandler_Recovery::SnapshotStreamHandler::packet_end(
MDP3PacketView const &mvp) {
me.book_snapshot.packet_end(mvp);
}
// void FeedHandler_Recovery::SnapshotStreamHandler::packet_end(
// MDP3PacketView const &mvp) {
// me.book_snapshot.packet_end(mvp);
// }
void FeedHandler_Recovery::SnapshotStreamHandler::operator()(
::mdp3::SnapshotFullRefresh52 &snap) {
me.book_snapshot(snap);
}
// void FeedHandler_Recovery::SnapshotStreamHandler::operator()(
// ::mdp3::SnapshotFullRefresh52 &snap) {
// me.book_snapshot(snap);
// }
void FeedHandler_Recovery::SnapshotStreamHandler::operator()(
::mdp3::SnapshotFullRefreshOrderBook53 &snap) {
me.book_snapshot(snap);
}
// void FeedHandler_Recovery::SnapshotStreamHandler::operator()(
// ::mdp3::SnapshotFullRefreshOrderBook53 &snap) {
// me.book_snapshot(snap);
// }
// Incremental feed -------------------------------------------
void FeedHandler_Recovery::IncrementalStreamHandler::packet_begin(
MDP3PacketView const &p) {
me.incremental_queue.packet_begin(p);
}
void FeedHandler_Recovery::IncrementalStreamHandler::packet_end(
MDP3PacketView const &mvp) {
me.incremental_queue.packet_end(mvp);
}
void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
::mdp3::MDIncrementalRefreshBook46 &m) {
me.incremental_queue(m);
}
void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
::mdp3::MDIncrementalRefreshDailyStatistics49 &m) {
me.incremental_queue(m);
}
void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
::mdp3::MDIncrementalRefreshLimitsBanding50 &m) {
me.incremental_queue(m);
}
void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
::mdp3::MDIncrementalRefreshOrderBook47 &m) {
me.incremental_queue(m);
}
void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
::mdp3::MDIncrementalRefreshSessionStatistics51 &m) {
me.incremental_queue(m);
}
void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
::mdp3::MDIncrementalRefreshTradeSummary48 &m) {
me.incremental_queue(m);
}
void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
::mdp3::MDIncrementalRefreshVolume37 &m) {
me.incremental_queue(m);
}
void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
::mdp3::MDInstrumentDefinitionFuture54 &m) {
me.incremental_queue(m);
}
void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
::mdp3::MDInstrumentDefinitionOption55 &m) {
me.incremental_queue(m);
}
void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
::mdp3::MDInstrumentDefinitionSpread56 &m) {
me.incremental_queue(m);
}
void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
::mdp3::QuoteRequest39 &m) {
me.incremental_queue(m);
}
void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
::mdp3::SecurityStatus30 &m) {
me.incremental_queue(m);
}
void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
::mdp3::ChannelReset4 &m) {
me.incremental_queue(m);
}
// // Incremental feed -------------------------------------------
// void FeedHandler_Recovery::IncrementalStreamHandler::packet_begin(
// MDP3PacketView const &p) {
// me.incremental_queue.packet_begin(p);
// }
// void FeedHandler_Recovery::IncrementalStreamHandler::packet_end(
// MDP3PacketView const &mvp) {
// me.incremental_queue.packet_end(mvp);
// }
// void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
// ::mdp3::MDIncrementalRefreshBook46 &m) {
// me.incremental_queue(m);
// }
// void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
// ::mdp3::MDIncrementalRefreshDailyStatistics49 &m) {
// me.incremental_queue(m);
// }
// void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
// ::mdp3::MDIncrementalRefreshLimitsBanding50 &m) {
// me.incremental_queue(m);
// }
// void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
// ::mdp3::MDIncrementalRefreshOrderBook47 &m) {
// me.incremental_queue(m);
// }
// void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
// ::mdp3::MDIncrementalRefreshSessionStatistics51 &m) {
// me.incremental_queue(m);
// }
// void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
// ::mdp3::MDIncrementalRefreshTradeSummary48 &m) {
// me.incremental_queue(m);
// }
// void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
// ::mdp3::MDIncrementalRefreshVolume37 &m) {
// me.incremental_queue(m);
// }
// void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
// ::mdp3::MDInstrumentDefinitionFuture54 &m) {
// me.incremental_queue(m);
// }
// void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
// ::mdp3::MDInstrumentDefinitionOption55 &m) {
// me.incremental_queue(m);
// }
// void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
// ::mdp3::MDInstrumentDefinitionSpread56 &m) {
// me.incremental_queue(m);
// }
// void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
// ::mdp3::QuoteRequest39 &m) {
// me.incremental_queue(m);
// }
// void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
// ::mdp3::SecurityStatus30 &m) {
// me.incremental_queue(m);
// }
// void FeedHandler_Recovery::IncrementalStreamHandler::operator()(
// ::mdp3::ChannelReset4 &m) {
// me.incremental_queue(m);
// }
void FeedHandler_Recovery::update_book_in_snapshot(
SecuritySnapshot &snap, ::mdp3::SnapshotFullRefresh52 &r) {
snap.set_high_limit_price(
Price{r.highLimitPrice().mantissa(), r.highLimitPrice().exponent()});
snap.set_low_limit_price(
Price{r.lowLimitPrice().mantissa(), r.lowLimitPrice().exponent()});
snap.set_last_msg_processed_sn(r.lastMsgSeqNumProcessed());
r.noMDEntries().forEach([&snap](auto &md_entry) {
switch (md_entry.mDEntryType()) {
case ::mdp3::MDEntryType::Bid:
case ::mdp3::MDEntryType::Offer:
snap.update_book_level(
convert_side(md_entry.mDEntryType()), md_entry.mDPriceLevel(),
BookLevel{
Price{
md_entry.mDEntryPx().mantissa(),
md_entry.mDEntryPx().exponent()},
Quantity{md_entry.mDEntrySize()}, md_entry.numberOfOrders()});
break;
case ::mdp3::MDEntryType::ImpliedBid:
case ::mdp3::MDEntryType::ImpliedOffer:
snap.update_implied_book_level(
convert_side(md_entry.mDEntryType()), md_entry.mDPriceLevel(),
BookLevel{
Price{
md_entry.mDEntryPx().mantissa(),
md_entry.mDEntryPx().exponent()},
Quantity{md_entry.mDEntrySize()}, md_entry.numberOfOrders()});
break;
case ::mdp3::MDEntryType::Trade:
break;
case ::mdp3::MDEntryType::OpenPrice:
snap.set_open_price(Price{
md_entry.mDEntryPx().mantissa(), md_entry.mDEntryPx().exponent()});
break;
case ::mdp3::MDEntryType::SettlementPrice:
snap.set_settlement_price(Price{
md_entry.mDEntryPx().mantissa(), md_entry.mDEntryPx().exponent()});
break;
case ::mdp3::MDEntryType::TradingSessionHighPrice:
snap.set_high_limit_price(Price{
md_entry.mDEntryPx().mantissa(), md_entry.mDEntryPx().exponent()});
break;
case ::mdp3::MDEntryType::TradingSessionLowPrice:
snap.set_low_limit_price(Price{
md_entry.mDEntryPx().mantissa(), md_entry.mDEntryPx().exponent()});
break;
case ::mdp3::MDEntryType::ClearedVolume:
snap.set_cleared_volume(Quantity{md_entry.mDEntrySize()});
break;
case ::mdp3::MDEntryType::OpenInterest:
snap.set_open_interest(Quantity{md_entry.mDEntrySize()});
break;
case ::mdp3::MDEntryType::BookReset:
snap.reset_books();
break;
case ::mdp3::MDEntryType::SessionHighBid:
snap.set_high_bid(Price{
md_entry.mDEntryPx().mantissa(), md_entry.mDEntryPx().exponent()});
break;
case ::mdp3::MDEntryType::SessionLowOffer:
snap.set_low_offer(Price{
md_entry.mDEntryPx().mantissa(), md_entry.mDEntryPx().exponent()});
break;
case ::mdp3::MDEntryType::FixingPrice:
snap.set_fixing_price(Price{
md_entry.mDEntryPx().mantissa(), md_entry.mDEntryPx().exponent()});
break;
case ::mdp3::MDEntryType::ElectronicVolume:
snap.set_electronic_volume(Quantity{md_entry.mDEntrySize()});
break;
case ::mdp3::MDEntryType::ThresholdLimitsandPriceBandVariation:
break;
default:
bts_assert(false);
}
});
}
// void FeedHandler_Recovery::update_book_in_snapshot(
// SecuritySnapshot &snap, ::mdp3::SnapshotFullRefresh52 &r) {
// snap.set_high_limit_price(
// Price{r.highLimitPrice().mantissa(), r.highLimitPrice().exponent()});
// snap.set_low_limit_price(
// Price{r.lowLimitPrice().mantissa(), r.lowLimitPrice().exponent()});
// snap.set_last_msg_processed_sn(r.lastMsgSeqNumProcessed());
// r.noMDEntries().forEach([&snap](auto &md_entry) {
// switch (md_entry.mDEntryType()) {
// case ::mdp3::MDEntryType::Bid:
// case ::mdp3::MDEntryType::Offer:
// snap.update_book_level(
// convert_side(md_entry.mDEntryType()), md_entry.mDPriceLevel(),
// BookLevel{
// Price{
// md_entry.mDEntryPx().mantissa(),
// md_entry.mDEntryPx().exponent()},
// Quantity{md_entry.mDEntrySize()},
// md_entry.numberOfOrders()});
// break;
// case ::mdp3::MDEntryType::ImpliedBid:
// case ::mdp3::MDEntryType::ImpliedOffer:
// snap.update_implied_book_level(
// convert_side(md_entry.mDEntryType()), md_entry.mDPriceLevel(),
// BookLevel{
// Price{
// md_entry.mDEntryPx().mantissa(),
// md_entry.mDEntryPx().exponent()},
// Quantity{md_entry.mDEntrySize()},
// md_entry.numberOfOrders()});
// break;
// case ::mdp3::MDEntryType::Trade:
// break;
// case ::mdp3::MDEntryType::OpenPrice:
// snap.set_open_price(Price{
// md_entry.mDEntryPx().mantissa(),
// md_entry.mDEntryPx().exponent()});
// break;
// case ::mdp3::MDEntryType::SettlementPrice:
// snap.set_settlement_price(Price{
// md_entry.mDEntryPx().mantissa(),
// md_entry.mDEntryPx().exponent()});
// break;
// case ::mdp3::MDEntryType::TradingSessionHighPrice:
// snap.set_high_limit_price(Price{
// md_entry.mDEntryPx().mantissa(),
// md_entry.mDEntryPx().exponent()});
// break;
// case ::mdp3::MDEntryType::TradingSessionLowPrice:
// snap.set_low_limit_price(Price{
// md_entry.mDEntryPx().mantissa(),
// md_entry.mDEntryPx().exponent()});
// break;
// case ::mdp3::MDEntryType::ClearedVolume:
// snap.set_cleared_volume(Quantity{md_entry.mDEntrySize()});
// break;
// case ::mdp3::MDEntryType::OpenInterest:
// snap.set_open_interest(Quantity{md_entry.mDEntrySize()});
// break;
// case ::mdp3::MDEntryType::BookReset:
// snap.reset_books();
// break;
// case ::mdp3::MDEntryType::SessionHighBid:
// snap.set_high_bid(Price{
// md_entry.mDEntryPx().mantissa(),
// md_entry.mDEntryPx().exponent()});
// break;
// case ::mdp3::MDEntryType::SessionLowOffer:
// snap.set_low_offer(Price{
// md_entry.mDEntryPx().mantissa(),
// md_entry.mDEntryPx().exponent()});
// break;
// case ::mdp3::MDEntryType::FixingPrice:
// snap.set_fixing_price(Price{
// md_entry.mDEntryPx().mantissa(),
// md_entry.mDEntryPx().exponent()});
// break;
// case ::mdp3::MDEntryType::ElectronicVolume:
// snap.set_electronic_volume(Quantity{md_entry.mDEntrySize()});
// break;
// case ::mdp3::MDEntryType::ThresholdLimitsandPriceBandVariation:
// break;
// default:
// bts_assert(false);
// }
// });
// }
void FeedHandler_Recovery::update_book_chunk_in_snapshot(
SecuritySnapshot &snap, ::mdp3::SnapshotFullRefreshOrderBook53 &fr) {
fr.noMDEntries().forEach([&snap](auto &md_entry) {
MDP3Order order;
order.key = OrderKey{md_entry.orderID()};
order.security = snap.security_id();
order.side = convert_side(md_entry.mDEntryType());
order.priority = MDP3OrderPriority{md_entry.mDOrderPriority()};
order.price = Price{
md_entry.mDEntryPx().mantissa(), md_entry.mDEntryPx().exponent()};
order.quantity = Quantity{md_entry.mDDisplayQty()};
snap.insert_order(order);
});
}
// void FeedHandler_Recovery::update_book_chunk_in_snapshot(
// SecuritySnapshot &snap, ::mdp3::SnapshotFullRefreshOrderBook53 &fr) {
// fr.noMDEntries().forEach([&snap](auto &md_entry) {
// MDP3Order order;
// order.key = OrderKey{md_entry.orderID()};
// order.security = snap.security_id();
// order.side = convert_side(md_entry.mDEntryType());
// order.priority = MDP3OrderPriority{md_entry.mDOrderPriority()};
// order.price = Price{
// md_entry.mDEntryPx().mantissa(), md_entry.mDEntryPx().exponent()};
// order.quantity = Quantity{md_entry.mDDisplayQty()};
// snap.insert_order(order);
// });
// }
} // namespace bts::spartan::mdp3
// } // namespace bts::spartan::mdp3
@@ -1,114 +1,114 @@
#pragma once
// #pragma once
#include "back_testing/common/mdp3_common.h"
#include "domain/SecuritySnapshotPtr.h"
// #include "back_testing/common/mdp3_common.h"
// #include "domain/SecuritySnapshotPtr.h"
#include <optional>
#include <vector>
// #include <optional>
// #include <vector>
namespace mdp3 {
class ChannelReset4;
class MDIncrementalRefreshBook46;
class MDIncrementalRefreshDailyStatistics49;
class MDIncrementalRefreshLimitsBanding50;
class MDIncrementalRefreshOrderBook47;
class MDIncrementalRefreshSessionStatistics51;
class MDIncrementalRefreshTradeSummary48;
class MDIncrementalRefreshVolume37;
class MDInstrumentDefinitionFuture54;
class MDInstrumentDefinitionOption55;
class MDInstrumentDefinitionSpread56;
class QuoteRequest39;
class SecurityStatus30;
class SnapshotFullRefresh52;
class SnapshotFullRefreshOrderBook53;
} // namespace mdp3
// namespace mdp3 {
// class ChannelReset4;
// class MDIncrementalRefreshBook46;
// class MDIncrementalRefreshDailyStatistics49;
// class MDIncrementalRefreshLimitsBanding50;
// class MDIncrementalRefreshOrderBook47;
// class MDIncrementalRefreshSessionStatistics51;
// class MDIncrementalRefreshTradeSummary48;
// class MDIncrementalRefreshVolume37;
// class MDInstrumentDefinitionFuture54;
// class MDInstrumentDefinitionOption55;
// class MDInstrumentDefinitionSpread56;
// class QuoteRequest39;
// class SecurityStatus30;
// class SnapshotFullRefresh52;
// class SnapshotFullRefreshOrderBook53;
// } // namespace mdp3
namespace bts::spartan {
class IRealTimeFeedObserver;
class MDP3PacketView;
}
// namespace bts::spartan {
// class IRealTimeFeedObserver;
// class MDP3PacketView;
// }
namespace bts::spartan::mdp3 {
class IRecoveryObserver;
// namespace bts::spartan::mdp3 {
// class IRecoveryObserver;
// This class can be used to boostrap a set of intrument snapshots
// from the recovery streams. This is necessary both in case of
// multicast loss and when booting the system. Once a snapshot is
// built this class will reset its internal state and begin to recover
// another snapshot.
class FeedHandler_Recovery {
private:
struct PImpl;
std::unique_ptr<PImpl> me;
void update_book_in_snapshot(
SecuritySnapshot &, ::mdp3::SnapshotFullRefresh52 &);
void update_book_chunk_in_snapshot(
SecuritySnapshot &, ::mdp3::SnapshotFullRefreshOrderBook53 &);
// // This class can be used to boostrap a set of intrument snapshots
// // from the recovery streams. This is necessary both in case of
// // multicast loss and when booting the system. Once a snapshot is
// // built this class will reset its internal state and begin to recover
// // another snapshot.
// class FeedHandler_Recovery {
// private:
// struct PImpl;
// std::unique_ptr<PImpl> me;
// void update_book_in_snapshot(
// SecuritySnapshot &, ::mdp3::SnapshotFullRefresh52 &);
// void update_book_chunk_in_snapshot(
// SecuritySnapshot &, ::mdp3::SnapshotFullRefreshOrderBook53 &);
public:
FeedHandler_Recovery();
~FeedHandler_Recovery();
using MaybeSnapshot = std::optional<std::vector<SecuritySnapshotPtr>>;
void reset();
MaybeSnapshot try_build_snapshot_and_reset();
// public:
// FeedHandler_Recovery();
// ~FeedHandler_Recovery();
// using MaybeSnapshot = std::optional<std::vector<SecuritySnapshotPtr>>;
// void reset();
// MaybeSnapshot try_build_snapshot_and_reset();
class InstrumentStreamHandler {
public:
void packet_begin(MDP3PacketView const &);
void packet_end(MDP3PacketView const &);
void operator()(::mdp3::MDInstrumentDefinitionFuture54 &);
void operator()(::mdp3::MDInstrumentDefinitionOption55 &);
void operator()(::mdp3::MDInstrumentDefinitionSpread56 &);
// class InstrumentStreamHandler {
// public:
// void packet_begin(MDP3PacketView const &);
// void packet_end(MDP3PacketView const &);
// void operator()(::mdp3::MDInstrumentDefinitionFuture54 &);
// void operator()(::mdp3::MDInstrumentDefinitionOption55 &);
// void operator()(::mdp3::MDInstrumentDefinitionSpread56 &);
private:
friend class FeedHandler_Recovery;
InstrumentStreamHandler(PImpl &me) : me(me) {}
PImpl &me;
};
InstrumentStreamHandler &instrument_stream_handler;
// private:
// friend class FeedHandler_Recovery;
// InstrumentStreamHandler(PImpl &me) : me(me) {}
// PImpl &me;
// };
// InstrumentStreamHandler &instrument_stream_handler;
class SnapshotStreamHandler {
public:
void packet_begin(MDP3PacketView const &);
void packet_end(MDP3PacketView const &);
void operator()(::mdp3::SnapshotFullRefresh52 &);
void operator()(::mdp3::SnapshotFullRefreshOrderBook53 &);
// class SnapshotStreamHandler {
// public:
// void packet_begin(MDP3PacketView const &);
// void packet_end(MDP3PacketView const &);
// void operator()(::mdp3::SnapshotFullRefresh52 &);
// void operator()(::mdp3::SnapshotFullRefreshOrderBook53 &);
private:
friend class FeedHandler_Recovery;
SnapshotStreamHandler(PImpl &me) : me(me) {}
PImpl &me;
};
SnapshotStreamHandler &snapshot_stream_handler;
// private:
// friend class FeedHandler_Recovery;
// SnapshotStreamHandler(PImpl &me) : me(me) {}
// PImpl &me;
// };
// SnapshotStreamHandler &snapshot_stream_handler;
// No loss on the incremental stream should be observed by this
// class. Packet loss for the incremental stream should be managed
// by the caller.
class IncrementalStreamHandler {
public:
void packet_begin(MDP3PacketView const &);
void packet_end(MDP3PacketView const &);
void operator()(::mdp3::MDIncrementalRefreshBook46 &);
void operator()(::mdp3::MDIncrementalRefreshDailyStatistics49 &);
void operator()(::mdp3::MDIncrementalRefreshLimitsBanding50 &);
void operator()(::mdp3::MDIncrementalRefreshOrderBook47 &);
void operator()(::mdp3::MDIncrementalRefreshSessionStatistics51 &);
void operator()(::mdp3::MDIncrementalRefreshTradeSummary48 &);
void operator()(::mdp3::MDIncrementalRefreshVolume37 &);
void operator()(::mdp3::MDInstrumentDefinitionFuture54 &);
void operator()(::mdp3::MDInstrumentDefinitionOption55 &);
void operator()(::mdp3::MDInstrumentDefinitionSpread56 &);
void operator()(::mdp3::QuoteRequest39 &);
void operator()(::mdp3::SecurityStatus30 &);
void operator()(::mdp3::ChannelReset4 &);
// // No loss on the incremental stream should be observed by this
// // class. Packet loss for the incremental stream should be managed
// // by the caller.
// class IncrementalStreamHandler {
// public:
// void packet_begin(MDP3PacketView const &);
// void packet_end(MDP3PacketView const &);
// void operator()(::mdp3::MDIncrementalRefreshBook46 &);
// void operator()(::mdp3::MDIncrementalRefreshDailyStatistics49 &);
// void operator()(::mdp3::MDIncrementalRefreshLimitsBanding50 &);
// void operator()(::mdp3::MDIncrementalRefreshOrderBook47 &);
// void operator()(::mdp3::MDIncrementalRefreshSessionStatistics51 &);
// void operator()(::mdp3::MDIncrementalRefreshTradeSummary48 &);
// void operator()(::mdp3::MDIncrementalRefreshVolume37 &);
// void operator()(::mdp3::MDInstrumentDefinitionFuture54 &);
// void operator()(::mdp3::MDInstrumentDefinitionOption55 &);
// void operator()(::mdp3::MDInstrumentDefinitionSpread56 &);
// void operator()(::mdp3::QuoteRequest39 &);
// void operator()(::mdp3::SecurityStatus30 &);
// void operator()(::mdp3::ChannelReset4 &);
private:
friend class FeedHandler_Recovery;
IncrementalStreamHandler(PImpl &me) : me(me) {}
PImpl &me;
};
IncrementalStreamHandler &incremental_stream_handler;
};
// private:
// friend class FeedHandler_Recovery;
// IncrementalStreamHandler(PImpl &me) : me(me) {}
// PImpl &me;
// };
// IncrementalStreamHandler &incremental_stream_handler;
// };
} // namespace bts::spartan::mdp3
// } // namespace bts::spartan::mdp3
@@ -209,53 +209,53 @@ TEST_CASE("spartan_md", "[spartan_md] [spartan_slow]") {
REQUIRE(q.is_consistent());
}
SECTION("can_build_snapshot") {
FeedHandler_Recovery recovery;
AB_Arbitrageur ab;
FeedHandler_Recovery::MaybeSnapshot maybe_snapshot;
reader.on_packet() = [&](auto const &info, auto const &payload) {
if ((info.dst_ip == feed_map.incremental[0].ip &&
info.dst_port == feed_map.incremental[0].port)) {
buffers[0].i = MDP3Packet{payload};
} else if ((info.dst_ip == feed_map.incremental[1].ip &&
info.dst_port == feed_map.incremental[1].port)) {
buffers[1].i = MDP3Packet{payload};
} else if ((info.dst_ip == feed_map.instrument.ip &&
info.dst_port == feed_map.instrument.port)) {
MDP3Parser::parse(
MDP3PacketView{payload}, recovery.instrument_stream_handler);
maybe_snapshot = recovery.try_build_snapshot_and_reset();
return !maybe_snapshot;
} else if ((info.dst_ip == feed_map.snapshot.ip &&
info.dst_port == feed_map.snapshot.port)) {
MDP3Parser::parse(
MDP3PacketView{payload}, recovery.snapshot_stream_handler);
maybe_snapshot = recovery.try_build_snapshot_and_reset();
return !maybe_snapshot;
} else
return true;
// SECTION("can_build_snapshot") {
// FeedHandler_Recovery recovery;
// AB_Arbitrageur ab;
// FeedHandler_Recovery::MaybeSnapshot maybe_snapshot;
// reader.on_packet() = [&](auto const &info, auto const &payload) {
// if ((info.dst_ip == feed_map.incremental[0].ip &&
// info.dst_port == feed_map.incremental[0].port)) {
// buffers[0].i = MDP3Packet{payload};
// } else if ((info.dst_ip == feed_map.incremental[1].ip &&
// info.dst_port == feed_map.incremental[1].port)) {
// buffers[1].i = MDP3Packet{payload};
// } else if ((info.dst_ip == feed_map.instrument.ip &&
// info.dst_port == feed_map.instrument.port)) {
// MDP3Parser::parse(
// MDP3PacketView{payload}, recovery.instrument_stream_handler);
// maybe_snapshot = recovery.try_build_snapshot_and_reset();
// return !maybe_snapshot;
// } else if ((info.dst_ip == feed_map.snapshot.ip &&
// info.dst_port == feed_map.snapshot.port)) {
// MDP3Parser::parse(
// MDP3PacketView{payload}, recovery.snapshot_stream_handler);
// maybe_snapshot = recovery.try_build_snapshot_and_reset();
// return !maybe_snapshot;
// } else
// return true;
auto action = ab(buffers[0].i.view(), buffers[1].i.view());
switch (action.action) {
case AB_Arbitrageur::APPLY:
MDP3Parser::parse(
action.packet, recovery.incremental_stream_handler);
break;
case AB_Arbitrageur::IGNORE:
break;
case AB_Arbitrageur::RECOVER:
REQUIRE(false);
break;
}
maybe_snapshot = recovery.try_build_snapshot_and_reset();
return !maybe_snapshot;
};
// auto action = ab(buffers[0].i.view(), buffers[1].i.view());
// switch (action.action) {
// case AB_Arbitrageur::APPLY:
// MDP3Parser::parse(
// action.packet, recovery.incremental_stream_handler);
// break;
// case AB_Arbitrageur::IGNORE:
// break;
// case AB_Arbitrageur::RECOVER:
// REQUIRE(false);
// break;
// }
// maybe_snapshot = recovery.try_build_snapshot_and_reset();
// return !maybe_snapshot;
// };
while (reader.read_next())
;
REQUIRE(maybe_snapshot);
REQUIRE(maybe_snapshot.value().size());
}
// while (reader.read_next())
// ;
// REQUIRE(maybe_snapshot);
// REQUIRE(maybe_snapshot.value().size());
// }
}
} // namespace bts::spartan::mdp3::tests
+1 -1
View File
@@ -1 +1 @@
set(sources ../../externals/linux/include/google/protobuf/descriptor.proto;../../externals/linux/include/google/protobuf/timestamp.proto;../lib/api/analytics/ExpirationDriver.proto;../lib/api/analytics/TimeWeightedInterpolatedDriver.proto;../lib/api/apicore.proto;../lib/api/apigateway.proto;../lib/api/apioptions.proto;../lib/api/domain/Currency.proto;../lib/api/domain/SecurityCriteria.proto;../lib/api/domain/SecurityCriteriaClause.proto;../lib/api/domain/SecurityExpiration.proto;../lib/api/domain/SecurityMetadata.proto;../lib/api/domain/SecurityMetadataCollection.proto;../lib/api/domain/SecurityMetadataItem.proto;../lib/api/domain/SecurityType.proto;../lib/api/domain/TickDisplaySettings.proto;../lib/api/domain/TickFactors.proto;../lib/api/domain/Venue.proto;../lib/api/io/URL.proto;../lib/api/md/MarketDataSubscriptionParams.proto;../lib/api/md/binance/BinanceDepthStreamParams.proto;../lib/api/md/binance/BinanceMarketDataSubscriptionParams.proto;../lib/api/md/deribit/DeribitMarketDataSubscriptionParams.proto;../lib/api/md/ftx/FTXDepthStreamParams.proto;../lib/api/md/ftx/FTXMarketDataSubscriptionParams.proto;../lib/api/md/glbx/GlbxMarketDataSubscriptionParams.proto;../lib/api/md/huobi/HuobiMarketDataSubscriptionParams.proto;../lib/api/services/AdminService.proto;../lib/api/services/AlgoDefinitionService.proto;../lib/api/services/AlgoService.proto;../lib/api/services/AnalyticsService.proto;../lib/api/services/ApiUnitTestService.proto;../lib/api/services/AuthService.proto;../lib/api/services/BasePositionService.proto;../lib/api/services/ErrorReportService.proto;../lib/api/services/HelloService.proto;../lib/api/services/MBOService.proto;../lib/api/services/MarginService.proto;../lib/api/services/MarketDataAuxiliaryService.proto;../lib/api/services/MarketDataRelay.proto;../lib/api/services/MarketDataService.proto;../lib/api/services/MoneyFileService.proto;../lib/api/services/OrderService.proto;../lib/api/services/OutOfProcessURLListener.proto;../lib/api/services/PersistenceService.proto;../lib/api/services/PositionService.proto;../lib/api/services/ShellDiagnosticService.proto;../lib/api/services/ShellLatencyService.proto;../lib/api/services/SyntheticSecurityService.proto;../lib/domain_model/Security.proto;../lib/md/protos/co2.proto;../lib/sparkproto/SparkProtos.proto;/home/taha/spark/.venv/bin/python;/home/taha/spark/src/lib/api/service_compiler/templates/fs/fable.fs;/home/taha/spark/src/web/api/package-lock.json;/home/taha/spark/src/web/api/tsconfig.last.g.json;/home/taha/spark/src/web/ui/src/ui.fsproj;/home/taha/spark/src/web/ui/webpack.config.js;/home/taha/spark/tools/py/build_web.py;/home/taha/spark/tools/venv_exec.sh;api/src/DynamicService.ts;api/src/ServiceContext.ts;api/src/bts_assert.ts;ui/src/Access.fs;ui/src/Accounts/ClipLimits.fs;ui/src/Accounts/ProductLimits.fs;ui/src/Accounts/SecurityLimits.fs;ui/src/Accounts/State.fs;ui/src/Accounts/Types.fs;ui/src/Accounts/View.fs;ui/src/App.fs;ui/src/Cmd.fs;ui/src/Controls/Button.fs;ui/src/Controls/DataGrid.fs;ui/src/Controls/Fields.fs;ui/src/Controls/Modal.fs;ui/src/Controls/ReactGrid.fs;ui/src/Controls/Table.fs;ui/src/Controls/nbsp.fs;ui/src/Global.fs;ui/src/Imports.fs;ui/src/Lens.fs;ui/src/Login/Login.fs;ui/src/Nav.fs;ui/src/State.fs;ui/src/Types.fs;ui/src/Users/State.fs;ui/src/Users/Types.fs;ui/src/Users/View.fs;ui/src/Util/EnumUtils.fs;ui/src/Util/JSMap.fs;ui/src/Util/StreamUtils.fs;ui/src/obj/Debug/net6.0/ui.AssemblyInfo.fs;ui/src/obj/Debug/netstandard2.0/ui.AssemblyInfo.fs)
set(sources ../../externals/linux/include/google/protobuf/descriptor.proto;../../externals/linux/include/google/protobuf/timestamp.proto;../lib/api/analytics/ExpirationDriver.proto;../lib/api/analytics/TimeWeightedInterpolatedDriver.proto;../lib/api/apicore.proto;../lib/api/apigateway.proto;../lib/api/apioptions.proto;../lib/api/domain/Currency.proto;../lib/api/domain/SecurityCriteria.proto;../lib/api/domain/SecurityCriteriaClause.proto;../lib/api/domain/SecurityExpiration.proto;../lib/api/domain/SecurityMetadata.proto;../lib/api/domain/SecurityMetadataCollection.proto;../lib/api/domain/SecurityMetadataItem.proto;../lib/api/domain/SecurityType.proto;../lib/api/domain/TickDisplaySettings.proto;../lib/api/domain/TickFactors.proto;../lib/api/domain/Venue.proto;../lib/api/io/URL.proto;../lib/api/md/MarketDataSubscriptionParams.proto;../lib/api/md/binance/BinanceDepthStreamParams.proto;../lib/api/md/binance/BinanceMarketDataSubscriptionParams.proto;../lib/api/md/deribit/DeribitMarketDataSubscriptionParams.proto;../lib/api/md/ftx/FTXDepthStreamParams.proto;../lib/api/md/ftx/FTXMarketDataSubscriptionParams.proto;../lib/api/md/glbx/GlbxMarketDataSubscriptionParams.proto;../lib/api/md/huobi/HuobiMarketDataSubscriptionParams.proto;../lib/api/services/AdminService.proto;../lib/api/services/AlgoDefinitionService.proto;../lib/api/services/AlgoService.proto;../lib/api/services/AnalyticsService.proto;../lib/api/services/ApiUnitTestService.proto;../lib/api/services/AuthService.proto;../lib/api/services/BasePositionService.proto;../lib/api/services/ErrorReportService.proto;../lib/api/services/HelloService.proto;../lib/api/services/MBOService.proto;../lib/api/services/MarginService.proto;../lib/api/services/MarketDataAuxiliaryService.proto;../lib/api/services/MarketDataRelay.proto;../lib/api/services/MarketDataService.proto;../lib/api/services/MoneyFileService.proto;../lib/api/services/OrderService.proto;../lib/api/services/OutOfProcessURLListener.proto;../lib/api/services/PersistenceService.proto;../lib/api/services/PositionService.proto;../lib/api/services/ShellDiagnosticService.proto;../lib/api/services/ShellLatencyService.proto;../lib/api/services/SyntheticSecurityService.proto;../lib/domain_model/Security.proto;../lib/md/protos/co2.proto;../lib/sparkproto/SparkProtos.proto;/home/taha/spark/.venv/bin/python;/home/taha/spark/src/lib/api/service_compiler/templates/fs/fable.fs;/home/taha/spark/src/web/api/package-lock.json;/home/taha/spark/src/web/api/tsconfig.release-gcc.g.json;/home/taha/spark/src/web/ui/src/ui.fsproj;/home/taha/spark/src/web/ui/webpack.config.js;/home/taha/spark/tools/py/build_web.py;/home/taha/spark/tools/venv_exec.sh;api/src/DynamicService.ts;api/src/ServiceContext.ts;api/src/bts_assert.ts;ui/src/Access.fs;ui/src/Accounts/ClipLimits.fs;ui/src/Accounts/ProductLimits.fs;ui/src/Accounts/SecurityLimits.fs;ui/src/Accounts/State.fs;ui/src/Accounts/Types.fs;ui/src/Accounts/View.fs;ui/src/App.fs;ui/src/Cmd.fs;ui/src/Controls/Button.fs;ui/src/Controls/DataGrid.fs;ui/src/Controls/Fields.fs;ui/src/Controls/Modal.fs;ui/src/Controls/ReactGrid.fs;ui/src/Controls/Table.fs;ui/src/Controls/nbsp.fs;ui/src/Global.fs;ui/src/Imports.fs;ui/src/Lens.fs;ui/src/Login/Login.fs;ui/src/Nav.fs;ui/src/State.fs;ui/src/Types.fs;ui/src/Users/State.fs;ui/src/Users/Types.fs;ui/src/Users/View.fs;ui/src/Util/EnumUtils.fs;ui/src/Util/JSMap.fs;ui/src/Util/StreamUtils.fs;ui/src/obj/Debug/net6.0/ui.AssemblyInfo.fs;ui/src/obj/Debug/netstandard2.0/ui.AssemblyInfo.fs)