From 36e4f62a53de4da7b05d4b8cb38e537a2a5adbed Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Mon, 11 Feb 2019 12:38:00 -0500 Subject: [PATCH 01/72] moved externals pointer forward to capture onixs ice addition --- externals | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals b/externals index c0941c565..67323401a 160000 --- a/externals +++ b/externals @@ -1 +1 @@ -Subproject commit c0941c5650a2a136cb036960d009fb8a16fb1165 +Subproject commit 67323401ad4287eaa70b7aca6b4cf016ed8db4f3 From b2e275124f9f3daf8bb5a3882a710a42d9b4c00e Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Mon, 11 Feb 2019 13:35:14 -0500 Subject: [PATCH 02/72] update externals with onixs ice docs --- externals | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals b/externals index 67323401a..430a9c6b5 160000 --- a/externals +++ b/externals @@ -1 +1 @@ -Subproject commit 67323401ad4287eaa70b7aca6b4cf016ed8db4f3 +Subproject commit 430a9c6b5cb063710f961ef9878b6eb3cd4602d9 From 4c798f6db4c6205fd460548d36fcd3ff78e5d1a5 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Mon, 11 Feb 2019 16:14:41 -0500 Subject: [PATCH 03/72] initial push --- .../ice/ConnectivityConfiguration.APITest.xml | 659 +++++++++++++++++ .../ConnectivityConfiguration.PerfTest.xml | 364 ++++++++++ .../ConnectivityConfiguration.Production.xml | 677 ++++++++++++++++++ src/lib/md/ice/ICEUtils.cpp | 169 +++++ src/lib/md/ice/ICEUtils.h | 103 +++ .../md/platforms/ice_onixs/ICEListener.cpp | 266 +++++++ .../md/platforms/ice_onixs/ICEListener.h | 545 ++++++++++++++ .../platforms/ice_onixs/ICEListenerHelpers.h | 49 ++ .../sparkd/md/platforms/ice_onixs/ICEMain.cpp | 368 ++++++++++ .../sparkd/md/platforms/ice_onixs/ICEMain.h | 48 ++ .../md/platforms/ice_onixs/ICESecurityIndex.h | 19 + .../sparkd/md/platforms/ice_onixs/onixs.h | 7 + .../platforms/ice_onixs/tests/ice_tests.cpp | 210 ++++++ 13 files changed, 3484 insertions(+) create mode 100644 src/lib/md/ice/ConnectivityConfiguration.APITest.xml create mode 100644 src/lib/md/ice/ConnectivityConfiguration.PerfTest.xml create mode 100644 src/lib/md/ice/ConnectivityConfiguration.Production.xml create mode 100644 src/lib/md/ice/ICEUtils.cpp create mode 100644 src/lib/md/ice/ICEUtils.h create mode 100644 src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp create mode 100644 src/server/sparkd/md/platforms/ice_onixs/ICEListener.h create mode 100644 src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h create mode 100644 src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp create mode 100644 src/server/sparkd/md/platforms/ice_onixs/ICEMain.h create mode 100644 src/server/sparkd/md/platforms/ice_onixs/ICESecurityIndex.h create mode 100644 src/server/sparkd/md/platforms/ice_onixs/onixs.h create mode 100644 src/server/sparkd/md/platforms/ice_onixs/tests/ice_tests.cpp diff --git a/src/lib/md/ice/ConnectivityConfiguration.APITest.xml b/src/lib/md/ice/ConnectivityConfiguration.APITest.xml new file mode 100644 index 000000000..4cb6546b7 --- /dev/null +++ b/src/lib/md/ice/ConnectivityConfiguration.APITest.xml @@ -0,0 +1,659 @@ + + + + + + + + 63.247.113.163 + 3000 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 63.247.113.77 + 3000 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 63.247.113.229 + 3000 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 16 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Financial Gas + Financial Power + Oil + IPE Natural Gas Futures + IPE Gas Oil Futures + IPE Brent Futures + IPE UK Electricity Futures Peak + IPE UK Electricity Futures Base + ICE WTI Crude Futures + gC Newcastle Coal Futures + ICE Brent-WTI Futures Spread + IPE-ECX European Emissions + ICE Heating Oil Futures + ICE Heating Oil/WTI Futures Crack + ICE NYH (RBOB) Gasoline Futures + ICE NYH (RBOB) Gasoline/WTI Futures Crack + ICE Rotterdam Coal Futures + ICE Richards Bay Coal Futures + ICE Rotterdam/Richards Bay Coal Futures Spread + Cocoa + Coffee C + Cotton No 2 + FCOJ A + Sugar No 11 + Heat Rate Spread + US Dollar Index + ICE Middle East Sour Crude Futures + ICE Brent/Middle East Crude Futures Spread + ICE WTI/Middle East Crude Futures Spread + Canadian Oilseeds + Canadian Grains + ICE ECX CER Futures + Foreign Exchange + Financial Index Data + Sugar No 16 + ECX EUA/CER Futures Spread + Henry Hub + Dutch TTF Gas Futures + German Natural Gas Futures + European Gas Spreads + Canadian Financial Gas + NGX Canadian Physical Crude + US Coal Futures + FOB Indo sub-bit Coal Futures + Heating Oil/Brent Futures Crack + NYH (RBOB) Gasoline/Brent Futures Crack + NYH (RBOB) Gasoline/Heating Oil Spread + Physical Environmental + Heating Oil/LS Gasoil Futures Spread + LS Gasoil/Brent Futures Crack + NYH (RBOB) Gasoline/LS Gasoil Futures Spread + ECX EUAA Futures + ECX CER/EUAA Futures Spread + ECX EUAA/EUA Futures Spread + Soybean + Wheat + Corn + CFR South China Coal Futures + Belgian Power Futures + Dutch Power Futures + gC Newcastle/FOB Indo sub-bit Coal Futures Spread + Richards Bay/gC Newcastle Coal Futures Spread + CIF US + Financial Environmental + European Power Spreads + TAQA + Belgian ZTP Gas Spot + Dutch TTF Gas Spot + Dutch TTF Gas Storage + European Gas Spot Spreads + Belgian ZTP Gas Futures + Belgian Gas Spreads + German Power Futures + Atlantic Coal Futures + Financial Olefins + Financial Monomers + Endex Spot Market Indices + Russell Cash Indices + Interest Rate Futures + Singapore Energy + Singapore Financials + Singapore Metals + Italian Natural Gas Futures + Italian Power Futures + World Cotton + ICE Rotterdam/Newcastle Coal Futures Spread + IFUS ICE Indices + Liffe STIRs + Liffe Bonds + Liffe Swapnotes + Liffe Commodities + Metals + IFUS Equity Indices + GCF Repo + Liffe Three Month Euro and EONIA + Eurodollar + Liffe Equity Derivatives - Non-US Based + Liffe Equity Derivatives - US Based + Liffe Index Options + Liffe Index Futures - US Restricted + Liffe Index Futures - Non-US Restricted + NGX Physical Gas + NGX Financial Power + Financial NGL + Olefins/Polymers + + + diff --git a/src/lib/md/ice/ConnectivityConfiguration.PerfTest.xml b/src/lib/md/ice/ConnectivityConfiguration.PerfTest.xml new file mode 100644 index 000000000..23680779e --- /dev/null +++ b/src/lib/md/ice/ConnectivityConfiguration.PerfTest.xml @@ -0,0 +1,364 @@ + + + + + + + + + 63.247.113.214 + 3000 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 16 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Financial Gas + Financial Power + Oil + IPE Natural Gas Futures + IPE Gas Oil Futures + IPE Brent Futures + IPE UK Electricity Futures Peak + IPE UK Electricity Futures Base + ICE WTI Crude Futures + gC Newcastle Coal Futures + ICE Brent-WTI Futures Spread + IPE-ECX European Emissions + ICE Heating Oil Futures + ICE Heating Oil/WTI Futures Crack + ICE NYH (RBOB) Gasoline Futures + ICE NYH (RBOB) Gasoline/WTI Futures Crack + ICE Rotterdam Coal Futures + ICE Richards Bay Coal Futures + ICE Rotterdam/Richards Bay Coal Futures Spread + Cocoa + Coffee C + Cotton No 2 + FCOJ A + Sugar No 11 + Heat Rate Spread + US Dollar Index + ICE Middle East Sour Crude Futures + ICE Brent/Middle East Crude Futures Spread + ICE WTI/Middle East Crude Futures Spread + Canadian Oilseeds + Canadian Grains + ICE ECX CER Futures + Foreign Exchange + Financial Index Data + Sugar No 16 + ECX EUA/CER Futures Spread + Henry Hub + Canadian Financial Gas + NGX Canadian Physical Crude + US Coal Futures + FOB Indo sub-bit Coal Futures + Heating Oil/Brent Futures Crack + NYH (RBOB) Gasoline/Brent Futures Crack + NYH (RBOB) Gasoline/Heating Oil Spread + Physical Environmental + Heating Oil/LS Gasoil Futures Spread + LS Gasoil/Brent Futures Crack + NYH (RBOB) Gasoline/LS Gasoil Futures Spread + ECX EUAA Futures + ECX CER/EUAA Futures Spread + ECX EUAA/EUA Futures Spread + Soybean + Wheat + Corn + CFR South China Coal Futures + gC Newcastle/FOB Indo sub-bit Coal Futures Spread + Richards Bay/gC Newcastle Coal Futures Spread + Financial Environmental + Atlantic Coal Futures + Financial Olefins + Financial Monomers + ICE Rotterdam/Newcastle Coal Futures Spread + IFUS ICE Indices + Liffe Commodities + Metals + IFUS Equity Indices + GCF Repo + Eurodollar + NGX Physical Gas + NGX Financial Power + Financial NGL + Olefins/Polymers + + + diff --git a/src/lib/md/ice/ConnectivityConfiguration.Production.xml b/src/lib/md/ice/ConnectivityConfiguration.Production.xml new file mode 100644 index 000000000..796e1d195 --- /dev/null +++ b/src/lib/md/ice/ConnectivityConfiguration.Production.xml @@ -0,0 +1,677 @@ + + + + + + + + + 63.247.112.185 + 80 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 63.247.112.190 + 80 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 63.247.125.185 + 80 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 16 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Financial Gas + Financial Power + Oil + IPE Natural Gas Futures + IPE Gas Oil Futures + IPE Brent Futures + IPE UK Electricity Futures Peak + IPE UK Electricity Futures Base + ICE WTI Crude Futures + gC Newcastle Coal Futures + ICE Brent-WTI Futures Spread + IPE-ECX European Emissions + ICE Heating Oil Futures + ICE Heating Oil/WTI Futures Crack + ICE NYH (RBOB) Gasoline Futures + ICE NYH (RBOB) Gasoline/WTI Futures Crack + ICE Rotterdam Coal Futures + ICE Richards Bay Coal Futures + ICE Rotterdam/Richards Bay Coal Futures Spread + Cocoa + Coffee C + Cotton No 2 + FCOJ A + Sugar No 11 + Heat Rate Spread + US Dollar Index + ICE Middle East Sour Crude Futures + ICE Brent/Middle East Crude Futures Spread + ICE WTI/Middle East Crude Futures Spread + Canadian Oilseeds + Canadian Grains + ICE ECX CER Futures + Foreign Exchange + Financial Index Data + Sugar No 16 + ECX EUA/CER Futures Spread + Henry Hub + Dutch TTF Gas Futures + German Natural Gas Futures + European Gas Spreads + Canadian Financial Gas + NGX Canadian Physical Crude + US Coal Futures + FOB Indo sub-bit Coal Futures + Heating Oil/Brent Futures Crack + NYH (RBOB) Gasoline/Brent Futures Crack + NYH (RBOB) Gasoline/Heating Oil Spread + Physical Environmental + Heating Oil/LS Gasoil Futures Spread + LS Gasoil/Brent Futures Crack + NYH (RBOB) Gasoline/LS Gasoil Futures Spread + ECX EUAA Futures + ECX CER/EUAA Futures Spread + ECX EUAA/EUA Futures Spread + Soybean + Wheat + Corn + CFR South China Coal Futures + Belgian Power Futures + Dutch Power Futures + gC Newcastle/FOB Indo sub-bit Coal Futures Spread + Richards Bay/gC Newcastle Coal Futures Spread + CIF US + Financial Environmental + European Power Spreads + TAQA + Belgian ZTP Gas Spot + Dutch TTF Gas Spot + Dutch TTF Gas Storage + European Gas Spot Spreads + Belgian ZTP Gas Futures + Belgian Gas Spreads + German Power Futures + Atlantic Coal Futures + Financial Olefins + Financial Monomers + Russell Cash Indices + Interest Rate Futures + Italian Natural Gas Futures + Italian Power Futures + ICE Rotterdam/Newcastle Coal Futures Spread + IFUS ICE Indices + Liffe STIRs + Liffe Bonds + Liffe Swapnotes + Liffe Commodities + Metals + IFUS Equity Indices + GCF Repo + Liffe Three Month Euro and EONIA + Eurodollar + Liffe Equity Derivatives - Non-US Based + Liffe Equity Derivatives - US Based + Liffe Index Options + Liffe Index Futures - US Restricted + Liffe Index Futures - Non-US Restricted + NGX Physical Gas + NGX Financial Power + Financial NGL + Olefins/Polymers + + + \ No newline at end of file diff --git a/src/lib/md/ice/ICEUtils.cpp b/src/lib/md/ice/ICEUtils.cpp new file mode 100644 index 000000000..44144916f --- /dev/null +++ b/src/lib/md/ice/ICEUtils.cpp @@ -0,0 +1,169 @@ +#ifndef _WIN32 +#include "ICEUtils.h" + +#include "lib/config/config.h" +#include "lib/utils/datetime.h" +#include "lib/utils/bts_chrono.h" +#include "lib/utils/download.h" +#include "lib/logging/logging.h" +#include "lib/md/get_symbols.h" + +#include "lib/config/protos/MarketData.pb.h" +#include "lib/config/protos/system.pb.h" + +#include +#include + + +using namespace std; +using namespace bts::api; + +namespace bts { +namespace md { + +string data_path() { + auto p = config::get().data_path() + "ice/"; +#ifdef _WIN32 + // OnixS requires win32 paths to look like Win32 paths - everyone else in the world is ok with '/' + os::normalize_path(p, '\\'); +#else + os::normalize_path(p); +#endif + return p; +} +const string api_test_config_path() { return data_path() + "ConnectivityConfiguration.APITest.xml"; } +const string perf_test_config_path() { return data_path() + "ConnectivityConfiguration.PerfTest.xml"; } +const string production_config_path() { return data_path() + "ConnectivityConfiguration.Production.xml"; } + +const std::string log_path() {return log:: log_path().string() + "/onix_ice";} + +bool check_file_exists_with_instructions(const string& filename, const string& url, bool log) { + if (!boost::filesystem::exists(filename)) { + download_file(url.c_str(), filename.c_str()); + } + if (!boost::filesystem::exists(filename)) { + if (log) { + LOG(md,Error, + "File {} is not present on this system. " + "Please download it from the CME ftp site. " + "I will wait until the file is present.\n$ curl {} > {} ", + filename, url, filename); + } + return false; + } + return true; +} + +// For exponential backoff on logging this return true if x is a power of 2 or 0 +bool is_pow_two_or_0(uint32_t x) { return (x & (~x + 1)) == x; } + +void await_cme_config() { + std::string config_url; + std::string templates_url; + + if (config::get().type() != "dev") { + config_url = "ftp://ftp.cmegroup.com/SBEFix/Production/Configuration/config.xml"; + templates_url = "ftp://ftp.cmegroup.com/SBEFix/Production/Templates/templates_FixBinary.xml"; + } + else { + config_url = "ftp://ftp.cmegroup.com/SBEFix/Cert/Configuration/config.xml"; + templates_url = "ftp://ftp.cmegroup.com/SBEFix/Cert/Templates/templates_FixBinary.xml"; + } + + boost::filesystem::create_directories(data_path()); + boost::filesystem::create_directories(log_path()); + + // Check config is present and give instructions for downloading it if not + // If the file is not present log an error and wait a second. Continue to log the error ever power of 2 seconds until the file appears or the process is killed. + uint32_t count = 0; + while(!check_file_exists_with_instructions(config_path(), config_url, is_pow_two_or_0(count))) { + ++count; + std::this_thread::sleep_for(1s); + } + count = 0; + while(!check_file_exists_with_instructions(template_path(), templates_url, is_pow_two_or_0(count))) { + ++count; + std::this_thread::sleep_for(1s); + } + + // If we waited for someone to download the file give it a second to be finished downloading + if (count > 0) { + std::this_thread::sleep_for(1s); + } +} + +SecurityType infer_security_type(const string& label) { + if (label.find("Option") != std::string::npos) { + return SECURITYTYPE_OPTION; + } + + if (label.find("Future") != std::string::npos) { + return SECURITYTYPE_FUTURE; + } + + // TODO: Allow configuration to override this? + LOG(md,Warn,"Unable to guess security type from label: '{}" + "' Treating as OPTION.",label); + return SECURITYTYPE_OPTION; +} + +const std::vector get_configured_cme_channels() { + std::vector symbols; + // Get all glbx symbols + get_system_md_symbols(api::VENUE_GLBX, api::SECURITYTYPE_UNSET, &symbols); + return parse_channels(symbols); +} +const vector parse_channels(const vector& symbols) { + vector result; + bool skip_options = config::get().skip_options(); + + pugi::xml_document doc; + bts_assert_msg(doc.load_file(config_path().c_str()), "Error parsing config.xml as xml"); + + auto configuration = doc.root().child("configuration"); + bts_assert(configuration); + + LOG(md,Info,"CME: Loaded '{}' config. Last updated: {}" , + std::string(configuration.attribute("environment").as_string("??")), + std::string(configuration.attribute("updated").as_string("??"))); + auto channels = configuration.children("channel"); + for (const auto& chan : channels) { + CMEChannel channel; + channel.id = chan.attribute("id").as_string(); + auto channel_type = infer_security_type(chan.attribute("label").as_string()); + if (channel_type == SECURITYTYPE_OPTION && skip_options) continue; + if (!(channel.id.empty())) { + auto product_list = chan.child("products").children("product"); + for (const auto& product : product_list) { + auto symbol = product.attribute("code").as_string(); + for (auto s : symbols) { + if ((s.type() == channel_type || s.type() == SECURITYTYPE_SPREAD) + && s.symbol() == symbol) { + channel.symbols.insert(s); + } + } + } + if (!channel.symbols.empty()) { + auto connections = chan.child("connections").children("connection"); + for (const auto& srccon : connections) { + std::string id = srccon.attribute("id").as_string(); + if (!id.empty()) { + CMEConnection connection; + connection.feed_type = srccon.child("type").attribute("feed-type").as_string(); + connection.ip = srccon.child_value("ip"); + connection.port = srccon.child("port").text().as_uint(); + connection.feed = srccon.child_value("feed")[0]; + channel.connections.insert(std::make_pair(id, connection)); + } + } + + result.push_back(channel); + } + } + } + + return result; +} + +}}//namespace +#endif \ No newline at end of file diff --git a/src/lib/md/ice/ICEUtils.h b/src/lib/md/ice/ICEUtils.h new file mode 100644 index 000000000..f412364d7 --- /dev/null +++ b/src/lib/md/ice/ICEUtils.h @@ -0,0 +1,103 @@ +#pragma once + +#include "lib/md/coconut2.h" +#include +#include +#include + +namespace bts { +namespace md { + +struct ICEConnection { + std::string feed_type; + std::string ip; + uint port; + char feed; +}; + +struct ICEChannel { + std::string id; + std::set symbols; + std::map connections; +}; + +void await_ice_config(); +const std::vector get_configured_ice_channels(); +const std::vector parse_channels(const std::vector& symbols); + +const std::string config_path(); +const std::string template_path(); +const std::string log_path(); + +inline void decode_ticks(int vtt, double mintick, FixedSecurity& dest) { + switch(vtt) { + default: + case 0: + dest.low_tick = mintick; + dest.high_tick = mintick; + dest.price_break = 0; + break; + case 1: + dest.price_break = 500; + dest.low_tick = 5; + dest.high_tick = 10; + break; + case 2: + dest.price_break = 5; + dest.low_tick = 0.5; + dest.high_tick = 1; + break; + case 3: + dest.price_break = 10; + dest.low_tick = 1; + dest.high_tick = 2; + break; + case 4: + dest.price_break = 500; + dest.low_tick = 5; + dest.high_tick = 25; + break; + case 10: + dest.price_break = 300; + dest.low_tick = 5; + dest.high_tick = 25; + break; + case 11: + dest.price_break = 300; + dest.low_tick = 5; + dest.high_tick = 10; + break; + case 12: + dest.price_break = 5; + dest.low_tick = 0.25; + dest.high_tick = 0.5; + break; + } +} + +inline int floorlog10(int64_t m) { + bts_assert(m >= 0); + if (m < 10) return 0; + if (m < 100) return 1; + if (m < 1000) return 2; + if (m < 10000) return 3; + if (m < 100000) return 4; + if (m < 1000000) return 5; + if (m < 10000000) return 6; + if (m < 100000000) return 7; + if (m < 1000000000) return 8; + if (m < 10000000000) return 9; + if (m < 100000000000) return 10; + if (m < 1000000000000) return 11; + if (m < 10000000000000) return 12; + if (m < 100000000000000) return 13; + if (m < 1000000000000000) return 14; + if (m < 10000000000000000) return 15; + if (m < 100000000000000000) return 16; + if (m < 1000000000000000000) return 17; + return 19; +} + + +}}//namespace + diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp new file mode 100644 index 000000000..6049e982b --- /dev/null +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp @@ -0,0 +1,266 @@ +#include "MDP3Listener.h" +#include "lib/utils/datetime.h" +#include +#include "lib/utils/helper_macros.h" +#include "lib/config/protos/MarketData.pb.h" +#include "lib/md/protos/co2.pb.h" + +using namespace std; +using namespace bts::co2; + +namespace bts { +namespace md { + + +MDP3Listener::MDP3Listener( + CMESecurityIndex& index, + MDProducer& producer, + // co2::SettlementRecorder& , + const std::vector channels) : + _index(index), + _producer(producer), + _verbose_ticker(config::get().verbose_ticker()), + _packet_arrived(), + _latest_sequence(0), + // _settlement_recorder(settles), + _symbol_filter_storage(), + _symbol_filter(), + _channels(channels), + _concurrency_monitor(0), + _book_updates() +{ + _book_updates.reserve(32); +} + +MDP3Listener::~MDP3Listener() { +} + +// +// Warnings/Errors +void MDP3Listener::onError(onixs::Handler&, const onixs::ErrorArgs& error) { + tracepoint (bts_trace,trace_order,(char*) "onError", _latest_sequence, (uint16_t) _latest_sequence, 0); + LOG(md,Warn, "OnixS Error: {} - {}", error.description(), error.source()); +} +void MDP3Listener::onWarning(onixs::Handler&, const onixs::WarningArgs& warning) { + tracepoint (bts_trace,trace_order,(char*) "onWarning", _latest_sequence, (uint16_t) _latest_sequence, 0); + LOG(md,Warn, "OnixS Warn: {} - {}", warning.description(), warning.source()); +} +void MDP3Listener::onInstrumentRecovery(onixs::Handler& h) { + tracepoint (bts_trace,trace_order,(char*) "onInstrumentRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); + LOG(md,Info, "Beginning security definition recovery for channel {}", h.settings().channel()); +} +void MDP3Listener::onEndOfInstrumentRecovery(onixs::Handler& h, const onixs::RecoveryCompletionArgs&) { + tracepoint (bts_trace,trace_order,(char*) "onEndOfInstrumentRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); + LOG(md,Info, "Finished Security definition recovery for channel {}", h.settings().channel()); +} + +// +// Gap Recovery +void MDP3Listener::onMarketRecovery(onixs::Handler& h) { + tracepoint (bts_trace,trace_order,(char*) "onMarketRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); + update_all_status(COCONUTSECURITYSTATUS_PACKET_LOSS); + for (auto& c : _channels) { c.gap(); } + LOG(md,Info, "Beginning market recovery for channel {}", h.settings().channel()); +} +void MDP3Listener::onEndOfMarketRecovery(onixs::Handler& h, const onixs::RecoveryCompletionArgs&) { + tracepoint (bts_trace,trace_order,(char*) "onEndOfMarketRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); + update_all_status(COCONUTSECURITYSTATUS_OK); + LOG(md,Info, "Finished market recovery for channel {}", h.settings().channel()); +} +void MDP3Listener::onTcpRecovery(onixs::Handler& h) { + tracepoint (bts_trace,trace_order,(char*) "onTcpRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); + update_all_status(COCONUTSECURITYSTATUS_PACKET_LOSS); + LOG(md,Info, "Beginning tcp recovery for channel {}", h.settings().channel()); +} +void MDP3Listener::onEndOfTcpRecovery(onixs::Handler& h, const onixs::RecoveryCompletionArgs&) { + tracepoint (bts_trace,trace_order,(char*) "onEndOfTcpRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); + update_all_status(COCONUTSECURITYSTATUS_OK); + LOG(md,Info, "Finished tcp recovery for channel {}", h.settings().channel()); +} + +// +// Mark the start/end of a packet +void MDP3Listener::onPacket(onixs::Handler&, const onixs::PacketArgs& args) { + // Mark the arrival of the packet + _packet_arrived = TimeStamp::now(); + auto seq = args.seqNumber(); + if (!_book_updates.empty()) { + if (_latest_sequence != seq) { + LOG(md, Error, "Expected sequence {} got {} did not flush {} book updates.", + _latest_sequence, seq, _book_updates.size()); + } + } + _latest_sequence = seq; + auto onixs_zero = args.receiveTime().sinceEpoch(); + auto onixs_now = OnixS::CME::MDH::UtcWatch::now().sinceEpoch(); + + // needed for clang compilation + UNUSED(onixs_zero); + UNUSED(onixs_now); + // was needed for clang compilation + + tracepoint (bts_trace,trace_order,(char*) "onPacket", + _latest_sequence,(uint16_t) _latest_sequence, onixs_now-onixs_zero); +} +void MDP3Listener::onEndOfPacket(onixs::Handler&, const onixs::PacketArgs&) { + tracepoint (bts_trace,trace_order,(char*) "onEndOfPacket.begin", _latest_sequence, (uint16_t) _latest_sequence, 0); + flush_books(); + tracepoint (bts_trace,trace_order,(char*) "onEndOfPacket.end", _latest_sequence, (uint16_t) _latest_sequence, 0); +} + +// +// Security discovery + +void MDP3Listener::onBookUpdate(onixs::Handler&, const onixs::Security& sec, const onixs::DirectBook& book) { + onBookUpdate(sec, book, book_type_direct); +} + +void MDP3Listener::onBookUpdate(onixs::Handler&, const onixs::Security& sec, const onixs::ImpliedBook& book) { + onBookUpdate(sec, book, book_type_implied); +} + +// +// Trades + +AggressorSide map_aggressor(onixs::AggressorSide::Enum agside) { + switch(agside) { + default: + case onixs::AggressorSide::NoAggressor: + return AGGRESSOR_SIDE_NONE; + case onixs::AggressorSide::Buy: + return AGGRESSOR_SIDE_BUY; + case onixs::AggressorSide::Sell: + return AGGRESSOR_SIDE_SELL; + } +} + +void on_trade(SecurityData* data, const onixs::Decimal& price, int size, onixs::AggressorSide::Enum agside, const onixs::Timestamp& onixs_date) { + auto ts = utils::TimeStamp::now(); + PriceSize ps = pricesize_of_price_size(price, data->handle.security().display_factor, size); + auto date = ll_of_timestamp(onixs_date); + data->handle.add_trade(ts, ps, date, map_aggressor(agside), data->electronic_volume + size); +} + +// +// RFQ +void MDP3Listener::onQuoteRequest(onixs::Handler&, const onixs::Security& sec, const onixs::QuoteRequest39RelatedSymArgs& arg) { + tracepoint (bts_trace,trace_order,(char*) "onQuoteRequest", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(sec.id()); + if (data != nullptr) { + auto ts = utils::TimeStamp::now(); + + co2::QuoteRequestMessage message; + message.set_key(data->handle.key()); + + auto time = ll_of_timestamp(arg.message().transactTime()); + message.set_time(time); + + onixs::StrRef id = arg.message().quoteReqId(); + message.set_request_id(id.items(), id.size()); + + // https://www.cmegroup.com/confluence/display/EPICSANDBOX/MDP+3.0+-+Request+for+Quote + int8_t side; + if (arg.entry().side(side)) { + switch(side) { + case 1: // buy + case '1': + message.set_side(co2::QuoteRequestMessage::BUY); + break; + case 2: // sell + case '2': + message.set_side(co2::QuoteRequestMessage::SELL); + break; + case 8: // cross + case '8': + message.set_side(co2::QuoteRequestMessage::CROSS); + break; + } + } + + message.set_tradable(arg.entry().quoteType() == 1); + + int32_t size; + if (arg.entry().orderQty(size)) { + message.set_size(size); + } + + data->handle.add_rfq(ts, message); + + } +} + + +// +// Volume +void MDP3Listener::onElectronicVolume(onixs::Handler&, const onixs::Security& sec, const onixs::Volume37Args& args) { + tracepoint (bts_trace,trace_order,(char*) "onElectronicVolume.volume", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(sec.id()); + if (data != nullptr) { + bts_assert_d( args.entry().entryType().value() == 'e'); + bts_assert_d(args.entry().updateAction() == onixs::UpdateAction::New || + args.entry().updateAction() == onixs::UpdateAction::Change); + data->electronic_volume = args.entry().entrySize(); + } +} + +// +// Non-onixs calls + +void MDP3Listener::add_filter_symbol(const std::string& symbol) { + _symbol_filter_storage.push_back(symbol); + _symbol_filter.clear(); + for (const auto& str : _symbol_filter_storage) { + _symbol_filter.insert(onixs::StrRef(str.c_str(), str.size())); + } +} + +void MDP3Listener::heartbeat() { + for (auto& c : _channels) { c.heartbeat(); } +} + +// +// Private functions + +void MDP3Listener::add_security(const FixedSecurity& security) { + // Set up the shared memory for this security + auto handle = _producer.add_security(security); + bts_assert(security.numeric_id != 0); + // Add it to the index so it can receive messages + _index.add_security(security.numeric_id, handle); +} + +void MDP3Listener::flush_books() { + // This is called at the end of the packet + // Write all book updates to shared memory and reset for the next packet + for (auto& entry : _book_updates) { + uint32_t sequence = _latest_sequence; + if (entry.type_flags == book_type_direct) { + entry.handle.update_direct(_packet_arrived, + entry.bids.first, entry.asks.first, sequence); + } + else if (entry.type_flags == book_type_implied) { + entry.handle.update_implied(_packet_arrived, + entry.bids.second, entry.asks.second, sequence); + } + else if (entry.type_flags == book_type_both) { + entry.handle.update_books(_packet_arrived, + entry.bids.first, entry.asks.first, + entry.bids.second, entry.asks.second, + sequence); + } + } + // Reset pending updates + _book_updates.clear(); +} + +void MDP3Listener::update_all_status(CoconutSecurityStatus status) { + _index.walk_security_list([=](SecurityData& data) { + data.handle.set_status(status); + }); +} + +md::MDP3Listener::BookData::BookData(MDProducerHandle & handle) : handle(handle), type_flags(0), bids(), asks() { } + +}}//namespace + + diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h new file mode 100644 index 000000000..787628750 --- /dev/null +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h @@ -0,0 +1,545 @@ +#pragma once + +#include "lib/utils/bts_no_copy.h" +#include "lib/md/coconut2.h" +#include "ICESecurityIndex.h" +#include "lib/tracing/bts_trace.h" + +#include "ICEListenerHelpers.h" +#include "onixs.h" + +#include +#include +#include +#include +#include + +namespace bts { +namespace md { + + +class MDP3Listener : + public onixs::HandlerListener, + public onixs::MarketDataListener, + public onixs::SecurityListener +{ + typedef uint32_t BookType; + static constexpr BookType book_type_direct=1; + static constexpr BookType book_type_implied=2; + static constexpr BookType book_type_both=(book_type_direct|book_type_implied); + +public: + MDP3Listener(CMESecurityIndex& index, + MDProducer&, + // co2::SettlementRecorder&, + const std::vector); + virtual ~MDP3Listener(); + + // + // Warnings/Errors/Info + void onError(onixs::Handler&, const onixs::ErrorArgs&) override; + void onWarning(onixs::Handler&, const onixs::WarningArgs&) override; + void onInstrumentRecovery(onixs::Handler&) override; + void onEndOfInstrumentRecovery(onixs::Handler&, const onixs::RecoveryCompletionArgs&) override; + + // + // Gap Recovery + void onMarketRecovery(onixs::Handler&) override; + void onEndOfMarketRecovery(onixs::Handler&, const onixs::RecoveryCompletionArgs&) override; + void onTcpRecovery(onixs::Handler&) override; + void onEndOfTcpRecovery(onixs::Handler&, const onixs::RecoveryCompletionArgs&) override; + + // + // Mark the start/end of a packet + void onPacket(onixs::Handler&, const onixs::PacketArgs&) override; + void onEndOfPacket(onixs::Handler&, const onixs::PacketArgs&) override; + + // + // Security discovery + template + void onFuture(onixs::Handler&, const onixs::Security&, const InstrumentDefinitionFuture&); + template + void onOption(onixs::Handler&, const onixs::Security&, const InstrumentDefinition&); + template + void onSpread(onixs::Handler&, const onixs::Security&, const InstrumentDefinition&); + + void onDefinition(onixs::Handler& h, const onixs::Security& s, const onixs::InstrumentDefinitionFuture27Args& def) override { onFuture(h, s, def); } + void onDefinition(onixs::Handler& h, const onixs::Security& s, const onixs::InstrumentDefinitionFuture54Args& def) override { onFuture(h, s, def); } + + void onDefinition(onixs::Handler& h, const onixs::Security& s, const onixs::InstrumentDefinitionOption41Args& def) override { onOption(h, s, def); } + void onDefinition(onixs::Handler& h, const onixs::Security& s, const onixs::InstrumentDefinitionOption55Args& def) override { onOption(h, s, def); } + + void onDefinition(onixs::Handler& h, const onixs::Security& s, const onixs::InstrumentDefinitionSpread29Args& def) override { onSpread(h, s, def); } + void onDefinition(onixs::Handler& h, const onixs::Security& s, const onixs::InstrumentDefinitionSpread56Args& def) override { onSpread(h, s, def); } + + // + // Book + // void onBookUpdate(onixs::Handler&, const onixs::Security&, const onixs::MboBook&) override; + void onBookUpdate(onixs::Handler&, const onixs::Security&, const onixs::DirectBook&) override; + void onBookUpdate(onixs::Handler&, const onixs::Security&, const onixs::ImpliedBook&) override; + // void onBookUpdate(onixs::Handler&, const onixs::Security&, const onixs::ConsolidatedBook&) override; + + template + void onBookUpdate(const onixs::Security& sec, const TBook& book, BookType booktype); + + // + // Trades + template + void onTradeRecovery(const onixs::Security&, const TradeRecovery&); + void onTrade(onixs::Handler&, const onixs::Security& s, const onixs::Recovery52EntryArgs& arg) override { onTradeRecovery(s, arg); } + void onTrade(onixs::Handler&, const onixs::Security& s, const onixs::Recovery38EntryArgs& arg) override { onTradeRecovery(s, arg); } + + template + void onTradeSummary(const onixs::Security&, const Trade&); + void onTrade(onixs::Handler&, const onixs::Security& s, const onixs::TradeSummary48Args& arg) override { onTradeSummary(s, arg); } + void onTrade(onixs::Handler&, const onixs::Security& s, const onixs::TradeSummary42Args& arg) override { onTradeSummary(s, arg); } + + // + // RFQ + void onQuoteRequest(onixs::Handler&, const onixs::Security&, const onixs::QuoteRequest39RelatedSymArgs&) override; + + // + // Volume + void onElectronicVolume(onixs::Handler&, const onixs::Security&, const onixs::Volume37Args&) override; + template + void onElectronicVolume(const onixs::Security&, const RecoveryEntry&); + void onElectronicVolume(onixs::Handler&, const onixs::Security& s, const onixs::Recovery52EntryArgs& arg) override { onElectronicVolume(s, arg); } + void onElectronicVolume(onixs::Handler&, const onixs::Security& s, const onixs::Recovery38EntryArgs& arg) override { onElectronicVolume(s, arg); } + + // + // Misc + template + void onSettlementPrice(const onixs::Security& sec, const StatisticsArgs& args); + void onSettlementPrice(onixs::Handler&, const onixs::Security& s, const onixs::DailyStatistics49Args& arg) override { + auto type = arg.entry().settlPriceType(); + if (type.finalDaily() && type.actual()) { + onSettlementPrice(s, arg); + } + } + void onSettlementPrice(onixs::Handler&, const onixs::Security& s, const onixs::DailyStatistics33Args& arg) override { + auto type = arg.entry().settlPriceType(); + if (type.finalDaily() && type.actual()) { + onSettlementPrice(s, arg); + } + } + void onSettlementPrice(onixs::Handler&, const onixs::Security& s, const onixs::Recovery52EntryArgs& arg) override { onSettlementPrice(s, arg); } + void onSettlementPrice(onixs::Handler&, const onixs::Security& s, const onixs::Recovery38EntryArgs& arg) override { onSettlementPrice(s, arg); } + + template + void onSessionOpeningPrice(const onixs::Security&, const SessionArgs&); + template + void onRecoveryOpeningPrice(const onixs::Security& sec, const RecoveryArgs& args); + void onOpeningPrice(onixs::Handler&, const onixs::Security& s, const onixs::SessionStatistics51Args& arg) override { onSessionOpeningPrice(s, arg); } + void onOpeningPrice(onixs::Handler&, const onixs::Security& s, const onixs::SessionStatistics35Args& arg) override { onSessionOpeningPrice(s, arg); } + void onOpeningPrice(onixs::Handler&, const onixs::Security& s, const onixs::Recovery52EntryArgs& arg) override { onRecoveryOpeningPrice(s, arg); } + void onOpeningPrice(onixs::Handler&, const onixs::Security& s, const onixs::Recovery38EntryArgs& arg) override { onRecoveryOpeningPrice(s, arg); } + + template + void onSessionHighTradePrice(const onixs::Security&, const SessionArgs&); + template + void onRecoveryHighTradePrice(const onixs::Security&, const RecoveryArgs&); + void onHighTradePrice(onixs::Handler&, const onixs::Security& s, const onixs::SessionStatistics51Args& arg) override { onSessionHighTradePrice(s, arg); } + void onHighTradePrice(onixs::Handler&, const onixs::Security& s, const onixs::SessionStatistics35Args& arg) override { onSessionHighTradePrice(s, arg); } + void onHighTradePrice(onixs::Handler&, const onixs::Security& s, const onixs::Recovery52EntryArgs& arg) override { onRecoveryHighTradePrice(s, arg); } + void onHighTradePrice(onixs::Handler&, const onixs::Security& s, const onixs::Recovery38EntryArgs& arg) override { onRecoveryHighTradePrice(s, arg); } + + template + void onSessionLowTradePrice(const onixs::Security&, const SessionArgs&); + template + void onRecoveryLowTradePrice(const onixs::Security&, const RecoveryArgs&); + void onLowTradePrice(onixs::Handler&, const onixs::Security& s, const onixs::SessionStatistics51Args& arg) override { onSessionLowTradePrice(s, arg); } + void onLowTradePrice(onixs::Handler&, const onixs::Security& s, const onixs::SessionStatistics35Args& arg) override { onSessionLowTradePrice(s, arg); } + void onLowTradePrice(onixs::Handler&, const onixs::Security& s, const onixs::Recovery52EntryArgs& arg) override { onRecoveryLowTradePrice(s, arg); } + void onLowTradePrice(onixs::Handler&, const onixs::Security& s, const onixs::Recovery38EntryArgs& arg) override { onRecoveryLowTradePrice(s, arg); } + + // + // Discover securities + void add_filter_symbol(const std::string& symbol); + void heartbeat(); + + // Add a new security to the index + void add_security(const FixedSecurity& security); + +private: + enum SecurityFilterAction { ADD, SKIP, DELETE }; + template + SecurityFilterAction filter_security(int exchange_id, const Sec& sec) { + if (sec.securityUpdateAction() == onixs::SecurityUpdateAction::Delete) { + auto* data = _index.get_security(exchange_id); + if (data != nullptr) { + data->handle.mark_deleted(); + } + return DELETE; + } + if (_index.has_security(exchange_id)) return SKIP; + onixs::SecurityTradingStatus::Enum trading_status; + if(sec.securityTradingStatus(trading_status) && + trading_status == onixs::SecurityTradingStatus::NotAvailableForTrading) return SKIP; + return _symbol_filter.count(sec.asset()) > 0 ? ADD : SKIP; + } + void flush_books(); + void update_all_status(co2::CoconutSecurityStatus status); + + CMESecurityIndex& _index; + MDProducer& _producer; + bool _verbose_ticker; + utils::TimeStamp _packet_arrived; + uint32_t _latest_sequence; + // co2::SettlementRecorder& _settlement_recorder; + std::vector _symbol_filter_storage; + std::set _symbol_filter; + std::vector _channels; + std::atomic _concurrency_monitor; + + struct BookData { + BookData(MDProducerHandle& handle); + MDProducerHandle handle; + BookType type_flags; + std::pair, std::array> bids; + std::pair, std::array> asks; + }; + std::vector _book_updates; +}; + +////////////////////////////////////////// +// Template Member Function Definitions +////////////////////////////////////////// + +template +void set_security_common(const Definition& def, FixedSecurity& fsec) { + fsec.numeric_id = def.securityId(); + fsec.symbol(def.asset().items(), def.asset().size()); + fsec.cfi_code(def.cfiCode().items(), def.cfiCode().size()); + fsec.alt_symbol(def.securityGroup().items(), def.securityGroup().size()); + fsec.security_desc(def.symbol().items(), def.symbol().size()); + fsec.exchange = api::Venue::VENUE_GLBX; + // tickRule not present in futures + fsec.cme_market_segment_id = def.marketSegmentId(); + fsec.display_factor = def.displayFactor().exponent() + floorlog10(def.displayFactor().mantissa()); + + def.mainFraction(fsec.cme_main_fraction); + def.subFraction(fsec.cme_sub_fraction); + def.priceDisplayFormat(fsec.cme_price_display_format); +} + + +template +void MDP3Listener::onFuture(onixs::Handler&, const onixs::Security& osec, const InstrumentDefinition& def) { + tracepoint (bts_trace,trace_order,(char*) "onDefinition.future", _latest_sequence, (uint16_t) _latest_sequence, 0); + const auto& sec = def.message(); + auto exchange_id = sec.securityId(); + // LOG(md, Info, "onDefinition future {} {}", + // std::string(sec.asset().items(), sec.asset().size()), + // std::string(sec.symbol().items(), sec.symbol().size())); + + if (filter_security(exchange_id, sec) != ADD) return; + bts_assert(exchange_id == osec.id()); + + FixedFutureSecurity fsec; + + set_security_common(sec, fsec); + fsec.price_break = 0; + // low/high tick are stored non-premultiplied and multiplied in conversion to api::Secutity + double min_tick = double_of_price(sec.minPriceIncrement(), 0); + fsec.low_tick = fsec.high_tick = min_tick; + onixs::Decimal min_tick_amount; + sec.minPriceIncrementAmount(min_tick_amount); + double min_tick_dbl = double_of_price(min_tick_amount, 0); + fsec.cash_per_point = min_tick_dbl / min_tick / pow10(fsec.display_factor); + auto expiration = date_of_maturity(sec); + fsec.expiration_year = expiration.year; + fsec.expiration_month = expiration.month; + fsec.expiration_day = expiration.day; + add_security(fsec); +} + +template +void MDP3Listener::onOption(onixs::Handler&, const onixs::Security&, const InstrumentDefinition& def) { + tracepoint (bts_trace,trace_order,(char*) "onDefinition.option", _latest_sequence, (uint16_t) _latest_sequence, 0); + const auto& sec = def.message(); + auto exchange_id = sec.securityId(); + // LOG(Info, MarketData) << "onDefinition option " << exchange_id; + if (filter_security(exchange_id, sec) != ADD) return; + + FixedOptionSecurity fsec; + set_security_common(sec, fsec); + auto expiration = date_of_maturity(sec); + fsec.expiration_year = expiration.year; + fsec.expiration_month = expiration.month; + fsec.expiration_day = expiration.day; + + onixs::Decimal strike_price; + bts_assert(sec.strikePrice(strike_price)); + fsec.strike = double_of_price(strike_price, fsec.display_factor); + + onixs::Decimal min_tick, min_tick_amount; + sec.minPriceIncrement(min_tick); + sec.minPriceIncrementAmount(min_tick_amount); + + int8_t tick_rule; + if (sec.tickRule(tick_rule)) { + decode_ticks(tick_rule, double_of_price(min_tick, 0), fsec); + } + fsec.cash_per_point = double_of_price(min_tick_amount, 0) / fsec.low_tick / pow10(fsec.display_factor); + + fsec.call_put = sec.putOrCall() == onixs::PutOrCall::Call ? api::PUTORCALL_CALL : api::PUTORCALL_PUT; + + add_security(fsec); +} + +// min_tick specializations +inline onixs::Decimal tick_rule(const onixs::InstrumentDefinitionSpread29& sec) { + return sec.minPriceIncrement(); +} +inline onixs::Decimal tick_rule(const onixs::InstrumentDefinitionSpread56& sec) { + onixs::Decimal min_tick; + sec.minPriceIncrement(min_tick); + return min_tick; +} + +template +void MDP3Listener::onSpread(onixs::Handler&, const onixs::Security&, const InstrumentDefinition& spread_args) { + tracepoint (bts_trace,trace_order,(char*) "onDefinition.spread", _latest_sequence, (uint16_t) _latest_sequence, 0); + const auto& sec = spread_args.message(); + auto exchange_id = sec.securityId(); + // LOG(md, Info, "onDefinition spread {} {}", + // std::string(sec.asset().items(), sec.asset().size()), + // std::string(sec.symbol().items(), sec.symbol().size())); + if (filter_security(exchange_id, sec) != ADD) return; + + // Filter out any already expired spreads + auto expiration = date_of_maturity(sec); + if (expiration < datetime::today()) return; + + FixedSpreadSecurityL fsec; + set_security_common(sec, fsec); + + onixs::Decimal min_tick = tick_rule(sec); + + int8_t tick_rule; + if (sec.tickRule(tick_rule)) { + decode_ticks(tick_rule, double_of_price(min_tick, 0), fsec); + } + else { + double mintick = double_of_price(min_tick, 0); + fsec.low_tick = mintick; + fsec.high_tick = mintick; + fsec.price_break = 0; + } + + fsec.set_leg_count(sec.legs().size()); + for(size_t x = 0; x < fsec.leg_count(); ++x) { + const auto& leg = sec.legs()[x]; + onixs::Decimal price; + if (leg.legPrice(price)) { + fsec.legs[x].leg_price = double_of_price(price, fsec.display_factor); + } + onixs::Decimal qty; + if (leg.legOptionDelta(qty)) { + fsec.legs[x].leg_delta = double_of_price(qty, 0); + } + fsec.legs[x].leg_quantity = leg.legRatioQty(); + fsec.legs[x].leg_side = leg.legSide() == onixs::LegSide::BuySide ? api::SIDE_BUY : api::SIDE_SELL; + fsec.legs[x].exchange_key = ExchangeKey(leg.legSecurityId()); + fsec.legs[x].key = invalid_security_key; + } + add_security(fsec); +} + +template +void MDP3Listener::onBookUpdate(const onixs::Security& sec, const TBook& onixs_book, BookType booktype) { + tracepoint (bts_trace,trace_order,(char*) "onBookUpdate", _latest_sequence, (uint16_t) _latest_sequence, 0); + + auto data = _index.get_security(sec.id()); + if (data == nullptr) return; + bts_assert(data->id == (uint32_t)sec.id()); + auto display_factor = data->handle.security().display_factor; + + // Put the data into the cache. Flush at the end of the packet. + auto key = data->handle.key(); + auto find_iter = std::find_if(_book_updates.begin(), _book_updates.end(), [key](const BookData& entry) { + return key == entry.handle.key(); + }); + bool found = find_iter != _book_updates.end(); + if (!found) { + _book_updates.emplace_back(data->handle); + } + BookData& cache = found ? *find_iter : _book_updates.back(); + cache.type_flags |= booktype; + auto& cache_bids = std::get>(cache.bids); + auto& cache_asks = std::get>(cache.asks); + + // Overwrite all entries every time + size_t bids_size = onixs_book.bids().size(); + size_t asks_size = onixs_book.offers().size(); + if (!data->handle.has_depth()) { + bids_size = std::min(bids_size, size_t { 1 }); + asks_size = std::min(asks_size, size_t { 1 }); + } + for (size_t x = 0; x < bids_size; ++x) { + cache_bids[x] = pricesize_of_price_size(onixs_book.bids()[x].price(), display_factor, onixs_book.bids()[x].quantity()); + } + for (size_t x = 0; x < asks_size; ++x) { + cache_asks[x] = pricesize_of_price_size(onixs_book.offers()[x].price(), display_factor, onixs_book.offers()[x].quantity()); + } + if (!found) { + // NaN out the remaining depth + for (size_t x = bids_size; x < MAX_DEPTH; ++x) { + cache_bids[x] = NO_MARKET; + } + for (size_t x = asks_size; x < MAX_DEPTH; ++x) { + cache_asks[x] = NO_MARKET; + } + } +} + +void on_trade(SecurityData* data, const onixs::Decimal& price, int size, onixs::AggressorSide::Enum agside, const onixs::Timestamp& onixs_date); + +template +void MDP3Listener::onTradeRecovery(const onixs::Security& sec, const TradeRecovery& arg) { + tracepoint (bts_trace,trace_order,(char*) "onTrade.recovery", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(sec.id()); + if (data != NULL) { + int size = 0; + arg.entry().entrySize(size); + onixs::Decimal price; + arg.entry().entryPx(price); + on_trade(data, price, size, onixs::AggressorSide::NoAggressor, arg.message().transactTime()); + } +} + +template +void MDP3Listener::onTradeSummary(const onixs::Security& sec, const TradeSummary& arg) { + tracepoint (bts_trace,trace_order,(char*) "onTrade.summary", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(sec.id()); + if (data != NULL) { + auto size = arg.entry().entrySize(); + onixs::Decimal price = arg.entry().entryPx(); + onixs::AggressorSide::Enum agside = onixs::AggressorSide::NoAggressor; + arg.entry().aggressorSide(agside); + if (_verbose_ticker) { + const auto& details = arg.orderIds(); + auto sz = details.size(); + for (size_t x = 0; x < sz; ++x) { + const auto& d = details[x]; + on_trade(data, price, d.lastQty(), agside, arg.message().transactTime()); + } + } + else { + on_trade(data, price, size, agside, arg.message().transactTime()); + } + } +} + + +template +void MDP3Listener::onElectronicVolume(const onixs::Security& sec, const RecoveryEntryArgs& args) { + tracepoint (bts_trace,trace_order,(char*) "onElectronicVolume.recovery", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(sec.id()); + if (data) { + int32_t size; + if (args.entry().entrySize(size)) { + data->electronic_volume = size; + } + } +} + +template +void MDP3Listener::onSettlementPrice(const onixs::Security& sec, const StatisticsArgs& args) { + tracepoint (bts_trace,trace_order,(char*) "onSettlementPrice.daily", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(sec.id()); + if (data != nullptr) { + onixs::Decimal price; + onixs::Timestamp time; + args.entry().entryPx(price); + args.entry().tradingReferenceDate(time); + auto display_factor = data->handle.security().display_factor; + data->handle.update_settlement( + utils::TimeStamp::now(), + convert_price(price, display_factor), + date_of_timestamp(time)); + } +} + +template +void MDP3Listener::onSessionOpeningPrice(const onixs::Security& sec, const SessionArgs& args) { + tracepoint (bts_trace,trace_order,(char*) "onOpeningPrice.session", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(sec.id()); + if (data != nullptr) { + onixs::Decimal price = args.entry().entryPx(); + onixs::Timestamp time = args.message().transactTime(); + auto display_factor = data->handle.security().display_factor; + data->handle.update_opening( + utils::TimeStamp::now(), + double_of_price(price, display_factor), + date_of_timestamp(time)); + } +} +template +void MDP3Listener::onRecoveryOpeningPrice(const onixs::Security& sec, const RecoveryArgs& args) { + tracepoint (bts_trace,trace_order,(char*) "onOpeningPrice.recovery", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(sec.id()); + if (data != nullptr) { + onixs::Decimal price; + args.entry().entryPx(price); + onixs::Timestamp time; + args.entry().tradingReferenceDate(time); + auto display_factor = data->handle.security().display_factor; + data->handle.update_opening( + utils::TimeStamp::now(), + double_of_price(price, display_factor), + date_of_timestamp(time)); + } +} + +template +void MDP3Listener::onSessionHighTradePrice(const onixs::Security& sec, const SessionArgs& args) { + tracepoint (bts_trace,trace_order,(char*) "onHighTradePrice.session", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(sec.id()); + if (data != nullptr) { + auto display_factor = data->handle.security().display_factor; + data->handle.update_session_high( + utils::TimeStamp::now(), + double_of_price(args.entry().entryPx(), display_factor)); + } +} +template +void MDP3Listener::onRecoveryHighTradePrice(const onixs::Security& sec, const RecoveryArgs& args) { + tracepoint (bts_trace,trace_order,(char*) "onHighTradePrice.recovery", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(sec.id()); + if (data != nullptr) { + auto display_factor = data->handle.security().display_factor; + onixs::Decimal price; + args.entry().entryPx(price); + data->handle.update_session_high( + utils::TimeStamp::now(), + double_of_price(price, display_factor)); + } +} +template +void MDP3Listener::onSessionLowTradePrice(const onixs::Security& sec, const SessionArgs& args) { + tracepoint (bts_trace,trace_order,(char*) "onLowTradePrice.session", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(sec.id()); + if (data != nullptr) { + auto display_factor = data->handle.security().display_factor; + data->handle.update_session_low( + utils::TimeStamp::now(), + double_of_price(args.entry().entryPx(), display_factor)); + } +} +template +void MDP3Listener::onRecoveryLowTradePrice(const onixs::Security& sec, const RecoveryArgs& args) { + tracepoint (bts_trace,trace_order,(char*) "onLowTradePrice.recovery", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(sec.id()); + if (data != nullptr) { + auto display_factor = data->handle.security().display_factor; + onixs::Decimal price; + args.entry().entryPx(price); + data->handle.update_session_low( + utils::TimeStamp::now(), + double_of_price(price, display_factor)); + } +} + + +}}//namespace diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h new file mode 100644 index 000000000..7c63a24df --- /dev/null +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h @@ -0,0 +1,49 @@ +#include "lib/utils/bts_assert.h" +#include "lib/md/cme/ICEUtils.h" +#include "lib/md/coconut2.h" + +#include "onixs.h" + +#include +#include +#include + +namespace bts { +namespace md { + +inline PriceSize pricesize_of_price_size(const onixs::Decimal price, int8_t display_factor, Size size) { + PriceSize result({price.mantissa(), (int8_t)(price.exponent() + display_factor)}, size); + return result; +} + +template +double double_of_price(const OnixPrice& price, int8_t display_factor) { + // order of multiplication is important because of floating point error + return (price.mantissa() * pow10(price.exponent())) * pow10(display_factor); +} + +template +IntPrice convert_price(const OnixsPrice& price, int8_t display_factor) { + return IntPrice(price.mantissa(), price.exponent() + display_factor); +} + +inline datetime::LLDateTime ll_of_timestamp(const onixs::Timestamp& ts) { + return datetime::ll_from_parts(ts.year(), (int)ts.month(), ts.day(), ts.hour(), ts.minute(), ts.second(), ts.millisecond()); +} + +inline datetime::Date date_of_timestamp(const onixs::Timestamp& ts) { + return datetime::Date(ts.year(), (int)ts.month(), ts.day()); +} + +template +datetime::Date date_of_maturity(const Definition& def) { + for (const auto& event : def.events()) { + if (event.eventType() == onixs::EventType::LastEligibleTradeDate) { + return date_of_timestamp(event.eventTime()); + } + } + return datetime::Date(); +} + + +}}//namespace \ No newline at end of file diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp new file mode 100644 index 000000000..82d6aa0de --- /dev/null +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp @@ -0,0 +1,368 @@ +#include "MDP3Main.h" + +#include "lib/md/cme/MDP3Utils.h" +#include "lib/config/config.h" +#include "lib/md/coconut2.h" +#include "lib/md/SecurityDB.h" +#include "lib/os/os.h" +#include "lib/utils/Dispatcher.h" +#include "lib/utils/proto_helper.h" +#include "lib/md/protos/co2.pb.h" + +#include "lib/config/protos/MarketData.pb.h" +#include "lib/config/protos/system.pb.h" +#include "lib/utils/thread_manager.h" + + +#include +#include +#include + +using namespace std; +using namespace bts::co2; +using std::size_t; + +namespace bts { +namespace md { + +MDP3Main::MDP3Main() : + _index(), + _recorder ({ utils::Dispatcher::current(), [=](ExchangeKey k) { return SecurityKey(_index.get_key(k.value())); } }), + _producer(PLATFORM_MDP3ONIXS, _recorder ), + // _settlement_recorder(PLATFORM_MDP3ONIXS), + _engines(), + _handlers(), + _listeners(), + _recovery() +{ +} + +MDP3Main::~MDP3Main() {} + +const CMEOptions::CMEChannel channel_settings_for(const string& id) { + const auto& config = config::get(); + for (const auto& ch : config.channel()) { + bool found = std::find_if(ch.id().begin(), ch.id().end(), [&](const string& chan_id) { return chan_id == id || chan_id == "*"; }) != ch.id().end(); + if (found) { + return ch; + } + } + return CMEOptions::CMEChannel(); +} +bool feed_engine_exists(const string& name) { + const auto& config = config::get(); + for (const auto& feed : config.feed_engine()) { + if (feed.name() == name) return true; + } + return false; +} + +const onixs::FeedEngineSettings feed_engine_settings_from_config(const CMEOptions::FeedEngineSettings& settings, int feed_count) { + onixs::FeedEngineSettings result; + + if (settings.has_data_wait()) result.dataWaitTime(settings.data_wait()); + if (settings.has_spin_time()) result.spinBeforeIdleTime(settings.spin_time()); + + result.socketBufferSize(settings.udp_socket_buffer_size()); + + auto affinity = threading::get_affinity(settings.name()); + for (auto& core : affinity) { + result.threadAffinity().cpus().insert(core); + } + + // num_threads() overrides anything else + if (settings.has_num_threads()) { + result.threadCount(settings.num_threads()); + } + else { + // If num_threads is absent determine thread count based on #channels + result.threadCount((feed_count / settings.channels_per_thread()) + 1); + } + return result; +} + +size_t count_engine_uses(const vector& channels, const string& feed_name) { + return count_if(channels.begin(), channels.end(), [&](const CMEChannel& ch) { + const auto& settings = channel_settings_for(ch.id); + return settings.has_feed_engine() && settings.feed_engine() == feed_name; + }); +} + +map create_feed_engine_settings(const std::vector& channels) { + map settings; + const auto& config = config::get(); + + // For each feed engine in feed_engine + for (const auto& feed : config.feed_engine()) { + // - see if it is in use + size_t use_count = count_engine_uses(channels, feed.name()); + // - Only create if this feed engine is in use + if (use_count > 0) { + settings[feed.name()] = feed_engine_settings_from_config(feed, use_count); + } + } + + return settings; +} + +map> create_feed_engines(const vector& channels) { + map> result; + auto settings = create_feed_engine_settings(channels); + // Loop through settings and instantiate feed engines + for (const auto& s : settings) { + unique_ptr temp(new onixs::FeedEngine(s.second)); + result.insert(make_pair(s.first, move(temp))); + } + + return result; +} + +onixs::SessionSettings session_settings_for_channel(const string& channel_id) { + const auto& options = channel_settings_for(channel_id); + onixs::SessionSettings settings; + settings.marketRecovery(onixs::MarketRecoveryOptions::MbpOnly); + if (!options.join_snapshot_on_gap()) { + settings.gapAndErrorHandling(onixs::GapAndErrorHandlingOptions::ContinueProcessing); + } + if (options.use_natural_refresh()) { + settings.joinRecovery(onixs::JoinRecoveryOptions::Disabled); + settings.gapAndErrorHandling(onixs::GapAndErrorHandlingOptions::ContinueProcessing); + } + return settings; +} + +void MDP3Main::run(std::vector& symbols) { + await_cme_config(); + initialize(); + const auto& channels = parse_channels(symbols); + _engines = create_feed_engines(channels); + for (const auto& channel : channels) { + unique_ptr phandler = prepare_handler(channel.id); + _listeners.push_back(prepare_listener(*phandler, channel)); + _handlers.insert(std::make_pair(channel.id, move(phandler))); + std::stringstream symstr; + for (const auto& sym : channel.symbols) { symstr << sym.symbol() << "-" << SecurityType_Name(sym.type()) << " "; } + LOG(md,Info, "CME: Initialized channel {} ({})",channel.id,symstr.str()); + } + + for (auto& pair : _handlers) { + onixs::SessionSettings settings = session_settings_for_channel(pair.first); + pair.second->start(settings); + } + + // + // Timers + + auto& disp = utils::Dispatcher::current(); + + // utils::DispatcherTimer settlement_timer(disp, 100, [&]() { + // _settlement_recorder.do_work(); + // }); + // settlement_timer.start(); + + utils::DispatcherTimer heartbeat_timer(disp, 250, [&]() { + for (const auto& listener: _listeners) { + listener->heartbeat(); + } + }); + heartbeat_timer.start(); + + LOG(md,Info, "** CME MDP3 Publisher started **"); + + disp.run(); +} + + +void MDP3Main::initialize() { + const auto& options = config::get(); + auto license_location = os::bts_data_path() + "/licenses/"; + + if (!boost::filesystem::is_directory(license_location)) { + auto license_path =os::sparkd_wd() + "/data_files/Onixs.BTS.lic" ; + boost::filesystem::create_directories(license_location); + boost::filesystem::copy_file(license_path,license_location+"/Onixs.BTS.lic"); + } + + // + // License path + onixs::InitializationSettings init_settings; + auto license = options.onixs_license(); + init_settings.licenseStore(license); + if (license == "{default}") { + init_settings.licenseStore(license_location); + } + LOG(md,Info,"Loading onixs license from {}", init_settings.licenseStore()); + onixs::initialize(init_settings); +} + +// // +// Initialize HandlerSettings and allocate the channel Handler +unique_ptr MDP3Main::prepare_handler(const string& channel_id) { + const auto& pub_options = config::get(); + const auto& options = channel_settings_for(channel_id); + LOG(md,Info,"Loaded channel options for channel {}:\n{}",channel_id ,options.DebugString()); + + onixs::HandlerSettings settings; + settings.channel(std::stoul(channel_id)); + settings.feeds().connectivityConfigurationFile(config_path()); + + // Market data options + settings.bookManagement().directBooks().maintain(true); + settings.bookManagement().impliedBooks().maintain(true); + settings.bookManagement().consolidatedBooks().maintain(false); + + // 10k default is *far* too low + settings.recoveryQueueMaxSize(options.recovery_queue_size()); + + // + // Network settings + + if (options.has_lost_packet_wait_timeout_ms()) { + settings.feeds().incrementalFeeds().lostPacketWaitTime((size_t)options.lost_packet_wait_timeout_ms() * 1000); + } + if (pub_options.has_network_interface()) { + settings.feeds().feedANetworkInterfaces(pub_options.network_interface()); + settings.feeds().feedBNetworkInterfaces(pub_options.network_interface()); + } + else { + if (pub_options.has_network_interface_a()) { + settings.feeds().feedANetworkInterfaces(pub_options.network_interface_a()); + } + if (pub_options.has_network_interface_b()) { + settings.feeds().feedBNetworkInterfaces(pub_options.network_interface_b()); + } + } + + if (pub_options.has_network_interface() || + (pub_options.has_network_interface_a() && + pub_options.has_network_interface_b()) ) { + if (options.prefer_backup_feeds()) { + settings.feeds().instrumentFeeds().layout(onixs::RecoveryFeedLayout::FeedBWithFailoverToFeedA); + settings.feeds().incrementalFeeds().layout(onixs::RealtimeFeedLayout::BothFeedsWithArbitrage); + settings.feeds().snapshotFeeds().layout(onixs::RecoveryFeedLayout::FeedBWithFailoverToFeedA); + settings.feeds().mboSnapshotFeeds().layout(onixs::RecoveryFeedLayout::FeedBWithFailoverToFeedA); + } + else { + auto layout = onixs::RecoveryFeedLayout::FeedAWithFailoverToFeedB; + settings.feeds().instrumentFeeds().layout(layout); + settings.feeds().incrementalFeeds().layout(onixs::RealtimeFeedLayout::BothFeedsWithArbitrage); + settings.feeds().snapshotFeeds().layout(layout); + settings.feeds().mboSnapshotFeeds().layout(layout); + } + } + else if (pub_options.has_network_interface_a()) { + auto layout = onixs::RecoveryFeedLayout::FeedAOnly; + settings.feeds().instrumentFeeds().layout(layout); + settings.feeds().incrementalFeeds().layout(onixs::RealtimeFeedLayout::FeedAOnly); + settings.feeds().snapshotFeeds().layout(layout); + settings.feeds().mboSnapshotFeeds().layout(layout); + } + else if (pub_options.has_network_interface_b()) { + auto layout = onixs::RecoveryFeedLayout::FeedBOnly; + settings.feeds().instrumentFeeds().layout(layout); + settings.feeds().incrementalFeeds().layout(onixs::RealtimeFeedLayout::FeedBOnly); + settings.feeds().snapshotFeeds().layout(layout); + settings.feeds().mboSnapshotFeeds().layout(layout); + } + + // + // Misc settings + + settings.bookManagement().updateNotification(onixs::BookUpdateNotification::OnEndOfEvent); + settings.tradeProcessing( + config::get().verbose_ticker() ? + onixs::TradeProcessing::OrderDetails : + onixs::TradeProcessing::SummaryLevel); + + // + // Logging + onixs::Logger* logger; + if (options.onixs_log_mode() == CMEOptions_OnixSLogMode_None) { + logger = new onixs::NullLogger(); + } + else { + onixs::FileLoggerSettings loggerSettings; + loggerSettings.filename(log_path() + "/log_" + channel_id); + loggerSettings.severityLevel((onixs::LogSeverity::Enum)options.onixs_log_mode()); + logger = new onixs::FileLogger(loggerSettings); + if (options.onixs_log_mode() == CMEOptions::Debug) { + // trace all the things + settings.debugLogging().traceBooks(true); + settings.debugLogging().traceFeeds(true); + settings.debugLogging().traceMessages(onixs::MessageTracing::FixFormat); + } + } + + + // + // Tcp Replay options + + std::unique_ptr recovery; + if (options.use_tcp_replay()) { + LOG(md,Info,"CME: Enabled TCP replay"); + onixs::TcpRecoverySettings tcpSettings; + tcpSettings.username(options.tcp_replay_username()); + tcpSettings.password(options.tcp_replay_password()); + tcpSettings.reconnectAttempts(options.tcp_replay_connect_attempts()); + tcpSettings.reconnectInterval(options.tcp_replay_reconnect_interval_ms()); + recovery.reset(new onixs::TcpRecoveryService(tcpSettings)); + } + + // + // Associate with feed handler + + try { + auto handler = unique_ptr(new onixs::Handler(settings)); + handler->bindFeedEngine(*_engines.at(options.feed_engine())); + if (recovery) { + handler->bindTcpRecovery(*recovery); + _recovery.push_back(std::move(recovery)); + } + if (logger) { + handler->bindLogger(*logger); + } + + return handler; + } + catch (std::exception& e) { + LOG(md,Error,"{}", std::string(e.what())); + throw; + } +} + +// +// Create a listener for this channel and register callbacks +unique_ptr MDP3Main::prepare_listener(onixs::Handler& handler, const CMEChannel& channel) { + // We need to get a handler to the producer channels so we can produce heartbeats + vector producer_channels; + for (auto& symbol : channel.symbols) { + producer_channels.push_back(_producer.get_channel(symbol.symbol().c_str(), symbol.type(), symbol.exchange())); + } + + const auto& options = channel_settings_for(channel.id); + + unique_ptr listener(new MDP3Listener(_index, _producer, /*_settlement_recorder,*/ producer_channels)); + for (auto& symbol : channel.symbols) { + listener->add_filter_symbol(symbol.symbol()); + } + + if (options.load_security_db()) { + // Load the list of known securities and add them to the index for fast startup + db::load_securities(channel.symbols, [&](const api::Security& security) { + with_security_like(security, [&](FixedSecurity& fs) { + convert_security(security, fs, true); + listener->add_security(fs); + }); + }); + } + + handler.registerListener(*listener); + handler.registerMarketDataListener(*listener); + handler.registerSecurityListener(*listener); + + return listener; +} + + +}}//namespace + diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h new file mode 100644 index 000000000..5e1b402c1 --- /dev/null +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h @@ -0,0 +1,48 @@ +#pragma once + +#include "lib/utils/bts_no_copy.h" +#include "lib/md/coconut2.h" +#include "ICEListener.h" +#include "ICESecurityIndex.h" +#include "onixs.h" + +#include +#include +#include + +namespace bts { +namespace md { + +// void run_onixs_ice_server(UserSymbol* sym, size_t symcount); + +struct ICEChannel; + +/* + * The ICE provider is very simple + * Control starts in ICEMain which gets a list of all the symbols we need and starts the onixs handlers + * There is a single listener for all callbacks which maps the exchange id to the MDProducerHandle and writes + * the data to it. + */ +class ICEMain +{ +public: + ICEMain(); + ~ICEMain(); + + void run(std::vector&); + void initialize(); + std::unique_ptr prepare_handler(const std::string& channel); + std::unique_ptr prepare_listener(onixs::Handler& handler, const ICEChannel& channel); + +private: + BTS_NO_COPY(ICEMain); + + ICESecurityIndex _index; + SecurityIDRecorder _recorder; + MDProducer _producer; + std::map> _handlers; + std::vector> _listeners; +}; + +}}//namespace + diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICESecurityIndex.h b/src/server/sparkd/md/platforms/ice_onixs/ICESecurityIndex.h new file mode 100644 index 000000000..7c2bddc17 --- /dev/null +++ b/src/server/sparkd/md/platforms/ice_onixs/ICESecurityIndex.h @@ -0,0 +1,19 @@ +#pragma once + +#include "lib/md/SecurityIndex.h" +#include + +namespace bts { +namespace md { + +struct SecurityData { + SecurityData(uint32_t id, MDProducerHandle& h) : id(id), handle(h), electronic_volume(0) {} + uint32_t id; // exchange id + MDProducerHandle handle; + uint32_t electronic_volume; +}; + +typedef ConcurrentSecurityIndex ICESecurityIndex; + +}}//namespace + diff --git a/src/server/sparkd/md/platforms/ice_onixs/onixs.h b/src/server/sparkd/md/platforms/ice_onixs/onixs.h new file mode 100644 index 000000000..07b56a6e9 --- /dev/null +++ b/src/server/sparkd/md/platforms/ice_onixs/onixs.h @@ -0,0 +1,7 @@ +#pragma once +#include + +// namespace onixs = OnixS::CME::MDH; +namespace onixs { + using namespace OnixS::ICE::iMpact::MarketData; +} \ No newline at end of file diff --git a/src/server/sparkd/md/platforms/ice_onixs/tests/ice_tests.cpp b/src/server/sparkd/md/platforms/ice_onixs/tests/ice_tests.cpp new file mode 100644 index 000000000..0358d1741 --- /dev/null +++ b/src/server/sparkd/md/platforms/ice_onixs/tests/ice_tests.cpp @@ -0,0 +1,210 @@ +// #include "catch/catch.hpp" + +// #include "lib/config/config.h" +// #include "lib/config/protos/MarketData.pb.h" + +// #include +// #include +// #include +// #include + +// #include "../MDP3Utils.h" +// #include "../onixs.h" + +// using namespace bts::md; +// using namespace std; + + +// namespace bts { +// namespace md { + +// map create_feed_engine_settings(const std::vector& channels); +// const CMEOptions::CMEChannel channel_settings_for(const string& id); + +// namespace test { + +// vector test_channels(int count, ...) { +// // Doing this the C way because I still haven't updated VS +// vector result; +// va_list ap; +// va_start(ap, count); +// for (int x = 0; x < count; ++x) { +// const char* val = va_arg(ap, char*); +// CMEChannel temp; +// temp.id = val; +// result.push_back(temp); +// } +// va_end(ap); +// return result; +// } + + +// TEST_CASE("mdp3_tests","[md]") { +// SECTION("test_defaults") { +// config::internal::initialize_for_test("CMEOptions {}"); + +// vector channels = test_channels(1, "310"); +// auto result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); + +// channels = test_channels(2, "310", "311"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); + +// channels = test_channels(4, "310", "311", "400", "412"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); + +// REQUIRE(!channel_settings_for("310").has_feed_engine()); +// REQUIRE(!channel_settings_for("311").has_feed_engine()); +// REQUIRE(!channel_settings_for("315").has_feed_engine()); +// } + +// SECTION("test_segregate_futures") { +// config::internal::initialize_for_test( +// "CMEOptions {\n" +// " value {\n" +// " feed_engine {\n" +// " name: 'default'\n" +// " }\n" +// " feed_engine {\n" +// " name: 'futures'\n" +// " num_threads: 4\n" +// " }\n" +// " # Futures\n" +// " channel {\n" +// " id: '310'\n" +// " id: '312'\n" +// " feed_engine: 'futures'\n" +// " }\n" +// " # Options\n" +// " channel {\n" +// " id: '311'\n" +// " id: '313'\n" +// " id: '315'\n" +// " feed_engine: 'default'\n" +// " }\n" +// " }\n" +// "}"); + +// vector channels = test_channels(1, "310"); +// auto result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 1); +// REQUIRE(result.begin()->first == "futures"); +// REQUIRE(result.begin()->second.threadsCount() == 4); + +// channels = test_channels(1, "311"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 1); +// REQUIRE(result.begin()->first == "default"); +// REQUIRE(result.begin()->second.threadsCount() == 1); + +// channels = test_channels(2, "311", "310"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 2); +// REQUIRE(result["default"].threadsCount() == 1); +// REQUIRE(result["futures"].threadsCount() == 4); + +// // Test channels not listed in config +// channels = test_channels(2, "317", "318"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); +// } + +// SECTION("test_no_default") { +// config::internal::initialize_for_test( +// "CMEOptions {\n" +// " value {\n" +// " feed_engine {\n" +// " name: 'futures'\n" +// " num_threads: 4\n" +// " }\n" +// " # any channel not listed will use the default feed engine\n" +// " # Futures\n" +// " channel {\n" +// " id: '310'\n" +// " id: '312'\n" +// " feed_engine: 'futures'\n" +// " }\n" +// " # Options\n" +// " channel {\n" +// " id: '311'\n" +// " id: '313'\n" +// " id: '315'\n" +// " use_tcp_replay: false\n" +// " }\n" +// " }\n" +// "}"); + +// vector channels = test_channels(1, "310"); +// auto result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 1); +// REQUIRE(result.begin()->first == "futures"); +// REQUIRE(result.begin()->second.threadsCount() == 4); + +// channels = test_channels(1, "311"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); + +// channels = test_channels(2, "311", "310"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 1); +// REQUIRE(result["futures"].threadsCount() == 4); + + +// REQUIRE(channel_settings_for("310").use_tcp_replay() == true); +// REQUIRE(channel_settings_for("311").use_tcp_replay() == false); +// REQUIRE(channel_settings_for("315").use_tcp_replay() == false); +// } + +// SECTION("test_one_thread_each") { +// config::internal::initialize_for_test( +// "CMEOptions {\n" +// " value {\n" +// " channel {\n" +// " id: '*'\n" +// " }\n" +// " }\n" +// "}\n"); + +// vector channels = test_channels(1, "310", "311"); +// auto result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); + +// const auto& settings = channel_settings_for("311"); +// REQUIRE(!settings.has_feed_engine()); +// } + +// SECTION("test_common_futures_thread") { +// config::internal::initialize_for_test( +// "CMEOptions {\n" +// " value {\n" +// " feed_engine {\n" +// " name: 'futures'\n" +// " num_threads: 4\n" +// " }\n" +// " channel {\n" +// " id: '310'\n" +// " feed_engine: 'futures'\n" +// " udp_socket_buffer_size: 1234\n" +// " }\n" +// " channel {\n" +// " id: '*'\n" +// " }\n" +// " }\n" +// "}\n"); + +// vector channels = test_channels(6, "310", "311", "315", "100", "10", "42"); +// auto result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 1); +// result = create_feed_engine_settings(test_channels(1, "315")); +// REQUIRE(result.size() == 0); + +// REQUIRE(!channel_settings_for("311").has_feed_engine()); +// REQUIRE(channel_settings_for("310").has_feed_engine()); +// REQUIRE(channel_settings_for("310").udp_socket_buffer_size() == 1234); +// REQUIRE(channel_settings_for("311").has_udp_socket_buffer_size() == false); +// } +// } + +// }}}//namespace From 2b4add85a2cf9ce13dd6f0b50f0fa67fc41cc2d1 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Tue, 12 Feb 2019 13:00:47 -0500 Subject: [PATCH 04/72] kinda copy / pastey stuff from cme --- externals | 2 +- src/lib/config/defaults/MarketData.conf | 1 + src/lib/config/protos/MarketData.proto | 2 + src/lib/md/PlatformLoader.cpp | 2 + src/lib/md/ice/ICEUtils.cpp | 39 ++++------- src/lib/md/ice/ICEUtils.h | 69 ------------------- src/lib/md/protos/co2.proto | 1 + .../sparkd/md/platforms/ice_onixs/ICEMain.cpp | 6 +- 8 files changed, 25 insertions(+), 97 deletions(-) diff --git a/externals b/externals index 430a9c6b5..c0941c565 160000 --- a/externals +++ b/externals @@ -1 +1 @@ -Subproject commit 430a9c6b5cb063710f961ef9878b6eb3cd4602d9 +Subproject commit c0941c5650a2a136cb036960d009fb8a16fb1165 diff --git a/src/lib/config/defaults/MarketData.conf b/src/lib/config/defaults/MarketData.conf index 17d800d6b..da31831bb 100644 --- a/src/lib/config/defaults/MarketData.conf +++ b/src/lib/config/defaults/MarketData.conf @@ -10,6 +10,7 @@ MarketDataConfig { PlatformMap { value { glbx_platform: "PLATFORM_MDP3ONIXS" + ice_platform: "PLATFORM_ICEONIXS" } } diff --git a/src/lib/config/protos/MarketData.proto b/src/lib/config/protos/MarketData.proto index 4dde48bc2..f864786e5 100755 --- a/src/lib/config/protos/MarketData.proto +++ b/src/lib/config/protos/MarketData.proto @@ -12,6 +12,8 @@ message PlatformMap { // PLATFORM_MDP3ONIXS optional string glbx_platform = 1 [default = "PLATFORM_SIM"]; + // PLATFORM_ICEONIXS + optional string ice_platform = 1 [default = "PLATFORM_SIM"]; } diff --git a/src/lib/md/PlatformLoader.cpp b/src/lib/md/PlatformLoader.cpp index acd1ace54..21ef4c02e 100644 --- a/src/lib/md/PlatformLoader.cpp +++ b/src/lib/md/PlatformLoader.cpp @@ -61,6 +61,8 @@ void PlatformLoader::run() { switch (_platform) { case PLATFORM_MDP3ONIXS: break; + case PLATFORM_ICEONIXS: + break; default: bts_assert(false); break; diff --git a/src/lib/md/ice/ICEUtils.cpp b/src/lib/md/ice/ICEUtils.cpp index 44144916f..a71e9879d 100644 --- a/src/lib/md/ice/ICEUtils.cpp +++ b/src/lib/md/ice/ICEUtils.cpp @@ -38,14 +38,14 @@ const string production_config_path() { return data_path() + "ConnectivityConfig const std::string log_path() {return log:: log_path().string() + "/onix_ice";} bool check_file_exists_with_instructions(const string& filename, const string& url, bool log) { - if (!boost::filesystem::exists(filename)) { - download_file(url.c_str(), filename.c_str()); - } + // if (!boost::filesystem::exists(filename)) { + // download_file(url.c_str(), filename.c_str()); + // } if (!boost::filesystem::exists(filename)) { if (log) { LOG(md,Error, "File {} is not present on this system. " - "Please download it from the CME ftp site. " + "Please download it from the ICE web site. " "I will wait until the file is present.\n$ curl {} > {} ", filename, url, filename); } @@ -57,17 +57,14 @@ bool check_file_exists_with_instructions(const string& filename, const string& u // For exponential backoff on logging this return true if x is a power of 2 or 0 bool is_pow_two_or_0(uint32_t x) { return (x & (~x + 1)) == x; } -void await_cme_config() { +void await_ice_config() { std::string config_url; - std::string templates_url; if (config::get().type() != "dev") { - config_url = "ftp://ftp.cmegroup.com/SBEFix/Production/Configuration/config.xml"; - templates_url = "ftp://ftp.cmegroup.com/SBEFix/Production/Templates/templates_FixBinary.xml"; + config_url = "https://community.theice.com/docs/DOC-19989"; } else { - config_url = "ftp://ftp.cmegroup.com/SBEFix/Cert/Configuration/config.xml"; - templates_url = "ftp://ftp.cmegroup.com/SBEFix/Cert/Templates/templates_FixBinary.xml"; + config_url = "https://community.theice.com/docs/DOC-19989"; } boost::filesystem::create_directories(data_path()); @@ -80,12 +77,6 @@ void await_cme_config() { ++count; std::this_thread::sleep_for(1s); } - count = 0; - while(!check_file_exists_with_instructions(template_path(), templates_url, is_pow_two_or_0(count))) { - ++count; - std::this_thread::sleep_for(1s); - } - // If we waited for someone to download the file give it a second to be finished downloading if (count > 0) { std::this_thread::sleep_for(1s); @@ -104,17 +95,17 @@ SecurityType infer_security_type(const string& label) { // TODO: Allow configuration to override this? LOG(md,Warn,"Unable to guess security type from label: '{}" "' Treating as OPTION.",label); - return SECURITYTYPE_OPTION; + return SECURITYTYPE_FUTURE; } -const std::vector get_configured_cme_channels() { +const std::vector get_configured_ice_channels() { std::vector symbols; // Get all glbx symbols - get_system_md_symbols(api::VENUE_GLBX, api::SECURITYTYPE_UNSET, &symbols); + get_system_md_symbols(api::VENUE_ICE, api::SECURITYTYPE_UNSET, &symbols); return parse_channels(symbols); } -const vector parse_channels(const vector& symbols) { - vector result; +const vector parse_channels(const vector& symbols) { + vector result; bool skip_options = config::get().skip_options(); pugi::xml_document doc; @@ -123,12 +114,12 @@ const vector parse_channels(const vector& symbols) { auto configuration = doc.root().child("configuration"); bts_assert(configuration); - LOG(md,Info,"CME: Loaded '{}' config. Last updated: {}" , + LOG(md,Info,"ICE: Loaded '{}' config. Last updated: {}" , std::string(configuration.attribute("environment").as_string("??")), std::string(configuration.attribute("updated").as_string("??"))); auto channels = configuration.children("channel"); for (const auto& chan : channels) { - CMEChannel channel; + ICEChannel channel; channel.id = chan.attribute("id").as_string(); auto channel_type = infer_security_type(chan.attribute("label").as_string()); if (channel_type == SECURITYTYPE_OPTION && skip_options) continue; @@ -148,7 +139,7 @@ const vector parse_channels(const vector& symbols) { for (const auto& srccon : connections) { std::string id = srccon.attribute("id").as_string(); if (!id.empty()) { - CMEConnection connection; + ICEConnection connection; connection.feed_type = srccon.child("type").attribute("feed-type").as_string(); connection.ip = srccon.child_value("ip"); connection.port = srccon.child("port").text().as_uint(); diff --git a/src/lib/md/ice/ICEUtils.h b/src/lib/md/ice/ICEUtils.h index f412364d7..5c67020eb 100644 --- a/src/lib/md/ice/ICEUtils.h +++ b/src/lib/md/ice/ICEUtils.h @@ -29,75 +29,6 @@ const std::string config_path(); const std::string template_path(); const std::string log_path(); -inline void decode_ticks(int vtt, double mintick, FixedSecurity& dest) { - switch(vtt) { - default: - case 0: - dest.low_tick = mintick; - dest.high_tick = mintick; - dest.price_break = 0; - break; - case 1: - dest.price_break = 500; - dest.low_tick = 5; - dest.high_tick = 10; - break; - case 2: - dest.price_break = 5; - dest.low_tick = 0.5; - dest.high_tick = 1; - break; - case 3: - dest.price_break = 10; - dest.low_tick = 1; - dest.high_tick = 2; - break; - case 4: - dest.price_break = 500; - dest.low_tick = 5; - dest.high_tick = 25; - break; - case 10: - dest.price_break = 300; - dest.low_tick = 5; - dest.high_tick = 25; - break; - case 11: - dest.price_break = 300; - dest.low_tick = 5; - dest.high_tick = 10; - break; - case 12: - dest.price_break = 5; - dest.low_tick = 0.25; - dest.high_tick = 0.5; - break; - } -} - -inline int floorlog10(int64_t m) { - bts_assert(m >= 0); - if (m < 10) return 0; - if (m < 100) return 1; - if (m < 1000) return 2; - if (m < 10000) return 3; - if (m < 100000) return 4; - if (m < 1000000) return 5; - if (m < 10000000) return 6; - if (m < 100000000) return 7; - if (m < 1000000000) return 8; - if (m < 10000000000) return 9; - if (m < 100000000000) return 10; - if (m < 1000000000000) return 11; - if (m < 10000000000000) return 12; - if (m < 100000000000000) return 13; - if (m < 1000000000000000) return 14; - if (m < 10000000000000000) return 15; - if (m < 100000000000000000) return 16; - if (m < 1000000000000000000) return 17; - return 19; -} - }}//namespace diff --git a/src/lib/md/protos/co2.proto b/src/lib/md/protos/co2.proto index b05794f9c..8d5355be6 100644 --- a/src/lib/md/protos/co2.proto +++ b/src/lib/md/protos/co2.proto @@ -11,6 +11,7 @@ enum Platform { PLATFORM_MDP3ONIXS = 10; PLATFORM_CELOXICA = 13; PLATFORM_MDP3EMUMBA = 14; + PLATFORM_ICEONIXS = 15; } enum TradingStatus { diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp index 82d6aa0de..8e57ad375 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp @@ -1,6 +1,6 @@ -#include "MDP3Main.h" +#include "ICEMain.h" -#include "lib/md/cme/MDP3Utils.h" +#include "lib/md/cme/ICEUtils.h" #include "lib/config/config.h" #include "lib/md/coconut2.h" #include "lib/md/SecurityDB.h" @@ -25,7 +25,7 @@ using std::size_t; namespace bts { namespace md { -MDP3Main::MDP3Main() : +ICEMain::ICEMain() : _index(), _recorder ({ utils::Dispatcher::current(), [=](ExchangeKey k) { return SecurityKey(_index.get_key(k.value())); } }), _producer(PLATFORM_MDP3ONIXS, _recorder ), From 97f09768bb717b0e3f90785cc97fbecb07bf0de8 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Thu, 14 Feb 2019 17:55:34 -0500 Subject: [PATCH 05/72] got the boilerplate up, now just need to get the right ice handlers and options in there --- externals | 2 +- src/lib/config/protos/MarketData.proto | 59 ++++++++++++++++++- src/lib/md/cme/MDP3Utils.cpp | 3 +- src/lib/md/ice/ICEUtils.cpp | 24 ++++---- src/lib/md/ice/ICEUtils.h | 7 +-- .../md/platforms/ice_onixs/ICEListener.cpp | 52 ++++++++-------- .../md/platforms/ice_onixs/ICEListener.h | 36 +++++------ .../platforms/ice_onixs/ICEListenerHelpers.h | 2 +- .../sparkd/md/platforms/ice_onixs/ICEMain.cpp | 54 ++++++++--------- 9 files changed, 148 insertions(+), 91 deletions(-) diff --git a/externals b/externals index c0941c565..430a9c6b5 160000 --- a/externals +++ b/externals @@ -1 +1 @@ -Subproject commit c0941c5650a2a136cb036960d009fb8a16fb1165 +Subproject commit 430a9c6b5cb063710f961ef9878b6eb3cd4602d9 diff --git a/src/lib/config/protos/MarketData.proto b/src/lib/config/protos/MarketData.proto index f864786e5..921177db4 100755 --- a/src/lib/config/protos/MarketData.proto +++ b/src/lib/config/protos/MarketData.proto @@ -13,7 +13,7 @@ message PlatformMap // PLATFORM_MDP3ONIXS optional string glbx_platform = 1 [default = "PLATFORM_SIM"]; // PLATFORM_ICEONIXS - optional string ice_platform = 1 [default = "PLATFORM_SIM"]; + optional string ice_platform = 2 [default = "PLATFORM_SIM"]; } @@ -115,6 +115,63 @@ message CMEOptions optional bool verbose_ticker = 7 [default=false]; } +// +// CME Options +// +message ICEOptions +{ + enum OnixSLogMode { + None = 0; + Important = 10; + Regular = 50; + Debug = 100; + } + message FeedEngineSettings { + optional string name = 1; + // If num_threads is set it will use that - otherwise it will use channels_per_thread and the number of threads configured for this channel to determine the number of threads + optional uint32 num_threads = 2 [default = 1]; + // Defines amount of time Feed Engine spends on socket waiting for I/O while running master processing loop. + optional uint32 data_wait = 3 [default = 10]; + // Defines amount of time Feed Engine keeps cycling before going to sleep when no useful activity can be done + optional uint32 spin_time = 4 [default = 1]; + optional uint32 channels_per_thread = 5 [default = 3]; + optional uint32 udp_socket_buffer_size = 11 [default = 33554432]; //32mb + } + message ICEChannel { + repeated string id = 2; + optional string feed_engine = 3 [default = "default"]; + + + optional uint32 max_gap_recovery_cache_size = 11 [default = 6]; + optional uint32 lost_packet_wait_timeout_ms = 12 [default = 10]; + optional OnixSLogMode onixs_log_mode = 13 [default = Important]; + optional bool prefer_backup_feeds = 15 [default = false]; + + optional bool use_tcp_replay = 20 [default = true]; + optional string tcp_replay_username = 21 [default = "MDPFFBLUE"]; + optional string tcp_replay_password = 22 [default = "password01"]; + optional int32 tcp_replay_connect_attempts = 23 [default = 3]; + optional int32 tcp_replay_reconnect_interval_ms = 24 [default = 30000]; + optional int32 tcp_replay_timeout_s = 25 [default = 10]; + + optional uint32 recovery_queue_size = 30 [default = 640000]; + optional bool use_natural_refresh = 31 [default = false]; + optional bool join_snapshot_on_gap = 32 [default = false]; + + optional bool load_security_db = 33 [default = true]; + reserved 34; + // optional BookType book_type = 34 [default = BOOKTYPE_CONSOLIDATED]; + + } + optional string onixs_license = 1 [default = "{default}"]; + repeated ICEChannel channel = 3; + repeated FeedEngineSettings feed_engine = 5; + + // Prevents parsing trades/rfqs/doing anything not required for quoting + optional bool quoter_mode = 6; + optional bool verbose_ticker = 7 [default=false]; +} + message RecordOptions { // optional string output_path = 2 [default = "/home/bts/md/today"]; optional bool enable_depth = 3 [default = false]; diff --git a/src/lib/md/cme/MDP3Utils.cpp b/src/lib/md/cme/MDP3Utils.cpp index 3e027653d..42041ea28 100644 --- a/src/lib/md/cme/MDP3Utils.cpp +++ b/src/lib/md/cme/MDP3Utils.cpp @@ -20,6 +20,7 @@ using namespace bts::api; namespace bts { namespace md { +namespace cme { string data_path() { auto p = config::get().data_path() + "cme_mdp3/"; @@ -163,5 +164,5 @@ const vector parse_channels(const vector& symbols) { return result; } -}}//namespace +}}}//namespace #endif \ No newline at end of file diff --git a/src/lib/md/ice/ICEUtils.cpp b/src/lib/md/ice/ICEUtils.cpp index a71e9879d..e9527ed1a 100644 --- a/src/lib/md/ice/ICEUtils.cpp +++ b/src/lib/md/ice/ICEUtils.cpp @@ -21,7 +21,7 @@ using namespace bts::api; namespace bts { namespace md { -string data_path() { +string ice_data_path() { auto p = config::get().data_path() + "ice/"; #ifdef _WIN32 // OnixS requires win32 paths to look like Win32 paths - everyone else in the world is ok with '/' @@ -31,13 +31,13 @@ string data_path() { #endif return p; } -const string api_test_config_path() { return data_path() + "ConnectivityConfiguration.APITest.xml"; } -const string perf_test_config_path() { return data_path() + "ConnectivityConfiguration.PerfTest.xml"; } -const string production_config_path() { return data_path() + "ConnectivityConfiguration.Production.xml"; } +const string api_test_config_path() { return ice_data_path() + "ConnectivityConfiguration.APITest.xml"; } +const string perf_test_config_path() { return ice_data_path() + "ConnectivityConfiguration.PerfTest.xml"; } +const string ice_config_path() { return ice_data_path() + "ConnectivityConfiguration.Production.xml"; } -const std::string log_path() {return log:: log_path().string() + "/onix_ice";} +const std::string ice_log_path() {return log:: log_path().string() + "/onix_ice";} -bool check_file_exists_with_instructions(const string& filename, const string& url, bool log) { +bool ice_check_file_exists_with_instructions(const string& filename, const string& url, bool log) { // if (!boost::filesystem::exists(filename)) { // download_file(url.c_str(), filename.c_str()); // } @@ -67,13 +67,13 @@ void await_ice_config() { config_url = "https://community.theice.com/docs/DOC-19989"; } - boost::filesystem::create_directories(data_path()); - boost::filesystem::create_directories(log_path()); + boost::filesystem::create_directories(ice_data_path()); + boost::filesystem::create_directories(ice_log_path()); // Check config is present and give instructions for downloading it if not // If the file is not present log an error and wait a second. Continue to log the error ever power of 2 seconds until the file appears or the process is killed. uint32_t count = 0; - while(!check_file_exists_with_instructions(config_path(), config_url, is_pow_two_or_0(count))) { + while(!ice_check_file_exists_with_instructions(ice_config_path(), config_url, is_pow_two_or_0(count))) { ++count; std::this_thread::sleep_for(1s); } @@ -102,14 +102,14 @@ const std::vector get_configured_ice_channels() { std::vector symbols; // Get all glbx symbols get_system_md_symbols(api::VENUE_ICE, api::SECURITYTYPE_UNSET, &symbols); - return parse_channels(symbols); + return parse_ice_channels(symbols); } -const vector parse_channels(const vector& symbols) { +const vector parse_ice_channels(const vector& symbols) { vector result; bool skip_options = config::get().skip_options(); pugi::xml_document doc; - bts_assert_msg(doc.load_file(config_path().c_str()), "Error parsing config.xml as xml"); + bts_assert_msg(doc.load_file(ice_config_path().c_str()), "Error parsing config.xml as xml"); auto configuration = doc.root().child("configuration"); bts_assert(configuration); diff --git a/src/lib/md/ice/ICEUtils.h b/src/lib/md/ice/ICEUtils.h index 5c67020eb..604ad1b81 100644 --- a/src/lib/md/ice/ICEUtils.h +++ b/src/lib/md/ice/ICEUtils.h @@ -23,11 +23,10 @@ struct ICEChannel { void await_ice_config(); const std::vector get_configured_ice_channels(); -const std::vector parse_channels(const std::vector& symbols); +const std::vector parse_ice_channels(const std::vector& symbols); -const std::string config_path(); -const std::string template_path(); -const std::string log_path(); +const std::string ice_config_path(); +const std::string ice_log_path(); }}//namespace diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp index 6049e982b..34c873f22 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp @@ -1,4 +1,4 @@ -#include "MDP3Listener.h" +#include "ICEListener.h" #include "lib/utils/datetime.h" #include #include "lib/utils/helper_macros.h" @@ -12,14 +12,14 @@ namespace bts { namespace md { -MDP3Listener::MDP3Listener( - CMESecurityIndex& index, +ICEListener::ICEListener( + ICESecurityIndex& index, MDProducer& producer, // co2::SettlementRecorder& , const std::vector channels) : _index(index), _producer(producer), - _verbose_ticker(config::get().verbose_ticker()), + _verbose_ticker(config::get().verbose_ticker()), _packet_arrived(), _latest_sequence(0), // _settlement_recorder(settles), @@ -32,47 +32,47 @@ MDP3Listener::MDP3Listener( _book_updates.reserve(32); } -MDP3Listener::~MDP3Listener() { +ICEListener::~ICEListener() { } // // Warnings/Errors -void MDP3Listener::onError(onixs::Handler&, const onixs::ErrorArgs& error) { +void ICEListener::onError(onixs::Handler&, const onixs::ErrorArgs& error) { tracepoint (bts_trace,trace_order,(char*) "onError", _latest_sequence, (uint16_t) _latest_sequence, 0); LOG(md,Warn, "OnixS Error: {} - {}", error.description(), error.source()); } -void MDP3Listener::onWarning(onixs::Handler&, const onixs::WarningArgs& warning) { +void ICEListener::onWarning(onixs::Handler&, const onixs::WarningArgs& warning) { tracepoint (bts_trace,trace_order,(char*) "onWarning", _latest_sequence, (uint16_t) _latest_sequence, 0); LOG(md,Warn, "OnixS Warn: {} - {}", warning.description(), warning.source()); } -void MDP3Listener::onInstrumentRecovery(onixs::Handler& h) { +void ICEListener::onInstrumentRecovery(onixs::Handler& h) { tracepoint (bts_trace,trace_order,(char*) "onInstrumentRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); LOG(md,Info, "Beginning security definition recovery for channel {}", h.settings().channel()); } -void MDP3Listener::onEndOfInstrumentRecovery(onixs::Handler& h, const onixs::RecoveryCompletionArgs&) { +void ICEListener::onEndOfInstrumentRecovery(onixs::Handler& h, const onixs::RecoveryCompletionArgs&) { tracepoint (bts_trace,trace_order,(char*) "onEndOfInstrumentRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); LOG(md,Info, "Finished Security definition recovery for channel {}", h.settings().channel()); } // // Gap Recovery -void MDP3Listener::onMarketRecovery(onixs::Handler& h) { +void ICEListener::onMarketRecovery(onixs::Handler& h) { tracepoint (bts_trace,trace_order,(char*) "onMarketRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); update_all_status(COCONUTSECURITYSTATUS_PACKET_LOSS); for (auto& c : _channels) { c.gap(); } LOG(md,Info, "Beginning market recovery for channel {}", h.settings().channel()); } -void MDP3Listener::onEndOfMarketRecovery(onixs::Handler& h, const onixs::RecoveryCompletionArgs&) { +void ICEListener::onEndOfMarketRecovery(onixs::Handler& h, const onixs::RecoveryCompletionArgs&) { tracepoint (bts_trace,trace_order,(char*) "onEndOfMarketRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); update_all_status(COCONUTSECURITYSTATUS_OK); LOG(md,Info, "Finished market recovery for channel {}", h.settings().channel()); } -void MDP3Listener::onTcpRecovery(onixs::Handler& h) { +void ICEListener::onTcpRecovery(onixs::Handler& h) { tracepoint (bts_trace,trace_order,(char*) "onTcpRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); update_all_status(COCONUTSECURITYSTATUS_PACKET_LOSS); LOG(md,Info, "Beginning tcp recovery for channel {}", h.settings().channel()); } -void MDP3Listener::onEndOfTcpRecovery(onixs::Handler& h, const onixs::RecoveryCompletionArgs&) { +void ICEListener::onEndOfTcpRecovery(onixs::Handler& h, const onixs::RecoveryCompletionArgs&) { tracepoint (bts_trace,trace_order,(char*) "onEndOfTcpRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); update_all_status(COCONUTSECURITYSTATUS_OK); LOG(md,Info, "Finished tcp recovery for channel {}", h.settings().channel()); @@ -80,7 +80,7 @@ void MDP3Listener::onEndOfTcpRecovery(onixs::Handler& h, const onixs::RecoveryCo // // Mark the start/end of a packet -void MDP3Listener::onPacket(onixs::Handler&, const onixs::PacketArgs& args) { +void ICEListener::onPacket(onixs::Handler&, const onixs::PacketArgs& args) { // Mark the arrival of the packet _packet_arrived = TimeStamp::now(); auto seq = args.seqNumber(); @@ -92,7 +92,7 @@ void MDP3Listener::onPacket(onixs::Handler&, const onixs::PacketArgs& args) { } _latest_sequence = seq; auto onixs_zero = args.receiveTime().sinceEpoch(); - auto onixs_now = OnixS::CME::MDH::UtcWatch::now().sinceEpoch(); + auto onixs_now = OnixS::ICE::MDH::UtcWatch::now().sinceEpoch(); // needed for clang compilation UNUSED(onixs_zero); @@ -102,7 +102,7 @@ void MDP3Listener::onPacket(onixs::Handler&, const onixs::PacketArgs& args) { tracepoint (bts_trace,trace_order,(char*) "onPacket", _latest_sequence,(uint16_t) _latest_sequence, onixs_now-onixs_zero); } -void MDP3Listener::onEndOfPacket(onixs::Handler&, const onixs::PacketArgs&) { +void ICEListener::onEndOfPacket(onixs::Handler&, const onixs::PacketArgs&) { tracepoint (bts_trace,trace_order,(char*) "onEndOfPacket.begin", _latest_sequence, (uint16_t) _latest_sequence, 0); flush_books(); tracepoint (bts_trace,trace_order,(char*) "onEndOfPacket.end", _latest_sequence, (uint16_t) _latest_sequence, 0); @@ -111,11 +111,11 @@ void MDP3Listener::onEndOfPacket(onixs::Handler&, const onixs::PacketArgs&) { // // Security discovery -void MDP3Listener::onBookUpdate(onixs::Handler&, const onixs::Security& sec, const onixs::DirectBook& book) { +void ICEListener::onBookUpdate(onixs::Handler&, const onixs::Security& sec, const onixs::DirectBook& book) { onBookUpdate(sec, book, book_type_direct); } -void MDP3Listener::onBookUpdate(onixs::Handler&, const onixs::Security& sec, const onixs::ImpliedBook& book) { +void ICEListener::onBookUpdate(onixs::Handler&, const onixs::Security& sec, const onixs::ImpliedBook& book) { onBookUpdate(sec, book, book_type_implied); } @@ -143,7 +143,7 @@ void on_trade(SecurityData* data, const onixs::Decimal& price, int size, onixs:: // // RFQ -void MDP3Listener::onQuoteRequest(onixs::Handler&, const onixs::Security& sec, const onixs::QuoteRequest39RelatedSymArgs& arg) { +void ICEListener::onQuoteRequest(onixs::Handler&, const onixs::Security& sec, const onixs::QuoteRequest39RelatedSymArgs& arg) { tracepoint (bts_trace,trace_order,(char*) "onQuoteRequest", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(sec.id()); if (data != nullptr) { @@ -192,7 +192,7 @@ void MDP3Listener::onQuoteRequest(onixs::Handler&, const onixs::Security& sec, c // // Volume -void MDP3Listener::onElectronicVolume(onixs::Handler&, const onixs::Security& sec, const onixs::Volume37Args& args) { +void ICEListener::onElectronicVolume(onixs::Handler&, const onixs::Security& sec, const onixs::Volume37Args& args) { tracepoint (bts_trace,trace_order,(char*) "onElectronicVolume.volume", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(sec.id()); if (data != nullptr) { @@ -206,7 +206,7 @@ void MDP3Listener::onElectronicVolume(onixs::Handler&, const onixs::Security& se // // Non-onixs calls -void MDP3Listener::add_filter_symbol(const std::string& symbol) { +void ICEListener::add_filter_symbol(const std::string& symbol) { _symbol_filter_storage.push_back(symbol); _symbol_filter.clear(); for (const auto& str : _symbol_filter_storage) { @@ -214,14 +214,14 @@ void MDP3Listener::add_filter_symbol(const std::string& symbol) { } } -void MDP3Listener::heartbeat() { +void ICEListener::heartbeat() { for (auto& c : _channels) { c.heartbeat(); } } // // Private functions -void MDP3Listener::add_security(const FixedSecurity& security) { +void ICEListener::add_security(const FixedSecurity& security) { // Set up the shared memory for this security auto handle = _producer.add_security(security); bts_assert(security.numeric_id != 0); @@ -229,7 +229,7 @@ void MDP3Listener::add_security(const FixedSecurity& security) { _index.add_security(security.numeric_id, handle); } -void MDP3Listener::flush_books() { +void ICEListener::flush_books() { // This is called at the end of the packet // Write all book updates to shared memory and reset for the next packet for (auto& entry : _book_updates) { @@ -253,13 +253,13 @@ void MDP3Listener::flush_books() { _book_updates.clear(); } -void MDP3Listener::update_all_status(CoconutSecurityStatus status) { +void ICEListener::update_all_status(CoconutSecurityStatus status) { _index.walk_security_list([=](SecurityData& data) { data.handle.set_status(status); }); } -md::MDP3Listener::BookData::BookData(MDProducerHandle & handle) : handle(handle), type_flags(0), bids(), asks() { } +md::ICEListener::BookData::BookData(MDProducerHandle & handle) : handle(handle), type_flags(0), bids(), asks() { } }}//namespace diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h index 787628750..8d984cfba 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h @@ -18,7 +18,7 @@ namespace bts { namespace md { -class MDP3Listener : +class ICEListener : public onixs::HandlerListener, public onixs::MarketDataListener, public onixs::SecurityListener @@ -29,11 +29,11 @@ class MDP3Listener : static constexpr BookType book_type_both=(book_type_direct|book_type_implied); public: - MDP3Listener(CMESecurityIndex& index, + ICEListener(ICESecurityIndex& index, MDProducer&, // co2::SettlementRecorder&, const std::vector); - virtual ~MDP3Listener(); + virtual ~ICEListener(); // // Warnings/Errors/Info @@ -180,7 +180,7 @@ private: void flush_books(); void update_all_status(co2::CoconutSecurityStatus status); - CMESecurityIndex& _index; + ICESecurityIndex& _index; MDProducer& _producer; bool _verbose_ticker; utils::TimeStamp _packet_arrived; @@ -224,7 +224,7 @@ void set_security_common(const Definition& def, FixedSecurity& fsec) { template -void MDP3Listener::onFuture(onixs::Handler&, const onixs::Security& osec, const InstrumentDefinition& def) { +void ICEListener::onFuture(onixs::Handler&, const onixs::Security& osec, const InstrumentDefinition& def) { tracepoint (bts_trace,trace_order,(char*) "onDefinition.future", _latest_sequence, (uint16_t) _latest_sequence, 0); const auto& sec = def.message(); auto exchange_id = sec.securityId(); @@ -254,7 +254,7 @@ void MDP3Listener::onFuture(onixs::Handler&, const onixs::Security& osec, const } template -void MDP3Listener::onOption(onixs::Handler&, const onixs::Security&, const InstrumentDefinition& def) { +void ICEListener::onOption(onixs::Handler&, const onixs::Security&, const InstrumentDefinition& def) { tracepoint (bts_trace,trace_order,(char*) "onDefinition.option", _latest_sequence, (uint16_t) _latest_sequence, 0); const auto& sec = def.message(); auto exchange_id = sec.securityId(); @@ -298,7 +298,7 @@ inline onixs::Decimal tick_rule(const onixs::InstrumentDefinitionSpread56& sec) } template -void MDP3Listener::onSpread(onixs::Handler&, const onixs::Security&, const InstrumentDefinition& spread_args) { +void ICEListener::onSpread(onixs::Handler&, const onixs::Security&, const InstrumentDefinition& spread_args) { tracepoint (bts_trace,trace_order,(char*) "onDefinition.spread", _latest_sequence, (uint16_t) _latest_sequence, 0); const auto& sec = spread_args.message(); auto exchange_id = sec.securityId(); @@ -347,7 +347,7 @@ void MDP3Listener::onSpread(onixs::Handler&, const onixs::Security&, const Instr } template -void MDP3Listener::onBookUpdate(const onixs::Security& sec, const TBook& onixs_book, BookType booktype) { +void ICEListener::onBookUpdate(const onixs::Security& sec, const TBook& onixs_book, BookType booktype) { tracepoint (bts_trace,trace_order,(char*) "onBookUpdate", _latest_sequence, (uint16_t) _latest_sequence, 0); auto data = _index.get_security(sec.id()); @@ -396,7 +396,7 @@ void MDP3Listener::onBookUpdate(const onixs::Security& sec, const TBook& onixs_b void on_trade(SecurityData* data, const onixs::Decimal& price, int size, onixs::AggressorSide::Enum agside, const onixs::Timestamp& onixs_date); template -void MDP3Listener::onTradeRecovery(const onixs::Security& sec, const TradeRecovery& arg) { +void ICEListener::onTradeRecovery(const onixs::Security& sec, const TradeRecovery& arg) { tracepoint (bts_trace,trace_order,(char*) "onTrade.recovery", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(sec.id()); if (data != NULL) { @@ -409,7 +409,7 @@ void MDP3Listener::onTradeRecovery(const onixs::Security& sec, const TradeRecove } template -void MDP3Listener::onTradeSummary(const onixs::Security& sec, const TradeSummary& arg) { +void ICEListener::onTradeSummary(const onixs::Security& sec, const TradeSummary& arg) { tracepoint (bts_trace,trace_order,(char*) "onTrade.summary", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(sec.id()); if (data != NULL) { @@ -433,7 +433,7 @@ void MDP3Listener::onTradeSummary(const onixs::Security& sec, const TradeSummary template -void MDP3Listener::onElectronicVolume(const onixs::Security& sec, const RecoveryEntryArgs& args) { +void ICEListener::onElectronicVolume(const onixs::Security& sec, const RecoveryEntryArgs& args) { tracepoint (bts_trace,trace_order,(char*) "onElectronicVolume.recovery", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(sec.id()); if (data) { @@ -445,7 +445,7 @@ void MDP3Listener::onElectronicVolume(const onixs::Security& sec, const Recovery } template -void MDP3Listener::onSettlementPrice(const onixs::Security& sec, const StatisticsArgs& args) { +void ICEListener::onSettlementPrice(const onixs::Security& sec, const StatisticsArgs& args) { tracepoint (bts_trace,trace_order,(char*) "onSettlementPrice.daily", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(sec.id()); if (data != nullptr) { @@ -462,7 +462,7 @@ void MDP3Listener::onSettlementPrice(const onixs::Security& sec, const Statistic } template -void MDP3Listener::onSessionOpeningPrice(const onixs::Security& sec, const SessionArgs& args) { +void ICEListener::onSessionOpeningPrice(const onixs::Security& sec, const SessionArgs& args) { tracepoint (bts_trace,trace_order,(char*) "onOpeningPrice.session", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(sec.id()); if (data != nullptr) { @@ -476,7 +476,7 @@ void MDP3Listener::onSessionOpeningPrice(const onixs::Security& sec, const Sessi } } template -void MDP3Listener::onRecoveryOpeningPrice(const onixs::Security& sec, const RecoveryArgs& args) { +void ICEListener::onRecoveryOpeningPrice(const onixs::Security& sec, const RecoveryArgs& args) { tracepoint (bts_trace,trace_order,(char*) "onOpeningPrice.recovery", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(sec.id()); if (data != nullptr) { @@ -493,7 +493,7 @@ void MDP3Listener::onRecoveryOpeningPrice(const onixs::Security& sec, const Reco } template -void MDP3Listener::onSessionHighTradePrice(const onixs::Security& sec, const SessionArgs& args) { +void ICEListener::onSessionHighTradePrice(const onixs::Security& sec, const SessionArgs& args) { tracepoint (bts_trace,trace_order,(char*) "onHighTradePrice.session", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(sec.id()); if (data != nullptr) { @@ -504,7 +504,7 @@ void MDP3Listener::onSessionHighTradePrice(const onixs::Security& sec, const Ses } } template -void MDP3Listener::onRecoveryHighTradePrice(const onixs::Security& sec, const RecoveryArgs& args) { +void ICEListener::onRecoveryHighTradePrice(const onixs::Security& sec, const RecoveryArgs& args) { tracepoint (bts_trace,trace_order,(char*) "onHighTradePrice.recovery", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(sec.id()); if (data != nullptr) { @@ -517,7 +517,7 @@ void MDP3Listener::onRecoveryHighTradePrice(const onixs::Security& sec, const Re } } template -void MDP3Listener::onSessionLowTradePrice(const onixs::Security& sec, const SessionArgs& args) { +void ICEListener::onSessionLowTradePrice(const onixs::Security& sec, const SessionArgs& args) { tracepoint (bts_trace,trace_order,(char*) "onLowTradePrice.session", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(sec.id()); if (data != nullptr) { @@ -528,7 +528,7 @@ void MDP3Listener::onSessionLowTradePrice(const onixs::Security& sec, const Sess } } template -void MDP3Listener::onRecoveryLowTradePrice(const onixs::Security& sec, const RecoveryArgs& args) { +void ICEListener::onRecoveryLowTradePrice(const onixs::Security& sec, const RecoveryArgs& args) { tracepoint (bts_trace,trace_order,(char*) "onLowTradePrice.recovery", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(sec.id()); if (data != nullptr) { diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h index 7c63a24df..0f0e4893c 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h @@ -1,5 +1,5 @@ #include "lib/utils/bts_assert.h" -#include "lib/md/cme/ICEUtils.h" +#include "lib/md/ice/ICEUtils.h" #include "lib/md/coconut2.h" #include "onixs.h" diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp index 8e57ad375..2e42c994c 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp @@ -1,6 +1,6 @@ #include "ICEMain.h" -#include "lib/md/cme/ICEUtils.h" +#include "lib/md/ice/ICEUtils.h" #include "lib/config/config.h" #include "lib/md/coconut2.h" #include "lib/md/SecurityDB.h" @@ -28,8 +28,8 @@ namespace md { ICEMain::ICEMain() : _index(), _recorder ({ utils::Dispatcher::current(), [=](ExchangeKey k) { return SecurityKey(_index.get_key(k.value())); } }), - _producer(PLATFORM_MDP3ONIXS, _recorder ), - // _settlement_recorder(PLATFORM_MDP3ONIXS), + _producer(PLATFORM_ICEONIXS, _recorder ), + // _settlement_recorder(PLATFORM_ICEONIXS), _engines(), _handlers(), _listeners(), @@ -37,27 +37,27 @@ ICEMain::ICEMain() : { } -MDP3Main::~MDP3Main() {} +ICEMain::~ICEMain() {} -const CMEOptions::CMEChannel channel_settings_for(const string& id) { - const auto& config = config::get(); +const ICEOptions::ICEChannel channel_settings_for(const string& id) { + const auto& config = config::get(); for (const auto& ch : config.channel()) { bool found = std::find_if(ch.id().begin(), ch.id().end(), [&](const string& chan_id) { return chan_id == id || chan_id == "*"; }) != ch.id().end(); if (found) { return ch; } } - return CMEOptions::CMEChannel(); + return ICEOptions::ICEChannel(); } bool feed_engine_exists(const string& name) { - const auto& config = config::get(); + const auto& config = config::get(); for (const auto& feed : config.feed_engine()) { if (feed.name() == name) return true; } return false; } -const onixs::FeedEngineSettings feed_engine_settings_from_config(const CMEOptions::FeedEngineSettings& settings, int feed_count) { +const onixs::FeedEngineSettings feed_engine_settings_from_config(const ICEOptions::FeedEngineSettings& settings, int feed_count) { onixs::FeedEngineSettings result; if (settings.has_data_wait()) result.dataWaitTime(settings.data_wait()); @@ -81,16 +81,16 @@ const onixs::FeedEngineSettings feed_engine_settings_from_config(const CMEOption return result; } -size_t count_engine_uses(const vector& channels, const string& feed_name) { - return count_if(channels.begin(), channels.end(), [&](const CMEChannel& ch) { +size_t count_engine_uses(const vector& channels, const string& feed_name) { + return count_if(channels.begin(), channels.end(), [&](const ICEChannel& ch) { const auto& settings = channel_settings_for(ch.id); return settings.has_feed_engine() && settings.feed_engine() == feed_name; }); } -map create_feed_engine_settings(const std::vector& channels) { +map create_feed_engine_settings(const std::vector& channels) { map settings; - const auto& config = config::get(); + const auto& config = config::get(); // For each feed engine in feed_engine for (const auto& feed : config.feed_engine()) { @@ -105,7 +105,7 @@ map create_feed_engine_settings(const std::vec return settings; } -map> create_feed_engines(const vector& channels) { +map> create_feed_engines(const vector& channels) { map> result; auto settings = create_feed_engine_settings(channels); // Loop through settings and instantiate feed engines @@ -131,8 +131,8 @@ onixs::SessionSettings session_settings_for_channel(const string& channel_id) { return settings; } -void MDP3Main::run(std::vector& symbols) { - await_cme_config(); +void ICEMain::run(std::vector& symbols) { + await_ice_config(); initialize(); const auto& channels = parse_channels(symbols); _engines = create_feed_engines(channels); @@ -142,7 +142,7 @@ void MDP3Main::run(std::vector& symbols) { _handlers.insert(std::make_pair(channel.id, move(phandler))); std::stringstream symstr; for (const auto& sym : channel.symbols) { symstr << sym.symbol() << "-" << SecurityType_Name(sym.type()) << " "; } - LOG(md,Info, "CME: Initialized channel {} ({})",channel.id,symstr.str()); + LOG(md,Info, "ICE: Initialized channel {} ({})",channel.id,symstr.str()); } for (auto& pair : _handlers) { @@ -167,14 +167,14 @@ void MDP3Main::run(std::vector& symbols) { }); heartbeat_timer.start(); - LOG(md,Info, "** CME MDP3 Publisher started **"); + LOG(md,Info, "** ICE Publisher started **"); disp.run(); } -void MDP3Main::initialize() { - const auto& options = config::get(); +void ICEMain::initialize() { + const auto& options = config::get(); auto license_location = os::bts_data_path() + "/licenses/"; if (!boost::filesystem::is_directory(license_location)) { @@ -197,7 +197,7 @@ void MDP3Main::initialize() { // // // Initialize HandlerSettings and allocate the channel Handler -unique_ptr MDP3Main::prepare_handler(const string& channel_id) { +unique_ptr ICEMain::prepare_handler(const string& channel_id) { const auto& pub_options = config::get(); const auto& options = channel_settings_for(channel_id); LOG(md,Info,"Loaded channel options for channel {}:\n{}",channel_id ,options.DebugString()); @@ -270,14 +270,14 @@ unique_ptr MDP3Main::prepare_handler(const string& channel_id) { settings.bookManagement().updateNotification(onixs::BookUpdateNotification::OnEndOfEvent); settings.tradeProcessing( - config::get().verbose_ticker() ? + config::get().verbose_ticker() ? onixs::TradeProcessing::OrderDetails : onixs::TradeProcessing::SummaryLevel); // // Logging onixs::Logger* logger; - if (options.onixs_log_mode() == CMEOptions_OnixSLogMode_None) { + if (options.onixs_log_mode() == ICEOptions_OnixSLogMode_None) { logger = new onixs::NullLogger(); } else { @@ -285,7 +285,7 @@ unique_ptr MDP3Main::prepare_handler(const string& channel_id) { loggerSettings.filename(log_path() + "/log_" + channel_id); loggerSettings.severityLevel((onixs::LogSeverity::Enum)options.onixs_log_mode()); logger = new onixs::FileLogger(loggerSettings); - if (options.onixs_log_mode() == CMEOptions::Debug) { + if (options.onixs_log_mode() == ICEOptions::Debug) { // trace all the things settings.debugLogging().traceBooks(true); settings.debugLogging().traceFeeds(true); @@ -299,7 +299,7 @@ unique_ptr MDP3Main::prepare_handler(const string& channel_id) { std::unique_ptr recovery; if (options.use_tcp_replay()) { - LOG(md,Info,"CME: Enabled TCP replay"); + LOG(md,Info,"ICE: Enabled TCP replay"); onixs::TcpRecoverySettings tcpSettings; tcpSettings.username(options.tcp_replay_username()); tcpSettings.password(options.tcp_replay_password()); @@ -332,7 +332,7 @@ unique_ptr MDP3Main::prepare_handler(const string& channel_id) { // // Create a listener for this channel and register callbacks -unique_ptr MDP3Main::prepare_listener(onixs::Handler& handler, const CMEChannel& channel) { +unique_ptr ICEMain::prepare_listener(onixs::Handler& handler, const ICEChannel& channel) { // We need to get a handler to the producer channels so we can produce heartbeats vector producer_channels; for (auto& symbol : channel.symbols) { @@ -341,7 +341,7 @@ unique_ptr MDP3Main::prepare_listener(onixs::Handler& handler, con const auto& options = channel_settings_for(channel.id); - unique_ptr listener(new MDP3Listener(_index, _producer, /*_settlement_recorder,*/ producer_channels)); + unique_ptr listener(new ICEListener(_index, _producer, /*_settlement_recorder,*/ producer_channels)); for (auto& symbol : channel.symbols) { listener->add_filter_symbol(symbol.symbol()); } From 4a64e45d363667739d0be0e015c3d1d454032641 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Fri, 15 Feb 2019 18:08:26 -0500 Subject: [PATCH 06/72] translated onixs::Handler settings to our config. --- src/lib/config/defaults/MarketData.conf | 21 +++ src/lib/config/protos/MarketData.proto | 52 +++----- .../md/platforms/ice_onixs/ICEListener.cpp | 7 +- .../md/platforms/ice_onixs/ICEListener.h | 122 +++++------------- 4 files changed, 73 insertions(+), 129 deletions(-) diff --git a/src/lib/config/defaults/MarketData.conf b/src/lib/config/defaults/MarketData.conf index da31831bb..68adf0a79 100644 --- a/src/lib/config/defaults/MarketData.conf +++ b/src/lib/config/defaults/MarketData.conf @@ -36,3 +36,24 @@ CMEOptions { } } +ICEOptions { + value { + feed_engine { + name: "impactfeed1" + product_definition_cache_directory: "" + udp_buffer_size: 67108864 + } + feed_engine { + name: "impactfeed2" + product_definition_cache_directory: "" + } + channel { + id: "ICE Futures WTI" + feed_engine: "impactfeed1" + } + channel { + id: "*" + feed_engine: "impactfeed2" + } + } +} diff --git a/src/lib/config/protos/MarketData.proto b/src/lib/config/protos/MarketData.proto index 921177db4..cacc87a14 100755 --- a/src/lib/config/protos/MarketData.proto +++ b/src/lib/config/protos/MarketData.proto @@ -126,49 +126,37 @@ message ICEOptions Regular = 50; Debug = 100; } + //FeedEngineSettings is for an onixs::Handler, which has one thread message FeedEngineSettings { optional string name = 1; - // If num_threads is set it will use that - otherwise it will use channels_per_thread and the number of threads configured for this channel to determine the number of threads - optional uint32 num_threads = 2 [default = 1]; - // Defines amount of time Feed Engine spends on socket waiting for I/O while running master processing loop. - optional uint32 data_wait = 3 [default = 10]; - // Defines amount of time Feed Engine keeps cycling before going to sleep when no useful activity can be done - optional uint32 spin_time = 4 [default = 1]; - optional uint32 channels_per_thread = 5 [default = 3]; - optional uint32 udp_socket_buffer_size = 11 [default = 33554432]; //32mb + + optional uint32 udp_buffer_size = 2 [default = 33554432]; //32mb + optional uint32 heartbeat_interval = 3 [default = 36000]; + optional uint32 sequence_gap_margin = 4 [default = 10000]; + optional uint32 gap_timeout_in_ms = 5 [default = 10000]; + + optional int32 snapshot_recovery_timeout_in_ms = 10 [default = -1]; + optional int32 maximum_number_of_snapshot_recovery_attempts = 11 [default = -1]; + optional int32 maximum_size_of_snapshot_message_queue = 12 [default = -1]; + optional int32 maximum_size_of_live_message_queue = 13 [default = 200000]; + + optional string processing_thread_affinity = 20 [default = ""]; + optional string product_definition_cache_directory = 21 [default = ""]; + } + + //a channel is for what ice would consider a group, we still have to dereference the marketType codes within the group message ICEChannel { - repeated string id = 2; + repeated string id = 2; optional string feed_engine = 3 [default = "default"]; - - optional uint32 max_gap_recovery_cache_size = 11 [default = 6]; - optional uint32 lost_packet_wait_timeout_ms = 12 [default = 10]; optional OnixSLogMode onixs_log_mode = 13 [default = Important]; - optional bool prefer_backup_feeds = 15 [default = false]; - - optional bool use_tcp_replay = 20 [default = true]; - optional string tcp_replay_username = 21 [default = "MDPFFBLUE"]; - optional string tcp_replay_password = 22 [default = "password01"]; - optional int32 tcp_replay_connect_attempts = 23 [default = 3]; - optional int32 tcp_replay_reconnect_interval_ms = 24 [default = 30000]; - optional int32 tcp_replay_timeout_s = 25 [default = 10]; - - optional uint32 recovery_queue_size = 30 [default = 640000]; - optional bool use_natural_refresh = 31 [default = false]; - optional bool join_snapshot_on_gap = 32 [default = false]; - - optional bool load_security_db = 33 [default = true]; - reserved 34; - // optional BookType book_type = 34 [default = BOOKTYPE_CONSOLIDATED]; - + optional bool load_security_db = 33 [default = true]; } + optional string onixs_license = 1 [default = "{default}"]; repeated ICEChannel channel = 3; repeated FeedEngineSettings feed_engine = 5; - - // Prevents parsing trades/rfqs/doing anything not required for quoting - optional bool quoter_mode = 6; optional bool verbose_ticker = 7 [default=false]; } diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp index 34c873f22..4f38c6e00 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp @@ -12,17 +12,12 @@ namespace bts { namespace md { -ICEListener::ICEListener( - ICESecurityIndex& index, - MDProducer& producer, - // co2::SettlementRecorder& , - const std::vector channels) : +ICEListener::ICEListener(ICESecurityIndex& index, MDProducer& producer, const std::vector channels) : _index(index), _producer(producer), _verbose_ticker(config::get().verbose_ticker()), _packet_arrived(), _latest_sequence(0), - // _settlement_recorder(settles), _symbol_filter_storage(), _symbol_filter(), _channels(channels), diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h index 8d984cfba..a71d3a5ee 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h @@ -19,9 +19,11 @@ namespace md { class ICEListener : - public onixs::HandlerListener, - public onixs::MarketDataListener, - public onixs::SecurityListener + public onixs::ExchangeListener, //One Thread + public onixs::HandlerStateChangeListener //One thread + public onixs::FeedListener, //Multi thread + public onixs::ErrorListener //Multi thread + { typedef uint32_t BookType; static constexpr BookType book_type_direct=1; @@ -29,49 +31,36 @@ class ICEListener : static constexpr BookType book_type_both=(book_type_direct|book_type_implied); public: - ICEListener(ICESecurityIndex& index, - MDProducer&, - // co2::SettlementRecorder&, - const std::vector); + ICEListener(ICESecurityIndex& index, MDProducer&, const std::vector); virtual ~ICEListener(); - // + // + //State change + void onHandlerStateChange(const onixs::HandlerStateChange& change) override; + void onMarketStateChange(const onixs::MarketStateChange& msg, const onixs::MessageInfo& msgInfo) override; + // Warnings/Errors/Info - void onError(onixs::Handler&, const onixs::ErrorArgs&) override; - void onWarning(onixs::Handler&, const onixs::WarningArgs&) override; - void onInstrumentRecovery(onixs::Handler&) override; - void onEndOfInstrumentRecovery(onixs::Handler&, const onixs::RecoveryCompletionArgs&) override; + void onError(const onixs::Error&) override; + void onFeedError(onixs::FeedId feedid, onixs::ErrorCode code, const std::string& desc) override; // // Gap Recovery - void onMarketRecovery(onixs::Handler&) override; - void onEndOfMarketRecovery(onixs::Handler&, const onixs::RecoveryCompletionArgs&) override; - void onTcpRecovery(onixs::Handler&) override; - void onEndOfTcpRecovery(onixs::Handler&, const onixs::RecoveryCompletionArgs&) override; - - // - // Mark the start/end of a packet - void onPacket(onixs::Handler&, const onixs::PacketArgs&) override; - void onEndOfPacket(onixs::Handler&, const onixs::PacketArgs&) override; + void onMarketSnapshot(const onixs::MarketSnapshot& msg, const onixs::MessageInfo& msgInfo) override; + void onMarketSnapshotOrder(const onixs::MarketSnapshotOrder& msg, const onixs::MessageInfo& msgInfo) override; + void onMarketSnapshotPriceLevel(const onixs::MarketSnapshotPriceLevel& msg, const onixs::MessageInfo& msgInfo) override; // // Security discovery - template - void onFuture(onixs::Handler&, const onixs::Security&, const InstrumentDefinitionFuture&); - template - void onOption(onixs::Handler&, const onixs::Security&, const InstrumentDefinition&); - template - void onSpread(onixs::Handler&, const onixs::Security&, const InstrumentDefinition&); - - void onDefinition(onixs::Handler& h, const onixs::Security& s, const onixs::InstrumentDefinitionFuture27Args& def) override { onFuture(h, s, def); } - void onDefinition(onixs::Handler& h, const onixs::Security& s, const onixs::InstrumentDefinitionFuture54Args& def) override { onFuture(h, s, def); } - - void onDefinition(onixs::Handler& h, const onixs::Security& s, const onixs::InstrumentDefinitionOption41Args& def) override { onOption(h, s, def); } - void onDefinition(onixs::Handler& h, const onixs::Security& s, const onixs::InstrumentDefinitionOption55Args& def) override { onOption(h, s, def); } - - void onDefinition(onixs::Handler& h, const onixs::Security& s, const onixs::InstrumentDefinitionSpread29Args& def) override { onSpread(h, s, def); } - void onDefinition(onixs::Handler& h, const onixs::Security& s, const onixs::InstrumentDefinitionSpread56Args& def) override { onSpread(h, s, def); } - + void onFuturesProductDefinition(const onixs::FuturesProductDefinition& msg, bool& is_interested) override; + void onNewExpiry(const onixs::NewExpiry& msg, bool& is_interested, const onixs::MessageInfo& msg_info) override; + void onFuturesStrategyDefinition(const onixs::FuturesStrategyDefinition& def, bool& is_interested) override; + void onNewFuturesStrategyDefinition(const onixs::NewFuturesStrategyDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) override; + + void onOptionsProductDefinition(const onixs::OptionsProductDefinition& msg, bool& is_interested) override; + void onNewOptionsMarketDefinition(const onixs::NewOptionsMarketDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) override; + void onOptionsStrategyDefinition(const onixs::OptionsStrategyDefinition& msg, bool& is_interested) override; + void onNewOptionsStrategyDefinition(const onixs::NewOptionsStrategyDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) override; + // // Book // void onBookUpdate(onixs::Handler&, const onixs::Security&, const onixs::MboBook&) override; @@ -84,19 +73,11 @@ public: // // Trades - template - void onTradeRecovery(const onixs::Security&, const TradeRecovery&); - void onTrade(onixs::Handler&, const onixs::Security& s, const onixs::Recovery52EntryArgs& arg) override { onTradeRecovery(s, arg); } - void onTrade(onixs::Handler&, const onixs::Security& s, const onixs::Recovery38EntryArgs& arg) override { onTradeRecovery(s, arg); } - - template - void onTradeSummary(const onixs::Security&, const Trade&); - void onTrade(onixs::Handler&, const onixs::Security& s, const onixs::TradeSummary48Args& arg) override { onTradeSummary(s, arg); } - void onTrade(onixs::Handler&, const onixs::Security& s, const onixs::TradeSummary42Args& arg) override { onTradeSummary(s, arg); } + void onTrade (const onixs::Trade& msg, const onixs::MessageInfo& msgInfo) override; // // RFQ - void onQuoteRequest(onixs::Handler&, const onixs::Security&, const onixs::QuoteRequest39RelatedSymArgs&) override; + void onRfq (const onixs::Rfq& msg, const onixs::MessageInfo& msgInfo) override; // // Volume @@ -108,49 +89,9 @@ public: // // Misc - template - void onSettlementPrice(const onixs::Security& sec, const StatisticsArgs& args); - void onSettlementPrice(onixs::Handler&, const onixs::Security& s, const onixs::DailyStatistics49Args& arg) override { - auto type = arg.entry().settlPriceType(); - if (type.finalDaily() && type.actual()) { - onSettlementPrice(s, arg); - } - } - void onSettlementPrice(onixs::Handler&, const onixs::Security& s, const onixs::DailyStatistics33Args& arg) override { - auto type = arg.entry().settlPriceType(); - if (type.finalDaily() && type.actual()) { - onSettlementPrice(s, arg); - } - } - void onSettlementPrice(onixs::Handler&, const onixs::Security& s, const onixs::Recovery52EntryArgs& arg) override { onSettlementPrice(s, arg); } - void onSettlementPrice(onixs::Handler&, const onixs::Security& s, const onixs::Recovery38EntryArgs& arg) override { onSettlementPrice(s, arg); } - - template - void onSessionOpeningPrice(const onixs::Security&, const SessionArgs&); - template - void onRecoveryOpeningPrice(const onixs::Security& sec, const RecoveryArgs& args); - void onOpeningPrice(onixs::Handler&, const onixs::Security& s, const onixs::SessionStatistics51Args& arg) override { onSessionOpeningPrice(s, arg); } - void onOpeningPrice(onixs::Handler&, const onixs::Security& s, const onixs::SessionStatistics35Args& arg) override { onSessionOpeningPrice(s, arg); } - void onOpeningPrice(onixs::Handler&, const onixs::Security& s, const onixs::Recovery52EntryArgs& arg) override { onRecoveryOpeningPrice(s, arg); } - void onOpeningPrice(onixs::Handler&, const onixs::Security& s, const onixs::Recovery38EntryArgs& arg) override { onRecoveryOpeningPrice(s, arg); } - - template - void onSessionHighTradePrice(const onixs::Security&, const SessionArgs&); - template - void onRecoveryHighTradePrice(const onixs::Security&, const RecoveryArgs&); - void onHighTradePrice(onixs::Handler&, const onixs::Security& s, const onixs::SessionStatistics51Args& arg) override { onSessionHighTradePrice(s, arg); } - void onHighTradePrice(onixs::Handler&, const onixs::Security& s, const onixs::SessionStatistics35Args& arg) override { onSessionHighTradePrice(s, arg); } - void onHighTradePrice(onixs::Handler&, const onixs::Security& s, const onixs::Recovery52EntryArgs& arg) override { onRecoveryHighTradePrice(s, arg); } - void onHighTradePrice(onixs::Handler&, const onixs::Security& s, const onixs::Recovery38EntryArgs& arg) override { onRecoveryHighTradePrice(s, arg); } - - template - void onSessionLowTradePrice(const onixs::Security&, const SessionArgs&); - template - void onRecoveryLowTradePrice(const onixs::Security&, const RecoveryArgs&); - void onLowTradePrice(onixs::Handler&, const onixs::Security& s, const onixs::SessionStatistics51Args& arg) override { onSessionLowTradePrice(s, arg); } - void onLowTradePrice(onixs::Handler&, const onixs::Security& s, const onixs::SessionStatistics35Args& arg) override { onSessionLowTradePrice(s, arg); } - void onLowTradePrice(onixs::Handler&, const onixs::Security& s, const onixs::Recovery52EntryArgs& arg) override { onRecoveryLowTradePrice(s, arg); } - void onLowTradePrice(onixs::Handler&, const onixs::Security& s, const onixs::Recovery38EntryArgs& arg) override { onRecoveryLowTradePrice(s, arg); } + void onSettlementPrice(const onixs::SettlementPrice& msg, const onixs::MessageInfo& msgInfo) override; + void onOpenInterest(const onixs::OpenInterest &msg, const MessageInfo &msgInfo) override; + void onOpenPrice(const onixs::OpenPrice& msg, const onixs::MessageInfo& msgInfo) override; // // Discover securities @@ -185,7 +126,6 @@ private: bool _verbose_ticker; utils::TimeStamp _packet_arrived; uint32_t _latest_sequence; - // co2::SettlementRecorder& _settlement_recorder; std::vector _symbol_filter_storage; std::set _symbol_filter; std::vector _channels; From d0784fedddd27bfedf9a945e91021f97e9a98b57 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Mon, 25 Feb 2019 10:34:58 -0500 Subject: [PATCH 07/72] more ice --- src/lib/config/protos/MarketData.proto | 21 +-- .../md/platforms/ice_onixs/ICEListener.cpp | 10 +- .../md/platforms/ice_onixs/ICEListener.h | 21 +-- .../sparkd/md/platforms/ice_onixs/ICEMain.cpp | 168 +++++------------- .../sparkd/md/platforms/ice_onixs/ICEMain.h | 2 +- 5 files changed, 64 insertions(+), 158 deletions(-) diff --git a/src/lib/config/protos/MarketData.proto b/src/lib/config/protos/MarketData.proto index cacc87a14..4c6d82b2d 100755 --- a/src/lib/config/protos/MarketData.proto +++ b/src/lib/config/protos/MarketData.proto @@ -126,10 +126,10 @@ message ICEOptions Regular = 50; Debug = 100; } - //FeedEngineSettings is for an onixs::Handler, which has one thread - message FeedEngineSettings { - optional string name = 1; - + + //a channel is for what onixs-ice would consider a mcast group, we still have to dereference the marketType codes within the group + message ICEChannel { + optional string id = 1; optional uint32 udp_buffer_size = 2 [default = 33554432]; //32mb optional uint32 heartbeat_interval = 3 [default = 36000]; optional uint32 sequence_gap_margin = 4 [default = 10000]; @@ -142,22 +142,13 @@ message ICEOptions optional string processing_thread_affinity = 20 [default = ""]; optional string product_definition_cache_directory = 21 [default = ""]; - - } - - //a channel is for what ice would consider a group, we still have to dereference the marketType codes within the group - message ICEChannel { - repeated string id = 2; - optional string feed_engine = 3 [default = "default"]; - optional OnixSLogMode onixs_log_mode = 13 [default = Important]; - optional bool load_security_db = 33 [default = true]; + optional OnixSLogMode onixs_log_mode = 30 [default = Important]; + optional bool load_security_db = 31 [default = true]; } optional string onixs_license = 1 [default = "{default}"]; repeated ICEChannel channel = 3; - repeated FeedEngineSettings feed_engine = 5; - optional bool verbose_ticker = 7 [default=false]; } message RecordOptions { diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp index 4f38c6e00..71f6a765d 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp @@ -27,15 +27,19 @@ ICEListener::ICEListener(ICESecurityIndex& index, MDProducer& producer, const st _book_updates.reserve(32); } -ICEListener::~ICEListener() { -} +ICEListener::~ICEListener() {} // // Warnings/Errors -void ICEListener::onError(onixs::Handler&, const onixs::ErrorArgs& error) { +void ICEListener::onError(const onixs::Error& error) +{ tracepoint (bts_trace,trace_order,(char*) "onError", _latest_sequence, (uint16_t) _latest_sequence, 0); LOG(md,Warn, "OnixS Error: {} - {}", error.description(), error.source()); } + +void ICEListener::onFeedError(onixs::FeedId feedid, onixs::ErrorCode code, const std::string& desc) +{ +} void ICEListener::onWarning(onixs::Handler&, const onixs::WarningArgs& warning) { tracepoint (bts_trace,trace_order,(char*) "onWarning", _latest_sequence, (uint16_t) _latest_sequence, 0); LOG(md,Warn, "OnixS Warn: {} - {}", warning.description(), warning.source()); diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h index a71d3a5ee..de2ba0375 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h @@ -21,6 +21,7 @@ namespace md { class ICEListener : public onixs::ExchangeListener, //One Thread public onixs::HandlerStateChangeListener //One thread + public onixs::OrderBookUpdateListener //One thread //TODO? public onixs::FeedListener, //Multi thread public onixs::ErrorListener //Multi thread @@ -42,6 +43,7 @@ public: // Warnings/Errors/Info void onError(const onixs::Error&) override; void onFeedError(onixs::FeedId feedid, onixs::ErrorCode code, const std::string& desc) override; + void onWarning(const onixs::Warning& warning) override; // // Gap Recovery @@ -63,13 +65,7 @@ public: // // Book - // void onBookUpdate(onixs::Handler&, const onixs::Security&, const onixs::MboBook&) override; - void onBookUpdate(onixs::Handler&, const onixs::Security&, const onixs::DirectBook&) override; - void onBookUpdate(onixs::Handler&, const onixs::Security&, const onixs::ImpliedBook&) override; - // void onBookUpdate(onixs::Handler&, const onixs::Security&, const onixs::ConsolidatedBook&) override; - - template - void onBookUpdate(const onixs::Security& sec, const TBook& book, BookType booktype); + void onOrderBookUpdated(const onixs::OrderBook& book, const onixs::MessageInfo& msgInfo) override; // // Trades @@ -79,14 +75,6 @@ public: // RFQ void onRfq (const onixs::Rfq& msg, const onixs::MessageInfo& msgInfo) override; - // - // Volume - void onElectronicVolume(onixs::Handler&, const onixs::Security&, const onixs::Volume37Args&) override; - template - void onElectronicVolume(const onixs::Security&, const RecoveryEntry&); - void onElectronicVolume(onixs::Handler&, const onixs::Security& s, const onixs::Recovery52EntryArgs& arg) override { onElectronicVolume(s, arg); } - void onElectronicVolume(onixs::Handler&, const onixs::Security& s, const onixs::Recovery38EntryArgs& arg) override { onElectronicVolume(s, arg); } - // // Misc void onSettlementPrice(const onixs::SettlementPrice& msg, const onixs::MessageInfo& msgInfo) override; @@ -141,6 +129,7 @@ private: std::vector _book_updates; }; +#if false ////////////////////////////////////////// // Template Member Function Definitions ////////////////////////////////////////// @@ -481,5 +470,7 @@ void ICEListener::onRecoveryLowTradePrice(const onixs::Security& sec, const Reco } } +#endif + }}//namespace diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp index 2e42c994c..3440fc842 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp @@ -5,6 +5,7 @@ #include "lib/md/coconut2.h" #include "lib/md/SecurityDB.h" #include "lib/os/os.h" +#include "lib/utils/helper_macros.h" #include "lib/utils/Dispatcher.h" #include "lib/utils/proto_helper.h" #include "lib/md/protos/co2.pb.h" @@ -29,114 +30,39 @@ ICEMain::ICEMain() : _index(), _recorder ({ utils::Dispatcher::current(), [=](ExchangeKey k) { return SecurityKey(_index.get_key(k.value())); } }), _producer(PLATFORM_ICEONIXS, _recorder ), - // _settlement_recorder(PLATFORM_ICEONIXS), - _engines(), _handlers(), _listeners(), - _recovery() { } ICEMain::~ICEMain() {} -const ICEOptions::ICEChannel channel_settings_for(const string& id) { +const ICEOptions::ICEChannel channel_settings_for(const string& id) +{ const auto& config = config::get(); - for (const auto& ch : config.channel()) { + for (const auto& ch : config.channel()) + { bool found = std::find_if(ch.id().begin(), ch.id().end(), [&](const string& chan_id) { return chan_id == id || chan_id == "*"; }) != ch.id().end(); - if (found) { + if (found) return ch; - } } return ICEOptions::ICEChannel(); } -bool feed_engine_exists(const string& name) { - const auto& config = config::get(); - for (const auto& feed : config.feed_engine()) { - if (feed.name() == name) return true; - } - return false; -} -const onixs::FeedEngineSettings feed_engine_settings_from_config(const ICEOptions::FeedEngineSettings& settings, int feed_count) { - onixs::FeedEngineSettings result; - if (settings.has_data_wait()) result.dataWaitTime(settings.data_wait()); - if (settings.has_spin_time()) result.spinBeforeIdleTime(settings.spin_time()); - - result.socketBufferSize(settings.udp_socket_buffer_size()); - - auto affinity = threading::get_affinity(settings.name()); - for (auto& core : affinity) { - result.threadAffinity().cpus().insert(core); - } - - // num_threads() overrides anything else - if (settings.has_num_threads()) { - result.threadCount(settings.num_threads()); - } - else { - // If num_threads is absent determine thread count based on #channels - result.threadCount((feed_count / settings.channels_per_thread()) + 1); - } - return result; -} - -size_t count_engine_uses(const vector& channels, const string& feed_name) { - return count_if(channels.begin(), channels.end(), [&](const ICEChannel& ch) { - const auto& settings = channel_settings_for(ch.id); - return settings.has_feed_engine() && settings.feed_engine() == feed_name; - }); -} - -map create_feed_engine_settings(const std::vector& channels) { - map settings; - const auto& config = config::get(); - - // For each feed engine in feed_engine - for (const auto& feed : config.feed_engine()) { - // - see if it is in use - size_t use_count = count_engine_uses(channels, feed.name()); - // - Only create if this feed engine is in use - if (use_count > 0) { - settings[feed.name()] = feed_engine_settings_from_config(feed, use_count); - } - } - - return settings; -} - -map> create_feed_engines(const vector& channels) { - map> result; - auto settings = create_feed_engine_settings(channels); - // Loop through settings and instantiate feed engines - for (const auto& s : settings) { - unique_ptr temp(new onixs::FeedEngine(s.second)); - result.insert(make_pair(s.first, move(temp))); - } - - return result; -} - -onixs::SessionSettings session_settings_for_channel(const string& channel_id) { +onixs::MarketSubscriptions market_subcription_for_channel(const string& channel_id) +{ const auto& options = channel_settings_for(channel_id); - onixs::SessionSettings settings; - settings.marketRecovery(onixs::MarketRecoveryOptions::MbpOnly); - if (!options.join_snapshot_on_gap()) { - settings.gapAndErrorHandling(onixs::GapAndErrorHandlingOptions::ContinueProcessing); - } - if (options.use_natural_refresh()) { - settings.joinRecovery(onixs::JoinRecoveryOptions::Disabled); - settings.gapAndErrorHandling(onixs::GapAndErrorHandlingOptions::ContinueProcessing); - } - return settings; + onixs::MarketSubscriptions subs; + return subs; } -void ICEMain::run(std::vector& symbols) { +void ICEMain::run(std::vector& symbols) +{ await_ice_config(); - initialize(); - const auto& channels = parse_channels(symbols); - _engines = create_feed_engines(channels); - for (const auto& channel : channels) { + const auto& channels = parse_ice_channels(symbols); + for (const auto& channel : channels) + { unique_ptr phandler = prepare_handler(channel.id); _listeners.push_back(prepare_listener(*phandler, channel)); _handlers.insert(std::make_pair(channel.id, move(phandler))); @@ -145,55 +71,49 @@ void ICEMain::run(std::vector& symbols) { LOG(md,Info, "ICE: Initialized channel {} ({})",channel.id,symstr.str()); } - for (auto& pair : _handlers) { - onixs::SessionSettings settings = session_settings_for_channel(pair.first); + for (auto& pair : _handlers) + { + onixs::MarketSubscriptions subs = market_subcription_for_channel(pair.first); pair.second->start(settings); } // // Timers - auto& disp = utils::Dispatcher::current(); - - // utils::DispatcherTimer settlement_timer(disp, 100, [&]() { - // _settlement_recorder.do_work(); - // }); - // settlement_timer.start(); - - utils::DispatcherTimer heartbeat_timer(disp, 250, [&]() { - for (const auto& listener: _listeners) { - listener->heartbeat(); - } - }); + utils::DispatcherTimer heartbeat_timer(disp, 250, [&]() + { + for (const auto& listener: _listeners) + { + listener->heartbeat(); + } + }); heartbeat_timer.start(); - LOG(md,Info, "** ICE Publisher started **"); - disp.run(); } -void ICEMain::initialize() { - const auto& options = config::get(); - auto license_location = os::bts_data_path() + "/licenses/"; +// void ICEMain::initialize() { +// const auto& options = config::get(); +// auto license_location = os::bts_data_path() + "/licenses/"; - if (!boost::filesystem::is_directory(license_location)) { - auto license_path =os::sparkd_wd() + "/data_files/Onixs.BTS.lic" ; - boost::filesystem::create_directories(license_location); - boost::filesystem::copy_file(license_path,license_location+"/Onixs.BTS.lic"); - } +// if (!boost::filesystem::is_directory(license_location)) { +// auto license_path =os::sparkd_wd() + "/data_files/Onixs.BTS.lic" ; +// boost::filesystem::create_directories(license_location); +// boost::filesystem::copy_file(license_path,license_location+"/Onixs.BTS.lic"); +// } - // - // License path - onixs::InitializationSettings init_settings; - auto license = options.onixs_license(); - init_settings.licenseStore(license); - if (license == "{default}") { - init_settings.licenseStore(license_location); - } - LOG(md,Info,"Loading onixs license from {}", init_settings.licenseStore()); - onixs::initialize(init_settings); -} +// // +// // License path +// onixs::InitializationSettings init_settings; +// auto license = options.onixs_license(); +// init_settings.licenseStore(license); +// if (license == "{default}") { +// init_settings.licenseStore(license_location); +// } +// LOG(md,Info,"Loading onixs license from {}", init_settings.licenseStore()); +// onixs::initialize(init_settings); +// } // // // Initialize HandlerSettings and allocate the channel Handler diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h index 5e1b402c1..609ee2227 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h @@ -32,7 +32,7 @@ public: void run(std::vector&); void initialize(); std::unique_ptr prepare_handler(const std::string& channel); - std::unique_ptr prepare_listener(onixs::Handler& handler, const ICEChannel& channel); + std::unique_ptr prepare_listener(onixs::Handler& handler, const ICEChannel& channel); private: BTS_NO_COPY(ICEMain); From 9d2cdb702dcf74f4fe23af48a75e88d49959e1a3 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Tue, 26 Feb 2019 16:00:26 -0500 Subject: [PATCH 08/72] getting somewhere --- src/lib/config/protos/MarketData.proto | 19 +- .../md/platforms/ice_onixs/ICEListener.cpp | 152 ++++++++------- .../md/platforms/ice_onixs/ICEListener.h | 125 ++++++++---- .../platforms/ice_onixs/ICEListenerHelpers.h | 63 +++--- .../sparkd/md/platforms/ice_onixs/ICEMain.cpp | 179 +++++++----------- 5 files changed, 281 insertions(+), 257 deletions(-) diff --git a/src/lib/config/protos/MarketData.proto b/src/lib/config/protos/MarketData.proto index 4c6d82b2d..900fbb8d2 100755 --- a/src/lib/config/protos/MarketData.proto +++ b/src/lib/config/protos/MarketData.proto @@ -121,10 +121,12 @@ message CMEOptions message ICEOptions { enum OnixSLogMode { - None = 0; - Important = 10; - Regular = 50; - Debug = 100; + Fatal = 0; + Error = 1; + Warning = 2; + Info = 3; + Trace = 4; + Debug = 5; } //a channel is for what onixs-ice would consider a mcast group, we still have to dereference the marketType codes within the group @@ -141,10 +143,13 @@ message ICEOptions optional int32 maximum_size_of_live_message_queue = 13 [default = 200000]; optional string processing_thread_affinity = 20 [default = ""]; - optional string product_definition_cache_directory = 21 [default = ""]; + optional bool track_top_of_the_book_only = 30 [default = false]; + optional bool receive_product_definitions_only = 31 [default = false]; + optional uint32 max_multicast_message_block_size = 32 [default = 1400]; + optional string product_definition_cache_directory = 35 [default = ""]; - optional OnixSLogMode onixs_log_mode = 30 [default = Important]; - optional bool load_security_db = 31 [default = true]; + optional OnixSLogMode onixs_log_mode = 40 [default = Warning]; + optional bool load_security_db = 41 [default = true]; } optional string onixs_license = 1 [default = "{default}"]; diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp index 71f6a765d..99a20c820 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp @@ -18,7 +18,6 @@ ICEListener::ICEListener(ICESecurityIndex& index, MDProducer& producer, const st _verbose_ticker(config::get().verbose_ticker()), _packet_arrived(), _latest_sequence(0), - _symbol_filter_storage(), _symbol_filter(), _channels(channels), _concurrency_monitor(0), @@ -29,6 +28,18 @@ ICEListener::ICEListener(ICESecurityIndex& index, MDProducer& producer, const st ICEListener::~ICEListener() {} +// +//State change +void ICEListener::onHandlerStateChange(const onixs::HandlerStateChange& change) +{ + //TODO +} + +void ICEListener::onMarketStateChange(const onixs::MarketStateChange& msg, const onixs::MessageInfo& msgInfo) +{ + //TODO +} + // // Warnings/Errors void ICEListener::onError(const onixs::Error& error) @@ -36,76 +47,81 @@ void ICEListener::onError(const onixs::Error& error) tracepoint (bts_trace,trace_order,(char*) "onError", _latest_sequence, (uint16_t) _latest_sequence, 0); LOG(md,Warn, "OnixS Error: {} - {}", error.description(), error.source()); } - void ICEListener::onFeedError(onixs::FeedId feedid, onixs::ErrorCode code, const std::string& desc) { + tracepoint (bts_trace,trace_order,(char*) "onFeedError", _latest_sequence, (uint16_t) _latest_sequence, 0); + LOG(md,Warn, "OnixS FeedError: {} - {}", desc, code); } -void ICEListener::onWarning(onixs::Handler&, const onixs::WarningArgs& warning) { +void ICEListener::onWarning(const onixs::Warning& warning) +{ tracepoint (bts_trace,trace_order,(char*) "onWarning", _latest_sequence, (uint16_t) _latest_sequence, 0); LOG(md,Warn, "OnixS Warn: {} - {}", warning.description(), warning.source()); } -void ICEListener::onInstrumentRecovery(onixs::Handler& h) { - tracepoint (bts_trace,trace_order,(char*) "onInstrumentRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); - LOG(md,Info, "Beginning security definition recovery for channel {}", h.settings().channel()); -} -void ICEListener::onEndOfInstrumentRecovery(onixs::Handler& h, const onixs::RecoveryCompletionArgs&) { - tracepoint (bts_trace,trace_order,(char*) "onEndOfInstrumentRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); - LOG(md,Info, "Finished Security definition recovery for channel {}", h.settings().channel()); -} // -// Gap Recovery -void ICEListener::onMarketRecovery(onixs::Handler& h) { - tracepoint (bts_trace,trace_order,(char*) "onMarketRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); - update_all_status(COCONUTSECURITYSTATUS_PACKET_LOSS); - for (auto& c : _channels) { c.gap(); } - LOG(md,Info, "Beginning market recovery for channel {}", h.settings().channel()); +// Security discovery +void ICEListener::onFuturesProductDefinition(const onixs::FuturesProductDefinition& msg, bool& is_interested) +{ + tracepoint (bts_trace,trace_order,(char*) "onFuturesProductDefinition", _latest_sequence, (uint16_t) _latest_sequence, 0); + on_future(msg, is_interested); } -void ICEListener::onEndOfMarketRecovery(onixs::Handler& h, const onixs::RecoveryCompletionArgs&) { - tracepoint (bts_trace,trace_order,(char*) "onEndOfMarketRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); - update_all_status(COCONUTSECURITYSTATUS_OK); - LOG(md,Info, "Finished market recovery for channel {}", h.settings().channel()); +void ICEListener::onNewExpiry(const onixs::NewExpiry& msg, bool& is_interested, const onixs::MessageInfo& msg_info) +{ + tracepoint (bts_trace,trace_order,(char*) "onNewExpiry", _latest_sequence, (uint16_t) _latest_sequence, 0); + on_future(msg, is_interested); } -void ICEListener::onTcpRecovery(onixs::Handler& h) { - tracepoint (bts_trace,trace_order,(char*) "onTcpRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); - update_all_status(COCONUTSECURITYSTATUS_PACKET_LOSS); - LOG(md,Info, "Beginning tcp recovery for channel {}", h.settings().channel()); -} -void ICEListener::onEndOfTcpRecovery(onixs::Handler& h, const onixs::RecoveryCompletionArgs&) { - tracepoint (bts_trace,trace_order,(char*) "onEndOfTcpRecovery", _latest_sequence, (uint16_t) _latest_sequence, 0); - update_all_status(COCONUTSECURITYSTATUS_OK); - LOG(md,Info, "Finished tcp recovery for channel {}", h.settings().channel()); -} - -// -// Mark the start/end of a packet -void ICEListener::onPacket(onixs::Handler&, const onixs::PacketArgs& args) { - // Mark the arrival of the packet - _packet_arrived = TimeStamp::now(); - auto seq = args.seqNumber(); - if (!_book_updates.empty()) { - if (_latest_sequence != seq) { - LOG(md, Error, "Expected sequence {} got {} did not flush {} book updates.", - _latest_sequence, seq, _book_updates.size()); - } - } - _latest_sequence = seq; - auto onixs_zero = args.receiveTime().sinceEpoch(); - auto onixs_now = OnixS::ICE::MDH::UtcWatch::now().sinceEpoch(); - // needed for clang compilation - UNUSED(onixs_zero); - UNUSED(onixs_now); - // was needed for clang compilation +void ICEListener::onFuturesStrategyDefinition(const onixs::FuturesStrategyDefinition& def, bool& is_interested) +{ + tracepoint (bts_trace,trace_order,(char*) "onFuturesStrategyDefinition", _latest_sequence, (uint16_t) _latest_sequence, 0); + on_future_spread(def, is_interested); +} +void ICEListener::onNewFuturesStrategyDefinition(const onixs::NewFuturesStrategyDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) override +{ + tracepoint (bts_trace,trace_order,(char*) "onFuturesStrategyDefinition", _latest_sequence, (uint16_t) _latest_sequence, 0); + on_future_spread(msg, is_interested); +} - tracepoint (bts_trace,trace_order,(char*) "onPacket", - _latest_sequence,(uint16_t) _latest_sequence, onixs_now-onixs_zero); -} -void ICEListener::onEndOfPacket(onixs::Handler&, const onixs::PacketArgs&) { - tracepoint (bts_trace,trace_order,(char*) "onEndOfPacket.begin", _latest_sequence, (uint16_t) _latest_sequence, 0); - flush_books(); - tracepoint (bts_trace,trace_order,(char*) "onEndOfPacket.end", _latest_sequence, (uint16_t) _latest_sequence, 0); -} +void ICEListener::onOptionsProductDefinition(const onixs::OptionsProductDefinition& msg, bool& is_interested) +{ } +void ICEListener::onNewOptionsMarketDefinition(const onixs::NewOptionsMarketDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) +{ } +void ICEListener::onOptionsStrategyDefinition(const onixs::OptionsStrategyDefinition& msg, bool& is_interested) +{} +void ICEListener::onNewOptionsStrategyDefinition(const onixs::NewOptionsStrategyDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) +{} + + + +// // +// // Mark the start/end of a packet +// void ICEListener::onPacket(onixs::Handler&, const onixs::PacketArgs& args) { +// // Mark the arrival of the packet +// _packet_arrived = TimeStamp::now(); +// auto seq = args.seqNumber(); +// if (!_book_updates.empty()) { +// if (_latest_sequence != seq) { +// LOG(md, Error, "Expected sequence {} got {} did not flush {} book updates.", +// _latest_sequence, seq, _book_updates.size()); +// } +// } +// _latest_sequence = seq; +// auto onixs_zero = args.receiveTime().sinceEpoch(); +// auto onixs_now = OnixS::ICE::MDH::UtcWatch::now().sinceEpoch(); + +// // needed for clang compilation +// UNUSED(onixs_zero); +// UNUSED(onixs_now); +// // was needed for clang compilation + +// tracepoint (bts_trace,trace_order,(char*) "onPacket", +// _latest_sequence,(uint16_t) _latest_sequence, onixs_now-onixs_zero); +// } +// void ICEListener::onEndOfPacket(onixs::Handler&, const onixs::PacketArgs&) { +// tracepoint (bts_trace,trace_order,(char*) "onEndOfPacket.begin", _latest_sequence, (uint16_t) _latest_sequence, 0); +// flush_books(); +// tracepoint (bts_trace,trace_order,(char*) "onEndOfPacket.end", _latest_sequence, (uint16_t) _latest_sequence, 0); +// } // // Security discovery @@ -205,15 +221,13 @@ void ICEListener::onElectronicVolume(onixs::Handler&, const onixs::Security& sec // // Non-onixs calls -void ICEListener::add_filter_symbol(const std::string& symbol) { - _symbol_filter_storage.push_back(symbol); - _symbol_filter.clear(); - for (const auto& str : _symbol_filter_storage) { - _symbol_filter.insert(onixs::StrRef(str.c_str(), str.size())); - } +void ICEListener::add_filter_symbol(const std::string& symbol) +{ + _symbol_filter.insert(symbol); } -void ICEListener::heartbeat() { +void ICEListener::heartbeat() +{ for (auto& c : _channels) { c.heartbeat(); } } @@ -252,8 +266,10 @@ void ICEListener::flush_books() { _book_updates.clear(); } -void ICEListener::update_all_status(CoconutSecurityStatus status) { - _index.walk_security_list([=](SecurityData& data) { +void ICEListener::update_all_status(CoconutSecurityStatus status) +{ + _index.walk_security_list([=](SecurityData& data) + { data.handle.set_status(status); }); } diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h index de2ba0375..18e36aaf3 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h @@ -45,23 +45,23 @@ public: void onFeedError(onixs::FeedId feedid, onixs::ErrorCode code, const std::string& desc) override; void onWarning(const onixs::Warning& warning) override; - // - // Gap Recovery - void onMarketSnapshot(const onixs::MarketSnapshot& msg, const onixs::MessageInfo& msgInfo) override; - void onMarketSnapshotOrder(const onixs::MarketSnapshotOrder& msg, const onixs::MessageInfo& msgInfo) override; - void onMarketSnapshotPriceLevel(const onixs::MarketSnapshotPriceLevel& msg, const onixs::MessageInfo& msgInfo) override; - // // Security discovery - void onFuturesProductDefinition(const onixs::FuturesProductDefinition& msg, bool& is_interested) override; + void onFuturesProductDefinition(const onixs::FuturesProductDefinition& def, bool& is_interested) override; void onNewExpiry(const onixs::NewExpiry& msg, bool& is_interested, const onixs::MessageInfo& msg_info) override; void onFuturesStrategyDefinition(const onixs::FuturesStrategyDefinition& def, bool& is_interested) override; void onNewFuturesStrategyDefinition(const onixs::NewFuturesStrategyDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) override; - void onOptionsProductDefinition(const onixs::OptionsProductDefinition& msg, bool& is_interested) override; + void onOptionsProductDefinition(const onixs::OptionsProductDefinition& def, bool& is_interested) override; void onNewOptionsMarketDefinition(const onixs::NewOptionsMarketDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) override; - void onOptionsStrategyDefinition(const onixs::OptionsStrategyDefinition& msg, bool& is_interested) override; + void onOptionsStrategyDefinition(const onixs::OptionsStrategyDefinition& def, bool& is_interested) override; void onNewOptionsStrategyDefinition(const onixs::NewOptionsStrategyDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) override; + + // + // Gap Recovery + void onMarketSnapshot(const onixs::MarketSnapshot& msg, const onixs::MessageInfo& msgInfo) override; + void onMarketSnapshotOrder(const onixs::MarketSnapshotOrder& msg, const onixs::MessageInfo& msgInfo) override; + void onMarketSnapshotPriceLevel(const onixs::MarketSnapshotPriceLevel& msg, const onixs::MessageInfo& msgInfo) override; // // Book @@ -91,20 +91,12 @@ public: private: enum SecurityFilterAction { ADD, SKIP, DELETE }; - template - SecurityFilterAction filter_security(int exchange_id, const Sec& sec) { - if (sec.securityUpdateAction() == onixs::SecurityUpdateAction::Delete) { - auto* data = _index.get_security(exchange_id); - if (data != nullptr) { - data->handle.mark_deleted(); - } - return DELETE; - } - if (_index.has_security(exchange_id)) return SKIP; - onixs::SecurityTradingStatus::Enum trading_status; - if(sec.securityTradingStatus(trading_status) && - trading_status == onixs::SecurityTradingStatus::NotAvailableForTrading) return SKIP; - return _symbol_filter.count(sec.asset()) > 0 ? ADD : SKIP; + template + SecurityFilterAction filter_security(int exchange_id, const Definition& def) + { + if (_index.has_security(exchange_id)) + return SKIP; + return _symbol_filter.count(def.contractSymbol) > 0 ? ADD : SKIP; } void flush_books(); void update_all_status(co2::CoconutSecurityStatus status); @@ -114,8 +106,7 @@ private: bool _verbose_ticker; utils::TimeStamp _packet_arrived; uint32_t _latest_sequence; - std::vector _symbol_filter_storage; - std::set _symbol_filter; + std::set _symbol_filter; std::vector _channels; std::atomic _concurrency_monitor; @@ -129,27 +120,79 @@ private: std::vector _book_updates; }; +template +void set_security_common(const Definition& def, FixedSecurity& fsec) +{ + fsec.numeric_id = def.marketId; + fsec.symbol(def.contractSymbol); + fsec.security_desc(def.marketDesc); + fsec.exchange = api::Venue::VENUE_ICE; + fsec.display_factor = (int8_t)def.orderPriceDenominator; + double min_tick = double_of_price(def.incrementPrice, fsec.display_factor); + fsec.low_tick = fsec.high_tick = min_tick; + fsec.price_break = 0.; + fsec.cash_per_point = 0.; +} + +template +void on_future(const Definition& def, bool& is_interested) +{ + is_interested = false; + auto exchange_id = def.marketId; + if (filter_security(exchange_id, def) != ADD) return; + + FixedFutureSecurity fsec; + set_security_common(def, fsec); + + auto expiration = date_of_maturity(sec); + fsec.expiration_year = def.maturityYear; + fsec.expiration_month = def.maturityMonth; + fsec.expiration_day = def.maturityDay; + add_security(fsec); + is_interested = true; +} + +template +void on_future_spread(const Definition& def, bool& is_interested) +{ + is_interested = false; + auto exchange_id = def.marketId; + if (filter_security(exchange_id, def) != ADD) return; + // // Filter out any already expired spreads + // auto expiration = date_of_maturity(sec); + // if (expiration < datetime::today()) return; + + FixedSpreadSecurityL fsec; + set_security_common(def, fsec); + fsec.alt_symbol(def.strategySymbol); + + const auto& legs = def.legs; + fsec.set_leg_count(legs.size()); + for(size_t x = 0; x < fsec.leg_count(); ++x) + { + const auto& leg = legs[x]; + onixs::Decimal price; + if(leg.ratioPriceNumerator) + fsec.legs[x].leg_price = double_of_price(leg.ratioPriceNumerator.value(), leg.ratioPriceDenominator.value()); + + if(leg.ratioQtyNumerator && leg.ratioQtyDenominator) + fsec.legs[x].leg_delta = double_of_price(leg.ratioQtyNumerator.value(), leg.ratioQtyDenominator.value()); + + fsec.legs[x].leg_quantity = leg.ratio; + fsec.legs[x].leg_side = leg.side == onixs::Side::Bid ? api::SIDE_BUY : api::SIDE_SELL; + fsec.legs[x].exchange_key = ExchangeKey(leg.marketId); + fsec.legs[x].key = invalid_security_key; + } + add_security(fsec); + is_interested = true; +} + + #if false ////////////////////////////////////////// // Template Member Function Definitions ////////////////////////////////////////// -template -void set_security_common(const Definition& def, FixedSecurity& fsec) { - fsec.numeric_id = def.securityId(); - fsec.symbol(def.asset().items(), def.asset().size()); - fsec.cfi_code(def.cfiCode().items(), def.cfiCode().size()); - fsec.alt_symbol(def.securityGroup().items(), def.securityGroup().size()); - fsec.security_desc(def.symbol().items(), def.symbol().size()); - fsec.exchange = api::Venue::VENUE_GLBX; - // tickRule not present in futures - fsec.cme_market_segment_id = def.marketSegmentId(); - fsec.display_factor = def.displayFactor().exponent() + floorlog10(def.displayFactor().mantissa()); - - def.mainFraction(fsec.cme_main_fraction); - def.subFraction(fsec.cme_sub_fraction); - def.priceDisplayFormat(fsec.cme_price_display_format); -} template diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h index 0f0e4893c..e9f95229a 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h @@ -1,4 +1,5 @@ #include "lib/utils/bts_assert.h" +#include "lib/utils/helper_macros.h" #include "lib/md/ice/ICEUtils.h" #include "lib/md/coconut2.h" @@ -10,40 +11,50 @@ namespace bts { namespace md { + +template +double double_of_price(const OnixPrice& price, int8_t display_factor) +{ + double dbl = price / pow10(display_factor); + return dbl; +} -inline PriceSize pricesize_of_price_size(const onixs::Decimal price, int8_t display_factor, Size size) { - PriceSize result({price.mantissa(), (int8_t)(price.exponent() + display_factor)}, size); +template <> +double double_of_price(const onixs::Rational& price, int8_t display_factor) +{ + UNUSED(display_factor); + double dbl = price.convertTo(); + return dbl; +} + + +template +IntPrice convert_price(const OnixsPrice& price, int8_t display_factor) +{ + double dbl = double_of_price(price, display_factor); + const int PRECISION = 7; + auto intpx = md::IntPrice_from_double(dbl); + return intpx; +} + +inline PriceSize pricesize_of_price_size(const onixs::Rational price, int8_t display_factor, Size size) +{ + auto intpx = convert_price(price, display_factor); + PriceSize result({intpx.mantissa(), (int8_t)(intpx.exponent() + display_factor)}, size); return result; } -template -double double_of_price(const OnixPrice& price, int8_t display_factor) { - // order of multiplication is important because of floating point error - return (price.mantissa() * pow10(price.exponent())) * pow10(display_factor); +inline datetime::LLDateTime ll_of_timestamp(const onixs::DateTime& dt) +{ + return datetime::ll_from_unix_epoch_ms(dt); } -template -IntPrice convert_price(const OnixsPrice& price, int8_t display_factor) { - return IntPrice(price.mantissa(), price.exponent() + display_factor); +inline datetime::Date date_of_timestamp(const onixs::DateTime& dt) +{ + auto ll = ll_of_timestamp(dt); + return datetime::ll_to_date(ll); } -inline datetime::LLDateTime ll_of_timestamp(const onixs::Timestamp& ts) { - return datetime::ll_from_parts(ts.year(), (int)ts.month(), ts.day(), ts.hour(), ts.minute(), ts.second(), ts.millisecond()); -} - -inline datetime::Date date_of_timestamp(const onixs::Timestamp& ts) { - return datetime::Date(ts.year(), (int)ts.month(), ts.day()); -} - -template -datetime::Date date_of_maturity(const Definition& def) { - for (const auto& event : def.events()) { - if (event.eventType() == onixs::EventType::LastEligibleTradeDate) { - return date_of_timestamp(event.eventTime()); - } - } - return datetime::Date(); -} }}//namespace \ No newline at end of file diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp index 3440fc842..23613c5f6 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp @@ -67,14 +67,15 @@ void ICEMain::run(std::vector& symbols) _listeners.push_back(prepare_listener(*phandler, channel)); _handlers.insert(std::make_pair(channel.id, move(phandler))); std::stringstream symstr; - for (const auto& sym : channel.symbols) { symstr << sym.symbol() << "-" << SecurityType_Name(sym.type()) << " "; } + for (const auto& sym : channel.symbols) + symstr << sym.symbol() << "-" << SecurityType_Name(sym.type()) << " "; LOG(md,Info, "ICE: Initialized channel {} ({})",channel.id,symstr.str()); } for (auto& pair : _handlers) { onixs::MarketSubscriptions subs = market_subcription_for_channel(pair.first); - pair.second->start(settings); + pair.second->start(subs); } // @@ -83,9 +84,7 @@ void ICEMain::run(std::vector& symbols) utils::DispatcherTimer heartbeat_timer(disp, 250, [&]() { for (const auto& listener: _listeners) - { listener->heartbeat(); - } }); heartbeat_timer.start(); LOG(md,Info, "** ICE Publisher started **"); @@ -117,131 +116,81 @@ void ICEMain::run(std::vector& symbols) // // // Initialize HandlerSettings and allocate the channel Handler -unique_ptr ICEMain::prepare_handler(const string& channel_id) { +unique_ptr ICEMain::prepare_handler(const string& channel_id) +{ + // + // License path + const auto& ice_options = config::get(); + auto license_location = os::bts_data_path() + "/licenses/"; + if (!boost::filesystem::is_directory(license_location)) + { + auto license_path =os::sparkd_wd() + "/data_files/Onixs.BTS.lic" ; + boost::filesystem::create_directories(license_location); + boost::filesystem::copy_file(license_path,license_location+"/Onixs.BTS.lic"); + } + auto license = ice_options.onixs_license(); + if (license == "{default}") + license = (license_location; + const auto& pub_options = config::get(); const auto& options = channel_settings_for(channel_id); - LOG(md,Info,"Loaded channel options for channel {}:\n{}",channel_id ,options.DebugString()); + LOG(md,Info,"Loaded channel options for channel {}:\n{}",channel_id,options.DebugString()); onixs::HandlerSettings settings; - settings.channel(std::stoul(channel_id)); - settings.feeds().connectivityConfigurationFile(config_path()); - - // Market data options - settings.bookManagement().directBooks().maintain(true); - settings.bookManagement().impliedBooks().maintain(true); - settings.bookManagement().consolidatedBooks().maintain(false); - - // 10k default is *far* too low - settings.recoveryQueueMaxSize(options.recovery_queue_size()); + settings.licenseDirectory = license; + // + // Logging + settings.logLevel = (onixs::LogLevels::Enum) = options.onixs_log_mode(); + settings.logDirectory = ice_log_path(); + + // + // Config file + settings.connectivityConfiguration(ice_config_path()); // // Network settings - - if (options.has_lost_packet_wait_timeout_ms()) { - settings.feeds().incrementalFeeds().lostPacketWaitTime((size_t)options.lost_packet_wait_timeout_ms() * 1000); - } - if (pub_options.has_network_interface()) { + if (pub_options.has_network_interface()) + { settings.feeds().feedANetworkInterfaces(pub_options.network_interface()); settings.feeds().feedBNetworkInterfaces(pub_options.network_interface()); } - else { - if (pub_options.has_network_interface_a()) { - settings.feeds().feedANetworkInterfaces(pub_options.network_interface_a()); - } - if (pub_options.has_network_interface_b()) { - settings.feeds().feedBNetworkInterfaces(pub_options.network_interface_b()); - } - } - - if (pub_options.has_network_interface() || - (pub_options.has_network_interface_a() && - pub_options.has_network_interface_b()) ) { - if (options.prefer_backup_feeds()) { - settings.feeds().instrumentFeeds().layout(onixs::RecoveryFeedLayout::FeedBWithFailoverToFeedA); - settings.feeds().incrementalFeeds().layout(onixs::RealtimeFeedLayout::BothFeedsWithArbitrage); - settings.feeds().snapshotFeeds().layout(onixs::RecoveryFeedLayout::FeedBWithFailoverToFeedA); - settings.feeds().mboSnapshotFeeds().layout(onixs::RecoveryFeedLayout::FeedBWithFailoverToFeedA); - } - else { - auto layout = onixs::RecoveryFeedLayout::FeedAWithFailoverToFeedB; - settings.feeds().instrumentFeeds().layout(layout); - settings.feeds().incrementalFeeds().layout(onixs::RealtimeFeedLayout::BothFeedsWithArbitrage); - settings.feeds().snapshotFeeds().layout(layout); - settings.feeds().mboSnapshotFeeds().layout(layout); - } - } - else if (pub_options.has_network_interface_a()) { - auto layout = onixs::RecoveryFeedLayout::FeedAOnly; - settings.feeds().instrumentFeeds().layout(layout); - settings.feeds().incrementalFeeds().layout(onixs::RealtimeFeedLayout::FeedAOnly); - settings.feeds().snapshotFeeds().layout(layout); - settings.feeds().mboSnapshotFeeds().layout(layout); - } - else if (pub_options.has_network_interface_b()) { - auto layout = onixs::RecoveryFeedLayout::FeedBOnly; - settings.feeds().instrumentFeeds().layout(layout); - settings.feeds().incrementalFeeds().layout(onixs::RealtimeFeedLayout::FeedBOnly); - settings.feeds().snapshotFeeds().layout(layout); - settings.feeds().mboSnapshotFeeds().layout(layout); - } + else + { + if (pub_options.has_network_interface_a()) + settings.feeds().feedANetworkInterfaces(pub_options.network_interface_a()); + if (pub_options.has_network_interface_b()) + settings.feeds().feedBNetworkInterfaces(pub_options.network_interface_b()); + } + settings.udpBufferSize = options.udp_buffer_size(); + settings.heartbeatInterval = options.heartbeat_interval(); + settings.sequenceGapMargin = options.sequence_gap_margin(); + settings.gapTimeoutInMilliseconds = options.gap_timeout_in_ms(); + + // + // Snapshot recovery options + settings.snapshotRecoveryOptions.snapshotRecoveryTimeoutInMilliseconds = options.snapshot_recovery_timeout_in_ms(); + settings.snapshotRecoveryOptions.maximumNumberOfSnaphotRecoveryAttempts = options.maximum_number_of_snapshot_recovery_attempts(); + settings.snapshotRecoveryOptions.maximumSizeOfSnapshotMessageQueue = options.maximum_size_of_snapshot_message_queue(); + settings.snapshotRecoveryOptions.maximumSizeOfLiveMessageQueue = options.maximum_size_of_live_message_queue(); // - // Misc settings - - settings.bookManagement().updateNotification(onixs::BookUpdateNotification::OnEndOfEvent); - settings.tradeProcessing( - config::get().verbose_ticker() ? - onixs::TradeProcessing::OrderDetails : - onixs::TradeProcessing::SummaryLevel); - + // Misc settings + if(options.processing_thread_affinity() != "" ) + settings.processingThreadAffinity = onixs::ThreadAffinity::deserialize(options.processing_thread_affinity()); + if(settings.has_track_top_of_the_book_only() + settings.trackTopOfTheBookOnly = options.track_top_of_the_book_only(); + if(settings.has_receive_product_definitions_only()) + settings.receiveProductDefinitionsOnly = options.receive_product_definitions_only(); + if(options.has_max_multicast_message_block_size() && options.max_multicast_message_block_size() > 0) + settings.maxMulticastMessageBlockSize = options.max_multicast_message_block_size(); + if(options.product_definition_cache_directory() != "" ) + settings.productDefinitionCacheDirectory = options.product_definition_cache_directory(); + // - // Logging - onixs::Logger* logger; - if (options.onixs_log_mode() == ICEOptions_OnixSLogMode_None) { - logger = new onixs::NullLogger(); - } - else { - onixs::FileLoggerSettings loggerSettings; - loggerSettings.filename(log_path() + "/log_" + channel_id); - loggerSettings.severityLevel((onixs::LogSeverity::Enum)options.onixs_log_mode()); - logger = new onixs::FileLogger(loggerSettings); - if (options.onixs_log_mode() == ICEOptions::Debug) { - // trace all the things - settings.debugLogging().traceBooks(true); - settings.debugLogging().traceFeeds(true); - settings.debugLogging().traceMessages(onixs::MessageTracing::FixFormat); - } - } - - - // - // Tcp Replay options - - std::unique_ptr recovery; - if (options.use_tcp_replay()) { - LOG(md,Info,"ICE: Enabled TCP replay"); - onixs::TcpRecoverySettings tcpSettings; - tcpSettings.username(options.tcp_replay_username()); - tcpSettings.password(options.tcp_replay_password()); - tcpSettings.reconnectAttempts(options.tcp_replay_connect_attempts()); - tcpSettings.reconnectInterval(options.tcp_replay_reconnect_interval_ms()); - recovery.reset(new onixs::TcpRecoveryService(tcpSettings)); - } - - // - // Associate with feed handler - - try { + // return feed handler + try + { auto handler = unique_ptr(new onixs::Handler(settings)); - handler->bindFeedEngine(*_engines.at(options.feed_engine())); - if (recovery) { - handler->bindTcpRecovery(*recovery); - _recovery.push_back(std::move(recovery)); - } - if (logger) { - handler->bindLogger(*logger); - } - return handler; } catch (std::exception& e) { From a3b8d579a184bdac0f9397c7d938c1bf75fca8f1 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Tue, 26 Feb 2019 18:20:22 -0500 Subject: [PATCH 09/72] hooked up all ice callbacks except books --- src/lib/domain_model/Security.proto | 3 + src/lib/md/Shm/FixedSecurity.cpp | 10 +- src/lib/md/Shm/FixedSecurity.h | 2 + .../md/platforms/ice_onixs/ICEListener.cpp | 260 +++++++++------- .../md/platforms/ice_onixs/ICEListener.h | 288 +----------------- .../platforms/ice_onixs/ICEListenerHelpers.h | 2 +- 6 files changed, 181 insertions(+), 384 deletions(-) diff --git a/src/lib/domain_model/Security.proto b/src/lib/domain_model/Security.proto index 5e921021e..959787924 100644 --- a/src/lib/domain_model/Security.proto +++ b/src/lib/domain_model/Security.proto @@ -92,6 +92,9 @@ message CBOECFEExchangeData { int32 class_key = 30; } message ICEExchangeData { + int64 exchange_id = 10; + int32 deal_display_factor = 20; + int32 settle_display_factor = 30; } message FutureContract { diff --git a/src/lib/md/Shm/FixedSecurity.cpp b/src/lib/md/Shm/FixedSecurity.cpp index 7f7f78787..2c217c7b5 100644 --- a/src/lib/md/Shm/FixedSecurity.cpp +++ b/src/lib/md/Shm/FixedSecurity.cpp @@ -169,6 +169,10 @@ void convert_security(const FixedSecurity& source, Security* presult) { dest.mutable_glbx()->set_cme_symbol(source.alt_symbol()); if (source.cme_market_segment_id != 0) dest.mutable_glbx()->set_market_segment_id(source.cme_market_segment_id); break; + case Venue::VENUE_ICE: + dest.mutable_ice()->set_deal_display_factor(source.ice_deal_display_factor); + dest.mutable_ice()->set_settle_display_factor(source.ice_settle_display_factor); + break; case Venue::VENUE_BTS: break; default: @@ -257,7 +261,7 @@ uint64_t exchange_id(const Security& security) { case Security::ExchangeDataCase::kCboe: return security.cboe().exchange_id(); case Security::ExchangeDataCase::kGlbx: return security.glbx().exchange_id(); case Security::ExchangeDataCase::kCfe: return security.cfe().exchange_id(); - case Security::ExchangeDataCase::kIce: bts_assert(false); + case Security::ExchangeDataCase::kIce: return security.ice().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. @@ -288,7 +292,9 @@ void convert_security(const Security& src, FixedSecurity& dest, bool set_securit dest.cboe_class_key = src.cfe().class_key(); break; case Security::ExchangeDataCase::kIce: - bts_assert_d(false); + dest.ice_deal_display_factor = src.ice().deal_display_factor(); + dest.ice_settle_display_factor = src.ice().settle_display_factor(); + break; case Security::ExchangeDataCase::EXCHANGEDATA_NOT_SET: break; } diff --git a/src/lib/md/Shm/FixedSecurity.h b/src/lib/md/Shm/FixedSecurity.h index 0ad9e4ffa..c2421f4d9 100644 --- a/src/lib/md/Shm/FixedSecurity.h +++ b/src/lib/md/Shm/FixedSecurity.h @@ -59,6 +59,8 @@ public: uint8_t cme_main_fraction; uint8_t cme_sub_fraction; uint8_t cme_price_display_format; + int8_t ice_deal_display_factor; + int8_t ice_settle_display_factor; private: char _symbol[16]; // CME defines this as a char[6] but I'm padding diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp index 99a20c820..2230cc5a8 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp @@ -15,7 +15,6 @@ namespace md { ICEListener::ICEListener(ICESecurityIndex& index, MDProducer& producer, const std::vector channels) : _index(index), _producer(producer), - _verbose_ticker(config::get().verbose_ticker()), _packet_arrived(), _latest_sequence(0), _symbol_filter(), @@ -91,53 +90,30 @@ void ICEListener::onOptionsStrategyDefinition(const onixs::OptionsStrategyDefini void ICEListener::onNewOptionsStrategyDefinition(const onixs::NewOptionsStrategyDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) {} - - -// // -// // Mark the start/end of a packet -// void ICEListener::onPacket(onixs::Handler&, const onixs::PacketArgs& args) { -// // Mark the arrival of the packet -// _packet_arrived = TimeStamp::now(); -// auto seq = args.seqNumber(); -// if (!_book_updates.empty()) { -// if (_latest_sequence != seq) { -// LOG(md, Error, "Expected sequence {} got {} did not flush {} book updates.", -// _latest_sequence, seq, _book_updates.size()); -// } -// } -// _latest_sequence = seq; -// auto onixs_zero = args.receiveTime().sinceEpoch(); -// auto onixs_now = OnixS::ICE::MDH::UtcWatch::now().sinceEpoch(); - -// // needed for clang compilation -// UNUSED(onixs_zero); -// UNUSED(onixs_now); -// // was needed for clang compilation - -// tracepoint (bts_trace,trace_order,(char*) "onPacket", -// _latest_sequence,(uint16_t) _latest_sequence, onixs_now-onixs_zero); -// } -// void ICEListener::onEndOfPacket(onixs::Handler&, const onixs::PacketArgs&) { -// tracepoint (bts_trace,trace_order,(char*) "onEndOfPacket.begin", _latest_sequence, (uint16_t) _latest_sequence, 0); -// flush_books(); -// tracepoint (bts_trace,trace_order,(char*) "onEndOfPacket.end", _latest_sequence, (uint16_t) _latest_sequence, 0); -// } - +//TODO // -// Security discovery +// Gap Recovery +void ICEListener::onMarketSnapshot(const onixs::MarketSnapshot& msg, const onixs::MessageInfo& msgInfo) override; +void ICEListener::onMarketSnapshotOrder(const onixs::MarketSnapshotOrder& msg, const onixs::MessageInfo& msgInfo) override; +void ICEListener::onMarketSnapshotPriceLevel(const onixs::MarketSnapshotPriceLevel& msg, const onixs::MessageInfo& msgInfo) override; + +// +// Book +void ICEListener::onOrderBookUpdated(const onixs::OrderBook& book, const onixs::MessageInfo& msgInfo) +{ +// void ICEListener::onBookUpdate(onixs::Handler&, const onixs::Security& sec, const onixs::DirectBook& book) { +// onBookUpdate(sec, book, book_type_direct); +// } -void ICEListener::onBookUpdate(onixs::Handler&, const onixs::Security& sec, const onixs::DirectBook& book) { - onBookUpdate(sec, book, book_type_direct); -} - -void ICEListener::onBookUpdate(onixs::Handler&, const onixs::Security& sec, const onixs::ImpliedBook& book) { - onBookUpdate(sec, book, book_type_implied); +// void ICEListener::onBookUpdate(onixs::Handler&, const onixs::Security& sec, const onixs::ImpliedBook& book) { +// onBookUpdate(sec, book, book_type_implied); +// } } // // Trades - -AggressorSide map_aggressor(onixs::AggressorSide::Enum agside) { +AggressorSide map_aggressor(onixs::AggressorSide::Enum agside) +{ switch(agside) { default: case onixs::AggressorSide::NoAggressor: @@ -149,78 +125,155 @@ AggressorSide map_aggressor(onixs::AggressorSide::Enum agside) { } } -void on_trade(SecurityData* data, const onixs::Decimal& price, int size, onixs::AggressorSide::Enum agside, const onixs::Timestamp& onixs_date) { +void on_trade(SecurityData* data, const onixs::Price& price, int size, onixs::AggressorSide::Enum agside, const onixs::DateTime& onixs_date) +{ auto ts = utils::TimeStamp::now(); PriceSize ps = pricesize_of_price_size(price, data->handle.security().display_factor, size); auto date = ll_of_timestamp(onixs_date); - data->handle.add_trade(ts, ps, date, map_aggressor(agside), data->electronic_volume + size); + data->handle.add_trade(ts, ps, date, map_aggressor(agside), size); +} + +void ICEListener::onTrade(const onixs::Trade& msg, const onixs::MessageInfo& msgInfo) +{ + tracepoint (bts_trace,trace_order,(char*) "onTrade", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(msg.marketId); + if (data != NULL) + { + auto size = msg.quantity; + auto price = msg.price; + onixs::AggressorSide::Enum agside = msg.aggressorSide; + on_trade(data, price, size, agside, msg.transactDateTime); + } } // // RFQ -void ICEListener::onQuoteRequest(onixs::Handler&, const onixs::Security& sec, const onixs::QuoteRequest39RelatedSymArgs& arg) { - tracepoint (bts_trace,trace_order,(char*) "onQuoteRequest", _latest_sequence, (uint16_t) _latest_sequence, 0); - auto* data = _index.get_security(sec.id()); - if (data != nullptr) { +void ICEListener::onRfq(const onixs::Rfq& msg, const onixs::MessageInfo& msgInfo) +{ + tracepoint (bts_trace,trace_order,(char*) "onRfq", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(msg.marketId); + if (data != nullptr) + { auto ts = utils::TimeStamp::now(); - co2::QuoteRequestMessage message; message.set_key(data->handle.key()); - auto time = ll_of_timestamp(arg.message().transactTime()); + auto time = ll_of_timestamp(msg.messageTimestamp); message.set_time(time); - onixs::StrRef id = arg.message().quoteReqId(); - message.set_request_id(id.items(), id.size()); + long long rfqid = msg.rfqSystemId; + message.set_request_id(std::to_string(rfqid)); // https://www.cmegroup.com/confluence/display/EPICSANDBOX/MDP+3.0+-+Request+for+Quote - int8_t side; - if (arg.entry().side(side)) { - switch(side) { - case 1: // buy - case '1': - message.set_side(co2::QuoteRequestMessage::BUY); - break; - case 2: // sell - case '2': - message.set_side(co2::QuoteRequestMessage::SELL); - break; - case 8: // cross - case '8': - message.set_side(co2::QuoteRequestMessage::CROSS); - break; - } + switch(msg.side) + { + case 0 // undef + case ' ': + message.set_side(co2::QuoteRequestMessage::UNDEFINED); + break; + case 1: // buy + case '1': + message.set_side(co2::QuoteRequestMessage::BUY); + break; + case 2: // sell + case '2': + message.set_side(co2::QuoteRequestMessage::SELL); + break; } - - message.set_tradable(arg.entry().quoteType() == 1); - - int32_t size; - if (arg.entry().orderQty(size)) { - message.set_size(size); - } - + message.set_size(msg.quantity); data->handle.add_rfq(ts, message); - - } + } } +// +// Misc +void ICEListener::onSettlementPrice(const onixs::SettlementPrice& msg, const onixs::MessageInfo& msgInfo) +{ + tracepoint (bts_trace,trace_order,(char*) "onSettlementPrice", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(msg.marketId); + if (data != nullptr) + { + onixs::Price price = msg.settlementPrice; + onixs::DateTime time = msg.dateTime; + auto display_factor = data->handle.security().display_factor; + data->handle.update_settlement(utils::TimeStamp::now(), convert_price(price, display_factor), date_of_timestamp(time)); + } +} + +void ICEListener::onOpenInterest(const onixs::OpenInterest &msg, const MessageInfo &msgInfo) +{} + +void ICEListener::onOpenPrice(const onixs::OpenPrice& msg, const onixs::MessageInfo& msgInfo) +{ + tracepoint (bts_trace,trace_order,(char*) "onOpenPrice", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(msg.marketId); + if (data != nullptr) + { + onixs::Price price = msg.openPrice; + onixs::DateTime time = msg.dateTime; + auto display_factor = data->handle.security().display_factor; + data->handle.update_opening( utils::TimeStamp::now(), double_of_price(price, display_factor), date_of_timestamp(time)); + } +} + +void ICEListener::onClosePrice(const onixs::ClosePrice& msg, const MessageInfo& msgInfo) +{ + tracepoint (bts_trace,trace_order,(char*) "onClosePrice", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(msg.marketId); + if (data != nullptr) + { + onixs::Price price = msg.closePrice; + onixs::DateTime time = msg.dateTime; + auto display_factor = data->handle.security().display_factor; + data->handle.update_closing( utils::TimeStamp::now(), double_of_price(price, display_factor), date_of_timestamp(time)); + } +} + +void ICEListener::onEndOfDayMarketSummary(const EndOfDayMarketSummary& msg, const MessageInfo& msgInfo) +{ + tracepoint (bts_trace,trace_order,(char*) "onEndOfDayMarketSummary", _latest_sequence, (uint16_t) _latest_sequence, 0); + auto* data = _index.get_security(msg.marketId); + if (data != nullptr) + { + onixs::DateTime time = msg.dateTime; + auto display_factor = data->handle.security().display_factor; + data->handle.update_opening( utils::TimeStamp::now(), double_of_price(msg.openingPrice, display_factor), date_of_timestamp(time)); + data->handle.update_session_high( utils::TimeStamp::now(), double_of_price(msg.high, display_factor), date_of_timestamp(time)); + data->handle.update_session_low( utils::TimeStamp::now(), double_of_price(msg.low, display_factor), date_of_timestamp(time)); + data->handle.update_settlement( utils::TimeStamp::now(), double_of_price(msg.settlementPrice, display_factor), date_of_timestamp(time)); + } +} // -// Volume -void ICEListener::onElectronicVolume(onixs::Handler&, const onixs::Security& sec, const onixs::Volume37Args& args) { - tracepoint (bts_trace,trace_order,(char*) "onElectronicVolume.volume", _latest_sequence, (uint16_t) _latest_sequence, 0); - auto* data = _index.get_security(sec.id()); - if (data != nullptr) { - bts_assert_d( args.entry().entryType().value() == 'e'); - bts_assert_d(args.entry().updateAction() == onixs::UpdateAction::New || - args.entry().updateAction() == onixs::UpdateAction::Change); - data->electronic_volume = args.entry().entrySize(); +// Feed +void ICEListener::onMulticastMessageBlockBegin(FeedId feedId, const MessageInfo& msg) +{ + // Mark the arrival of the packet + _packet_arrived = TimeStamp::now(); + auto seq = msg.sequenceNumber; + if (!_book_updates.empty()) + { + if (_latest_sequence != seq) + LOG(md, Error, "Expected sequence {} got {} did not flush {} book updates.", _latest_sequence, seq, _book_updates.size()); } + _latest_sequence = seq; + auto onixs_zero = msg.receiveTime; + auto onixs_now = onixs::Time::utcNow(); + + UNUSED(onixs_zero); + UNUSED(onixs_now); + tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockBegin", _latest_sequence,(uint16_t) _latest_sequence, onixs_now-onixs_zero); +} + +void ICEListener::onMulticastMessageBlockEnd(FeedId feedId, const MarketIds& marketIds) +{ + tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockEnd.begin", _latest_sequence, (uint16_t) _latest_sequence, 0); + flush_books(); + tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockEnd.end", _latest_sequence, (uint16_t) _latest_sequence, 0); } // // Non-onixs calls - void ICEListener::add_filter_symbol(const std::string& symbol) { _symbol_filter.insert(symbol); @@ -233,8 +286,8 @@ void ICEListener::heartbeat() // // Private functions - -void ICEListener::add_security(const FixedSecurity& security) { +void ICEListener::add_security(const FixedSecurity& security) +{ // Set up the shared memory for this security auto handle = _producer.add_security(security); bts_assert(security.numeric_id != 0); @@ -242,24 +295,25 @@ void ICEListener::add_security(const FixedSecurity& security) { _index.add_security(security.numeric_id, handle); } -void ICEListener::flush_books() { +void ICEListener::flush_books() +{ // This is called at the end of the packet // Write all book updates to shared memory and reset for the next packet - for (auto& entry : _book_updates) { + for (auto& entry : _book_updates) + { uint32_t sequence = _latest_sequence; - if (entry.type_flags == book_type_direct) { - entry.handle.update_direct(_packet_arrived, - entry.bids.first, entry.asks.first, sequence); + if (entry.type_flags == book_type_direct) + { + entry.handle.update_direct(_packet_arrived, entry.bids.first, entry.asks.first, sequence); } - else if (entry.type_flags == book_type_implied) { - entry.handle.update_implied(_packet_arrived, - entry.bids.second, entry.asks.second, sequence); + else if (entry.type_flags == book_type_implied) + { + entry.handle.update_implied(_packet_arrived, entry.bids.second, entry.asks.second, sequence); } - else if (entry.type_flags == book_type_both) { - entry.handle.update_books(_packet_arrived, - entry.bids.first, entry.asks.first, - entry.bids.second, entry.asks.second, - sequence); + else if (entry.type_flags == book_type_both) + { + entry.handle.update_books(_packet_arrived, entry.bids.first, entry.asks.first, + entry.bids.second, entry.asks.second, sequence); } } // Reset pending updates diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h index 18e36aaf3..e3201ccca 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h @@ -80,6 +80,12 @@ public: void onSettlementPrice(const onixs::SettlementPrice& msg, const onixs::MessageInfo& msgInfo) override; void onOpenInterest(const onixs::OpenInterest &msg, const MessageInfo &msgInfo) override; void onOpenPrice(const onixs::OpenPrice& msg, const onixs::MessageInfo& msgInfo) override; + void onClosePrice(const onixs::ClosePrice& msg, const MessageInfo& msgInfo) override; + void onEndOfDayMarketSummary(const EndOfDayMarketSummary& msg, const MessageInfo& msgInfo) override; + + // Feed + void onMulticastMessageBlockBegin(FeedId feedId, const MessageInfo& msgInfo) override; + void onMulticastMessageBlockEnd(FeedId feedId, const MarketIds& marketIds) override; // // Discover securities @@ -103,7 +109,6 @@ private: ICESecurityIndex& _index; MDProducer& _producer; - bool _verbose_ticker; utils::TimeStamp _packet_arrived; uint32_t _latest_sequence; std::set _symbol_filter; @@ -128,10 +133,12 @@ void set_security_common(const Definition& def, FixedSecurity& fsec) fsec.security_desc(def.marketDesc); fsec.exchange = api::Venue::VENUE_ICE; fsec.display_factor = (int8_t)def.orderPriceDenominator; + fsec.ice_deal_display_factor = (int8_t)def.dealPriceDenominator; + fsec.ice_settle_display_factor = (int8_t)def.settlePriceDenominator; double min_tick = double_of_price(def.incrementPrice, fsec.display_factor); fsec.low_tick = fsec.high_tick = min_tick; fsec.price_break = 0.; - fsec.cash_per_point = 0.; + fsec.cash_per_point = double_of_price(def.tickValue, fsec.display_factor); } template @@ -188,135 +195,7 @@ void on_future_spread(const Definition& def, bool& is_interested) } -#if false -////////////////////////////////////////// -// Template Member Function Definitions -////////////////////////////////////////// - - - -template -void ICEListener::onFuture(onixs::Handler&, const onixs::Security& osec, const InstrumentDefinition& def) { - tracepoint (bts_trace,trace_order,(char*) "onDefinition.future", _latest_sequence, (uint16_t) _latest_sequence, 0); - const auto& sec = def.message(); - auto exchange_id = sec.securityId(); - // LOG(md, Info, "onDefinition future {} {}", - // std::string(sec.asset().items(), sec.asset().size()), - // std::string(sec.symbol().items(), sec.symbol().size())); - - if (filter_security(exchange_id, sec) != ADD) return; - bts_assert(exchange_id == osec.id()); - - FixedFutureSecurity fsec; - - set_security_common(sec, fsec); - fsec.price_break = 0; - // low/high tick are stored non-premultiplied and multiplied in conversion to api::Secutity - double min_tick = double_of_price(sec.minPriceIncrement(), 0); - fsec.low_tick = fsec.high_tick = min_tick; - onixs::Decimal min_tick_amount; - sec.minPriceIncrementAmount(min_tick_amount); - double min_tick_dbl = double_of_price(min_tick_amount, 0); - fsec.cash_per_point = min_tick_dbl / min_tick / pow10(fsec.display_factor); - auto expiration = date_of_maturity(sec); - fsec.expiration_year = expiration.year; - fsec.expiration_month = expiration.month; - fsec.expiration_day = expiration.day; - add_security(fsec); -} - -template -void ICEListener::onOption(onixs::Handler&, const onixs::Security&, const InstrumentDefinition& def) { - tracepoint (bts_trace,trace_order,(char*) "onDefinition.option", _latest_sequence, (uint16_t) _latest_sequence, 0); - const auto& sec = def.message(); - auto exchange_id = sec.securityId(); - // LOG(Info, MarketData) << "onDefinition option " << exchange_id; - if (filter_security(exchange_id, sec) != ADD) return; - - FixedOptionSecurity fsec; - set_security_common(sec, fsec); - auto expiration = date_of_maturity(sec); - fsec.expiration_year = expiration.year; - fsec.expiration_month = expiration.month; - fsec.expiration_day = expiration.day; - - onixs::Decimal strike_price; - bts_assert(sec.strikePrice(strike_price)); - fsec.strike = double_of_price(strike_price, fsec.display_factor); - - onixs::Decimal min_tick, min_tick_amount; - sec.minPriceIncrement(min_tick); - sec.minPriceIncrementAmount(min_tick_amount); - - int8_t tick_rule; - if (sec.tickRule(tick_rule)) { - decode_ticks(tick_rule, double_of_price(min_tick, 0), fsec); - } - fsec.cash_per_point = double_of_price(min_tick_amount, 0) / fsec.low_tick / pow10(fsec.display_factor); - - fsec.call_put = sec.putOrCall() == onixs::PutOrCall::Call ? api::PUTORCALL_CALL : api::PUTORCALL_PUT; - - add_security(fsec); -} - -// min_tick specializations -inline onixs::Decimal tick_rule(const onixs::InstrumentDefinitionSpread29& sec) { - return sec.minPriceIncrement(); -} -inline onixs::Decimal tick_rule(const onixs::InstrumentDefinitionSpread56& sec) { - onixs::Decimal min_tick; - sec.minPriceIncrement(min_tick); - return min_tick; -} - -template -void ICEListener::onSpread(onixs::Handler&, const onixs::Security&, const InstrumentDefinition& spread_args) { - tracepoint (bts_trace,trace_order,(char*) "onDefinition.spread", _latest_sequence, (uint16_t) _latest_sequence, 0); - const auto& sec = spread_args.message(); - auto exchange_id = sec.securityId(); - // LOG(md, Info, "onDefinition spread {} {}", - // std::string(sec.asset().items(), sec.asset().size()), - // std::string(sec.symbol().items(), sec.symbol().size())); - if (filter_security(exchange_id, sec) != ADD) return; - - // Filter out any already expired spreads - auto expiration = date_of_maturity(sec); - if (expiration < datetime::today()) return; - - FixedSpreadSecurityL fsec; - set_security_common(sec, fsec); - - onixs::Decimal min_tick = tick_rule(sec); - - int8_t tick_rule; - if (sec.tickRule(tick_rule)) { - decode_ticks(tick_rule, double_of_price(min_tick, 0), fsec); - } - else { - double mintick = double_of_price(min_tick, 0); - fsec.low_tick = mintick; - fsec.high_tick = mintick; - fsec.price_break = 0; - } - - fsec.set_leg_count(sec.legs().size()); - for(size_t x = 0; x < fsec.leg_count(); ++x) { - const auto& leg = sec.legs()[x]; - onixs::Decimal price; - if (leg.legPrice(price)) { - fsec.legs[x].leg_price = double_of_price(price, fsec.display_factor); - } - onixs::Decimal qty; - if (leg.legOptionDelta(qty)) { - fsec.legs[x].leg_delta = double_of_price(qty, 0); - } - fsec.legs[x].leg_quantity = leg.legRatioQty(); - fsec.legs[x].leg_side = leg.legSide() == onixs::LegSide::BuySide ? api::SIDE_BUY : api::SIDE_SELL; - fsec.legs[x].exchange_key = ExchangeKey(leg.legSecurityId()); - fsec.legs[x].key = invalid_security_key; - } - add_security(fsec); -} +#if false /**********************************/ template void ICEListener::onBookUpdate(const onixs::Security& sec, const TBook& onixs_book, BookType booktype) { @@ -365,153 +244,6 @@ void ICEListener::onBookUpdate(const onixs::Security& sec, const TBook& onixs_bo } } -void on_trade(SecurityData* data, const onixs::Decimal& price, int size, onixs::AggressorSide::Enum agside, const onixs::Timestamp& onixs_date); - -template -void ICEListener::onTradeRecovery(const onixs::Security& sec, const TradeRecovery& arg) { - tracepoint (bts_trace,trace_order,(char*) "onTrade.recovery", _latest_sequence, (uint16_t) _latest_sequence, 0); - auto* data = _index.get_security(sec.id()); - if (data != NULL) { - int size = 0; - arg.entry().entrySize(size); - onixs::Decimal price; - arg.entry().entryPx(price); - on_trade(data, price, size, onixs::AggressorSide::NoAggressor, arg.message().transactTime()); - } -} - -template -void ICEListener::onTradeSummary(const onixs::Security& sec, const TradeSummary& arg) { - tracepoint (bts_trace,trace_order,(char*) "onTrade.summary", _latest_sequence, (uint16_t) _latest_sequence, 0); - auto* data = _index.get_security(sec.id()); - if (data != NULL) { - auto size = arg.entry().entrySize(); - onixs::Decimal price = arg.entry().entryPx(); - onixs::AggressorSide::Enum agside = onixs::AggressorSide::NoAggressor; - arg.entry().aggressorSide(agside); - if (_verbose_ticker) { - const auto& details = arg.orderIds(); - auto sz = details.size(); - for (size_t x = 0; x < sz; ++x) { - const auto& d = details[x]; - on_trade(data, price, d.lastQty(), agside, arg.message().transactTime()); - } - } - else { - on_trade(data, price, size, agside, arg.message().transactTime()); - } - } -} - - -template -void ICEListener::onElectronicVolume(const onixs::Security& sec, const RecoveryEntryArgs& args) { - tracepoint (bts_trace,trace_order,(char*) "onElectronicVolume.recovery", _latest_sequence, (uint16_t) _latest_sequence, 0); - auto* data = _index.get_security(sec.id()); - if (data) { - int32_t size; - if (args.entry().entrySize(size)) { - data->electronic_volume = size; - } - } -} - -template -void ICEListener::onSettlementPrice(const onixs::Security& sec, const StatisticsArgs& args) { - tracepoint (bts_trace,trace_order,(char*) "onSettlementPrice.daily", _latest_sequence, (uint16_t) _latest_sequence, 0); - auto* data = _index.get_security(sec.id()); - if (data != nullptr) { - onixs::Decimal price; - onixs::Timestamp time; - args.entry().entryPx(price); - args.entry().tradingReferenceDate(time); - auto display_factor = data->handle.security().display_factor; - data->handle.update_settlement( - utils::TimeStamp::now(), - convert_price(price, display_factor), - date_of_timestamp(time)); - } -} - -template -void ICEListener::onSessionOpeningPrice(const onixs::Security& sec, const SessionArgs& args) { - tracepoint (bts_trace,trace_order,(char*) "onOpeningPrice.session", _latest_sequence, (uint16_t) _latest_sequence, 0); - auto* data = _index.get_security(sec.id()); - if (data != nullptr) { - onixs::Decimal price = args.entry().entryPx(); - onixs::Timestamp time = args.message().transactTime(); - auto display_factor = data->handle.security().display_factor; - data->handle.update_opening( - utils::TimeStamp::now(), - double_of_price(price, display_factor), - date_of_timestamp(time)); - } -} -template -void ICEListener::onRecoveryOpeningPrice(const onixs::Security& sec, const RecoveryArgs& args) { - tracepoint (bts_trace,trace_order,(char*) "onOpeningPrice.recovery", _latest_sequence, (uint16_t) _latest_sequence, 0); - auto* data = _index.get_security(sec.id()); - if (data != nullptr) { - onixs::Decimal price; - args.entry().entryPx(price); - onixs::Timestamp time; - args.entry().tradingReferenceDate(time); - auto display_factor = data->handle.security().display_factor; - data->handle.update_opening( - utils::TimeStamp::now(), - double_of_price(price, display_factor), - date_of_timestamp(time)); - } -} - -template -void ICEListener::onSessionHighTradePrice(const onixs::Security& sec, const SessionArgs& args) { - tracepoint (bts_trace,trace_order,(char*) "onHighTradePrice.session", _latest_sequence, (uint16_t) _latest_sequence, 0); - auto* data = _index.get_security(sec.id()); - if (data != nullptr) { - auto display_factor = data->handle.security().display_factor; - data->handle.update_session_high( - utils::TimeStamp::now(), - double_of_price(args.entry().entryPx(), display_factor)); - } -} -template -void ICEListener::onRecoveryHighTradePrice(const onixs::Security& sec, const RecoveryArgs& args) { - tracepoint (bts_trace,trace_order,(char*) "onHighTradePrice.recovery", _latest_sequence, (uint16_t) _latest_sequence, 0); - auto* data = _index.get_security(sec.id()); - if (data != nullptr) { - auto display_factor = data->handle.security().display_factor; - onixs::Decimal price; - args.entry().entryPx(price); - data->handle.update_session_high( - utils::TimeStamp::now(), - double_of_price(price, display_factor)); - } -} -template -void ICEListener::onSessionLowTradePrice(const onixs::Security& sec, const SessionArgs& args) { - tracepoint (bts_trace,trace_order,(char*) "onLowTradePrice.session", _latest_sequence, (uint16_t) _latest_sequence, 0); - auto* data = _index.get_security(sec.id()); - if (data != nullptr) { - auto display_factor = data->handle.security().display_factor; - data->handle.update_session_low( - utils::TimeStamp::now(), - double_of_price(args.entry().entryPx(), display_factor)); - } -} -template -void ICEListener::onRecoveryLowTradePrice(const onixs::Security& sec, const RecoveryArgs& args) { - tracepoint (bts_trace,trace_order,(char*) "onLowTradePrice.recovery", _latest_sequence, (uint16_t) _latest_sequence, 0); - auto* data = _index.get_security(sec.id()); - if (data != nullptr) { - auto display_factor = data->handle.security().display_factor; - onixs::Decimal price; - args.entry().entryPx(price); - data->handle.update_session_low( - utils::TimeStamp::now(), - double_of_price(price, display_factor)); - } -} #endif diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h index e9f95229a..7fc5d5067 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h @@ -37,7 +37,7 @@ IntPrice convert_price(const OnixsPrice& price, int8_t display_factor) return intpx; } -inline PriceSize pricesize_of_price_size(const onixs::Rational price, int8_t display_factor, Size size) +inline PriceSize pricesize_of_price_size(const onixs::Price price, int8_t display_factor, Size size) { auto intpx = convert_price(price, display_factor); PriceSize result({intpx.mantissa(), (int8_t)(intpx.exponent() + display_factor)}, size); From 1c54b0140bb1cc57a2d35fc383ba11b605e62a27 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Wed, 27 Feb 2019 16:41:38 -0500 Subject: [PATCH 10/72] ready to test, but we need to solve a link issue --- src/lib/config/defaults/MarketData.conf | 28 ++-- src/lib/config/protos/MarketData.proto | 2 +- src/lib/md/ice/ICEUtils.cpp | 3 +- src/lib/md/ice/ICEUtils.h | 3 +- src/server/sparkd/CMakeLists.txt | 1 + .../md/platforms/ice_onixs/ICEListener.cpp | 145 ++++++++++++------ .../md/platforms/ice_onixs/ICEListener.h | 114 ++++++++------ .../platforms/ice_onixs/ICEListenerHelpers.h | 19 ++- .../sparkd/md/platforms/ice_onixs/ICEMain.cpp | 58 ++++--- .../sparkd/md/platforms/ice_onixs/ICEMain.h | 3 +- 10 files changed, 234 insertions(+), 142 deletions(-) diff --git a/src/lib/config/defaults/MarketData.conf b/src/lib/config/defaults/MarketData.conf index f199f5c79..9a94cb5bb 100644 --- a/src/lib/config/defaults/MarketData.conf +++ b/src/lib/config/defaults/MarketData.conf @@ -39,25 +39,15 @@ CMEOptions { } ICEOptions { - value { - feed_engine { - name: "impactfeed1" - product_definition_cache_directory: "" - udp_buffer_size: 67108864 - } - feed_engine { - name: "impactfeed2" - product_definition_cache_directory: "" - } - channel { - id: "ICE Futures WTI" - feed_engine: "impactfeed1" - } - channel { - id: "*" - feed_engine: "impactfeed2" - } - } + value { + channel { + id: "ICE Futures WTI" + udp_buffer_size: 67108864 + } + channel { + id: "*" + } + } } MDBootDelayWindow { diff --git a/src/lib/config/protos/MarketData.proto b/src/lib/config/protos/MarketData.proto index 47e5031aa..cd245e9f1 100755 --- a/src/lib/config/protos/MarketData.proto +++ b/src/lib/config/protos/MarketData.proto @@ -143,7 +143,7 @@ message ICEOptions //a channel is for what onixs-ice would consider a mcast group, we still have to dereference the marketType codes within the group message ICEChannel { - optional string id = 1; + repeated string id = 1; optional uint32 udp_buffer_size = 2 [default = 33554432]; //32mb optional uint32 heartbeat_interval = 3 [default = 36000]; optional uint32 sequence_gap_margin = 4 [default = 10000]; diff --git a/src/lib/md/ice/ICEUtils.cpp b/src/lib/md/ice/ICEUtils.cpp index e9527ed1a..aca0f3fbd 100644 --- a/src/lib/md/ice/ICEUtils.cpp +++ b/src/lib/md/ice/ICEUtils.cpp @@ -20,6 +20,7 @@ using namespace bts::api; namespace bts { namespace md { +namespace ice { string ice_data_path() { auto p = config::get().data_path() + "ice/"; @@ -156,5 +157,5 @@ const vector parse_ice_channels(const vector& symbols) { return result; } -}}//namespace +}}} //namespace #endif \ No newline at end of file diff --git a/src/lib/md/ice/ICEUtils.h b/src/lib/md/ice/ICEUtils.h index 604ad1b81..bd4875e45 100644 --- a/src/lib/md/ice/ICEUtils.h +++ b/src/lib/md/ice/ICEUtils.h @@ -7,6 +7,7 @@ namespace bts { namespace md { +namespace ice { struct ICEConnection { std::string feed_type; @@ -29,5 +30,5 @@ const std::string ice_config_path(); const std::string ice_log_path(); -}}//namespace +}}} //namespace diff --git a/src/server/sparkd/CMakeLists.txt b/src/server/sparkd/CMakeLists.txt index 2213ae62c..f41796fba 100644 --- a/src/server/sparkd/CMakeLists.txt +++ b/src/server/sparkd/CMakeLists.txt @@ -26,6 +26,7 @@ target_link_libraries( sparkd cryptopp tbb onixs-cmemdh-all-4.8.0 + OnixS.IceImpactMulticastPriceFeedHandlerCpp quickfix benchmark lttng-ust diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp index 2230cc5a8..fe551131a 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp @@ -7,9 +7,11 @@ using namespace std; using namespace bts::co2; +using namespace bts::md::ice; namespace bts { namespace md { +namespace ice { ICEListener::ICEListener(ICESecurityIndex& index, MDProducer& producer, const std::vector channels) : @@ -29,12 +31,12 @@ ICEListener::~ICEListener() {} // //State change -void ICEListener::onHandlerStateChange(const onixs::HandlerStateChange& change) +void ICEListener::onHandlerStateChange(const onixs::HandlerStateChange& ) { //TODO } -void ICEListener::onMarketStateChange(const onixs::MarketStateChange& msg, const onixs::MessageInfo& msgInfo) +void ICEListener::onMarketStateChange(const onixs::MarketStateChange& , const onixs::MessageInfo& ) { //TODO } @@ -44,17 +46,17 @@ void ICEListener::onMarketStateChange(const onixs::MarketStateChange& msg, const void ICEListener::onError(const onixs::Error& error) { tracepoint (bts_trace,trace_order,(char*) "onError", _latest_sequence, (uint16_t) _latest_sequence, 0); - LOG(md,Warn, "OnixS Error: {} - {}", error.description(), error.source()); + LOG(md,Warn, "OnixS Error: {} - {}", error.toString() ); } void ICEListener::onFeedError(onixs::FeedId feedid, onixs::ErrorCode code, const std::string& desc) { tracepoint (bts_trace,trace_order,(char*) "onFeedError", _latest_sequence, (uint16_t) _latest_sequence, 0); - LOG(md,Warn, "OnixS FeedError: {} - {}", desc, code); + LOG(md,Warn, "OnixS FeedError: {} - {}", feedid, desc, code); } void ICEListener::onWarning(const onixs::Warning& warning) { tracepoint (bts_trace,trace_order,(char*) "onWarning", _latest_sequence, (uint16_t) _latest_sequence, 0); - LOG(md,Warn, "OnixS Warn: {} - {}", warning.description(), warning.source()); + LOG(md,Warn, "OnixS Warn: {} - {}", warning.toString() ); } // @@ -66,6 +68,7 @@ void ICEListener::onFuturesProductDefinition(const onixs::FuturesProductDefiniti } void ICEListener::onNewExpiry(const onixs::NewExpiry& msg, bool& is_interested, const onixs::MessageInfo& msg_info) { + UNUSED(msg_info); tracepoint (bts_trace,trace_order,(char*) "onNewExpiry", _latest_sequence, (uint16_t) _latest_sequence, 0); on_future(msg, is_interested); } @@ -75,39 +78,64 @@ void ICEListener::onFuturesStrategyDefinition(const onixs::FuturesStrategyDefini tracepoint (bts_trace,trace_order,(char*) "onFuturesStrategyDefinition", _latest_sequence, (uint16_t) _latest_sequence, 0); on_future_spread(def, is_interested); } -void ICEListener::onNewFuturesStrategyDefinition(const onixs::NewFuturesStrategyDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) override +void ICEListener::onNewFuturesStrategyDefinition(const onixs::NewFuturesStrategyDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) { + UNUSED(msg_info); tracepoint (bts_trace,trace_order,(char*) "onFuturesStrategyDefinition", _latest_sequence, (uint16_t) _latest_sequence, 0); on_future_spread(msg, is_interested); } void ICEListener::onOptionsProductDefinition(const onixs::OptionsProductDefinition& msg, bool& is_interested) -{ } +{ + UNUSED(msg); + UNUSED(is_interested); +} void ICEListener::onNewOptionsMarketDefinition(const onixs::NewOptionsMarketDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) -{ } +{ + UNUSED(msg); + UNUSED(is_interested); + UNUSED(msg_info); +} void ICEListener::onOptionsStrategyDefinition(const onixs::OptionsStrategyDefinition& msg, bool& is_interested) -{} +{ + UNUSED(msg); + UNUSED(is_interested); +} void ICEListener::onNewOptionsStrategyDefinition(const onixs::NewOptionsStrategyDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) -{} +{ + UNUSED(msg); + UNUSED(is_interested); + UNUSED(msg_info); +} //TODO // // Gap Recovery -void ICEListener::onMarketSnapshot(const onixs::MarketSnapshot& msg, const onixs::MessageInfo& msgInfo) override; -void ICEListener::onMarketSnapshotOrder(const onixs::MarketSnapshotOrder& msg, const onixs::MessageInfo& msgInfo) override; -void ICEListener::onMarketSnapshotPriceLevel(const onixs::MarketSnapshotPriceLevel& msg, const onixs::MessageInfo& msgInfo) override; - +void ICEListener::onMarketSnapshot(const onixs::MarketSnapshot& msg, const onixs::MessageInfo& msg_info) +{ + UNUSED(msg); + UNUSED(msg_info); +} + +void ICEListener::onMarketSnapshotOrder(const onixs::MarketSnapshotOrder& msg, const onixs::MessageInfo& msg_info) +{ + UNUSED(msg); + UNUSED(msg_info); +} + +void ICEListener::onMarketSnapshotPriceLevel(const onixs::MarketSnapshotPriceLevel& msg, const onixs::MessageInfo& msg_info) +{ + UNUSED(msg); + UNUSED(msg_info); +} + // // Book -void ICEListener::onOrderBookUpdated(const onixs::OrderBook& book, const onixs::MessageInfo& msgInfo) +void ICEListener::onOrderBookUpdated(const onixs::OrderBook& book, const onixs::MessageInfo& msg_info) { -// void ICEListener::onBookUpdate(onixs::Handler&, const onixs::Security& sec, const onixs::DirectBook& book) { -// onBookUpdate(sec, book, book_type_direct); -// } - -// void ICEListener::onBookUpdate(onixs::Handler&, const onixs::Security& sec, const onixs::ImpliedBook& book) { -// onBookUpdate(sec, book, book_type_implied); -// } + UNUSED(msg_info); + on_book(book, book_type_direct); + on_book(book, book_type_implied); } // @@ -133,12 +161,14 @@ void on_trade(SecurityData* data, const onixs::Price& price, int size, onixs::Ag data->handle.add_trade(ts, ps, date, map_aggressor(agside), size); } -void ICEListener::onTrade(const onixs::Trade& msg, const onixs::MessageInfo& msgInfo) +void ICEListener::onTrade(const onixs::Trade& msg, const onixs::MessageInfo& msg_info) { + UNUSED(msg_info); tracepoint (bts_trace,trace_order,(char*) "onTrade", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(msg.marketId); if (data != NULL) { + bts_assert(data->id == (uint32_t)msg.marketId); auto size = msg.quantity; auto price = msg.price; onixs::AggressorSide::Enum agside = msg.aggressorSide; @@ -148,12 +178,14 @@ void ICEListener::onTrade(const onixs::Trade& msg, const onixs::MessageInfo& msg // // RFQ -void ICEListener::onRfq(const onixs::Rfq& msg, const onixs::MessageInfo& msgInfo) +void ICEListener::onRfq(const onixs::Rfq& msg, const onixs::MessageInfo& msg_info) { + UNUSED(msg_info); tracepoint (bts_trace,trace_order,(char*) "onRfq", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(msg.marketId); if (data != nullptr) { + bts_assert(data->id == (uint32_t)msg.marketId); auto ts = utils::TimeStamp::now(); co2::QuoteRequestMessage message; message.set_key(data->handle.key()); @@ -167,15 +199,12 @@ void ICEListener::onRfq(const onixs::Rfq& msg, const onixs::MessageInfo& msgInfo // https://www.cmegroup.com/confluence/display/EPICSANDBOX/MDP+3.0+-+Request+for+Quote switch(msg.side) { - case 0 // undef case ' ': message.set_side(co2::QuoteRequestMessage::UNDEFINED); break; - case 1: // buy case '1': message.set_side(co2::QuoteRequestMessage::BUY); break; - case 2: // sell case '2': message.set_side(co2::QuoteRequestMessage::SELL); break; @@ -187,12 +216,14 @@ void ICEListener::onRfq(const onixs::Rfq& msg, const onixs::MessageInfo& msgInfo // // Misc -void ICEListener::onSettlementPrice(const onixs::SettlementPrice& msg, const onixs::MessageInfo& msgInfo) +void ICEListener::onSettlementPrice(const onixs::SettlementPrice& msg, const onixs::MessageInfo& msg_info) { + UNUSED(msg_info); tracepoint (bts_trace,trace_order,(char*) "onSettlementPrice", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(msg.marketId); if (data != nullptr) { + bts_assert(data->id == (uint32_t)msg.marketId); onixs::Price price = msg.settlementPrice; onixs::DateTime time = msg.dateTime; auto display_factor = data->handle.security().display_factor; @@ -200,15 +231,20 @@ void ICEListener::onSettlementPrice(const onixs::SettlementPrice& msg, const oni } } -void ICEListener::onOpenInterest(const onixs::OpenInterest &msg, const MessageInfo &msgInfo) -{} - -void ICEListener::onOpenPrice(const onixs::OpenPrice& msg, const onixs::MessageInfo& msgInfo) +void ICEListener::onOpenInterest(const onixs::OpenInterest &msg, const onixs::MessageInfo &msg_info) { + UNUSED(msg); + UNUSED(msg_info); +} + +void ICEListener::onOpenPrice(const onixs::OpenPrice& msg, const onixs::MessageInfo& msg_info) +{ + UNUSED(msg_info); tracepoint (bts_trace,trace_order,(char*) "onOpenPrice", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(msg.marketId); if (data != nullptr) { + bts_assert(data->id == (uint32_t)msg.marketId); onixs::Price price = msg.openPrice; onixs::DateTime time = msg.dateTime; auto display_factor = data->handle.security().display_factor; @@ -216,12 +252,14 @@ void ICEListener::onOpenPrice(const onixs::OpenPrice& msg, const onixs::MessageI } } -void ICEListener::onClosePrice(const onixs::ClosePrice& msg, const MessageInfo& msgInfo) +void ICEListener::onClosePrice(const onixs::ClosePrice& msg, const onixs::MessageInfo& msg_info) { + UNUSED(msg_info); tracepoint (bts_trace,trace_order,(char*) "onClosePrice", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(msg.marketId); if (data != nullptr) { + bts_assert(data->id == (uint32_t)msg.marketId); onixs::Price price = msg.closePrice; onixs::DateTime time = msg.dateTime; auto display_factor = data->handle.security().display_factor; @@ -229,49 +267,64 @@ void ICEListener::onClosePrice(const onixs::ClosePrice& msg, const MessageInfo& } } -void ICEListener::onEndOfDayMarketSummary(const EndOfDayMarketSummary& msg, const MessageInfo& msgInfo) +void ICEListener::onEndOfDayMarketSummary(const onixs::EndOfDayMarketSummary& msg, const onixs::MessageInfo& msg_info) { + UNUSED(msg_info); tracepoint (bts_trace,trace_order,(char*) "onEndOfDayMarketSummary", _latest_sequence, (uint16_t) _latest_sequence, 0); auto* data = _index.get_security(msg.marketId); if (data != nullptr) { + bts_assert(data->id == (uint32_t)msg.marketId); onixs::DateTime time = msg.dateTime; auto display_factor = data->handle.security().display_factor; - data->handle.update_opening( utils::TimeStamp::now(), double_of_price(msg.openingPrice, display_factor), date_of_timestamp(time)); - data->handle.update_session_high( utils::TimeStamp::now(), double_of_price(msg.high, display_factor), date_of_timestamp(time)); - data->handle.update_session_low( utils::TimeStamp::now(), double_of_price(msg.low, display_factor), date_of_timestamp(time)); - data->handle.update_settlement( utils::TimeStamp::now(), double_of_price(msg.settlementPrice, display_factor), date_of_timestamp(time)); + data->handle.update_opening( utils::TimeStamp::now(), double_of_price(msg.openingPrice, display_factor), date_of_timestamp(time) ); + data->handle.update_session_high( utils::TimeStamp::now(), double_of_price(msg.high, display_factor) ); + data->handle.update_session_low( utils::TimeStamp::now(), double_of_price(msg.low, display_factor) ); + data->handle.update_settlement( utils::TimeStamp::now(), convert_price(msg.settlementPrice, display_factor), date_of_timestamp(time) ); } } // // Feed -void ICEListener::onMulticastMessageBlockBegin(FeedId feedId, const MessageInfo& msg) +void ICEListener::onMulticastMessageBlockBegin(onixs::FeedId feedId, const onixs::MessageInfo& msg_info) { + UNUSED(feedId); // Mark the arrival of the packet _packet_arrived = TimeStamp::now(); - auto seq = msg.sequenceNumber; + uint32_t seq = (uint32_t)msg_info.sequenceNumber; if (!_book_updates.empty()) { if (_latest_sequence != seq) LOG(md, Error, "Expected sequence {} got {} did not flush {} book updates.", _latest_sequence, seq, _book_updates.size()); } _latest_sequence = seq; - auto onixs_zero = msg.receiveTime; - auto onixs_now = onixs::Time::utcNow(); + auto onixs_zero = msg_info.receiveTime; + auto onixs_now = onixs::Timestamp::utcNow(); UNUSED(onixs_zero); UNUSED(onixs_now); - tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockBegin", _latest_sequence,(uint16_t) _latest_sequence, onixs_now-onixs_zero); + tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockBegin", _latest_sequence,(uint16_t) _latest_sequence, /*onixs_now-onixs_zero*/0); } -void ICEListener::onMulticastMessageBlockEnd(FeedId feedId, const MarketIds& marketIds) +void ICEListener::onMulticastMessageBlockEnd(onixs::FeedId feedId, const onixs::MarketIds& marketIds) { + UNUSED(feedId); + UNUSED(marketIds); tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockEnd.begin", _latest_sequence, (uint16_t) _latest_sequence, 0); flush_books(); tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockEnd.end", _latest_sequence, (uint16_t) _latest_sequence, 0); } +void ICEListener::onFeedStarted(onixs::FeedId, const onixs::MarketIds&) +{} + +void ICEListener::onFeedStopped(onixs::FeedId) +{} + +void ICEListener::onSessionNumberChange(onixs::FeedId , short , short ) +{} + + // // Non-onixs calls void ICEListener::add_filter_symbol(const std::string& symbol) @@ -328,8 +381,8 @@ void ICEListener::update_all_status(CoconutSecurityStatus status) }); } -md::ICEListener::BookData::BookData(MDProducerHandle & handle) : handle(handle), type_flags(0), bids(), asks() { } +md::ice::ICEListener::BookData::BookData(MDProducerHandle & handle) : handle(handle), type_flags(0), bids(), asks() { } -}}//namespace +}}} //namespace diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h index e3201ccca..cf248d798 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h @@ -16,14 +16,15 @@ namespace bts { namespace md { - +namespace ice { class ICEListener : public onixs::ExchangeListener, //One Thread - public onixs::HandlerStateChangeListener //One thread - public onixs::OrderBookUpdateListener //One thread //TODO? + public onixs::HandlerStateChangeListener, //One thread + public onixs::OrderBookUpdateListener, //One thread //TODO? public onixs::FeedListener, //Multi thread - public onixs::ErrorListener //Multi thread + public onixs::ErrorListener, //Multi thread + public onixs::WarningListener //Multi thread { typedef uint32_t BookType; @@ -78,14 +79,17 @@ public: // // Misc void onSettlementPrice(const onixs::SettlementPrice& msg, const onixs::MessageInfo& msgInfo) override; - void onOpenInterest(const onixs::OpenInterest &msg, const MessageInfo &msgInfo) override; + void onOpenInterest(const onixs::OpenInterest &msg, const onixs::MessageInfo &msgInfo) override; void onOpenPrice(const onixs::OpenPrice& msg, const onixs::MessageInfo& msgInfo) override; - void onClosePrice(const onixs::ClosePrice& msg, const MessageInfo& msgInfo) override; - void onEndOfDayMarketSummary(const EndOfDayMarketSummary& msg, const MessageInfo& msgInfo) override; + void onClosePrice(const onixs::ClosePrice& msg, const onixs::MessageInfo& msgInfo) override; + void onEndOfDayMarketSummary(const onixs::EndOfDayMarketSummary& msg, const onixs::MessageInfo& msgInfo) override; // Feed - void onMulticastMessageBlockBegin(FeedId feedId, const MessageInfo& msgInfo) override; - void onMulticastMessageBlockEnd(FeedId feedId, const MarketIds& marketIds) override; + void onMulticastMessageBlockBegin(onixs::FeedId feedId, const onixs::MessageInfo& msgInfo) override; + void onMulticastMessageBlockEnd(onixs::FeedId feedId, const onixs::MarketIds& marketIds) override; + void onFeedStarted(onixs::FeedId feedId, const onixs::MarketIds& ids) override; + void onFeedStopped(onixs::FeedId feedId) override; + void onSessionNumberChange(onixs::FeedId feedId, short oldSessionNumber, short newSessionNumber) override; // // Discover securities @@ -94,9 +98,17 @@ public: // Add a new security to the index void add_security(const FixedSecurity& security); +private: + template + void on_future(const Definition& def, bool& is_interested); + template + void on_future_spread(const Definition& def, bool& is_interested); + template + void on_book(const TBook& onixs_book, BookType booktype); private: enum SecurityFilterAction { ADD, SKIP, DELETE }; + template SecurityFilterAction filter_security(int exchange_id, const Definition& def) { @@ -137,21 +149,20 @@ void set_security_common(const Definition& def, FixedSecurity& fsec) fsec.ice_settle_display_factor = (int8_t)def.settlePriceDenominator; double min_tick = double_of_price(def.incrementPrice, fsec.display_factor); fsec.low_tick = fsec.high_tick = min_tick; - fsec.price_break = 0.; - fsec.cash_per_point = double_of_price(def.tickValue, fsec.display_factor); + //fsec.cash_per_point = double_of_price(def.tickValue, fsec.display_factor); + fsec.price_break = 0.; } template -void on_future(const Definition& def, bool& is_interested) +void ICEListener::on_future(const Definition& def, bool& is_interested) { is_interested = false; auto exchange_id = def.marketId; if (filter_security(exchange_id, def) != ADD) return; FixedFutureSecurity fsec; - set_security_common(def, fsec); + set_security_common(def, fsec); - auto expiration = date_of_maturity(sec); fsec.expiration_year = def.maturityYear; fsec.expiration_month = def.maturityMonth; fsec.expiration_day = def.maturityDay; @@ -160,7 +171,7 @@ void on_future(const Definition& def, bool& is_interested) } template -void on_future_spread(const Definition& def, bool& is_interested) +void ICEListener::on_future_spread(const Definition& def, bool& is_interested) { is_interested = false; auto exchange_id = def.marketId; @@ -178,7 +189,6 @@ void on_future_spread(const Definition& def, bool& is_interested) for(size_t x = 0; x < fsec.leg_count(); ++x) { const auto& leg = legs[x]; - onixs::Decimal price; if(leg.ratioPriceNumerator) fsec.legs[x].leg_price = double_of_price(leg.ratioPriceNumerator.value(), leg.ratioPriceDenominator.value()); @@ -194,27 +204,27 @@ void on_future_spread(const Definition& def, bool& is_interested) is_interested = true; } - -#if false /**********************************/ - -template -void ICEListener::onBookUpdate(const onixs::Security& sec, const TBook& onixs_book, BookType booktype) { +template +void ICEListener::on_book(const TBook& onixs_book, BookType booktype) +{ tracepoint (bts_trace,trace_order,(char*) "onBookUpdate", _latest_sequence, (uint16_t) _latest_sequence, 0); - auto data = _index.get_security(sec.id()); - if (data == nullptr) return; - bts_assert(data->id == (uint32_t)sec.id()); + auto data = _index.get_security(onixs_book.marketId()); + if (data == nullptr) + return; + bts_assert(data->id == (uint32_t)onixs_book.marketId()); auto display_factor = data->handle.security().display_factor; // Put the data into the cache. Flush at the end of the packet. auto key = data->handle.key(); - auto find_iter = std::find_if(_book_updates.begin(), _book_updates.end(), [key](const BookData& entry) { + auto find_iter = std::find_if(_book_updates.begin(), _book_updates.end(), [key](const BookData& entry) + { return key == entry.handle.key(); }); bool found = find_iter != _book_updates.end(); - if (!found) { + if (!found) _book_updates.emplace_back(data->handle); - } + BookData& cache = found ? *find_iter : _book_updates.back(); cache.type_flags |= booktype; auto& cache_bids = std::get>(cache.bids); @@ -223,29 +233,43 @@ void ICEListener::onBookUpdate(const onixs::Security& sec, const TBook& onixs_bo // Overwrite all entries every time size_t bids_size = onixs_book.bids().size(); size_t asks_size = onixs_book.offers().size(); - if (!data->handle.has_depth()) { + if (!data->handle.has_depth()) + { bids_size = std::min(bids_size, size_t { 1 }); asks_size = std::min(asks_size, size_t { 1 }); } - for (size_t x = 0; x < bids_size; ++x) { - cache_bids[x] = pricesize_of_price_size(onixs_book.bids()[x].price(), display_factor, onixs_book.bids()[x].quantity()); - } - for (size_t x = 0; x < asks_size; ++x) { - cache_asks[x] = pricesize_of_price_size(onixs_book.offers()[x].price(), display_factor, onixs_book.offers()[x].quantity()); - } - if (!found) { - // NaN out the remaining depth - for (size_t x = bids_size; x < MAX_DEPTH; ++x) { - cache_bids[x] = NO_MARKET; - } - for (size_t x = asks_size; x < MAX_DEPTH; ++x) { - cache_asks[x] = NO_MARKET; + if(booktype == book_type_direct) + { + for (size_t x = 0; x < bids_size; ++x) + { + auto& bid = onixs_book.bids()[x]; + cache_bids[x] = pricesize_of_price_size(bid.price, display_factor, bid.quantity - bid.impliedQuantity); + } + for (size_t x = 0; x < asks_size; ++x) + { + auto& ask = onixs_book.offers()[x]; + cache_asks[x] = pricesize_of_price_size(ask.price, display_factor, ask.quantity - ask.impliedQuantity); } } + else if(booktype == book_type_implied) + { + for (size_t x = 0; x < bids_size; ++x) + cache_bids[x] = pricesize_of_price_size(onixs_book.bids()[x].price, display_factor, onixs_book.bids()[x].impliedQuantity); + for (size_t x = 0; x < asks_size; ++x) + cache_asks[x] = pricesize_of_price_size(onixs_book.offers()[x].price, display_factor, onixs_book.offers()[x].impliedQuantity); + } + else + bts_assert_msg(false, "invalid book type"); + + if (!found) + { + // NaN out the remaining depth + for (size_t x = bids_size; x < MAX_DEPTH; ++x) + cache_bids[x] = NO_MARKET; + for (size_t x = asks_size; x < MAX_DEPTH; ++x) + cache_asks[x] = NO_MARKET; + } } -#endif - - -}}//namespace +}}} //namespace diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h index 7fc5d5067..50480fedb 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h @@ -1,3 +1,5 @@ +#pragma once + #include "lib/utils/bts_assert.h" #include "lib/utils/helper_macros.h" #include "lib/md/ice/ICEUtils.h" @@ -11,8 +13,9 @@ namespace bts { namespace md { +namespace ice { -template +template double double_of_price(const OnixPrice& price, int8_t display_factor) { double dbl = price / pow10(display_factor); @@ -20,26 +23,26 @@ double double_of_price(const OnixPrice& price, int8_t display_factor) } template <> -double double_of_price(const onixs::Rational& price, int8_t display_factor) +double double_of_price(const onixs::Rational& price, int8_t display_factor) { UNUSED(display_factor); double dbl = price.convertTo(); return dbl; } - -template +template IntPrice convert_price(const OnixsPrice& price, int8_t display_factor) { - double dbl = double_of_price(price, display_factor); + double dbl = double_of_price(price, display_factor); const int PRECISION = 7; auto intpx = md::IntPrice_from_double(dbl); return intpx; } -inline PriceSize pricesize_of_price_size(const onixs::Price price, int8_t display_factor, Size size) +template +inline PriceSize pricesize_of_price_size(const OnixsPrice& price, int8_t display_factor, Size size) { - auto intpx = convert_price(price, display_factor); + auto intpx = convert_price(price, display_factor); PriceSize result({intpx.mantissa(), (int8_t)(intpx.exponent() + display_factor)}, size); return result; } @@ -57,4 +60,4 @@ inline datetime::Date date_of_timestamp(const onixs::DateTime& dt) -}}//namespace \ No newline at end of file +}}} //namespace \ No newline at end of file diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp index 23613c5f6..db70296d3 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp @@ -25,26 +25,40 @@ using std::size_t; namespace bts { namespace md { +namespace ice { ICEMain::ICEMain() : _index(), _recorder ({ utils::Dispatcher::current(), [=](ExchangeKey k) { return SecurityKey(_index.get_key(k.value())); } }), _producer(PLATFORM_ICEONIXS, _recorder ), _handlers(), - _listeners(), + _listeners() { } ICEMain::~ICEMain() {} +// const ICEOptions::ICEChannel channel_settings_for(const string& id) +// { +// const auto& config = config::get(); +// for (const auto& ch : config.channel()) +// { +// bool found = std::find_if(ch.id().begin(), ch.id().end(), [&](const string& chan_id) { return chan_id == id || chan_id == "*"; }) != ch.id().end(); +// if (found) +// return ch; +// } +// return ICEOptions::ICEChannel(); +// } + const ICEOptions::ICEChannel channel_settings_for(const string& id) { const auto& config = config::get(); for (const auto& ch : config.channel()) { bool found = std::find_if(ch.id().begin(), ch.id().end(), [&](const string& chan_id) { return chan_id == id || chan_id == "*"; }) != ch.id().end(); - if (found) + if (found) { return ch; + } } return ICEOptions::ICEChannel(); } @@ -130,7 +144,7 @@ unique_ptr ICEMain::prepare_handler(const string& channel_id) } auto license = ice_options.onixs_license(); if (license == "{default}") - license = (license_location; + license = license_location; const auto& pub_options = config::get(); const auto& options = channel_settings_for(channel_id); @@ -140,26 +154,27 @@ unique_ptr ICEMain::prepare_handler(const string& channel_id) settings.licenseDirectory = license; // // Logging - settings.logLevel = (onixs::LogLevels::Enum) = options.onixs_log_mode(); + settings.logLevel = (onixs::LogLevels::Enum) options.onixs_log_mode(); settings.logDirectory = ice_log_path(); // // Config file - settings.connectivityConfiguration(ice_config_path()); + settings.connectivityConfiguration = ice_config_path(); // // Network settings if (pub_options.has_network_interface()) - { - settings.feeds().feedANetworkInterfaces(pub_options.network_interface()); - settings.feeds().feedBNetworkInterfaces(pub_options.network_interface()); - } + settings.networkInterface = pub_options.network_interface(); else { - if (pub_options.has_network_interface_a()) - settings.feeds().feedANetworkInterfaces(pub_options.network_interface_a()); - if (pub_options.has_network_interface_b()) - settings.feeds().feedBNetworkInterfaces(pub_options.network_interface_b()); + std::string inter; + if (pub_options.has_network_interface_a() && !pub_options.has_network_interface_b()) + inter = pub_options.network_interface_a(); + if (!pub_options.has_network_interface_a() && pub_options.has_network_interface_b()) + inter = pub_options.network_interface_b(); + if (pub_options.has_network_interface_a() && pub_options.has_network_interface_b()) + inter = pub_options.network_interface_b() + ":" + pub_options.network_interface_b(); + settings.networkInterface = inter; } settings.udpBufferSize = options.udp_buffer_size(); settings.heartbeatInterval = options.heartbeat_interval(); @@ -177,9 +192,9 @@ unique_ptr ICEMain::prepare_handler(const string& channel_id) // Misc settings if(options.processing_thread_affinity() != "" ) settings.processingThreadAffinity = onixs::ThreadAffinity::deserialize(options.processing_thread_affinity()); - if(settings.has_track_top_of_the_book_only() - settings.trackTopOfTheBookOnly = options.track_top_of_the_book_only(); - if(settings.has_receive_product_definitions_only()) + // if(options.has_track_top_of_the_book_only() + // settings.trackTopOfTheBookOnly = options.track_top_of_the_book_only(); + if(options.has_receive_product_definitions_only()) settings.receiveProductDefinitionsOnly = options.receive_product_definitions_only(); if(options.has_max_multicast_message_block_size() && options.max_multicast_message_block_size() > 0) settings.maxMulticastMessageBlockSize = options.max_multicast_message_block_size(); @@ -225,13 +240,16 @@ unique_ptr ICEMain::prepare_listener(onixs::Handler& handler, const }); } - handler.registerListener(*listener); - handler.registerMarketDataListener(*listener); - handler.registerSecurityListener(*listener); + handler.registerExchangeListener(listener.get()); + handler.registerFeedListener(listener.get()); + handler.registerOrderBookUpdateListener(listener.get()); + handler.registerErrorListener(listener.get()); + handler.registerWarningListener(listener.get()); + handler.registerHandlerStateChangeListener(listener.get()); return listener; } -}}//namespace +}}} //namespace diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h index 609ee2227..876199bb2 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h @@ -12,6 +12,7 @@ namespace bts { namespace md { +namespace ice { // void run_onixs_ice_server(UserSymbol* sym, size_t symcount); @@ -44,5 +45,5 @@ private: std::vector> _listeners; }; -}}//namespace +}}} //namespace From dfcf38289fef12552c16c11a67f0b6dabfd078f2 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Thu, 28 Feb 2019 14:44:13 -0500 Subject: [PATCH 11/72] move externals up for ice .so --- externals | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals b/externals index 430a9c6b5..0dcc271a4 160000 --- a/externals +++ b/externals @@ -1 +1 @@ -Subproject commit 430a9c6b5cb063710f961ef9878b6eb3cd4602d9 +Subproject commit 0dcc271a46c25c610f948e9af76057b7217a1c3f From 2ae5b50445dae77da3ff20e6f0459a8f280eaddb Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Thu, 28 Feb 2019 15:01:35 -0500 Subject: [PATCH 12/72] ice builds with .so --- src/lib/md/cme/MDP3Utils.cpp | 3 +-- src/server/sparkd/CMakeLists.txt | 1 + src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp | 8 ++++++++ .../sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h | 8 -------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/md/cme/MDP3Utils.cpp b/src/lib/md/cme/MDP3Utils.cpp index 42041ea28..ae3ac82cd 100644 --- a/src/lib/md/cme/MDP3Utils.cpp +++ b/src/lib/md/cme/MDP3Utils.cpp @@ -20,7 +20,6 @@ using namespace bts::api; namespace bts { namespace md { -namespace cme { string data_path() { auto p = config::get().data_path() + "cme_mdp3/"; @@ -164,5 +163,5 @@ const vector parse_channels(const vector& symbols) { return result; } -}}}//namespace +}} //namespace #endif \ No newline at end of file diff --git a/src/server/sparkd/CMakeLists.txt b/src/server/sparkd/CMakeLists.txt index f41796fba..802ffd19b 100644 --- a/src/server/sparkd/CMakeLists.txt +++ b/src/server/sparkd/CMakeLists.txt @@ -27,6 +27,7 @@ target_link_libraries( sparkd tbb onixs-cmemdh-all-4.8.0 OnixS.IceImpactMulticastPriceFeedHandlerCpp + ACE quickfix benchmark lttng-ust diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp index fe551131a..8835fa5a4 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp @@ -12,6 +12,14 @@ using namespace bts::md::ice; namespace bts { namespace md { namespace ice { + +template <> +double double_of_price(const onixs::Rational& price, int8_t display_factor) +{ + UNUSED(display_factor); + double dbl = price.convertTo(); + return dbl; +} ICEListener::ICEListener(ICESecurityIndex& index, MDProducer& producer, const std::vector channels) : diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h index 50480fedb..46460c750 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h @@ -22,14 +22,6 @@ double double_of_price(const OnixPrice& price, int8_t display_factor) return dbl; } -template <> -double double_of_price(const onixs::Rational& price, int8_t display_factor) -{ - UNUSED(display_factor); - double dbl = price.convertTo(); - return dbl; -} - template IntPrice convert_price(const OnixsPrice& price, int8_t display_factor) { From 724da313169e31add3befd2d794318dd88e456b0 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Thu, 28 Feb 2019 17:50:46 -0500 Subject: [PATCH 13/72] adding data files --- .../ConnectivityConfiguration.APITest.xml | 659 +++++++++++++++++ .../ConnectivityConfiguration.PerfTest.xml | 364 ++++++++++ .../ConnectivityConfiguration.Production.xml | 677 ++++++++++++++++++ src/lib/config/defaults/Symbols.conf | 93 ++- src/lib/config/protos/MarketData.proto | 2 +- src/lib/config/protos/Symbols.proto | 1 + src/lib/md/PlatformLoader.cpp | 35 +- src/lib/md/ice/ICEUtils.cpp | 4 +- .../md/platforms/ice_onixs/ICEListener.cpp | 93 ++- .../md/platforms/ice_onixs/ICEListener.h | 72 +- .../platforms/ice_onixs/ICEListenerHelpers.h | 4 +- .../sparkd/md/platforms/ice_onixs/ICEMain.cpp | 55 +- .../sparkd/md/platforms/ice_onixs/ICEMain.h | 6 +- .../md/platforms/ice_onixs/ICESecurityIndex.h | 8 +- .../sparkd/md/platforms/ice_onixs/onixs.h | 2 +- src/server/sparkd/md/run_md.cpp | 9 + 16 files changed, 1905 insertions(+), 179 deletions(-) create mode 100644 src/data_files/files/onixs_ice/ConnectivityConfiguration.APITest.xml create mode 100644 src/data_files/files/onixs_ice/ConnectivityConfiguration.PerfTest.xml create mode 100644 src/data_files/files/onixs_ice/ConnectivityConfiguration.Production.xml diff --git a/src/data_files/files/onixs_ice/ConnectivityConfiguration.APITest.xml b/src/data_files/files/onixs_ice/ConnectivityConfiguration.APITest.xml new file mode 100644 index 000000000..4cb6546b7 --- /dev/null +++ b/src/data_files/files/onixs_ice/ConnectivityConfiguration.APITest.xml @@ -0,0 +1,659 @@ + + + + + + + + 63.247.113.163 + 3000 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 63.247.113.77 + 3000 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 63.247.113.229 + 3000 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 16 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Financial Gas + Financial Power + Oil + IPE Natural Gas Futures + IPE Gas Oil Futures + IPE Brent Futures + IPE UK Electricity Futures Peak + IPE UK Electricity Futures Base + ICE WTI Crude Futures + gC Newcastle Coal Futures + ICE Brent-WTI Futures Spread + IPE-ECX European Emissions + ICE Heating Oil Futures + ICE Heating Oil/WTI Futures Crack + ICE NYH (RBOB) Gasoline Futures + ICE NYH (RBOB) Gasoline/WTI Futures Crack + ICE Rotterdam Coal Futures + ICE Richards Bay Coal Futures + ICE Rotterdam/Richards Bay Coal Futures Spread + Cocoa + Coffee C + Cotton No 2 + FCOJ A + Sugar No 11 + Heat Rate Spread + US Dollar Index + ICE Middle East Sour Crude Futures + ICE Brent/Middle East Crude Futures Spread + ICE WTI/Middle East Crude Futures Spread + Canadian Oilseeds + Canadian Grains + ICE ECX CER Futures + Foreign Exchange + Financial Index Data + Sugar No 16 + ECX EUA/CER Futures Spread + Henry Hub + Dutch TTF Gas Futures + German Natural Gas Futures + European Gas Spreads + Canadian Financial Gas + NGX Canadian Physical Crude + US Coal Futures + FOB Indo sub-bit Coal Futures + Heating Oil/Brent Futures Crack + NYH (RBOB) Gasoline/Brent Futures Crack + NYH (RBOB) Gasoline/Heating Oil Spread + Physical Environmental + Heating Oil/LS Gasoil Futures Spread + LS Gasoil/Brent Futures Crack + NYH (RBOB) Gasoline/LS Gasoil Futures Spread + ECX EUAA Futures + ECX CER/EUAA Futures Spread + ECX EUAA/EUA Futures Spread + Soybean + Wheat + Corn + CFR South China Coal Futures + Belgian Power Futures + Dutch Power Futures + gC Newcastle/FOB Indo sub-bit Coal Futures Spread + Richards Bay/gC Newcastle Coal Futures Spread + CIF US + Financial Environmental + European Power Spreads + TAQA + Belgian ZTP Gas Spot + Dutch TTF Gas Spot + Dutch TTF Gas Storage + European Gas Spot Spreads + Belgian ZTP Gas Futures + Belgian Gas Spreads + German Power Futures + Atlantic Coal Futures + Financial Olefins + Financial Monomers + Endex Spot Market Indices + Russell Cash Indices + Interest Rate Futures + Singapore Energy + Singapore Financials + Singapore Metals + Italian Natural Gas Futures + Italian Power Futures + World Cotton + ICE Rotterdam/Newcastle Coal Futures Spread + IFUS ICE Indices + Liffe STIRs + Liffe Bonds + Liffe Swapnotes + Liffe Commodities + Metals + IFUS Equity Indices + GCF Repo + Liffe Three Month Euro and EONIA + Eurodollar + Liffe Equity Derivatives - Non-US Based + Liffe Equity Derivatives - US Based + Liffe Index Options + Liffe Index Futures - US Restricted + Liffe Index Futures - Non-US Restricted + NGX Physical Gas + NGX Financial Power + Financial NGL + Olefins/Polymers + + + diff --git a/src/data_files/files/onixs_ice/ConnectivityConfiguration.PerfTest.xml b/src/data_files/files/onixs_ice/ConnectivityConfiguration.PerfTest.xml new file mode 100644 index 000000000..23680779e --- /dev/null +++ b/src/data_files/files/onixs_ice/ConnectivityConfiguration.PerfTest.xml @@ -0,0 +1,364 @@ + + + + + + + + + 63.247.113.214 + 3000 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 16 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Financial Gas + Financial Power + Oil + IPE Natural Gas Futures + IPE Gas Oil Futures + IPE Brent Futures + IPE UK Electricity Futures Peak + IPE UK Electricity Futures Base + ICE WTI Crude Futures + gC Newcastle Coal Futures + ICE Brent-WTI Futures Spread + IPE-ECX European Emissions + ICE Heating Oil Futures + ICE Heating Oil/WTI Futures Crack + ICE NYH (RBOB) Gasoline Futures + ICE NYH (RBOB) Gasoline/WTI Futures Crack + ICE Rotterdam Coal Futures + ICE Richards Bay Coal Futures + ICE Rotterdam/Richards Bay Coal Futures Spread + Cocoa + Coffee C + Cotton No 2 + FCOJ A + Sugar No 11 + Heat Rate Spread + US Dollar Index + ICE Middle East Sour Crude Futures + ICE Brent/Middle East Crude Futures Spread + ICE WTI/Middle East Crude Futures Spread + Canadian Oilseeds + Canadian Grains + ICE ECX CER Futures + Foreign Exchange + Financial Index Data + Sugar No 16 + ECX EUA/CER Futures Spread + Henry Hub + Canadian Financial Gas + NGX Canadian Physical Crude + US Coal Futures + FOB Indo sub-bit Coal Futures + Heating Oil/Brent Futures Crack + NYH (RBOB) Gasoline/Brent Futures Crack + NYH (RBOB) Gasoline/Heating Oil Spread + Physical Environmental + Heating Oil/LS Gasoil Futures Spread + LS Gasoil/Brent Futures Crack + NYH (RBOB) Gasoline/LS Gasoil Futures Spread + ECX EUAA Futures + ECX CER/EUAA Futures Spread + ECX EUAA/EUA Futures Spread + Soybean + Wheat + Corn + CFR South China Coal Futures + gC Newcastle/FOB Indo sub-bit Coal Futures Spread + Richards Bay/gC Newcastle Coal Futures Spread + Financial Environmental + Atlantic Coal Futures + Financial Olefins + Financial Monomers + ICE Rotterdam/Newcastle Coal Futures Spread + IFUS ICE Indices + Liffe Commodities + Metals + IFUS Equity Indices + GCF Repo + Eurodollar + NGX Physical Gas + NGX Financial Power + Financial NGL + Olefins/Polymers + + + diff --git a/src/data_files/files/onixs_ice/ConnectivityConfiguration.Production.xml b/src/data_files/files/onixs_ice/ConnectivityConfiguration.Production.xml new file mode 100644 index 000000000..796e1d195 --- /dev/null +++ b/src/data_files/files/onixs_ice/ConnectivityConfiguration.Production.xml @@ -0,0 +1,677 @@ + + + + + + + + + 63.247.112.185 + 80 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 63.247.112.190 + 80 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 63.247.125.185 + 80 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 16 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Financial Gas + Financial Power + Oil + IPE Natural Gas Futures + IPE Gas Oil Futures + IPE Brent Futures + IPE UK Electricity Futures Peak + IPE UK Electricity Futures Base + ICE WTI Crude Futures + gC Newcastle Coal Futures + ICE Brent-WTI Futures Spread + IPE-ECX European Emissions + ICE Heating Oil Futures + ICE Heating Oil/WTI Futures Crack + ICE NYH (RBOB) Gasoline Futures + ICE NYH (RBOB) Gasoline/WTI Futures Crack + ICE Rotterdam Coal Futures + ICE Richards Bay Coal Futures + ICE Rotterdam/Richards Bay Coal Futures Spread + Cocoa + Coffee C + Cotton No 2 + FCOJ A + Sugar No 11 + Heat Rate Spread + US Dollar Index + ICE Middle East Sour Crude Futures + ICE Brent/Middle East Crude Futures Spread + ICE WTI/Middle East Crude Futures Spread + Canadian Oilseeds + Canadian Grains + ICE ECX CER Futures + Foreign Exchange + Financial Index Data + Sugar No 16 + ECX EUA/CER Futures Spread + Henry Hub + Dutch TTF Gas Futures + German Natural Gas Futures + European Gas Spreads + Canadian Financial Gas + NGX Canadian Physical Crude + US Coal Futures + FOB Indo sub-bit Coal Futures + Heating Oil/Brent Futures Crack + NYH (RBOB) Gasoline/Brent Futures Crack + NYH (RBOB) Gasoline/Heating Oil Spread + Physical Environmental + Heating Oil/LS Gasoil Futures Spread + LS Gasoil/Brent Futures Crack + NYH (RBOB) Gasoline/LS Gasoil Futures Spread + ECX EUAA Futures + ECX CER/EUAA Futures Spread + ECX EUAA/EUA Futures Spread + Soybean + Wheat + Corn + CFR South China Coal Futures + Belgian Power Futures + Dutch Power Futures + gC Newcastle/FOB Indo sub-bit Coal Futures Spread + Richards Bay/gC Newcastle Coal Futures Spread + CIF US + Financial Environmental + European Power Spreads + TAQA + Belgian ZTP Gas Spot + Dutch TTF Gas Spot + Dutch TTF Gas Storage + European Gas Spot Spreads + Belgian ZTP Gas Futures + Belgian Gas Spreads + German Power Futures + Atlantic Coal Futures + Financial Olefins + Financial Monomers + Russell Cash Indices + Interest Rate Futures + Italian Natural Gas Futures + Italian Power Futures + ICE Rotterdam/Newcastle Coal Futures Spread + IFUS ICE Indices + Liffe STIRs + Liffe Bonds + Liffe Swapnotes + Liffe Commodities + Metals + IFUS Equity Indices + GCF Repo + Liffe Three Month Euro and EONIA + Eurodollar + Liffe Equity Derivatives - Non-US Based + Liffe Equity Derivatives - US Based + Liffe Index Options + Liffe Index Futures - US Restricted + Liffe Index Futures - Non-US Restricted + NGX Physical Gas + NGX Financial Power + Financial NGL + Olefins/Polymers + + + \ No newline at end of file diff --git a/src/lib/config/defaults/Symbols.conf b/src/lib/config/defaults/Symbols.conf index e29ad43d0..86fca9c3a 100644 --- a/src/lib/config/defaults/Symbols.conf +++ b/src/lib/config/defaults/Symbols.conf @@ -1,38 +1,55 @@ - -SymbolList { - value { - symbol: "HE" - symbol: "LE" - symbol: "CL" - symbol: "RB" - symbol: "HO" - symbol: "BZ" - symbol: "NG" - symbol: "GC" - symbol: "SI" - symbol: "HG" - symbol: "ZW" - symbol: "ZC" - symbol: "ZS" - symbol: "ZM" - symbol: "ZL" - symbol: "ZO" - symbol: "ZR" - symbol: "ZB" - symbol: "ZN" - symbol: "ZF" - symbol: "ZT" - symbol: "UB" - } +SymbolLists +{ + value + { + list + { + key: "ICE" + + symbol: "B" + symbol: "T" + } + list + { + key: "GLBX" + + symbol: "HE" + symbol: "LE" + symbol: "CL" + symbol: "RB" + symbol: "HO" + symbol: "BZ" + symbol: "NG" + symbol: "GC" + symbol: "SI" + symbol: "HG" + symbol: "ZW" + symbol: "ZC" + symbol: "ZS" + symbol: "ZM" + symbol: "ZL" + symbol: "ZO" + symbol: "ZR" + symbol: "ZB" + symbol: "ZN" + symbol: "ZF" + symbol: "ZT" + symbol: "UB" + } + } } Symbols { rule: "DeploymentType.type == 'DEMO' and System.platform == 'windows'" value { sim { - future: @SymbolList.symbol - spread: @SymbolList.symbol + future: @SymbolLists.list[GLBX].symbol + spread: @SymbolLists.list[GLBX].symbol } + ice { + future: @SymbolLists.list[ICE].symbol + spread: @SymbolLists.list[ICE].symbol + } } } @@ -40,21 +57,29 @@ Symbols { rule: "DeploymentType.type == 'PROD' and System.platform == 'windows'" value { glbx { - future: @SymbolList.symbol - spread: @SymbolList.symbol + future: @SymbolLists.list[GLBX].symbol + spread: @SymbolLists.list[GLBX].symbol } + ice { + future: @SymbolLists.list[ICE].symbol + spread: @SymbolLists.list[ICE].symbol + } } } Symbols { value { glbx { - future: @SymbolList.symbol - spread: @SymbolList.symbol + future: @SymbolLists.list[GLBX].symbol + spread: @SymbolLists.list[GLBX].symbol } sim { - future: @SymbolList.symbol - spread: @SymbolList.symbol + future: @SymbolLists.list[GLBX].symbol + spread: @SymbolLists.list[GLBX].symbol } + ice { + future: @SymbolLists.list[ICE].symbol + spread: @SymbolLists.list[ICE].symbol + } } } diff --git a/src/lib/config/protos/MarketData.proto b/src/lib/config/protos/MarketData.proto index cd245e9f1..e3779de3e 100755 --- a/src/lib/config/protos/MarketData.proto +++ b/src/lib/config/protos/MarketData.proto @@ -14,7 +14,7 @@ message PlatformMap // PLATFORM_MDP3ONIXS optional string glbx_platform = 1 [default = "PLATFORM_SIM"]; // PLATFORM_ICEONIXS - optional string ice_platform = 2 [default = "PLATFORM_SIM"]; + optional string ice_platform = 2 [default = "PLATFORM_ICEONIXS"]; } // LOCAL TIME diff --git a/src/lib/config/protos/Symbols.proto b/src/lib/config/protos/Symbols.proto index bf52f670e..6d859c13f 100644 --- a/src/lib/config/protos/Symbols.proto +++ b/src/lib/config/protos/Symbols.proto @@ -19,4 +19,5 @@ message SecurityExchangeList { message Symbols { optional SecurityExchangeList glbx = 10; optional SecurityExchangeList sim = 20; + optional SecurityExchangeList ice = 30; } \ No newline at end of file diff --git a/src/lib/md/PlatformLoader.cpp b/src/lib/md/PlatformLoader.cpp index e214d6391..9ec7c953e 100644 --- a/src/lib/md/PlatformLoader.cpp +++ b/src/lib/md/PlatformLoader.cpp @@ -61,6 +61,8 @@ void PlatformLoader::run() { switch (_platform) { case PLATFORM_MDP3ONIXS: break; + case PLATFORM_MDP3EMUMBA: + break; case PLATFORM_ICEONIXS: break; default: @@ -120,6 +122,28 @@ size_t get_system_md_symbols(api::Venue exchange, SecurityType type, } } } + + { + auto const &e = config::get().ice(); + if (exchange == api::VENUE_UNSET || exchange == api::VENUE_ICE) + { + if (type == api::SECURITYTYPE_FUTURE || type == api::SECURITYTYPE_UNSET) + add_symbols_to_result(e.future(), api::VENUE_ICE, api::SECURITYTYPE_FUTURE, &result); + if (type == api::SECURITYTYPE_OPTION || type == api::SECURITYTYPE_UNSET) + add_symbols_to_result(e.option(), api::VENUE_ICE, api::SECURITYTYPE_OPTION, &result); + if (type == api::SECURITYTYPE_SPREAD || type == api::SECURITYTYPE_UNSET) + add_symbols_to_result(e.spread(), api::VENUE_ICE, api::SECURITYTYPE_SPREAD, &result); + } + if (exchange == api::VENUE_BTS || exchange == api::VENUE_UNSET) + { + std::set all_symbols; + all_symbols.insert(e.future().begin(), e.future().end()); + all_symbols.insert(e.option().begin(), e.option().end()); + all_symbols.insert(e.spread().begin(), e.spread().end()); + for (const auto &symbol : all_symbols) + result.insert(UserSymbol(symbol, api::VENUE_BTS, api::SECURITYTYPE_SYNTHETIC)); + } + } { auto const &e = config::get().sim(); @@ -183,10 +207,13 @@ std::set get_system_md_symbols() { extern "C" BTS_EXPORT Platform platform_for_exchange(Venue v) { const auto &pmap = config::get(); co2::Platform platform; - if (v == VENUE_SIM) return PLATFORM_SIM; - if (co2::Platform_Parse(pmap.glbx_platform(), &platform)) { - return platform; - } + if (v == VENUE_SIM) + return PLATFORM_SIM; + if (co2::Platform_Parse(pmap.glbx_platform(), &platform)) + return platform; + if (co2::Platform_Parse(pmap.ice_platform(), &platform)) + return platform; + return PLATFORM_UNSET; } diff --git a/src/lib/md/ice/ICEUtils.cpp b/src/lib/md/ice/ICEUtils.cpp index aca0f3fbd..ee8f55589 100644 --- a/src/lib/md/ice/ICEUtils.cpp +++ b/src/lib/md/ice/ICEUtils.cpp @@ -23,7 +23,7 @@ namespace md { namespace ice { string ice_data_path() { - auto p = config::get().data_path() + "ice/"; + auto p = config::get().data_path() + "onixs_ice/"; #ifdef _WIN32 // OnixS requires win32 paths to look like Win32 paths - everyone else in the world is ok with '/' os::normalize_path(p, '\\'); @@ -95,7 +95,7 @@ SecurityType infer_security_type(const string& label) { // TODO: Allow configuration to override this? LOG(md,Warn,"Unable to guess security type from label: '{}" - "' Treating as OPTION.",label); + "' Treating as FUTURE.",label); return SECURITYTYPE_FUTURE; } diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp index 8835fa5a4..c8259e1ec 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp @@ -14,7 +14,7 @@ namespace md { namespace ice { template <> -double double_of_price(const onixs::Rational& price, int8_t display_factor) +double double_of_price(const onixs_ice::Rational& price, int8_t display_factor) { UNUSED(display_factor); double dbl = price.convertTo(); @@ -39,29 +39,29 @@ ICEListener::~ICEListener() {} // //State change -void ICEListener::onHandlerStateChange(const onixs::HandlerStateChange& ) +void ICEListener::onHandlerStateChange(const onixs_ice::HandlerStateChange& ) { //TODO } -void ICEListener::onMarketStateChange(const onixs::MarketStateChange& , const onixs::MessageInfo& ) +void ICEListener::onMarketStateChange(const onixs_ice::MarketStateChange& , const onixs_ice::MessageInfo& ) { //TODO } // // Warnings/Errors -void ICEListener::onError(const onixs::Error& error) +void ICEListener::onError(const onixs_ice::Error& error) { tracepoint (bts_trace,trace_order,(char*) "onError", _latest_sequence, (uint16_t) _latest_sequence, 0); LOG(md,Warn, "OnixS Error: {} - {}", error.toString() ); } -void ICEListener::onFeedError(onixs::FeedId feedid, onixs::ErrorCode code, const std::string& desc) +void ICEListener::onFeedError(onixs_ice::FeedId feedid, onixs_ice::ErrorCode code, const std::string& desc) { tracepoint (bts_trace,trace_order,(char*) "onFeedError", _latest_sequence, (uint16_t) _latest_sequence, 0); LOG(md,Warn, "OnixS FeedError: {} - {}", feedid, desc, code); } -void ICEListener::onWarning(const onixs::Warning& warning) +void ICEListener::onWarning(const onixs_ice::Warning& warning) { tracepoint (bts_trace,trace_order,(char*) "onWarning", _latest_sequence, (uint16_t) _latest_sequence, 0); LOG(md,Warn, "OnixS Warn: {} - {}", warning.toString() ); @@ -69,69 +69,68 @@ void ICEListener::onWarning(const onixs::Warning& warning) // // Security discovery -void ICEListener::onFuturesProductDefinition(const onixs::FuturesProductDefinition& msg, bool& is_interested) +void ICEListener::onFuturesProductDefinition(const onixs_ice::FuturesProductDefinition& msg, bool& is_interested) { tracepoint (bts_trace,trace_order,(char*) "onFuturesProductDefinition", _latest_sequence, (uint16_t) _latest_sequence, 0); on_future(msg, is_interested); } -void ICEListener::onNewExpiry(const onixs::NewExpiry& msg, bool& is_interested, const onixs::MessageInfo& msg_info) +void ICEListener::onNewExpiry(const onixs_ice::NewExpiry& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) { UNUSED(msg_info); tracepoint (bts_trace,trace_order,(char*) "onNewExpiry", _latest_sequence, (uint16_t) _latest_sequence, 0); on_future(msg, is_interested); } -void ICEListener::onFuturesStrategyDefinition(const onixs::FuturesStrategyDefinition& def, bool& is_interested) +void ICEListener::onFuturesStrategyDefinition(const onixs_ice::FuturesStrategyDefinition& def, bool& is_interested) { tracepoint (bts_trace,trace_order,(char*) "onFuturesStrategyDefinition", _latest_sequence, (uint16_t) _latest_sequence, 0); on_future_spread(def, is_interested); } -void ICEListener::onNewFuturesStrategyDefinition(const onixs::NewFuturesStrategyDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) +void ICEListener::onNewFuturesStrategyDefinition(const onixs_ice::NewFuturesStrategyDefinition& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) { UNUSED(msg_info); tracepoint (bts_trace,trace_order,(char*) "onFuturesStrategyDefinition", _latest_sequence, (uint16_t) _latest_sequence, 0); on_future_spread(msg, is_interested); } -void ICEListener::onOptionsProductDefinition(const onixs::OptionsProductDefinition& msg, bool& is_interested) +void ICEListener::onOptionsProductDefinition(const onixs_ice::OptionsProductDefinition& msg, bool& is_interested) { UNUSED(msg); UNUSED(is_interested); } -void ICEListener::onNewOptionsMarketDefinition(const onixs::NewOptionsMarketDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) +void ICEListener::onNewOptionsMarketDefinition(const onixs_ice::NewOptionsMarketDefinition& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) { UNUSED(msg); UNUSED(is_interested); UNUSED(msg_info); } -void ICEListener::onOptionsStrategyDefinition(const onixs::OptionsStrategyDefinition& msg, bool& is_interested) +void ICEListener::onOptionsStrategyDefinition(const onixs_ice::OptionsStrategyDefinition& msg, bool& is_interested) { UNUSED(msg); UNUSED(is_interested); } -void ICEListener::onNewOptionsStrategyDefinition(const onixs::NewOptionsStrategyDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) +void ICEListener::onNewOptionsStrategyDefinition(const onixs_ice::NewOptionsStrategyDefinition& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) { UNUSED(msg); UNUSED(is_interested); UNUSED(msg_info); } -//TODO // -// Gap Recovery -void ICEListener::onMarketSnapshot(const onixs::MarketSnapshot& msg, const onixs::MessageInfo& msg_info) +// Gap Recovery -- This is not necessary if we subscribe to the onOrderBookUpdated callback, they handle the breaks transparently +void ICEListener::onMarketSnapshot(const onixs_ice::MarketSnapshot& msg, const onixs_ice::MessageInfo& msg_info) { UNUSED(msg); UNUSED(msg_info); } -void ICEListener::onMarketSnapshotOrder(const onixs::MarketSnapshotOrder& msg, const onixs::MessageInfo& msg_info) +void ICEListener::onMarketSnapshotOrder(const onixs_ice::MarketSnapshotOrder& msg, const onixs_ice::MessageInfo& msg_info) { UNUSED(msg); UNUSED(msg_info); } -void ICEListener::onMarketSnapshotPriceLevel(const onixs::MarketSnapshotPriceLevel& msg, const onixs::MessageInfo& msg_info) +void ICEListener::onMarketSnapshotPriceLevel(const onixs_ice::MarketSnapshotPriceLevel& msg, const onixs_ice::MessageInfo& msg_info) { UNUSED(msg); UNUSED(msg_info); @@ -139,7 +138,7 @@ void ICEListener::onMarketSnapshotPriceLevel(const onixs::MarketSnapshotPriceLev // // Book -void ICEListener::onOrderBookUpdated(const onixs::OrderBook& book, const onixs::MessageInfo& msg_info) +void ICEListener::onOrderBookUpdated(const onixs_ice::OrderBook& book, const onixs_ice::MessageInfo& msg_info) { UNUSED(msg_info); on_book(book, book_type_direct); @@ -148,20 +147,20 @@ void ICEListener::onOrderBookUpdated(const onixs::OrderBook& book, const onixs:: // // Trades -AggressorSide map_aggressor(onixs::AggressorSide::Enum agside) +AggressorSide map_aggressor(onixs_ice::AggressorSide::Enum agside) { switch(agside) { default: - case onixs::AggressorSide::NoAggressor: + case onixs_ice::AggressorSide::NoAggressor: return AGGRESSOR_SIDE_NONE; - case onixs::AggressorSide::Buy: + case onixs_ice::AggressorSide::Buy: return AGGRESSOR_SIDE_BUY; - case onixs::AggressorSide::Sell: + case onixs_ice::AggressorSide::Sell: return AGGRESSOR_SIDE_SELL; } } -void on_trade(SecurityData* data, const onixs::Price& price, int size, onixs::AggressorSide::Enum agside, const onixs::DateTime& onixs_date) +void on_trade(ICESecurityData* data, const onixs_ice::Price& price, int size, onixs_ice::AggressorSide::Enum agside, const onixs_ice::DateTime& onixs_date) { auto ts = utils::TimeStamp::now(); PriceSize ps = pricesize_of_price_size(price, data->handle.security().display_factor, size); @@ -169,7 +168,7 @@ void on_trade(SecurityData* data, const onixs::Price& price, int size, onixs::Ag data->handle.add_trade(ts, ps, date, map_aggressor(agside), size); } -void ICEListener::onTrade(const onixs::Trade& msg, const onixs::MessageInfo& msg_info) +void ICEListener::onTrade(const onixs_ice::Trade& msg, const onixs_ice::MessageInfo& msg_info) { UNUSED(msg_info); tracepoint (bts_trace,trace_order,(char*) "onTrade", _latest_sequence, (uint16_t) _latest_sequence, 0); @@ -179,14 +178,14 @@ void ICEListener::onTrade(const onixs::Trade& msg, const onixs::MessageInfo& msg bts_assert(data->id == (uint32_t)msg.marketId); auto size = msg.quantity; auto price = msg.price; - onixs::AggressorSide::Enum agside = msg.aggressorSide; + onixs_ice::AggressorSide::Enum agside = msg.aggressorSide; on_trade(data, price, size, agside, msg.transactDateTime); } } // // RFQ -void ICEListener::onRfq(const onixs::Rfq& msg, const onixs::MessageInfo& msg_info) +void ICEListener::onRfq(const onixs_ice::Rfq& msg, const onixs_ice::MessageInfo& msg_info) { UNUSED(msg_info); tracepoint (bts_trace,trace_order,(char*) "onRfq", _latest_sequence, (uint16_t) _latest_sequence, 0); @@ -224,7 +223,7 @@ void ICEListener::onRfq(const onixs::Rfq& msg, const onixs::MessageInfo& msg_inf // // Misc -void ICEListener::onSettlementPrice(const onixs::SettlementPrice& msg, const onixs::MessageInfo& msg_info) +void ICEListener::onSettlementPrice(const onixs_ice::SettlementPrice& msg, const onixs_ice::MessageInfo& msg_info) { UNUSED(msg_info); tracepoint (bts_trace,trace_order,(char*) "onSettlementPrice", _latest_sequence, (uint16_t) _latest_sequence, 0); @@ -232,20 +231,20 @@ void ICEListener::onSettlementPrice(const onixs::SettlementPrice& msg, const oni if (data != nullptr) { bts_assert(data->id == (uint32_t)msg.marketId); - onixs::Price price = msg.settlementPrice; - onixs::DateTime time = msg.dateTime; + onixs_ice::Price price = msg.settlementPrice; + onixs_ice::DateTime time = msg.dateTime; auto display_factor = data->handle.security().display_factor; data->handle.update_settlement(utils::TimeStamp::now(), convert_price(price, display_factor), date_of_timestamp(time)); } } -void ICEListener::onOpenInterest(const onixs::OpenInterest &msg, const onixs::MessageInfo &msg_info) +void ICEListener::onOpenInterest(const onixs_ice::OpenInterest &msg, const onixs_ice::MessageInfo &msg_info) { UNUSED(msg); UNUSED(msg_info); } -void ICEListener::onOpenPrice(const onixs::OpenPrice& msg, const onixs::MessageInfo& msg_info) +void ICEListener::onOpenPrice(const onixs_ice::OpenPrice& msg, const onixs_ice::MessageInfo& msg_info) { UNUSED(msg_info); tracepoint (bts_trace,trace_order,(char*) "onOpenPrice", _latest_sequence, (uint16_t) _latest_sequence, 0); @@ -253,14 +252,14 @@ void ICEListener::onOpenPrice(const onixs::OpenPrice& msg, const onixs::MessageI if (data != nullptr) { bts_assert(data->id == (uint32_t)msg.marketId); - onixs::Price price = msg.openPrice; - onixs::DateTime time = msg.dateTime; + onixs_ice::Price price = msg.openPrice; + onixs_ice::DateTime time = msg.dateTime; auto display_factor = data->handle.security().display_factor; data->handle.update_opening( utils::TimeStamp::now(), double_of_price(price, display_factor), date_of_timestamp(time)); } } -void ICEListener::onClosePrice(const onixs::ClosePrice& msg, const onixs::MessageInfo& msg_info) +void ICEListener::onClosePrice(const onixs_ice::ClosePrice& msg, const onixs_ice::MessageInfo& msg_info) { UNUSED(msg_info); tracepoint (bts_trace,trace_order,(char*) "onClosePrice", _latest_sequence, (uint16_t) _latest_sequence, 0); @@ -268,14 +267,14 @@ void ICEListener::onClosePrice(const onixs::ClosePrice& msg, const onixs::Messag if (data != nullptr) { bts_assert(data->id == (uint32_t)msg.marketId); - onixs::Price price = msg.closePrice; - onixs::DateTime time = msg.dateTime; + onixs_ice::Price price = msg.closePrice; + onixs_ice::DateTime time = msg.dateTime; auto display_factor = data->handle.security().display_factor; data->handle.update_closing( utils::TimeStamp::now(), double_of_price(price, display_factor), date_of_timestamp(time)); } } -void ICEListener::onEndOfDayMarketSummary(const onixs::EndOfDayMarketSummary& msg, const onixs::MessageInfo& msg_info) +void ICEListener::onEndOfDayMarketSummary(const onixs_ice::EndOfDayMarketSummary& msg, const onixs_ice::MessageInfo& msg_info) { UNUSED(msg_info); tracepoint (bts_trace,trace_order,(char*) "onEndOfDayMarketSummary", _latest_sequence, (uint16_t) _latest_sequence, 0); @@ -283,7 +282,7 @@ void ICEListener::onEndOfDayMarketSummary(const onixs::EndOfDayMarketSummary& ms if (data != nullptr) { bts_assert(data->id == (uint32_t)msg.marketId); - onixs::DateTime time = msg.dateTime; + onixs_ice::DateTime time = msg.dateTime; auto display_factor = data->handle.security().display_factor; data->handle.update_opening( utils::TimeStamp::now(), double_of_price(msg.openingPrice, display_factor), date_of_timestamp(time) ); data->handle.update_session_high( utils::TimeStamp::now(), double_of_price(msg.high, display_factor) ); @@ -294,7 +293,7 @@ void ICEListener::onEndOfDayMarketSummary(const onixs::EndOfDayMarketSummary& ms // // Feed -void ICEListener::onMulticastMessageBlockBegin(onixs::FeedId feedId, const onixs::MessageInfo& msg_info) +void ICEListener::onMulticastMessageBlockBegin(onixs_ice::FeedId feedId, const onixs_ice::MessageInfo& msg_info) { UNUSED(feedId); // Mark the arrival of the packet @@ -307,14 +306,14 @@ void ICEListener::onMulticastMessageBlockBegin(onixs::FeedId feedId, const onixs } _latest_sequence = seq; auto onixs_zero = msg_info.receiveTime; - auto onixs_now = onixs::Timestamp::utcNow(); + auto onixs_now = onixs_ice::Timestamp::utcNow(); UNUSED(onixs_zero); UNUSED(onixs_now); tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockBegin", _latest_sequence,(uint16_t) _latest_sequence, /*onixs_now-onixs_zero*/0); } -void ICEListener::onMulticastMessageBlockEnd(onixs::FeedId feedId, const onixs::MarketIds& marketIds) +void ICEListener::onMulticastMessageBlockEnd(onixs_ice::FeedId feedId, const onixs_ice::MarketIds& marketIds) { UNUSED(feedId); UNUSED(marketIds); @@ -323,13 +322,13 @@ void ICEListener::onMulticastMessageBlockEnd(onixs::FeedId feedId, const onixs:: tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockEnd.end", _latest_sequence, (uint16_t) _latest_sequence, 0); } -void ICEListener::onFeedStarted(onixs::FeedId, const onixs::MarketIds&) +void ICEListener::onFeedStarted(onixs_ice::FeedId, const onixs_ice::MarketIds&) {} -void ICEListener::onFeedStopped(onixs::FeedId) +void ICEListener::onFeedStopped(onixs_ice::FeedId) {} -void ICEListener::onSessionNumberChange(onixs::FeedId , short , short ) +void ICEListener::onSessionNumberChange(onixs_ice::FeedId , short , short ) {} @@ -383,7 +382,7 @@ void ICEListener::flush_books() void ICEListener::update_all_status(CoconutSecurityStatus status) { - _index.walk_security_list([=](SecurityData& data) + _index.walk_security_list([=](ICESecurityData& data) { data.handle.set_status(status); }); diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h index cf248d798..c3d10cefe 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h @@ -19,12 +19,12 @@ namespace md { namespace ice { class ICEListener : - public onixs::ExchangeListener, //One Thread - public onixs::HandlerStateChangeListener, //One thread - public onixs::OrderBookUpdateListener, //One thread //TODO? - public onixs::FeedListener, //Multi thread - public onixs::ErrorListener, //Multi thread - public onixs::WarningListener //Multi thread + public onixs_ice::ExchangeListener, //One Thread + public onixs_ice::HandlerStateChangeListener, //One thread + public onixs_ice::OrderBookUpdateListener, //One thread //TODO? + public onixs_ice::FeedListener, //Multi thread + public onixs_ice::ErrorListener, //Multi thread + public onixs_ice::WarningListener //Multi thread { typedef uint32_t BookType; @@ -38,58 +38,58 @@ public: // //State change - void onHandlerStateChange(const onixs::HandlerStateChange& change) override; - void onMarketStateChange(const onixs::MarketStateChange& msg, const onixs::MessageInfo& msgInfo) override; + void onHandlerStateChange(const onixs_ice::HandlerStateChange& change) override; + void onMarketStateChange(const onixs_ice::MarketStateChange& msg, const onixs_ice::MessageInfo& msgInfo) override; // Warnings/Errors/Info - void onError(const onixs::Error&) override; - void onFeedError(onixs::FeedId feedid, onixs::ErrorCode code, const std::string& desc) override; - void onWarning(const onixs::Warning& warning) override; + void onError(const onixs_ice::Error&) override; + void onFeedError(onixs_ice::FeedId feedid, onixs_ice::ErrorCode code, const std::string& desc) override; + void onWarning(const onixs_ice::Warning& warning) override; // // Security discovery - void onFuturesProductDefinition(const onixs::FuturesProductDefinition& def, bool& is_interested) override; - void onNewExpiry(const onixs::NewExpiry& msg, bool& is_interested, const onixs::MessageInfo& msg_info) override; - void onFuturesStrategyDefinition(const onixs::FuturesStrategyDefinition& def, bool& is_interested) override; - void onNewFuturesStrategyDefinition(const onixs::NewFuturesStrategyDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) override; + void onFuturesProductDefinition(const onixs_ice::FuturesProductDefinition& def, bool& is_interested) override; + void onNewExpiry(const onixs_ice::NewExpiry& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) override; + void onFuturesStrategyDefinition(const onixs_ice::FuturesStrategyDefinition& def, bool& is_interested) override; + void onNewFuturesStrategyDefinition(const onixs_ice::NewFuturesStrategyDefinition& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) override; - void onOptionsProductDefinition(const onixs::OptionsProductDefinition& def, bool& is_interested) override; - void onNewOptionsMarketDefinition(const onixs::NewOptionsMarketDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) override; - void onOptionsStrategyDefinition(const onixs::OptionsStrategyDefinition& def, bool& is_interested) override; - void onNewOptionsStrategyDefinition(const onixs::NewOptionsStrategyDefinition& msg, bool& is_interested, const onixs::MessageInfo& msg_info) override; + void onOptionsProductDefinition(const onixs_ice::OptionsProductDefinition& def, bool& is_interested) override; + void onNewOptionsMarketDefinition(const onixs_ice::NewOptionsMarketDefinition& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) override; + void onOptionsStrategyDefinition(const onixs_ice::OptionsStrategyDefinition& def, bool& is_interested) override; + void onNewOptionsStrategyDefinition(const onixs_ice::NewOptionsStrategyDefinition& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) override; // // Gap Recovery - void onMarketSnapshot(const onixs::MarketSnapshot& msg, const onixs::MessageInfo& msgInfo) override; - void onMarketSnapshotOrder(const onixs::MarketSnapshotOrder& msg, const onixs::MessageInfo& msgInfo) override; - void onMarketSnapshotPriceLevel(const onixs::MarketSnapshotPriceLevel& msg, const onixs::MessageInfo& msgInfo) override; + void onMarketSnapshot(const onixs_ice::MarketSnapshot& msg, const onixs_ice::MessageInfo& msgInfo) override; + void onMarketSnapshotOrder(const onixs_ice::MarketSnapshotOrder& msg, const onixs_ice::MessageInfo& msgInfo) override; + void onMarketSnapshotPriceLevel(const onixs_ice::MarketSnapshotPriceLevel& msg, const onixs_ice::MessageInfo& msgInfo) override; // // Book - void onOrderBookUpdated(const onixs::OrderBook& book, const onixs::MessageInfo& msgInfo) override; + void onOrderBookUpdated(const onixs_ice::OrderBook& book, const onixs_ice::MessageInfo& msgInfo) override; // // Trades - void onTrade (const onixs::Trade& msg, const onixs::MessageInfo& msgInfo) override; + void onTrade (const onixs_ice::Trade& msg, const onixs_ice::MessageInfo& msgInfo) override; // // RFQ - void onRfq (const onixs::Rfq& msg, const onixs::MessageInfo& msgInfo) override; + void onRfq (const onixs_ice::Rfq& msg, const onixs_ice::MessageInfo& msgInfo) override; // // Misc - void onSettlementPrice(const onixs::SettlementPrice& msg, const onixs::MessageInfo& msgInfo) override; - void onOpenInterest(const onixs::OpenInterest &msg, const onixs::MessageInfo &msgInfo) override; - void onOpenPrice(const onixs::OpenPrice& msg, const onixs::MessageInfo& msgInfo) override; - void onClosePrice(const onixs::ClosePrice& msg, const onixs::MessageInfo& msgInfo) override; - void onEndOfDayMarketSummary(const onixs::EndOfDayMarketSummary& msg, const onixs::MessageInfo& msgInfo) override; + void onSettlementPrice(const onixs_ice::SettlementPrice& msg, const onixs_ice::MessageInfo& msgInfo) override; + void onOpenInterest(const onixs_ice::OpenInterest &msg, const onixs_ice::MessageInfo &msgInfo) override; + void onOpenPrice(const onixs_ice::OpenPrice& msg, const onixs_ice::MessageInfo& msgInfo) override; + void onClosePrice(const onixs_ice::ClosePrice& msg, const onixs_ice::MessageInfo& msgInfo) override; + void onEndOfDayMarketSummary(const onixs_ice::EndOfDayMarketSummary& msg, const onixs_ice::MessageInfo& msgInfo) override; // Feed - void onMulticastMessageBlockBegin(onixs::FeedId feedId, const onixs::MessageInfo& msgInfo) override; - void onMulticastMessageBlockEnd(onixs::FeedId feedId, const onixs::MarketIds& marketIds) override; - void onFeedStarted(onixs::FeedId feedId, const onixs::MarketIds& ids) override; - void onFeedStopped(onixs::FeedId feedId) override; - void onSessionNumberChange(onixs::FeedId feedId, short oldSessionNumber, short newSessionNumber) override; + void onMulticastMessageBlockBegin(onixs_ice::FeedId feedId, const onixs_ice::MessageInfo& msgInfo) override; + void onMulticastMessageBlockEnd(onixs_ice::FeedId feedId, const onixs_ice::MarketIds& marketIds) override; + void onFeedStarted(onixs_ice::FeedId feedId, const onixs_ice::MarketIds& ids) override; + void onFeedStopped(onixs_ice::FeedId feedId) override; + void onSessionNumberChange(onixs_ice::FeedId feedId, short oldSessionNumber, short newSessionNumber) override; // // Discover securities @@ -196,7 +196,7 @@ void ICEListener::on_future_spread(const Definition& def, bool& is_interested) fsec.legs[x].leg_delta = double_of_price(leg.ratioQtyNumerator.value(), leg.ratioQtyDenominator.value()); fsec.legs[x].leg_quantity = leg.ratio; - fsec.legs[x].leg_side = leg.side == onixs::Side::Bid ? api::SIDE_BUY : api::SIDE_SELL; + fsec.legs[x].leg_side = leg.side == onixs_ice::Side::Bid ? api::SIDE_BUY : api::SIDE_SELL; fsec.legs[x].exchange_key = ExchangeKey(leg.marketId); fsec.legs[x].key = invalid_security_key; } diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h index 46460c750..82c10e90c 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h @@ -39,12 +39,12 @@ inline PriceSize pricesize_of_price_size(const OnixsPrice& price, int8_t display return result; } -inline datetime::LLDateTime ll_of_timestamp(const onixs::DateTime& dt) +inline datetime::LLDateTime ll_of_timestamp(const onixs_ice::DateTime& dt) { return datetime::ll_from_unix_epoch_ms(dt); } -inline datetime::Date date_of_timestamp(const onixs::DateTime& dt) +inline datetime::Date date_of_timestamp(const onixs_ice::DateTime& dt) { auto ll = ll_of_timestamp(dt); return datetime::ll_to_date(ll); diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp index db70296d3..ad6a915c4 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp @@ -38,18 +38,6 @@ ICEMain::ICEMain() : ICEMain::~ICEMain() {} -// const ICEOptions::ICEChannel channel_settings_for(const string& id) -// { -// const auto& config = config::get(); -// for (const auto& ch : config.channel()) -// { -// bool found = std::find_if(ch.id().begin(), ch.id().end(), [&](const string& chan_id) { return chan_id == id || chan_id == "*"; }) != ch.id().end(); -// if (found) -// return ch; -// } -// return ICEOptions::ICEChannel(); -// } - const ICEOptions::ICEChannel channel_settings_for(const string& id) { const auto& config = config::get(); @@ -64,10 +52,10 @@ const ICEOptions::ICEChannel channel_settings_for(const string& id) } -onixs::MarketSubscriptions market_subcription_for_channel(const string& channel_id) +onixs_ice::MarketSubscriptions market_subcription_for_channel(const string& channel_id) { const auto& options = channel_settings_for(channel_id); - onixs::MarketSubscriptions subs; + onixs_ice::MarketSubscriptions subs; return subs; } @@ -77,7 +65,7 @@ void ICEMain::run(std::vector& symbols) const auto& channels = parse_ice_channels(symbols); for (const auto& channel : channels) { - unique_ptr phandler = prepare_handler(channel.id); + unique_ptr phandler = prepare_handler(channel.id); _listeners.push_back(prepare_listener(*phandler, channel)); _handlers.insert(std::make_pair(channel.id, move(phandler))); std::stringstream symstr; @@ -88,7 +76,7 @@ void ICEMain::run(std::vector& symbols) for (auto& pair : _handlers) { - onixs::MarketSubscriptions subs = market_subcription_for_channel(pair.first); + onixs_ice::MarketSubscriptions subs = market_subcription_for_channel(pair.first); pair.second->start(subs); } @@ -105,32 +93,9 @@ void ICEMain::run(std::vector& symbols) disp.run(); } - -// void ICEMain::initialize() { -// const auto& options = config::get(); -// auto license_location = os::bts_data_path() + "/licenses/"; - -// if (!boost::filesystem::is_directory(license_location)) { -// auto license_path =os::sparkd_wd() + "/data_files/Onixs.BTS.lic" ; -// boost::filesystem::create_directories(license_location); -// boost::filesystem::copy_file(license_path,license_location+"/Onixs.BTS.lic"); -// } - -// // -// // License path -// onixs::InitializationSettings init_settings; -// auto license = options.onixs_license(); -// init_settings.licenseStore(license); -// if (license == "{default}") { -// init_settings.licenseStore(license_location); -// } -// LOG(md,Info,"Loading onixs license from {}", init_settings.licenseStore()); -// onixs::initialize(init_settings); -// } - // // // Initialize HandlerSettings and allocate the channel Handler -unique_ptr ICEMain::prepare_handler(const string& channel_id) +unique_ptr ICEMain::prepare_handler(const string& channel_id) { // // License path @@ -150,11 +115,11 @@ unique_ptr ICEMain::prepare_handler(const string& channel_id) const auto& options = channel_settings_for(channel_id); LOG(md,Info,"Loaded channel options for channel {}:\n{}",channel_id,options.DebugString()); - onixs::HandlerSettings settings; + onixs_ice::HandlerSettings settings; settings.licenseDirectory = license; // // Logging - settings.logLevel = (onixs::LogLevels::Enum) options.onixs_log_mode(); + settings.logLevel = (onixs_ice::LogLevels::Enum) options.onixs_log_mode(); settings.logDirectory = ice_log_path(); // @@ -191,7 +156,7 @@ unique_ptr ICEMain::prepare_handler(const string& channel_id) // // Misc settings if(options.processing_thread_affinity() != "" ) - settings.processingThreadAffinity = onixs::ThreadAffinity::deserialize(options.processing_thread_affinity()); + settings.processingThreadAffinity = onixs_ice::ThreadAffinity::deserialize(options.processing_thread_affinity()); // if(options.has_track_top_of_the_book_only() // settings.trackTopOfTheBookOnly = options.track_top_of_the_book_only(); if(options.has_receive_product_definitions_only()) @@ -205,7 +170,7 @@ unique_ptr ICEMain::prepare_handler(const string& channel_id) // return feed handler try { - auto handler = unique_ptr(new onixs::Handler(settings)); + auto handler = unique_ptr(new onixs_ice::Handler(settings)); return handler; } catch (std::exception& e) { @@ -216,7 +181,7 @@ unique_ptr ICEMain::prepare_handler(const string& channel_id) // // Create a listener for this channel and register callbacks -unique_ptr ICEMain::prepare_listener(onixs::Handler& handler, const ICEChannel& channel) { +unique_ptr ICEMain::prepare_listener(onixs_ice::Handler& handler, const ICEChannel& channel) { // We need to get a handler to the producer channels so we can produce heartbeats vector producer_channels; for (auto& symbol : channel.symbols) { diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h index 876199bb2..f482ea15e 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h @@ -32,8 +32,8 @@ public: void run(std::vector&); void initialize(); - std::unique_ptr prepare_handler(const std::string& channel); - std::unique_ptr prepare_listener(onixs::Handler& handler, const ICEChannel& channel); + std::unique_ptr prepare_handler(const std::string& channel); + std::unique_ptr prepare_listener(onixs_ice::Handler& handler, const ICEChannel& channel); private: BTS_NO_COPY(ICEMain); @@ -41,7 +41,7 @@ private: ICESecurityIndex _index; SecurityIDRecorder _recorder; MDProducer _producer; - std::map> _handlers; + std::map> _handlers; std::vector> _listeners; }; diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICESecurityIndex.h b/src/server/sparkd/md/platforms/ice_onixs/ICESecurityIndex.h index 7c2bddc17..e774bbb04 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICESecurityIndex.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICESecurityIndex.h @@ -6,14 +6,14 @@ namespace bts { namespace md { -struct SecurityData { - SecurityData(uint32_t id, MDProducerHandle& h) : id(id), handle(h), electronic_volume(0) {} +struct ICESecurityData +{ + ICESecurityData(uint32_t id, MDProducerHandle& h) : id(id), handle(h) {} uint32_t id; // exchange id MDProducerHandle handle; - uint32_t electronic_volume; }; -typedef ConcurrentSecurityIndex ICESecurityIndex; +typedef ConcurrentSecurityIndex ICESecurityIndex; }}//namespace diff --git a/src/server/sparkd/md/platforms/ice_onixs/onixs.h b/src/server/sparkd/md/platforms/ice_onixs/onixs.h index 07b56a6e9..bafa3f5e2 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/onixs.h +++ b/src/server/sparkd/md/platforms/ice_onixs/onixs.h @@ -2,6 +2,6 @@ #include // namespace onixs = OnixS::CME::MDH; -namespace onixs { +namespace onixs_ice { using namespace OnixS::ICE::iMpact::MarketData; } \ No newline at end of file diff --git a/src/server/sparkd/md/run_md.cpp b/src/server/sparkd/md/run_md.cpp index 56e2c2762..ebaadf9d6 100644 --- a/src/server/sparkd/md/run_md.cpp +++ b/src/server/sparkd/md/run_md.cpp @@ -11,6 +11,7 @@ #include "lib/md/Diag/MDPeriodicDumper.h" #include "lib/md/cme/MDP3Utils.h" #include "platforms/mdp3_onixs/MDP3Main.h" +#include "platforms/ice_onixs/ICEMain.h" #include "lib/md/SecurityDB.h" #include "server/sparkd/exchange_sim/ExchangeSim.h" #include "lib/utils/thread_manager.h" @@ -71,6 +72,14 @@ void run_onixs() { get_system_md_symbols(api::VENUE_GLBX, api::SECURITYTYPE_UNSET, &symbols); MDP3Main main; main.run(symbols); + + std::vector ice_symbols; + get_system_md_symbols(api::VENUE_ICE, api::SECURITYTYPE_UNSET, &ice_symbols); + if(ice_symbols.size() > 0) + { + ice::ICEMain imain; + imain.run(symbols); + } } void run_cleanup() { From f7265740e7de5a8383b518877949bcddd962c2d8 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Tue, 5 Mar 2019 18:08:20 -0500 Subject: [PATCH 14/72] ICE securities, from the actual ICE --- CMakeLists.txt | 2 + .../ConnectivityConfiguration.APITest.xml | 8 +- src/lib/CMakeDeps_win.cmake | 2 +- src/lib/config/defaults/MarketData.conf | 10 +- src/lib/config/defaults/Symbols.conf | 48 ++++----- src/lib/config/protos/MarketData.proto | 5 +- src/lib/md/PlatformLoader.cpp | 9 +- src/lib/md/ice/ICEUtils.cpp | 72 ++++---------- src/lib/md/ice/ICEUtils.h | 13 +-- .../md/platforms/ice_onixs/ICEListener.cpp | 13 ++- .../md/platforms/ice_onixs/ICEListener.h | 22 +++-- .../sparkd/md/platforms/ice_onixs/ICEMain.cpp | 99 +++++++++++-------- .../sparkd/md/platforms/ice_onixs/ICEMain.h | 4 +- src/server/sparkd/md/run_md.cpp | 4 +- 14 files changed, 155 insertions(+), 156 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a4395bfcf..be98723f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,8 @@ else () COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/web ${CMAKE_BINARY_DIR}/server COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/data_files ${CMAKE_BINARY_DIR}/server COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/src/lib/libspark.so ${CMAKE_BINARY_DIR}/server + COMMAND ln ARGS -sf ${EXTERNALS_ROOT}/lib/Release/libOnixS.IceImpactMulticastPriceFeedHandlerCpp.so.3.13.0.0 ${CMAKE_BINARY_DIR}/server + COMMAND ln ARGS -sf ${EXTERNALS_ROOT}/lib/Release/libACE-5.7.5.so ${CMAKE_BINARY_DIR}/server COMMAND mkdir ARGS -p ${CMAKE_BINARY_DIR}/server/plugins COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/sdk/examples/order_plugin_example.so ${CMAKE_BINARY_DIR}/server/plugins/ COMMENT "Creating server runtime layout" diff --git a/src/data_files/files/onixs_ice/ConnectivityConfiguration.APITest.xml b/src/data_files/files/onixs_ice/ConnectivityConfiguration.APITest.xml index 4cb6546b7..334c3c48f 100644 --- a/src/data_files/files/onixs_ice/ConnectivityConfiguration.APITest.xml +++ b/src/data_files/files/onixs_ice/ConnectivityConfiguration.APITest.xml @@ -16,8 +16,8 @@ 63.247.113.163 3000 - Value from ICE Support - Value from ICE Support + bluetrd-ps + Starts123 N Legacy @@ -34,8 +34,8 @@ 63.247.113.229 3000 - Value from ICE Support - Value from ICE Support + bluetrdl-ps + Starts123 N Legacy diff --git a/src/lib/CMakeDeps_win.cmake b/src/lib/CMakeDeps_win.cmake index 879f19a67..67cdb8a9f 100644 --- a/src/lib/CMakeDeps_win.cmake +++ b/src/lib/CMakeDeps_win.cmake @@ -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/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.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/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.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/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/quickbus_cfg.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/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_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/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/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.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/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/stats.cpp;utils/tests/AuthTokenTests.cpp;utils/thread_manager.cpp) \ No newline at end of file +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/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.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/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.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/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/quickbus_cfg.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/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_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/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/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/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/stats.cpp;utils/tests/AuthTokenTests.cpp;utils/thread_manager.cpp) \ No newline at end of file diff --git a/src/lib/config/defaults/MarketData.conf b/src/lib/config/defaults/MarketData.conf index 9a94cb5bb..ab4c47638 100644 --- a/src/lib/config/defaults/MarketData.conf +++ b/src/lib/config/defaults/MarketData.conf @@ -41,12 +41,14 @@ CMEOptions { ICEOptions { value { channel { - id: "ICE Futures WTI" - udp_buffer_size: 67108864 + market_type: 5 #ICE Futures Brent, IPE Brent Futures + market_type: 9 #ICE Futures WTI, ICE WTI Crude Futures + #udp_buffer_size: 67108864 } channel { - id: "*" - } + market_type: 23 #ICE Futures US Agricultures, FCOJ A + } + ice_config_file: "ConnectivityConfiguration.APITest.xml" } } diff --git a/src/lib/config/defaults/Symbols.conf b/src/lib/config/defaults/Symbols.conf index 86fca9c3a..89737ff10 100644 --- a/src/lib/config/defaults/Symbols.conf +++ b/src/lib/config/defaults/Symbols.conf @@ -6,35 +6,35 @@ SymbolLists { key: "ICE" - symbol: "B" - symbol: "T" + symbol: "BRN" + symbol: "WBS" } list { key: "GLBX" - symbol: "HE" - symbol: "LE" - symbol: "CL" - symbol: "RB" - symbol: "HO" - symbol: "BZ" - symbol: "NG" - symbol: "GC" - symbol: "SI" - symbol: "HG" - symbol: "ZW" - symbol: "ZC" - symbol: "ZS" - symbol: "ZM" - symbol: "ZL" - symbol: "ZO" - symbol: "ZR" - symbol: "ZB" - symbol: "ZN" - symbol: "ZF" - symbol: "ZT" - symbol: "UB" + # symbol: "HE" + # symbol: "LE" + # symbol: "CL" + # symbol: "RB" + # symbol: "HO" + # symbol: "BZ" + # symbol: "NG" + # symbol: "GC" + # symbol: "SI" + # symbol: "HG" + # symbol: "ZW" + # symbol: "ZC" + # symbol: "ZS" + # symbol: "ZM" + # symbol: "ZL" + # symbol: "ZO" + # symbol: "ZR" + # symbol: "ZB" + # symbol: "ZN" + # symbol: "ZF" + # symbol: "ZT" + # symbol: "UB" } } } diff --git a/src/lib/config/protos/MarketData.proto b/src/lib/config/protos/MarketData.proto index e3779de3e..1119b8683 100755 --- a/src/lib/config/protos/MarketData.proto +++ b/src/lib/config/protos/MarketData.proto @@ -141,9 +141,9 @@ message ICEOptions Debug = 5; } - //a channel is for what onixs-ice would consider a mcast group, we still have to dereference the marketType codes within the group + //A channel is one onixs-ice thread message ICEChannel { - repeated string id = 1; + repeated uint32 market_type = 1; optional uint32 udp_buffer_size = 2 [default = 33554432]; //32mb optional uint32 heartbeat_interval = 3 [default = 36000]; optional uint32 sequence_gap_margin = 4 [default = 10000]; @@ -165,6 +165,7 @@ message ICEOptions } optional string onixs_license = 1 [default = "{default}"]; + optional string ice_config_file = 2 [default = "ConnectivityConfiguration.Production.xml"]; repeated ICEChannel channel = 3; } diff --git a/src/lib/md/PlatformLoader.cpp b/src/lib/md/PlatformLoader.cpp index 9ec7c953e..87475254d 100644 --- a/src/lib/md/PlatformLoader.cpp +++ b/src/lib/md/PlatformLoader.cpp @@ -90,8 +90,7 @@ void add_symbols_to_result( size_t get_system_md_symbols(api::Venue exchange, SecurityType type, std::set &result) { - bts_assert(config::system_symbols::Symbols::descriptor()->field_count() == - 2); + bts_assert(config::system_symbols::Symbols::descriptor()->field_count() == 3); { auto const &e = config::get().glbx(); if (exchange == api::VENUE_UNSET || exchange == api::VENUE_GLBX) { @@ -209,9 +208,9 @@ extern "C" BTS_EXPORT Platform platform_for_exchange(Venue v) { co2::Platform platform; if (v == VENUE_SIM) return PLATFORM_SIM; - if (co2::Platform_Parse(pmap.glbx_platform(), &platform)) - return platform; - if (co2::Platform_Parse(pmap.ice_platform(), &platform)) + if (v == VENUE_GLBX && co2::Platform_Parse(pmap.glbx_platform(), &platform)) + return platform; + if (v == VENUE_ICE && co2::Platform_Parse(pmap.ice_platform(), &platform)) return platform; return PLATFORM_UNSET; diff --git a/src/lib/md/ice/ICEUtils.cpp b/src/lib/md/ice/ICEUtils.cpp index ee8f55589..139f3c117 100644 --- a/src/lib/md/ice/ICEUtils.cpp +++ b/src/lib/md/ice/ICEUtils.cpp @@ -32,9 +32,8 @@ string ice_data_path() { #endif return p; } -const string api_test_config_path() { return ice_data_path() + "ConnectivityConfiguration.APITest.xml"; } -const string perf_test_config_path() { return ice_data_path() + "ConnectivityConfiguration.PerfTest.xml"; } -const string ice_config_path() { return ice_data_path() + "ConnectivityConfiguration.Production.xml"; } +const string ice_config_file() { return config::get().ice_config_file(); } +const string ice_config_path() { return ice_data_path() + "/" + ice_config_file(); } const std::string ice_log_path() {return log:: log_path().string() + "/onix_ice";} @@ -73,8 +72,9 @@ void await_ice_config() { // Check config is present and give instructions for downloading it if not // If the file is not present log an error and wait a second. Continue to log the error ever power of 2 seconds until the file appears or the process is killed. + auto configpath = ice_config_path(); uint32_t count = 0; - while(!ice_check_file_exists_with_instructions(ice_config_path(), config_url, is_pow_two_or_0(count))) { + while(!ice_check_file_exists_with_instructions(configpath, config_url, is_pow_two_or_0(count))) { ++count; std::this_thread::sleep_for(1s); } @@ -101,59 +101,29 @@ SecurityType infer_security_type(const string& label) { const std::vector get_configured_ice_channels() { std::vector symbols; - // Get all glbx symbols + // Get all ice symbols get_system_md_symbols(api::VENUE_ICE, api::SECURITYTYPE_UNSET, &symbols); return parse_ice_channels(symbols); } -const vector parse_ice_channels(const vector& symbols) { + +//We are sort of punting on symbols here because there is no symbol -> channel mapping supplied by ice +//therefore we must 1) enumerate the channels we want in config, and smash them together with the list of +//symbols we care about. This has the unfortunate side effect of not knowing what channel should heartbeat what symbol +//but Eric says this is ok +const vector parse_ice_channels(const vector& symbols) +{ vector result; - bool skip_options = config::get().skip_options(); - - pugi::xml_document doc; - bts_assert_msg(doc.load_file(ice_config_path().c_str()), "Error parsing config.xml as xml"); - - auto configuration = doc.root().child("configuration"); - bts_assert(configuration); - - LOG(md,Info,"ICE: Loaded '{}' config. Last updated: {}" , - std::string(configuration.attribute("environment").as_string("??")), - std::string(configuration.attribute("updated").as_string("??"))); - auto channels = configuration.children("channel"); - for (const auto& chan : channels) { - ICEChannel channel; - channel.id = chan.attribute("id").as_string(); - auto channel_type = infer_security_type(chan.attribute("label").as_string()); - if (channel_type == SECURITYTYPE_OPTION && skip_options) continue; - if (!(channel.id.empty())) { - auto product_list = chan.child("products").children("product"); - for (const auto& product : product_list) { - auto symbol = product.attribute("code").as_string(); - for (auto s : symbols) { - if ((s.type() == channel_type || s.type() == SECURITYTYPE_SPREAD) - && s.symbol() == symbol) { - channel.symbols.insert(s); - } - } - } - if (!channel.symbols.empty()) { - auto connections = chan.child("connections").children("connection"); - for (const auto& srccon : connections) { - std::string id = srccon.attribute("id").as_string(); - if (!id.empty()) { - ICEConnection connection; - connection.feed_type = srccon.child("type").attribute("feed-type").as_string(); - connection.ip = srccon.child_value("ip"); - connection.port = srccon.child("port").text().as_uint(); - connection.feed = srccon.child_value("feed")[0]; - channel.connections.insert(std::make_pair(id, connection)); - } - } - - result.push_back(channel); - } + const auto& ice_options = config::get(); + for(const auto& x : ice_options.channel()) + { + for(const auto& xx : x.market_type()) + { + md::ice::ICEChannel chan; + chan.market_type = xx; + chan.symbols.insert(symbols.begin(), symbols.end()); + result.push_back(chan); } } - return result; } diff --git a/src/lib/md/ice/ICEUtils.h b/src/lib/md/ice/ICEUtils.h index bd4875e45..32c043201 100644 --- a/src/lib/md/ice/ICEUtils.h +++ b/src/lib/md/ice/ICEUtils.h @@ -9,17 +9,10 @@ namespace bts { namespace md { namespace ice { -struct ICEConnection { - std::string feed_type; - std::string ip; - uint port; - char feed; -}; - -struct ICEChannel { - std::string id; +struct ICEChannel +{ + uint32_t market_type; std::set symbols; - std::map connections; }; void await_ice_config(); diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp index c8259e1ec..8d462a2c8 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp @@ -37,6 +37,12 @@ ICEListener::ICEListener(ICESecurityIndex& index, MDProducer& producer, const st ICEListener::~ICEListener() {} +std::string ICEListener::parse_contract_symbol(const std::string& sym) +{ + const auto&& res = sym.substr(0, sym.find(' ')); + return res; +} + // //State change void ICEListener::onHandlerStateChange(const onixs_ice::HandlerStateChange& ) @@ -53,18 +59,19 @@ void ICEListener::onMarketStateChange(const onixs_ice::MarketStateChange& , cons // Warnings/Errors void ICEListener::onError(const onixs_ice::Error& error) { + std::string error_desc(error.description()); tracepoint (bts_trace,trace_order,(char*) "onError", _latest_sequence, (uint16_t) _latest_sequence, 0); - LOG(md,Warn, "OnixS Error: {} - {}", error.toString() ); + LOG(md,Warn, "OnixS ICE Error: {} - {}", error.toString(), error_desc ); } void ICEListener::onFeedError(onixs_ice::FeedId feedid, onixs_ice::ErrorCode code, const std::string& desc) { tracepoint (bts_trace,trace_order,(char*) "onFeedError", _latest_sequence, (uint16_t) _latest_sequence, 0); - LOG(md,Warn, "OnixS FeedError: {} - {}", feedid, desc, code); + LOG(md,Warn, "OnixS ICE FeedError: {} - {}", feedid, desc, code); } void ICEListener::onWarning(const onixs_ice::Warning& warning) { tracepoint (bts_trace,trace_order,(char*) "onWarning", _latest_sequence, (uint16_t) _latest_sequence, 0); - LOG(md,Warn, "OnixS Warn: {} - {}", warning.toString() ); + LOG(md,Warn, "OnixS ICE Warn: {} - {}", warning.toString(), std::string(warning.description()) ); } // diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h index c3d10cefe..c7cac707a 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h @@ -99,6 +99,8 @@ public: // Add a new security to the index void add_security(const FixedSecurity& security); private: + template + void set_security_common(const Definition& def, FixedSecurity& fsec); template void on_future(const Definition& def, bool& is_interested); template @@ -109,12 +111,16 @@ private: private: enum SecurityFilterAction { ADD, SKIP, DELETE }; + std::string parse_contract_symbol(const std::string& sym); + template SecurityFilterAction filter_security(int exchange_id, const Definition& def) { if (_index.has_security(exchange_id)) return SKIP; - return _symbol_filter.count(def.contractSymbol) > 0 ? ADD : SKIP; + // if(_symbol_filter.count("*") > 0) + // return ADD; + return _symbol_filter.count( parse_contract_symbol(def.contractSymbol) ) > 0 ? ADD : SKIP; } void flush_books(); void update_all_status(co2::CoconutSecurityStatus status); @@ -138,15 +144,17 @@ private: }; template -void set_security_common(const Definition& def, FixedSecurity& fsec) +void ICEListener::set_security_common(const Definition& def, FixedSecurity& fsec) { fsec.numeric_id = def.marketId; - fsec.symbol(def.contractSymbol); - fsec.security_desc(def.marketDesc); + std::string sym = parse_contract_symbol(def.contractSymbol); + fsec.symbol( sym ); + //fsec.security_desc(def.marketDesc); + fsec.security_desc(def.contractSymbol); fsec.exchange = api::Venue::VENUE_ICE; - fsec.display_factor = (int8_t)def.orderPriceDenominator; - fsec.ice_deal_display_factor = (int8_t)def.dealPriceDenominator; - fsec.ice_settle_display_factor = (int8_t)def.settlePriceDenominator; + fsec.display_factor = (int8_t)(def.orderPriceDenominator - '0'); + fsec.ice_deal_display_factor = (int8_t)(def.dealPriceDenominator - '0'); + fsec.ice_settle_display_factor = (int8_t)(def.settlePriceDenominator - '0'); double min_tick = double_of_price(def.incrementPrice, fsec.display_factor); fsec.low_tick = fsec.high_tick = min_tick; //fsec.cash_per_point = double_of_price(def.tickValue, fsec.display_factor); diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp index ad6a915c4..2f4b7d0c6 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp @@ -19,6 +19,22 @@ #include #include +void recursive_copy(const boost::filesystem::path &src, const boost::filesystem::path &dst) +{ + if (boost::filesystem::exists(dst)) + throw std::runtime_error(dst.generic_string() + " exists"); + if (boost::filesystem::is_directory(src)) + { + boost::filesystem::create_directories(dst); + for (boost::filesystem::directory_entry& item : boost::filesystem::directory_iterator(src)) + recursive_copy(item.path(), dst/item.path().filename()); + } + else if (boost::filesystem::is_regular_file(src)) + boost::filesystem::copy(src, dst); + else + throw std::runtime_error(dst.generic_string() + " not dir or file"); +} + using namespace std; using namespace bts::co2; using std::size_t; @@ -38,40 +54,60 @@ ICEMain::ICEMain() : ICEMain::~ICEMain() {} -const ICEOptions::ICEChannel channel_settings_for(const string& id) +const ICEOptions::ICEChannel channel_settings_for(uint32_t id) { const auto& config = config::get(); for (const auto& ch : config.channel()) { - bool found = std::find_if(ch.id().begin(), ch.id().end(), [&](const string& chan_id) { return chan_id == id || chan_id == "*"; }) != ch.id().end(); - if (found) { - return ch; - } + bool found = std::find_if(ch.market_type().begin(), ch.market_type().end(), [&](const uint32_t& chan_id) { return chan_id == id ; }) != ch.market_type().end(); + if(found) + return ch; } return ICEOptions::ICEChannel(); } -onixs_ice::MarketSubscriptions market_subcription_for_channel(const string& channel_id) +onixs_ice::MarketSubscriptions market_subcription_for_channel(uint32_t market_type) { - const auto& options = channel_settings_for(channel_id); + const auto& options = channel_settings_for(market_type); onixs_ice::MarketSubscriptions subs; + //onixs_ice::MarketSubType::NonImplied + onixs_ice::MarketSubscription futures(market_type, onixs_ice::MarketSubType::FullImplied, onixs_ice::SecurityType::Futures, onixs_ice::BookDepth::FOD); + onixs_ice::MarketSubscription spreads(market_type, onixs_ice::MarketSubType::FullImplied, onixs_ice::SecurityType::UdsFuturesMarkets, onixs_ice::BookDepth::FOD); + subs.push_back(futures); + subs.push_back(spreads); return subs; } + void ICEMain::run(std::vector& symbols) { + // License path and config file + auto license_location = os::bts_data_path() + "/licenses/"; + if (!boost::filesystem::is_directory(license_location)) + { + auto license_path =os::sparkd_wd() + "/data_files/Onixs.BTS.lic" ; + boost::filesystem::create_directories(license_location); + boost::filesystem::copy_file(license_path,license_location+"/Onixs.BTS.lic"); + } + auto ice_conf_location = os::bts_data_path() + "/onixs_ice/"; + if (!boost::filesystem::is_directory(ice_conf_location)) + { + auto conf_path = os::sparkd_wd() + "/data_files/onixs_ice/" ; + recursive_copy(boost::filesystem::path(conf_path), boost::filesystem::path(ice_conf_location)); + } + await_ice_config(); const auto& channels = parse_ice_channels(symbols); for (const auto& channel : channels) { - unique_ptr phandler = prepare_handler(channel.id); + unique_ptr phandler = prepare_handler(channel.market_type); _listeners.push_back(prepare_listener(*phandler, channel)); - _handlers.insert(std::make_pair(channel.id, move(phandler))); + _handlers.insert(std::make_pair(channel.market_type, move(phandler))); std::stringstream symstr; for (const auto& sym : channel.symbols) symstr << sym.symbol() << "-" << SecurityType_Name(sym.type()) << " "; - LOG(md,Info, "ICE: Initialized channel {} ({})",channel.id,symstr.str()); + LOG(md,Info, "ICE: Initialized channel {} ({})",channel.market_type,symstr.str()); } for (auto& pair : _handlers) @@ -95,25 +131,16 @@ void ICEMain::run(std::vector& symbols) // // // Initialize HandlerSettings and allocate the channel Handler -unique_ptr ICEMain::prepare_handler(const string& channel_id) +unique_ptr ICEMain::prepare_handler(uint32_t market_type) { - // - // License path const auto& ice_options = config::get(); - auto license_location = os::bts_data_path() + "/licenses/"; - if (!boost::filesystem::is_directory(license_location)) - { - auto license_path =os::sparkd_wd() + "/data_files/Onixs.BTS.lic" ; - boost::filesystem::create_directories(license_location); - boost::filesystem::copy_file(license_path,license_location+"/Onixs.BTS.lic"); - } auto license = ice_options.onixs_license(); if (license == "{default}") - license = license_location; + license = os::bts_data_path() + "/licenses/"; const auto& pub_options = config::get(); - const auto& options = channel_settings_for(channel_id); - LOG(md,Info,"Loaded channel options for channel {}:\n{}",channel_id,options.DebugString()); + const auto& options = channel_settings_for(market_type); + LOG(md,Info,"Loaded channel options for channel {}:\n{}",market_type,options.DebugString()); onixs_ice::HandlerSettings settings; settings.licenseDirectory = license; @@ -181,29 +208,19 @@ unique_ptr ICEMain::prepare_handler(const string& channel_id // // Create a listener for this channel and register callbacks -unique_ptr ICEMain::prepare_listener(onixs_ice::Handler& handler, const ICEChannel& channel) { +unique_ptr ICEMain::prepare_listener(onixs_ice::Handler& handler, const ICEChannel& channel) +{ // We need to get a handler to the producer channels so we can produce heartbeats vector producer_channels; - for (auto& symbol : channel.symbols) { + for (auto& symbol : channel.symbols) + { producer_channels.push_back(_producer.get_channel(symbol.symbol().c_str(), symbol.type(), symbol.exchange())); - } - - const auto& options = channel_settings_for(channel.id); + } + const auto& options = channel_settings_for(channel.market_type); unique_ptr listener(new ICEListener(_index, _producer, /*_settlement_recorder,*/ producer_channels)); - for (auto& symbol : channel.symbols) { - listener->add_filter_symbol(symbol.symbol()); - } - - if (options.load_security_db()) { - // Load the list of known securities and add them to the index for fast startup - db::load_securities(channel.symbols, [&](const api::Security& security) { - with_security_like(security, [&](FixedSecurity& fs) { - convert_security(security, fs, true); - listener->add_security(fs); - }); - }); - } + for (auto& symbol : channel.symbols) + listener->add_filter_symbol(symbol.symbol()); handler.registerExchangeListener(listener.get()); handler.registerFeedListener(listener.get()); diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h index f482ea15e..3ec06504a 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h @@ -32,7 +32,7 @@ public: void run(std::vector&); void initialize(); - std::unique_ptr prepare_handler(const std::string& channel); + std::unique_ptr prepare_handler(uint32_t channel); std::unique_ptr prepare_listener(onixs_ice::Handler& handler, const ICEChannel& channel); private: @@ -41,7 +41,7 @@ private: ICESecurityIndex _index; SecurityIDRecorder _recorder; MDProducer _producer; - std::map> _handlers; + std::map> _handlers; std::vector> _listeners; }; diff --git a/src/server/sparkd/md/run_md.cpp b/src/server/sparkd/md/run_md.cpp index ebaadf9d6..8fa973de2 100644 --- a/src/server/sparkd/md/run_md.cpp +++ b/src/server/sparkd/md/run_md.cpp @@ -71,14 +71,14 @@ void run_onixs() { std::vector symbols; get_system_md_symbols(api::VENUE_GLBX, api::SECURITYTYPE_UNSET, &symbols); MDP3Main main; - main.run(symbols); + //main.run(symbols); TODO std::vector ice_symbols; get_system_md_symbols(api::VENUE_ICE, api::SECURITYTYPE_UNSET, &ice_symbols); if(ice_symbols.size() > 0) { ice::ICEMain imain; - imain.run(symbols); + imain.run(ice_symbols); } } From 6b6fd9c40a36cf45ef5067fa05091b5585250394 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Wed, 6 Mar 2019 14:58:09 -0500 Subject: [PATCH 15/72] more ice --- .vscode/launch.json | 12 ++++++++++-- src/lib/CMakeLists.txt | 2 +- src/lib/config/defaults/Symbols.conf | 2 +- src/lib/domain_model/Security.cpp | 2 ++ src/lib/domain_model/Security.proto | 1 + src/lib/md/Shm/FixedSecurity.cpp | 6 +++++- src/lib/md/relay/QueryServer.cpp | 6 ++++++ 7 files changed, 26 insertions(+), 5 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 0cd375b54..84ec3ec01 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -75,11 +75,14 @@ "name": "SparkVM Launch", "type": "cppdbg", "request": "launch", + "program": "/home/bts/spark/build/ninja_debug/server/sparkd", "args": ["run"], "stopAtEntry": false, "cwd": "/home/bts/spark/build/ninja_debug/server/", - "environment": [], + "environment": [ + {"name":"LD_LIBRARY_PATH", "value": "."} + ], "externalConsole": true, "MIMode": "gdb", "preLaunchTask": "", @@ -96,7 +99,12 @@ "description": "Skip STL", "text": "skip -gfi /usr/include/c++/7/bits/*.h", "ignoreFailures": true - } + }, + { + "description": "LD LIBRARY", + "text": "set env LD_LIBRARY_PATH=.", + "ignoreFailures": false + } ], "pipeTransport": { "pipeCwd": "${workspaceRoot}", diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 65064d4d2..2bc9cd150 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -141,4 +141,4 @@ if (WIN32) include(${CMAKE_SOURCE_DIR}/tools/vs_filters.cmake) endif() - \ No newline at end of file + diff --git a/src/lib/config/defaults/Symbols.conf b/src/lib/config/defaults/Symbols.conf index 89737ff10..fcbaa4439 100644 --- a/src/lib/config/defaults/Symbols.conf +++ b/src/lib/config/defaults/Symbols.conf @@ -1,5 +1,5 @@ SymbolLists -{ +{ value { list diff --git a/src/lib/domain_model/Security.cpp b/src/lib/domain_model/Security.cpp index ea84b2c41..6f51a5d9d 100644 --- a/src/lib/domain_model/Security.cpp +++ b/src/lib/domain_model/Security.cpp @@ -24,6 +24,8 @@ std::string descriptor(api::Security const&sec) { if (sec.has_glbx()) return sec.glbx().security_desc(); + else if (sec.has_ice()) + return sec.ice().security_desc(); else return "No descriptor for non glbx exchange"; } diff --git a/src/lib/domain_model/Security.proto b/src/lib/domain_model/Security.proto index b9ba361be..068f6bff2 100644 --- a/src/lib/domain_model/Security.proto +++ b/src/lib/domain_model/Security.proto @@ -102,6 +102,7 @@ message CBOECFEExchangeData { } message ICEExchangeData { int64 exchange_id = 10; + string security_desc = 15; int32 deal_display_factor = 20; int32 settle_display_factor = 30; } diff --git a/src/lib/md/Shm/FixedSecurity.cpp b/src/lib/md/Shm/FixedSecurity.cpp index 2c217c7b5..5cf47d145 100644 --- a/src/lib/md/Shm/FixedSecurity.cpp +++ b/src/lib/md/Shm/FixedSecurity.cpp @@ -169,7 +169,9 @@ void convert_security(const FixedSecurity& source, Security* presult) { dest.mutable_glbx()->set_cme_symbol(source.alt_symbol()); if (source.cme_market_segment_id != 0) dest.mutable_glbx()->set_market_segment_id(source.cme_market_segment_id); break; - case Venue::VENUE_ICE: + case Venue::VENUE_ICE: + dest.mutable_ice()->set_exchange_id(source.numeric_id); + dest.mutable_ice()->set_security_desc(source.security_desc()); dest.mutable_ice()->set_deal_display_factor(source.ice_deal_display_factor); dest.mutable_ice()->set_settle_display_factor(source.ice_settle_display_factor); break; @@ -292,6 +294,8 @@ void convert_security(const Security& src, FixedSecurity& dest, bool set_securit dest.cboe_class_key = src.cfe().class_key(); break; case Security::ExchangeDataCase::kIce: + dest.numeric_id = src.ice().exchange_id(); + dest.security_desc(src.ice().security_desc()); dest.ice_deal_display_factor = src.ice().deal_display_factor(); dest.ice_settle_display_factor = src.ice().settle_display_factor(); break; diff --git a/src/lib/md/relay/QueryServer.cpp b/src/lib/md/relay/QueryServer.cpp index e8331308b..1d2a5ac3c 100644 --- a/src/lib/md/relay/QueryServer.cpp +++ b/src/lib/md/relay/QueryServer.cpp @@ -376,6 +376,12 @@ public: google::protobuf::MapPair v(h.handle.key(), security.glbx().security_desc()); x->insert(v); } + else if (security.ExchangeData_case() == Security::kIce) { + google::protobuf::MapPair v(h.handle.key(), security.ice().security_desc()); + x->insert(v); + } + else + bts_assert_msg(false, "exchange case"); } } } From d488ff23ba429701faacb857c6c8e2abdeb8e4b4 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Thu, 7 Mar 2019 11:38:38 -0500 Subject: [PATCH 16/72] I misunderstood how onixs wants to do the ice threading. fixed --- src/lib/config/defaults/MarketData.conf | 2 + src/lib/config/protos/MarketData.proto | 11 +++-- src/lib/md/ice/ICEUtils.cpp | 49 +++++++++++-------- src/lib/md/ice/ICEUtils.h | 4 +- .../sparkd/md/platforms/ice_onixs/ICEMain.cpp | 49 ++++++++++--------- .../sparkd/md/platforms/ice_onixs/ICEMain.h | 6 +-- 6 files changed, 70 insertions(+), 51 deletions(-) diff --git a/src/lib/config/defaults/MarketData.conf b/src/lib/config/defaults/MarketData.conf index ab4c47638..b42302541 100644 --- a/src/lib/config/defaults/MarketData.conf +++ b/src/lib/config/defaults/MarketData.conf @@ -41,11 +41,13 @@ CMEOptions { ICEOptions { value { channel { + name: "oil" market_type: 5 #ICE Futures Brent, IPE Brent Futures market_type: 9 #ICE Futures WTI, ICE WTI Crude Futures #udp_buffer_size: 67108864 } channel { + name: "juice" market_type: 23 #ICE Futures US Agricultures, FCOJ A } ice_config_file: "ConnectivityConfiguration.APITest.xml" diff --git a/src/lib/config/protos/MarketData.proto b/src/lib/config/protos/MarketData.proto index 1119b8683..955e2934d 100755 --- a/src/lib/config/protos/MarketData.proto +++ b/src/lib/config/protos/MarketData.proto @@ -143,11 +143,12 @@ message ICEOptions //A channel is one onixs-ice thread message ICEChannel { - repeated uint32 market_type = 1; - optional uint32 udp_buffer_size = 2 [default = 33554432]; //32mb - optional uint32 heartbeat_interval = 3 [default = 36000]; - optional uint32 sequence_gap_margin = 4 [default = 10000]; - optional uint32 gap_timeout_in_ms = 5 [default = 10000]; + required string name = 1; + repeated uint32 market_type = 2; + optional uint32 udp_buffer_size = 3 [default = 33554432]; //32mb + optional uint32 heartbeat_interval = 4 [default = 36000]; + optional uint32 sequence_gap_margin = 5 [default = 10000]; + optional uint32 gap_timeout_in_ms = 6 [default = 10000]; optional int32 snapshot_recovery_timeout_in_ms = 10 [default = -1]; optional int32 maximum_number_of_snapshot_recovery_attempts = 11 [default = -1]; diff --git a/src/lib/md/ice/ICEUtils.cpp b/src/lib/md/ice/ICEUtils.cpp index 139f3c117..0a54775fa 100644 --- a/src/lib/md/ice/ICEUtils.cpp +++ b/src/lib/md/ice/ICEUtils.cpp @@ -21,6 +21,35 @@ using namespace bts::api; namespace bts { namespace md { namespace ice { + +std::string ICEChannel::to_string() const +{ + std::string mt = name; + for(const auto& x : market_types) + mt += " " + x; + return mt; +} + +//We are sort of punting on symbols here because there is no symbol -> channel mapping supplied by ice +//therefore we must 1) enumerate the channels we want in config, and smash them together with the list of +//symbols we care about. This has the unfortunate side effect of not knowing what channel should heartbeat what symbol +//but Eric says this is ok +const vector parse_ice_channels(const vector& symbols) +{ + vector result; + const auto& ice_options = config::get(); + for(const auto& x : ice_options.channel()) + { + md::ice::ICEChannel chan; + chan.name = x.name(); + chan.symbols.insert(symbols.begin(), symbols.end()); + for(const auto& xx : x.market_type()) + chan.market_types.push_back(xx); + result.push_back(chan); + } + return result; +} + string ice_data_path() { auto p = config::get().data_path() + "onixs_ice/"; @@ -106,26 +135,6 @@ const std::vector get_configured_ice_channels() { return parse_ice_channels(symbols); } -//We are sort of punting on symbols here because there is no symbol -> channel mapping supplied by ice -//therefore we must 1) enumerate the channels we want in config, and smash them together with the list of -//symbols we care about. This has the unfortunate side effect of not knowing what channel should heartbeat what symbol -//but Eric says this is ok -const vector parse_ice_channels(const vector& symbols) -{ - vector result; - const auto& ice_options = config::get(); - for(const auto& x : ice_options.channel()) - { - for(const auto& xx : x.market_type()) - { - md::ice::ICEChannel chan; - chan.market_type = xx; - chan.symbols.insert(symbols.begin(), symbols.end()); - result.push_back(chan); - } - } - return result; -} }}} //namespace #endif \ No newline at end of file diff --git a/src/lib/md/ice/ICEUtils.h b/src/lib/md/ice/ICEUtils.h index 32c043201..5e0df291e 100644 --- a/src/lib/md/ice/ICEUtils.h +++ b/src/lib/md/ice/ICEUtils.h @@ -11,8 +11,10 @@ namespace ice { struct ICEChannel { - uint32_t market_type; + std::string name; + std::vector market_types; std::set symbols; + std::string to_string() const; }; void await_ice_config(); diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp index 2f4b7d0c6..ce2384b05 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp @@ -8,6 +8,7 @@ #include "lib/utils/helper_macros.h" #include "lib/utils/Dispatcher.h" #include "lib/utils/proto_helper.h" +#include "lib/utils/bts_chrono.h" #include "lib/md/protos/co2.pb.h" #include "lib/config/protos/MarketData.pb.h" @@ -54,28 +55,29 @@ ICEMain::ICEMain() : ICEMain::~ICEMain() {} -const ICEOptions::ICEChannel channel_settings_for(uint32_t id) +const ICEOptions::ICEChannel channel_settings_for(const ICEChannel& channel) { const auto& config = config::get(); for (const auto& ch : config.channel()) { - bool found = std::find_if(ch.market_type().begin(), ch.market_type().end(), [&](const uint32_t& chan_id) { return chan_id == id ; }) != ch.market_type().end(); - if(found) - return ch; + if(ch.name() == channel.name) + return ch; } return ICEOptions::ICEChannel(); } -onixs_ice::MarketSubscriptions market_subcription_for_channel(uint32_t market_type) +onixs_ice::MarketSubscriptions market_subcription_for_channel(const ICEChannel& chan) { - const auto& options = channel_settings_for(market_type); onixs_ice::MarketSubscriptions subs; - //onixs_ice::MarketSubType::NonImplied - onixs_ice::MarketSubscription futures(market_type, onixs_ice::MarketSubType::FullImplied, onixs_ice::SecurityType::Futures, onixs_ice::BookDepth::FOD); - onixs_ice::MarketSubscription spreads(market_type, onixs_ice::MarketSubType::FullImplied, onixs_ice::SecurityType::UdsFuturesMarkets, onixs_ice::BookDepth::FOD); - subs.push_back(futures); - subs.push_back(spreads); + for(const auto& x : chan.market_types) + { + //onixs_ice::MarketSubType::NonImplied + onixs_ice::MarketSubscription futures(x, onixs_ice::MarketSubType::FullImplied, onixs_ice::SecurityType::Futures, onixs_ice::BookDepth::FOD); + onixs_ice::MarketSubscription spreads(x, onixs_ice::MarketSubType::FullImplied, onixs_ice::SecurityType::UdsFuturesMarkets, onixs_ice::BookDepth::FOD); + subs.push_back(futures); + subs.push_back(spreads); + } return subs; } @@ -101,19 +103,22 @@ void ICEMain::run(std::vector& symbols) const auto& channels = parse_ice_channels(symbols); for (const auto& channel : channels) { - unique_ptr phandler = prepare_handler(channel.market_type); + unique_ptr phandler = prepare_handler(channel); _listeners.push_back(prepare_listener(*phandler, channel)); - _handlers.insert(std::make_pair(channel.market_type, move(phandler))); - std::stringstream symstr; + _handlers.push_back(std::make_pair(channel, move(phandler))); + + std::stringstream symstr; for (const auto& sym : channel.symbols) symstr << sym.symbol() << "-" << SecurityType_Name(sym.type()) << " "; - LOG(md,Info, "ICE: Initialized channel {} ({})",channel.market_type,symstr.str()); + LOG(md,Info, "ICE: Initialized channel {} ({})", channel.to_string(), symstr.str()); } for (auto& pair : _handlers) - { - onixs_ice::MarketSubscriptions subs = market_subcription_for_channel(pair.first); + { + LOG(md,Info, "ICE: Init Handler {}", pair.first.to_string()); + onixs_ice::MarketSubscriptions subs = market_subcription_for_channel(pair.first); pair.second->start(subs); + sleep_for(16s); } // @@ -131,7 +136,7 @@ void ICEMain::run(std::vector& symbols) // // // Initialize HandlerSettings and allocate the channel Handler -unique_ptr ICEMain::prepare_handler(uint32_t market_type) +unique_ptr ICEMain::prepare_handler(const ICEChannel& channel) { const auto& ice_options = config::get(); auto license = ice_options.onixs_license(); @@ -139,8 +144,8 @@ unique_ptr ICEMain::prepare_handler(uint32_t market_type) license = os::bts_data_path() + "/licenses/"; const auto& pub_options = config::get(); - const auto& options = channel_settings_for(market_type); - LOG(md,Info,"Loaded channel options for channel {}:\n{}",market_type,options.DebugString()); + const auto& options = channel_settings_for(channel); + LOG(md,Info,"Loaded channel options for channel {}:\n{}", channel.to_string(), options.DebugString()); onixs_ice::HandlerSettings settings; settings.licenseDirectory = license; @@ -201,7 +206,7 @@ unique_ptr ICEMain::prepare_handler(uint32_t market_type) return handler; } catch (std::exception& e) { - LOG(md,Error,"{}", std::string(e.what())); + LOG(md,Error,"ONIXSERROR{}", std::string(e.what())); throw; } } @@ -217,7 +222,7 @@ unique_ptr ICEMain::prepare_listener(onixs_ice::Handler& handler, c producer_channels.push_back(_producer.get_channel(symbol.symbol().c_str(), symbol.type(), symbol.exchange())); } - const auto& options = channel_settings_for(channel.market_type); + const auto& options = channel_settings_for(channel); unique_ptr listener(new ICEListener(_index, _producer, /*_settlement_recorder,*/ producer_channels)); for (auto& symbol : channel.symbols) listener->add_filter_symbol(symbol.symbol()); diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h index 3ec06504a..4b974a9d5 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h @@ -32,7 +32,7 @@ public: void run(std::vector&); void initialize(); - std::unique_ptr prepare_handler(uint32_t channel); + std::unique_ptr prepare_handler(const ICEChannel& channel); std::unique_ptr prepare_listener(onixs_ice::Handler& handler, const ICEChannel& channel); private: @@ -41,8 +41,8 @@ private: ICESecurityIndex _index; SecurityIDRecorder _recorder; MDProducer _producer; - std::map> _handlers; - std::vector> _listeners; + std::vector< std::pair> > _handlers; + std::vector< std::unique_ptr > _listeners; }; }}} //namespace From e4bf9fc7470205622afba34f81adbd171eb2eb44 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Thu, 7 Mar 2019 17:56:28 -0500 Subject: [PATCH 17/72] ice market data --- src/client/spark_api/md/MarketDataClient.cs | 4 +- .../spark_api/security/SecurityFormatter.cs | 2 +- .../spark_api/security/SecurityHelper.cs | 16 ++- src/lib/config/ConfigurationState.cpp | 2 +- src/lib/config/defaults/MarketData.conf | 10 +- src/lib/config/defaults/Symbols.conf | 1 + src/lib/config/protos/MarketData.proto | 10 +- .../md/platforms/ice_onixs/ICEListener.cpp | 134 ++++++++---------- .../md/platforms/ice_onixs/ICEListener.h | 78 ---------- .../sparkd/md/platforms/ice_onixs/ICEMain.cpp | 10 +- src/server/sparkd/md/run_md.cpp | 11 +- 11 files changed, 104 insertions(+), 174 deletions(-) diff --git a/src/client/spark_api/md/MarketDataClient.cs b/src/client/spark_api/md/MarketDataClient.cs index 87749fcee..3e5e0b4fb 100644 --- a/src/client/spark_api/md/MarketDataClient.cs +++ b/src/client/spark_api/md/MarketDataClient.cs @@ -189,7 +189,7 @@ namespace bts.md var sec = lookup(key); if (sec.HasValue) { - security_desc = sec.Value.glbx_desc(); + security_desc = sec.Value.security_desc(); return true; } return false; @@ -198,7 +198,7 @@ namespace bts.md public bool lookup_security_key_from_desc(string security_desc, out SecurityKey key) { key = 0; - var fnd = find(x => x.glbx_desc() == security_desc).TryFirst(); + var fnd = find(x => x.security_desc() == security_desc).TryFirst(); if (fnd.HasValue) { key = fnd.Value.security.Id; diff --git a/src/client/spark_api/security/SecurityFormatter.cs b/src/client/spark_api/security/SecurityFormatter.cs index 0a328cdf2..f67123fca 100644 --- a/src/client/spark_api/security/SecurityFormatter.cs +++ b/src/client/spark_api/security/SecurityFormatter.cs @@ -39,7 +39,7 @@ namespace bts.api { static string _format(SecurityImmutable? security) { switch (security?.ContractCase) { - case ContractOneofCase.Future: return format_future(security?.Symbol, security?.glbx_desc(), security.Value.Future); + case ContractOneofCase.Future: return format_future(security?.Symbol, security?.security_desc(), security.Value.Future); case ContractOneofCase.Spread: if (security?.HasGlbx == true) { // In case we ever bring it back, pretty printed spread names can be found here: diff --git a/src/client/spark_api/security/SecurityHelper.cs b/src/client/spark_api/security/SecurityHelper.cs index 7ef75b988..905d34846 100644 --- a/src/client/spark_api/security/SecurityHelper.cs +++ b/src/client/spark_api/security/SecurityHelper.cs @@ -19,7 +19,7 @@ namespace bts.api { foreach (var l in legs) { switch (l.Security.ContractCase) { case ContractOneofCase.Future: - yield return new FutureLeg(l.Security.Exchange, l.Security.Symbol, l.Security.glbx_desc(), l.Security.Future, qty * l.SignedQuantity()); + yield return new FutureLeg(l.Security.Exchange, l.Security.Symbol, l.Security.security_desc(), l.Security.Future, qty * l.SignedQuantity()); break; case ContractOneofCase.Spread: foreach (var fl in _get_flat_future_legs(l.Security.Spread.Legs, qty * l.SignedQuantity())) @@ -57,8 +57,18 @@ namespace bts.api { public static string DisplayExchange(this SecurityImmutable security) => security.ContractCase == ContractOneofCase.Synthetic ? $"[{string.Join(",", get_flat_future_legs(security).Select(flt => flt.exchange.ToString()).Distinct().OrderBy(e => e))}]" : security.Exchange.ToString(); - public static string glbx_desc(this SecurityImmutable security) => - security.HasGlbx ? security.Glbx.SecurityDesc ?? string.Empty : string.Empty; + public static string security_desc(this SecurityImmutable security) + { + if(security.HasGlbx) + return security.Glbx.SecurityDesc; + else if(security.HasIce) + return security.Ice.SecurityDesc; + else + { + Log.assert(false, "security_desc not implemented for exchange"); + return null; + } + } #endregion public static class Comparer { diff --git a/src/lib/config/ConfigurationState.cpp b/src/lib/config/ConfigurationState.cpp index df1f97e64..dce50e8c6 100755 --- a/src/lib/config/ConfigurationState.cpp +++ b/src/lib/config/ConfigurationState.cpp @@ -40,7 +40,7 @@ #include "lib/config_proto_files.h" #include "lib/config_defaults.h" -using namespace std; +using namespace std; namespace bts { namespace config { diff --git a/src/lib/config/defaults/MarketData.conf b/src/lib/config/defaults/MarketData.conf index b42302541..80a42b405 100644 --- a/src/lib/config/defaults/MarketData.conf +++ b/src/lib/config/defaults/MarketData.conf @@ -38,19 +38,25 @@ CMEOptions { } } +ICEPublisherOptions { + value { + network_interface: "eth1" + } +} + ICEOptions { value { channel { name: "oil" market_type: 5 #ICE Futures Brent, IPE Brent Futures market_type: 9 #ICE Futures WTI, ICE WTI Crude Futures - #udp_buffer_size: 67108864 + #udp_buffer_size: 33554432 #32mb } channel { name: "juice" market_type: 23 #ICE Futures US Agricultures, FCOJ A } - ice_config_file: "ConnectivityConfiguration.APITest.xml" + ice_config_file: "ConnectivityConfiguration.APITest.xml" } } diff --git a/src/lib/config/defaults/Symbols.conf b/src/lib/config/defaults/Symbols.conf index fcbaa4439..c58ac27e2 100644 --- a/src/lib/config/defaults/Symbols.conf +++ b/src/lib/config/defaults/Symbols.conf @@ -8,6 +8,7 @@ SymbolLists symbol: "BRN" symbol: "WBS" + symbol: "OJ" } list { diff --git a/src/lib/config/protos/MarketData.proto b/src/lib/config/protos/MarketData.proto index 955e2934d..60cbd52b4 100755 --- a/src/lib/config/protos/MarketData.proto +++ b/src/lib/config/protos/MarketData.proto @@ -54,6 +54,14 @@ message PublisherOptions optional bool skip_options = 13 [default = true]; } +message ICEPublisherOptions +{ + optional string network_interface = 3 [default = "0.0.0.0"]; + // Supply either network_interface -or- network_interface_[a,b] + optional string network_interface_a = 30; + optional string network_interface_b = 31; +} + message PlatformConfig { required string platform = 1; @@ -145,7 +153,7 @@ message ICEOptions message ICEChannel { required string name = 1; repeated uint32 market_type = 2; - optional uint32 udp_buffer_size = 3 [default = 33554432]; //32mb + optional uint32 udp_buffer_size = 3 [default = 4194304]; //4mb optional uint32 heartbeat_interval = 4 [default = 36000]; optional uint32 sequence_gap_margin = 5 [default = 10000]; optional uint32 gap_timeout_in_ms = 6 [default = 10000]; diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp index 8d462a2c8..90103e41d 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp @@ -25,14 +25,10 @@ double double_of_price(const onixs_ice::Rational& price, in ICEListener::ICEListener(ICESecurityIndex& index, MDProducer& producer, const std::vector channels) : _index(index), _producer(producer), - _packet_arrived(), - _latest_sequence(0), _symbol_filter(), _channels(channels), - _concurrency_monitor(0), - _book_updates() + _concurrency_monitor(0) { - _book_updates.reserve(32); } ICEListener::~ICEListener() {} @@ -60,17 +56,17 @@ void ICEListener::onMarketStateChange(const onixs_ice::MarketStateChange& , cons void ICEListener::onError(const onixs_ice::Error& error) { std::string error_desc(error.description()); - tracepoint (bts_trace,trace_order,(char*) "onError", _latest_sequence, (uint16_t) _latest_sequence, 0); + tracepoint (bts_trace,trace_order,(char*) "onError", 0, (uint16_t) 0, 0); LOG(md,Warn, "OnixS ICE Error: {} - {}", error.toString(), error_desc ); } void ICEListener::onFeedError(onixs_ice::FeedId feedid, onixs_ice::ErrorCode code, const std::string& desc) { - tracepoint (bts_trace,trace_order,(char*) "onFeedError", _latest_sequence, (uint16_t) _latest_sequence, 0); + tracepoint (bts_trace,trace_order,(char*) "onFeedError", 0, (uint16_t) 0, 0); LOG(md,Warn, "OnixS ICE FeedError: {} - {}", feedid, desc, code); } void ICEListener::onWarning(const onixs_ice::Warning& warning) { - tracepoint (bts_trace,trace_order,(char*) "onWarning", _latest_sequence, (uint16_t) _latest_sequence, 0); + tracepoint (bts_trace,trace_order,(char*) "onWarning", 0, (uint16_t) 0, 0); LOG(md,Warn, "OnixS ICE Warn: {} - {}", warning.toString(), std::string(warning.description()) ); } @@ -78,25 +74,23 @@ void ICEListener::onWarning(const onixs_ice::Warning& warning) // Security discovery void ICEListener::onFuturesProductDefinition(const onixs_ice::FuturesProductDefinition& msg, bool& is_interested) { - tracepoint (bts_trace,trace_order,(char*) "onFuturesProductDefinition", _latest_sequence, (uint16_t) _latest_sequence, 0); + tracepoint (bts_trace,trace_order,(char*) "onFuturesProductDefinition", 0, (uint16_t) 0, 0); on_future(msg, is_interested); } void ICEListener::onNewExpiry(const onixs_ice::NewExpiry& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) -{ - UNUSED(msg_info); - tracepoint (bts_trace,trace_order,(char*) "onNewExpiry", _latest_sequence, (uint16_t) _latest_sequence, 0); +{ + tracepoint (bts_trace,trace_order,(char*) "onNewExpiry", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); on_future(msg, is_interested); } void ICEListener::onFuturesStrategyDefinition(const onixs_ice::FuturesStrategyDefinition& def, bool& is_interested) { - tracepoint (bts_trace,trace_order,(char*) "onFuturesStrategyDefinition", _latest_sequence, (uint16_t) _latest_sequence, 0); + tracepoint (bts_trace,trace_order,(char*) "onFuturesStrategyDefinition", 0, (uint16_t) 0, 0); on_future_spread(def, is_interested); } void ICEListener::onNewFuturesStrategyDefinition(const onixs_ice::NewFuturesStrategyDefinition& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) { - UNUSED(msg_info); - tracepoint (bts_trace,trace_order,(char*) "onFuturesStrategyDefinition", _latest_sequence, (uint16_t) _latest_sequence, 0); + tracepoint (bts_trace,trace_order,(char*) "onFuturesStrategyDefinition", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); on_future_spread(msg, is_interested); } @@ -145,11 +139,45 @@ void ICEListener::onMarketSnapshotPriceLevel(const onixs_ice::MarketSnapshotPric // // Book -void ICEListener::onOrderBookUpdated(const onixs_ice::OrderBook& book, const onixs_ice::MessageInfo& msg_info) +void ICEListener::onOrderBookUpdated(const onixs_ice::OrderBook& onixs_book, const onixs_ice::MessageInfo& msg_info) { - UNUSED(msg_info); - on_book(book, book_type_direct); - on_book(book, book_type_implied); + tracepoint (bts_trace,trace_order,(char*) "onBookUpdate", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); + + auto data = _index.get_security(onixs_book.marketId()); + if (data == nullptr) + return; + bts_assert(data->id == (uint32_t)onixs_book.marketId()); + auto display_factor = data->handle.security().display_factor; + + // Overwrite all entries every time + size_t bids_size = onixs_book.bids().size(); + size_t asks_size = onixs_book.offers().size(); + if (!data->handle.has_depth()) + { + bids_size = std::min(bids_size, size_t { 1 }); + asks_size = std::min(asks_size, size_t { 1 }); + } + std::array dbids; dbids.fill(NO_MARKET); + std::array ibids; ibids.fill(NO_MARKET); + std::array dasks; dasks.fill(NO_MARKET); + std::array iasks; iasks.fill(NO_MARKET); + for (size_t x = 0; x < bids_size; ++x) + { + auto& bid = onixs_book.bids()[x]; + if(x < COCONUT_MAX_DEPTH) + dbids[x] = pricesize_of_price_size(bid.price, display_factor, bid.quantity - bid.impliedQuantity); + if(x < COCONUT_MAX_IMPLIED_DEPTH) + ibids[x] = pricesize_of_price_size(bid.price, display_factor, bid.impliedQuantity); + } + for (size_t x = 0; x < asks_size; ++x) + { + auto& ask = onixs_book.offers()[x]; + if(x < COCONUT_MAX_DEPTH) + dasks[x] = pricesize_of_price_size(ask.price, display_factor, ask.quantity - ask.impliedQuantity); + if(x < COCONUT_MAX_IMPLIED_DEPTH) + iasks[x] = pricesize_of_price_size(ask.price, display_factor, ask.impliedQuantity); + } + data->handle.update_books(TimeStamp::now(), dbids, dasks, ibids, iasks, (uint32_t) msg_info.sequenceNumber); } // @@ -177,8 +205,7 @@ void on_trade(ICESecurityData* data, const onixs_ice::Price& price, int size, on void ICEListener::onTrade(const onixs_ice::Trade& msg, const onixs_ice::MessageInfo& msg_info) { - UNUSED(msg_info); - tracepoint (bts_trace,trace_order,(char*) "onTrade", _latest_sequence, (uint16_t) _latest_sequence, 0); + tracepoint (bts_trace,trace_order,(char*) "onTrade", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); auto* data = _index.get_security(msg.marketId); if (data != NULL) { @@ -194,8 +221,7 @@ void ICEListener::onTrade(const onixs_ice::Trade& msg, const onixs_ice::MessageI // RFQ void ICEListener::onRfq(const onixs_ice::Rfq& msg, const onixs_ice::MessageInfo& msg_info) { - UNUSED(msg_info); - tracepoint (bts_trace,trace_order,(char*) "onRfq", _latest_sequence, (uint16_t) _latest_sequence, 0); + tracepoint (bts_trace,trace_order,(char*) "onRfq", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); auto* data = _index.get_security(msg.marketId); if (data != nullptr) { @@ -231,9 +257,8 @@ void ICEListener::onRfq(const onixs_ice::Rfq& msg, const onixs_ice::MessageInfo& // // Misc void ICEListener::onSettlementPrice(const onixs_ice::SettlementPrice& msg, const onixs_ice::MessageInfo& msg_info) -{ - UNUSED(msg_info); - tracepoint (bts_trace,trace_order,(char*) "onSettlementPrice", _latest_sequence, (uint16_t) _latest_sequence, 0); +{ + tracepoint (bts_trace,trace_order,(char*) "onSettlementPrice", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); auto* data = _index.get_security(msg.marketId); if (data != nullptr) { @@ -253,8 +278,7 @@ void ICEListener::onOpenInterest(const onixs_ice::OpenInterest &msg, const onixs void ICEListener::onOpenPrice(const onixs_ice::OpenPrice& msg, const onixs_ice::MessageInfo& msg_info) { - UNUSED(msg_info); - tracepoint (bts_trace,trace_order,(char*) "onOpenPrice", _latest_sequence, (uint16_t) _latest_sequence, 0); + tracepoint (bts_trace,trace_order,(char*) "onOpenPrice", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); auto* data = _index.get_security(msg.marketId); if (data != nullptr) { @@ -268,8 +292,7 @@ void ICEListener::onOpenPrice(const onixs_ice::OpenPrice& msg, const onixs_ice:: void ICEListener::onClosePrice(const onixs_ice::ClosePrice& msg, const onixs_ice::MessageInfo& msg_info) { - UNUSED(msg_info); - tracepoint (bts_trace,trace_order,(char*) "onClosePrice", _latest_sequence, (uint16_t) _latest_sequence, 0); + tracepoint (bts_trace,trace_order,(char*) "onClosePrice", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); auto* data = _index.get_security(msg.marketId); if (data != nullptr) { @@ -283,8 +306,7 @@ void ICEListener::onClosePrice(const onixs_ice::ClosePrice& msg, const onixs_ice void ICEListener::onEndOfDayMarketSummary(const onixs_ice::EndOfDayMarketSummary& msg, const onixs_ice::MessageInfo& msg_info) { - UNUSED(msg_info); - tracepoint (bts_trace,trace_order,(char*) "onEndOfDayMarketSummary", _latest_sequence, (uint16_t) _latest_sequence, 0); + tracepoint (bts_trace,trace_order,(char*) "onEndOfDayMarketSummary", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); auto* data = _index.get_security(msg.marketId); if (data != nullptr) { @@ -303,30 +325,15 @@ void ICEListener::onEndOfDayMarketSummary(const onixs_ice::EndOfDayMarketSummary void ICEListener::onMulticastMessageBlockBegin(onixs_ice::FeedId feedId, const onixs_ice::MessageInfo& msg_info) { UNUSED(feedId); - // Mark the arrival of the packet - _packet_arrived = TimeStamp::now(); - uint32_t seq = (uint32_t)msg_info.sequenceNumber; - if (!_book_updates.empty()) - { - if (_latest_sequence != seq) - LOG(md, Error, "Expected sequence {} got {} did not flush {} book updates.", _latest_sequence, seq, _book_updates.size()); - } - _latest_sequence = seq; - auto onixs_zero = msg_info.receiveTime; - auto onixs_now = onixs_ice::Timestamp::utcNow(); - - UNUSED(onixs_zero); - UNUSED(onixs_now); - tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockBegin", _latest_sequence,(uint16_t) _latest_sequence, /*onixs_now-onixs_zero*/0); + tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockBegin", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); } void ICEListener::onMulticastMessageBlockEnd(onixs_ice::FeedId feedId, const onixs_ice::MarketIds& marketIds) { UNUSED(feedId); UNUSED(marketIds); - tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockEnd.begin", _latest_sequence, (uint16_t) _latest_sequence, 0); - flush_books(); - tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockEnd.end", _latest_sequence, (uint16_t) _latest_sequence, 0); + tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockEnd.begin", 0, (uint16_t) 0, 0); + tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockEnd.end", 0, (uint16_t) 0, 0); } void ICEListener::onFeedStarted(onixs_ice::FeedId, const onixs_ice::MarketIds&) @@ -362,31 +369,6 @@ void ICEListener::add_security(const FixedSecurity& security) _index.add_security(security.numeric_id, handle); } -void ICEListener::flush_books() -{ - // This is called at the end of the packet - // Write all book updates to shared memory and reset for the next packet - for (auto& entry : _book_updates) - { - uint32_t sequence = _latest_sequence; - if (entry.type_flags == book_type_direct) - { - entry.handle.update_direct(_packet_arrived, entry.bids.first, entry.asks.first, sequence); - } - else if (entry.type_flags == book_type_implied) - { - entry.handle.update_implied(_packet_arrived, entry.bids.second, entry.asks.second, sequence); - } - else if (entry.type_flags == book_type_both) - { - entry.handle.update_books(_packet_arrived, entry.bids.first, entry.asks.first, - entry.bids.second, entry.asks.second, sequence); - } - } - // Reset pending updates - _book_updates.clear(); -} - void ICEListener::update_all_status(CoconutSecurityStatus status) { _index.walk_security_list([=](ICESecurityData& data) @@ -395,8 +377,6 @@ void ICEListener::update_all_status(CoconutSecurityStatus status) }); } -md::ice::ICEListener::BookData::BookData(MDProducerHandle & handle) : handle(handle), type_flags(0), bids(), asks() { } - }}} //namespace diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h index c7cac707a..b3146c3e5 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h @@ -127,20 +127,9 @@ private: ICESecurityIndex& _index; MDProducer& _producer; - utils::TimeStamp _packet_arrived; - uint32_t _latest_sequence; std::set _symbol_filter; std::vector _channels; std::atomic _concurrency_monitor; - - struct BookData { - BookData(MDProducerHandle& handle); - MDProducerHandle handle; - BookType type_flags; - std::pair, std::array> bids; - std::pair, std::array> asks; - }; - std::vector _book_updates; }; template @@ -212,72 +201,5 @@ void ICEListener::on_future_spread(const Definition& def, bool& is_interested) is_interested = true; } -template -void ICEListener::on_book(const TBook& onixs_book, BookType booktype) -{ - tracepoint (bts_trace,trace_order,(char*) "onBookUpdate", _latest_sequence, (uint16_t) _latest_sequence, 0); - - auto data = _index.get_security(onixs_book.marketId()); - if (data == nullptr) - return; - bts_assert(data->id == (uint32_t)onixs_book.marketId()); - auto display_factor = data->handle.security().display_factor; - - // Put the data into the cache. Flush at the end of the packet. - auto key = data->handle.key(); - auto find_iter = std::find_if(_book_updates.begin(), _book_updates.end(), [key](const BookData& entry) - { - return key == entry.handle.key(); - }); - bool found = find_iter != _book_updates.end(); - if (!found) - _book_updates.emplace_back(data->handle); - - BookData& cache = found ? *find_iter : _book_updates.back(); - cache.type_flags |= booktype; - auto& cache_bids = std::get>(cache.bids); - auto& cache_asks = std::get>(cache.asks); - - // Overwrite all entries every time - size_t bids_size = onixs_book.bids().size(); - size_t asks_size = onixs_book.offers().size(); - if (!data->handle.has_depth()) - { - bids_size = std::min(bids_size, size_t { 1 }); - asks_size = std::min(asks_size, size_t { 1 }); - } - if(booktype == book_type_direct) - { - for (size_t x = 0; x < bids_size; ++x) - { - auto& bid = onixs_book.bids()[x]; - cache_bids[x] = pricesize_of_price_size(bid.price, display_factor, bid.quantity - bid.impliedQuantity); - } - for (size_t x = 0; x < asks_size; ++x) - { - auto& ask = onixs_book.offers()[x]; - cache_asks[x] = pricesize_of_price_size(ask.price, display_factor, ask.quantity - ask.impliedQuantity); - } - } - else if(booktype == book_type_implied) - { - for (size_t x = 0; x < bids_size; ++x) - cache_bids[x] = pricesize_of_price_size(onixs_book.bids()[x].price, display_factor, onixs_book.bids()[x].impliedQuantity); - for (size_t x = 0; x < asks_size; ++x) - cache_asks[x] = pricesize_of_price_size(onixs_book.offers()[x].price, display_factor, onixs_book.offers()[x].impliedQuantity); - } - else - bts_assert_msg(false, "invalid book type"); - - if (!found) - { - // NaN out the remaining depth - for (size_t x = bids_size; x < MAX_DEPTH; ++x) - cache_bids[x] = NO_MARKET; - for (size_t x = asks_size; x < MAX_DEPTH; ++x) - cache_asks[x] = NO_MARKET; - } -} - }}} //namespace diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp index ce2384b05..4942e9585 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp @@ -114,10 +114,10 @@ void ICEMain::run(std::vector& symbols) } for (auto& pair : _handlers) - { - LOG(md,Info, "ICE: Init Handler {}", pair.first.to_string()); + { onixs_ice::MarketSubscriptions subs = market_subcription_for_channel(pair.first); pair.second->start(subs); + LOG(md,Info, "ICE: Init Handler {}", pair.first.to_string()); sleep_for(16s); } @@ -142,8 +142,7 @@ unique_ptr ICEMain::prepare_handler(const ICEChannel& channe auto license = ice_options.onixs_license(); if (license == "{default}") license = os::bts_data_path() + "/licenses/"; - - const auto& pub_options = config::get(); + const auto& options = channel_settings_for(channel); LOG(md,Info,"Loaded channel options for channel {}:\n{}", channel.to_string(), options.DebugString()); @@ -158,8 +157,9 @@ unique_ptr ICEMain::prepare_handler(const ICEChannel& channe // Config file settings.connectivityConfiguration = ice_config_path(); - // + // // Network settings + const auto& pub_options = config::get(); if (pub_options.has_network_interface()) settings.networkInterface = pub_options.network_interface(); else diff --git a/src/server/sparkd/md/run_md.cpp b/src/server/sparkd/md/run_md.cpp index 8fa973de2..16d13a876 100644 --- a/src/server/sparkd/md/run_md.cpp +++ b/src/server/sparkd/md/run_md.cpp @@ -68,10 +68,13 @@ void run_replay() { void run_onixs() { // get all glbx symbols - std::vector symbols; - get_system_md_symbols(api::VENUE_GLBX, api::SECURITYTYPE_UNSET, &symbols); - MDP3Main main; - //main.run(symbols); TODO + std::vector cme_symbols; + get_system_md_symbols(api::VENUE_GLBX, api::SECURITYTYPE_UNSET, &cme_symbols); + if(cme_symbols.size() > 0) + { + MDP3Main main; + //main.run(symbols); TODO + } std::vector ice_symbols; get_system_md_symbols(api::VENUE_ICE, api::SECURITYTYPE_UNSET, &ice_symbols); From 76edb94905652c5c2c375345e1ab7a6d447b4573 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Thu, 7 Mar 2019 18:10:11 -0500 Subject: [PATCH 18/72] ticks.... --- externals | 2 +- src/server/sparkd/md/platforms/ice_onixs/ICEListener.h | 4 ++-- src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/externals b/externals index 0dcc271a4..88a371e03 160000 --- a/externals +++ b/externals @@ -1 +1 @@ -Subproject commit 0dcc271a46c25c610f948e9af76057b7217a1c3f +Subproject commit 88a371e03bd446aee42e68abcd9d17db16cf1415 diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h index b3146c3e5..09284190f 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h @@ -145,8 +145,7 @@ void ICEListener::set_security_common(const Definition& def, FixedSecurity& fsec fsec.ice_deal_display_factor = (int8_t)(def.dealPriceDenominator - '0'); fsec.ice_settle_display_factor = (int8_t)(def.settlePriceDenominator - '0'); double min_tick = double_of_price(def.incrementPrice, fsec.display_factor); - fsec.low_tick = fsec.high_tick = min_tick; - //fsec.cash_per_point = double_of_price(def.tickValue, fsec.display_factor); + fsec.low_tick = fsec.high_tick = min_tick; fsec.price_break = 0.; } @@ -159,6 +158,7 @@ void ICEListener::on_future(const Definition& def, bool& is_interested) FixedFutureSecurity fsec; set_security_common(def, fsec); + //fsec.cash_per_point = double_of_price(def.tickValue, fsec.display_factor); fsec.expiration_year = def.maturityYear; fsec.expiration_month = def.maturityMonth; diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h index 82c10e90c..aff669a64 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h @@ -35,7 +35,7 @@ template inline PriceSize pricesize_of_price_size(const OnixsPrice& price, int8_t display_factor, Size size) { auto intpx = convert_price(price, display_factor); - PriceSize result({intpx.mantissa(), (int8_t)(intpx.exponent() + display_factor)}, size); + PriceSize result({intpx.mantissa(), (int8_t)(intpx.exponent())}, size); return result; } From 6cfef51e3d597be1c0c46be95138f39ec62b570c Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Thu, 7 Mar 2019 18:12:39 -0500 Subject: [PATCH 19/72] subrepo --- externals | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals b/externals index 88a371e03..d0e8645b5 160000 --- a/externals +++ b/externals @@ -1 +1 @@ -Subproject commit 88a371e03bd446aee42e68abcd9d17db16cf1415 +Subproject commit d0e8645b5ef7380314eddc68114a9f0eaa379318 From 3b902b61ddad4a82a2b2065bae3ab0ee81b86628 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Fri, 8 Mar 2019 15:55:10 -0500 Subject: [PATCH 20/72] ice spreads --- src/lib/domain_model/Security.proto | 9 ++++- src/lib/md/Shm/FixedSecurity.cpp | 14 ++++++++ src/lib/md/Shm/FixedSecurity.h | 17 +++++++++- .../md/platforms/ice_onixs/ICEListener.cpp | 11 +++++-- .../md/platforms/ice_onixs/ICEListener.h | 33 +++++++++++++++++-- .../sparkd/md/platforms/ice_onixs/ICEMain.cpp | 4 +-- 6 files changed, 78 insertions(+), 10 deletions(-) diff --git a/src/lib/domain_model/Security.proto b/src/lib/domain_model/Security.proto index 068f6bff2..ff7bcd661 100644 --- a/src/lib/domain_model/Security.proto +++ b/src/lib/domain_model/Security.proto @@ -102,9 +102,16 @@ message CBOECFEExchangeData { } message ICEExchangeData { int64 exchange_id = 10; - string security_desc = 15; + string security_desc = 15; //contractSymbol int32 deal_display_factor = 20; int32 settle_display_factor = 30; + + string market_description = 100; + string cleared_alias = 110; + string product_name = 120; + string hub_alias = 130; + string strip_name = 140; + string mic_code = 150; } message FutureContract { diff --git a/src/lib/md/Shm/FixedSecurity.cpp b/src/lib/md/Shm/FixedSecurity.cpp index 5cf47d145..15a19cf56 100644 --- a/src/lib/md/Shm/FixedSecurity.cpp +++ b/src/lib/md/Shm/FixedSecurity.cpp @@ -174,6 +174,13 @@ void convert_security(const FixedSecurity& source, Security* presult) { dest.mutable_ice()->set_security_desc(source.security_desc()); dest.mutable_ice()->set_deal_display_factor(source.ice_deal_display_factor); dest.mutable_ice()->set_settle_display_factor(source.ice_settle_display_factor); + + dest.mutable_ice()->set_market_description(source.ice_market_description()); + dest.mutable_ice()->set_cleared_alias(source.ice_cleared_alias()); + dest.mutable_ice()->set_product_name(source.ice_product_name()); + dest.mutable_ice()->set_hub_alias(source.ice_hub_alias()); + dest.mutable_ice()->set_strip_name(source.ice_strip_name()); + dest.mutable_ice()->set_mic_code(source.mic_code()); break; case Venue::VENUE_BTS: break; @@ -298,6 +305,13 @@ void convert_security(const Security& src, FixedSecurity& dest, bool set_securit dest.security_desc(src.ice().security_desc()); dest.ice_deal_display_factor = src.ice().deal_display_factor(); dest.ice_settle_display_factor = src.ice().settle_display_factor(); + + dest.ice_market_description(src.ice().market_description()); + dest.ice_cleared_alias(src.ice().cleared_alias()); + dest.ice_product_name(src.ice().product_name()); + dest.ice_hub_alias(src.ice().hub_alias()); + dest.ice_strip_name(src.ice().strip_name()); + dest.mic_code(src.ice().mic_code()); break; case Security::ExchangeDataCase::EXCHANGEDATA_NOT_SET: break; diff --git a/src/lib/md/Shm/FixedSecurity.h b/src/lib/md/Shm/FixedSecurity.h index c2421f4d9..853db1308 100644 --- a/src/lib/md/Shm/FixedSecurity.h +++ b/src/lib/md/Shm/FixedSecurity.h @@ -61,13 +61,27 @@ public: uint8_t cme_price_display_format; int8_t ice_deal_display_factor; int8_t ice_settle_display_factor; + + STRING_PROPERTY(ice_market_description); + STRING_PROPERTY(ice_cleared_alias); + STRING_PROPERTY(ice_product_name); + STRING_PROPERTY(ice_hub_alias); + STRING_PROPERTY(ice_strip_name); + STRING_PROPERTY(mic_code); private: char _symbol[16]; // CME defines this as a char[6] but I'm padding char _cfi_code[8]; // CME defines this as char[6] - char _security_desc[32]; // cme security desc FIX=107 + char _security_desc[32]; // cme security desc FIX=107 //ice wants this to be 35 char _alt_symbol[16]; // "cme symbol" or alternate symbol char _platform_id[64]; + + char _ice_market_description[120]; + char _ice_cleared_alias[15]; + char _ice_product_name[62]; + char _ice_hub_alias[80]; + char _ice_strip_name[39]; + char _mic_code[4]; }; class FixedStockSecurity : public FixedSecurity { @@ -173,6 +187,7 @@ private: }; // Stack allocate a FixedSpreadSecurity with a high number of legs then memcpy the right size to shared memory +typedef FixedSpreadSecurity<2> FixedSpreadSecurityXS; typedef FixedSpreadSecurity<16> FixedSpreadSecurityS; typedef FixedSpreadSecurity<128> FixedSpreadSecurityL; typedef FixedSpreadSecurity<512> FixedSpreadSecurityXL; diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp index 90103e41d..1d91cfe5b 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp @@ -75,8 +75,12 @@ void ICEListener::onWarning(const onixs_ice::Warning& warning) void ICEListener::onFuturesProductDefinition(const onixs_ice::FuturesProductDefinition& msg, bool& is_interested) { tracepoint (bts_trace,trace_order,(char*) "onFuturesProductDefinition", 0, (uint16_t) 0, 0); - on_future(msg, is_interested); + if(msg.isSpread) + on_future_strip(msg, is_interested); + else + on_future(msg, is_interested); } + void ICEListener::onNewExpiry(const onixs_ice::NewExpiry& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) { tracepoint (bts_trace,trace_order,(char*) "onNewExpiry", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); @@ -86,12 +90,13 @@ void ICEListener::onNewExpiry(const onixs_ice::NewExpiry& msg, bool& is_interest void ICEListener::onFuturesStrategyDefinition(const onixs_ice::FuturesStrategyDefinition& def, bool& is_interested) { tracepoint (bts_trace,trace_order,(char*) "onFuturesStrategyDefinition", 0, (uint16_t) 0, 0); - on_future_spread(def, is_interested); + on_uds_future_spread(def, is_interested); } +//This is only for UDS void ICEListener::onNewFuturesStrategyDefinition(const onixs_ice::NewFuturesStrategyDefinition& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) { tracepoint (bts_trace,trace_order,(char*) "onFuturesStrategyDefinition", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); - on_future_spread(msg, is_interested); + on_uds_future_spread(msg, is_interested); } void ICEListener::onOptionsProductDefinition(const onixs_ice::OptionsProductDefinition& msg, bool& is_interested) diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h index 09284190f..38b84d138 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h @@ -48,7 +48,9 @@ public: // // Security discovery - void onFuturesProductDefinition(const onixs_ice::FuturesProductDefinition& def, bool& is_interested) override; + void onFuturesProductDefinition(const onixs_ice::FuturesProductDefinition& def, bool& is_interested) override; + void process_strip(int stripid); + void onNewExpiry(const onixs_ice::NewExpiry& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) override; void onFuturesStrategyDefinition(const onixs_ice::FuturesStrategyDefinition& def, bool& is_interested) override; void onNewFuturesStrategyDefinition(const onixs_ice::NewFuturesStrategyDefinition& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) override; @@ -104,7 +106,9 @@ private: template void on_future(const Definition& def, bool& is_interested); template - void on_future_spread(const Definition& def, bool& is_interested); + void on_uds_future_spread(const Definition& def, bool& is_interested); + template + void on_future_strip(const Definition& def, bool& is_interested); template void on_book(const TBook& onixs_book, BookType booktype); @@ -168,7 +172,7 @@ void ICEListener::on_future(const Definition& def, bool& is_interested) } template -void ICEListener::on_future_spread(const Definition& def, bool& is_interested) +void ICEListener::on_uds_future_spread(const Definition& def, bool& is_interested) { is_interested = false; auto exchange_id = def.marketId; @@ -202,4 +206,27 @@ void ICEListener::on_future_spread(const Definition& def, bool& is_interested) } +template +void ICEListener::on_future_strip(const FutureDefinition& def, bool& is_interested) +{ + is_interested = false; + auto exchange_id = def.marketId; + if (filter_security(exchange_id, def) != ADD) return; + + FixedSpreadSecurityXS fsec; + set_security_common(def, fsec); + fsec.alt_symbol(def.stripName); + + fsec.set_leg_count(2); + for(size_t x = 0; x < fsec.leg_count(); ++x) + { + fsec.legs[x].leg_quantity = 1.0; + fsec.legs[x].leg_side = (x == 0) ? api::SIDE_BUY : api::SIDE_SELL; + fsec.legs[x].exchange_key = ExchangeKey((x == 0) ? def.primaryMarketId : def.secondaryMarketId); + fsec.legs[x].key = invalid_security_key; + } + add_security(fsec); + is_interested = true; +} + }}} //namespace diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp index 4942e9585..794029456 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp @@ -115,10 +115,10 @@ void ICEMain::run(std::vector& symbols) for (auto& pair : _handlers) { + LOG(md,Info, "ICE: Init Handler {}", pair.first.to_string()); + sleep_for(16s); onixs_ice::MarketSubscriptions subs = market_subcription_for_channel(pair.first); pair.second->start(subs); - LOG(md,Info, "ICE: Init Handler {}", pair.first.to_string()); - sleep_for(16s); } // From 7259f81ab59ef129a78c7e0f6addf350bce7d1ea Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Fri, 8 Mar 2019 16:03:49 -0500 Subject: [PATCH 21/72] forgot to init new string fields --- src/lib/md/Shm/FixedSecurity.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lib/md/Shm/FixedSecurity.cpp b/src/lib/md/Shm/FixedSecurity.cpp index 15a19cf56..14f9da614 100644 --- a/src/lib/md/Shm/FixedSecurity.cpp +++ b/src/lib/md/Shm/FixedSecurity.cpp @@ -41,6 +41,13 @@ FixedSecurity::FixedSecurity() : memset(_cfi_code, 0, BTS_ARRAYSIZE(_cfi_code)); memset(_security_desc, 0, BTS_ARRAYSIZE(_security_desc)); memset(_platform_id, 0, BTS_ARRAYSIZE(_platform_id)); + + memset(_ice_market_description, 0, BTS_ARRAYSIZE(_ice_market_description)); + memset(_ice_cleared_alias, 0, BTS_ARRAYSIZE(_ice_cleared_alias)); + memset(_ice_product_name, 0, BTS_ARRAYSIZE(_ice_product_name)); + memset(_ice_hub_alias, 0, BTS_ARRAYSIZE(_ice_hub_alias)); + memset(_ice_strip_name, 0, BTS_ARRAYSIZE(_ice_strip_name)); + memset(_mic_code, 0, BTS_ARRAYSIZE(_mic_code)); } FixedSecurity::~FixedSecurity(){} From f0b14cb8dc637edaca8244f122715ba448ed4def Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Fri, 8 Mar 2019 16:10:02 -0500 Subject: [PATCH 22/72] forgot to init new string fields --- src/server/sparkd/md/platforms/ice_onixs/ICEListener.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h index 38b84d138..25eacf3aa 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h @@ -151,6 +151,13 @@ void ICEListener::set_security_common(const Definition& def, FixedSecurity& fsec double min_tick = double_of_price(def.incrementPrice, fsec.display_factor); fsec.low_tick = fsec.high_tick = min_tick; fsec.price_break = 0.; + + fsec.ice_market_description(def.marketDesc); + fsec.ice_cleared_alias(def.clearedAlias); + fsec.ice_product_name(def.productName); + fsec.ice_hub_alias(def.hubAlias); + fsec.ice_strip_name(def.stripName); + fsec.mic_code(def.micCode); } template From 1ebf8219c23156b1ff472d589c473c45d5b26f23 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Fri, 8 Mar 2019 16:17:53 -0500 Subject: [PATCH 23/72] ice descriptions in mview --- .../Market/MarketView/MarketViewRow.cs | 6 +++++ .../Modules/Market/MarketView/MarketViewVM.cs | 23 +++++++++++++++++- .../Market/MarketView/MarketViewView.xaml.cs | 4 +++- .../MarketView/MarketViewWindowFactory.cs | 24 +++++++++++++++++++ .../Controls/DIYGrid/Columns/ColumnBase.cs | 10 +++++++- src/lib/md/Diag/ShmDumper.cpp | 7 ++++++ 6 files changed, 71 insertions(+), 3 deletions(-) diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs b/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs index 5eda77cdf..9f7b69efe 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs @@ -137,6 +137,12 @@ namespace mbts.spark { public ICommand ask_implied_size_click { get; } public ICommand working_asks_click { get; } public ICommand default_command { get; } + public string market_description {get;} + public string cleared_alias { get; } + public string product_description { get; } + public string hub_alias { get; } + public string strip_name{ get; } + public string mic_code { get; } public ObservableCollection row_animations { get; } = new ObservableCollection(); diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs b/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs index c193f506c..65644a29e 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs @@ -57,6 +57,13 @@ namespace mbts.spark { add_col(Columns.SessionLow, "Low", r => r.format_price(r.session_low), nameof(Row.session_low), DefaultColumnWidths.Price, session_low_filter, DataGridFilterKnownTemplates.DoubleMinMax, h_alignment: System.Windows.HorizontalAlignment.Right); add_col(Columns.SessionHigh, "High", r => r.format_price(r.session_high), nameof(Row.session_high), DefaultColumnWidths.Price, session_high_filter, DataGridFilterKnownTemplates.DoubleMinMax, h_alignment: System.Windows.HorizontalAlignment.Right); add_col(Columns.SecurityKey, "Security Key", r => r.security_key.ToString(), nameof(Row.security_key), DefaultColumnWidths.SecurityKey, security_key_filter, DataGridFilterKnownTemplates.Regex); + + add_col(Columns.MarketDescription, "Market Description", r => r.md.security.HasIce ? r.md.security.Ice.MarketDescription : string.Empty, nameof(Row.market_description), DefaultColumnWidths.SecurityKey, market_description_filter, DataGridFilterKnownTemplates.Regex); + add_col(Columns.ClearedAlias, "Cleared Alias", r => r.md.security.HasIce ? r.md.security.Ice.ClearedAlias : string.Empty, nameof(Row.cleared_alias), DefaultColumnWidths.SecurityKey, cleared_alias_filter, DataGridFilterKnownTemplates.Regex); + add_col(Columns.ProductDescription, "Product Description", r => r.md.security.HasIce ? r.md.security.Ice.ProductName : string.Empty, nameof(Row.product_description), DefaultColumnWidths.SecurityKey, product_description_filter, DataGridFilterKnownTemplates.Regex); + add_col(Columns.HubAlias, "Hub Alias", r => r.md.security.HasIce ? r.md.security.Ice.HubAlias : string.Empty, nameof(Row.hub_alias), DefaultColumnWidths.SecurityKey, hub_alias_filter, DataGridFilterKnownTemplates.Regex); + add_col(Columns.StripName, "Strip Name", r => r.md.security.HasIce ? r.md.security.Ice.StripName : string.Empty, nameof(Row.strip_name), DefaultColumnWidths.SecurityKey, strip_name_filter, DataGridFilterKnownTemplates.Regex); + add_col(Columns.MicCode, "Mic Code", r => r.md.security.HasIce ? r.md.security.Ice.MicCode : string.Empty, nameof(Row.mic_code), DefaultColumnWidths.SecurityKey, mic_code_filter, DataGridFilterKnownTemplates.Regex); // void add_col(Columns col_key, string header, Func get_text, string prop, double width, IDataGridColumnFilter filter, string filter_template, bool is_animatable = false, Color? font_color = null, System.Windows.HorizontalAlignment h_alignment = System.Windows.HorizontalAlignment.Left) => columns.Add(new RenderTextColumn(col_key, get_text, filter, filter_template) { @@ -194,6 +201,14 @@ namespace mbts.spark { public IDataGridColumnPersistentFilter working_ask_volume_filter { get; } = new IntMinMax(r => r.working_ask_volume, nameof(Row.working_ask_volume)); public IDataGridColumnPersistentFilter volume_filter { get; } = new ULongMinMax(r => r.volume, nameof(Row.volume)); public IDataGridColumnPersistentFilter security_key_filter { get; } = new RegexFilterVM(r => r.security_key.ToString(), nameof(Row.security_key)); + + public IDataGridColumnPersistentFilter market_description_filter { get; } = new RegexFilterVM(r => r.security.HasIce ? r.security.Ice.MarketDescription : "", nameof(Row.market_description)); + public IDataGridColumnPersistentFilter cleared_alias_filter { get; } = new RegexFilterVM(r => r.security.HasIce ? r.security.Ice.ClearedAlias : "", nameof(Row.cleared_alias)); + public IDataGridColumnPersistentFilter product_description_filter { get; } = new RegexFilterVM(r => r.security.HasIce ? r.security.Ice.ProductName : "", nameof(Row.product_description)); + public IDataGridColumnPersistentFilter hub_alias_filter { get; } = new RegexFilterVM(r => r.security.HasIce ? r.security.Ice.HubAlias : "", nameof(Row.hub_alias)); + public IDataGridColumnPersistentFilter strip_name_filter { get; } = new RegexFilterVM(r => r.security.HasIce ? r.security.Ice.StripName : "", nameof(Row.strip_name)); + public IDataGridColumnPersistentFilter mic_code_filter { get; } = new RegexFilterVM(r => r.security.HasIce ? r.security.Ice.MicCode : "", nameof(Row.mic_code)); + public FilterStates get_filter_states() { return new FilterStates { @@ -216,7 +231,13 @@ namespace mbts.spark { working_bid_volume = working_bid_volume_filter.get_state(), working_ask_volume = working_ask_volume_filter.get_state(), volume = volume_filter.get_state(), - security_key = security_key_filter.get_state() + security_key = security_key_filter.get_state(), + market_description = market_description_filter.get_state(), + cleared_alias = cleared_alias_filter.get_state(), + product_description = product_description_filter.get_state(), + hub_alias = hub_alias_filter.get_state(), + strip_name = strip_name_filter.get_state(), + mic_code = mic_code_filter.get_state(), }; } #endregion diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewView.xaml.cs b/src/client/spark/Modules/Market/MarketView/MarketViewView.xaml.cs index 5f4107956..edbea884b 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewView.xaml.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewView.xaml.cs @@ -8,7 +8,9 @@ namespace mbts.ui.spark { /// Interaction logic for MarketSheetsView.xaml /// partial class MarketViewView : UserControl { - public enum Columns { Security, Volume, Last, LastSize, Position, WorkingBids, Bid, BidMergedSize, BidDirectSize, BidImpliedSize, Ask, AskMergedSize, AskDirectSize, AskImpliedSize, WorkingAsks, Settlement, DayChange, SessionLow, SessionHigh, SecurityKey } + public enum Columns { Security, Volume, Last, LastSize, Position, WorkingBids, Bid, BidMergedSize, BidDirectSize, BidImpliedSize, Ask, AskMergedSize, AskDirectSize, AskImpliedSize, WorkingAsks, Settlement, DayChange, SessionLow, SessionHigh, SecurityKey, + MarketDescription, ClearedAlias, ProductDescription, HubAlias, StripName, MicCode + } public MarketViewView() { InitializeComponent(); diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs b/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs index 44759c0c5..38931a3eb 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs @@ -97,6 +97,12 @@ namespace bts.shell { public static GridColumnSettings session_low => new GridColumnSettings(col_id(Columns.SessionLow), DefaultColumnHeaders.SessionLow, width: DefaultColumnWidths.Price, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings session_high => new GridColumnSettings(col_id(Columns.SessionHigh), DefaultColumnHeaders.SessionHigh, width: DefaultColumnWidths.Price, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings security_key => new GridColumnSettings(col_id(Columns.SecurityKey), DefaultColumnHeaders.SecurityKey, is_visible: false, width: DefaultColumnWidths.SecurityKey); + public static GridColumnSettings market_description => new GridColumnSettings(col_id(Columns.MarketDescription), DefaultColumnHeaders.MarketDescription, is_visible: false, width: DefaultColumnWidths.SecurityKey); + public static GridColumnSettings cleared_alias => new GridColumnSettings(col_id(Columns.ClearedAlias), DefaultColumnHeaders.ClearedAlias, is_visible: false, width: DefaultColumnWidths.SecurityKey); + public static GridColumnSettings product_description => new GridColumnSettings(col_id(Columns.ProductDescription), DefaultColumnHeaders.ProductDescription, is_visible: false, width: DefaultColumnWidths.SecurityKey); + public static GridColumnSettings hub_alias => new GridColumnSettings(col_id(Columns.HubAlias), DefaultColumnHeaders.HubAlias, is_visible: false, width: DefaultColumnWidths.SecurityKey); + public static GridColumnSettings strip_name => new GridColumnSettings(col_id(Columns.StripName), DefaultColumnHeaders.StripName, is_visible: false, width: DefaultColumnWidths.SecurityKey); + public static GridColumnSettings mic_code => new GridColumnSettings(col_id(Columns.MicCode), DefaultColumnHeaders.MicCode, is_visible: false, width: DefaultColumnWidths.SecurityKey); @@ -128,6 +134,12 @@ namespace bts.shell { yield return session_low; yield return session_high; yield return security_key; + yield return market_description; + yield return cleared_alias; + yield return product_description; + yield return hub_alias; + yield return strip_name; + yield return mic_code; } } @@ -177,6 +189,18 @@ namespace bts.shell { public UIntMinMaxState ask_direct_size; [ProtoMember(20)] public UIntMinMaxState ask_implied_size; + [ProtoMember(21)] + public string market_description; + [ProtoMember(22)] + public string cleared_alias; + [ProtoMember(23)] + public string product_description; + [ProtoMember(24)] + public string hub_alias; + [ProtoMember(25)] + public string strip_name; + [ProtoMember(26)] + public string mic_code; } } } \ No newline at end of file diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs index 336861a5c..3c4d7869d 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs @@ -96,7 +96,15 @@ namespace mbts.ui.controls { TotalNetPos = "Total Net Pos", TotalPnL = "Total PnL", PnLPrice = "PnL Price", - Cancel = "Cancel"; + Cancel = "Cancel", + + MarketDescription = "Market Description", + ClearedAlias = "Cleared Alias", + ProductDescription = "Product Description", + HubAlias = "Hub Alias", + StripName = "Strip Name", + MicCode = "Mic Code" + ; } public interface IKeyedColumn { diff --git a/src/lib/md/Diag/ShmDumper.cpp b/src/lib/md/Diag/ShmDumper.cpp index a0b4272d0..d12f4c729 100644 --- a/src/lib/md/Diag/ShmDumper.cpp +++ b/src/lib/md/Diag/ShmDumper.cpp @@ -90,6 +90,13 @@ string dump_security(const FixedSecurity& security) { res << "'low_tick': " << security.low_tick << ", "; res << "'high_tick': " << security.high_tick << ", "; res << "'cpp': " << security.cash_per_point << ", "; + + res << "'market_description ': " << security.ice_market_description() << ", "; + res << "'cleared_alias ': " << security.ice_cleared_alias() << ", "; + res << "'product_description ': " << security.ice_product_name() << ", "; + res << "'hub_alias ': " << security.ice_hub_alias() << ", "; + res << "'strip_name': " << security.ice_strip_name() << ", "; + res << "'mic_code': " << security.mic_code() << ", "; switch(security.type) { case SECURITYTYPE_STOCK: break; From 5b959ca5bdb91a8c7588804520a3a8d27c5837e1 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 12 Mar 2019 14:39:25 -0500 Subject: [PATCH 24/72] OB window command update when selected row's row vm changes --- .../spark/Modules/Trading/OrderBook/OrderBookRowVM.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs index c1b07eecb..407f5a8d1 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs @@ -42,6 +42,16 @@ namespace mbts.spark { private void OrderBookRowVM_invalidated() { modify_order_quantity?.TryRaiseCanExecuteChanged(); modify_order_price?.TryRaiseCanExecuteChanged(); + + // This takes care of the case where the OB has all rows visible + // and an order is cancelled outside of the OB (say via the ladder). + // Since the OB window Commands only revaluate their CanExecuteChanged + // when the OrderBookVM.selected_order_changes, this emulates the selected + // order changing since the current_row setter invokes the selected_order_changed + // handler + if (_owner.current_row == this) { + _owner.current_row = this; + } } protected override void Dispose(bool disposing) { From 04e006b812d159a092d1a83727c87bd43f46fdc8 Mon Sep 17 00:00:00 2001 From: Michael Harding Date: Fri, 15 Mar 2019 10:44:58 -0400 Subject: [PATCH 25/72] Add new Spreader and Algo studio videos to the manual --- doc/user/content/bts_spark/Spreader/index.md | 1 + doc/user/content/bts_spark/Trading/index.md | 2 ++ doc/user/sass/book.scss | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/doc/user/content/bts_spark/Spreader/index.md b/doc/user/content/bts_spark/Spreader/index.md index 56ae31714..a69a3731e 100644 --- a/doc/user/content/bts_spark/Spreader/index.md +++ b/doc/user/content/bts_spark/Spreader/index.md @@ -5,6 +5,7 @@ sort_by = "weight" insert_anchor_links = "right" +++ +{{ youtube(id="RZU9Wj0cETo") }}
diff --git a/doc/user/content/bts_spark/Trading/index.md b/doc/user/content/bts_spark/Trading/index.md index bdca5dc4b..1edcf1850 100644 --- a/doc/user/content/bts_spark/Trading/index.md +++ b/doc/user/content/bts_spark/Trading/index.md @@ -406,6 +406,8 @@ insert_anchor_links = "right" ## Algo Studio +{{ youtube(id="DHIa5tnifKc") }} + - The BTS Algo Studio was built for users to experience algo composability never seen before in a professional futures trading system. diff --git a/doc/user/sass/book.scss b/doc/user/sass/book.scss index 207cac8b0..af81ecfc1 100644 --- a/doc/user/sass/book.scss +++ b/doc/user/sass/book.scss @@ -54,3 +54,8 @@ img { background: #ccc; border: 1px solid #aaa; } + +iframe { + width:560px; + height:315px; +} \ No newline at end of file From 28980f10ae1fc2bea759ad2443eac09999836581 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 18 Mar 2019 13:41:29 -0500 Subject: [PATCH 26/72] SPARK-2160 shell windows come up off screen sometimes --- .../spark/view/Extensions/WindowExtensions.cs | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/client/spark/view/Extensions/WindowExtensions.cs b/src/client/spark/view/Extensions/WindowExtensions.cs index f1a267df2..1f45c26e4 100644 --- a/src/client/spark/view/Extensions/WindowExtensions.cs +++ b/src/client/spark/view/Extensions/WindowExtensions.cs @@ -153,37 +153,28 @@ namespace mbts.ui // need to convert them to WPF cooredinates/pixels var transform = get_transform_from_device(window); task_bar_rect = Rect.Transform(task_bar_rect, transform); - + // our source window is already in WPF pixels, so no conversion - Rect source_window_rect = new Rect((int)window.Left, (int)window.Top, (int)window.Width, (int)window.Height); + Rect source_window_rect = new Rect(window.Left, window.Top, window.ActualWidth, window.ActualHeight); - while (source_window_rect.IntersectsWith(task_bar_rect)) { - // we have some kind of intersection, let's figure out what kind + if (source_window_rect.IntersectsWith(task_bar_rect)) { var intersection = Rect.Intersect(task_bar_rect, source_window_rect); - if (intersection.Height == 0 && intersection.Width == 0 || - intersection.Width == 0 && intersection.Height == window.Height || - intersection.Height == 0 && intersection.Width == window.Width) break; - + const double error_margin = 0.00005; int nudge_direction = 0; - if (intersection.Width < window.Width) { + if ((window.Width - intersection.Width) > error_margin) { // 1 = task bar on left, so nudge right // -1 = task on right, so nuedge left nudge_direction = (task_bar_rect.Left == 0) ? 1 : -1; window.Left = window.Left + nudge_direction * intersection.Width; } - if (intersection.Height < window.Height) { + if ((window.Height - intersection.Height) > error_margin) { // 1 = task bar on top, so nudge down // -1 = task on bottom, so nuedge up nudge_direction = (task_bar_rect.Top == 0) ? 1 : -1; window.Top = window.Top + nudge_direction * intersection.Height; - } - - // update the rect w/ the new window position to see if we have to go another round - source_window_rect = new Rect((int)window.Left, (int)window.Top, (int)window.Width, (int)window.Height); - - } - } + } + } } } } From 91f4de00f8b813779e21932d3948b4ca1d7f586a Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 18 Mar 2019 13:52:28 -0500 Subject: [PATCH 27/72] pr edit: should not have changed while-loop to if-condition --- src/client/spark/view/Extensions/WindowExtensions.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/client/spark/view/Extensions/WindowExtensions.cs b/src/client/spark/view/Extensions/WindowExtensions.cs index 1f45c26e4..59a78b179 100644 --- a/src/client/spark/view/Extensions/WindowExtensions.cs +++ b/src/client/spark/view/Extensions/WindowExtensions.cs @@ -157,7 +157,10 @@ namespace mbts.ui // our source window is already in WPF pixels, so no conversion Rect source_window_rect = new Rect(window.Left, window.Top, window.ActualWidth, window.ActualHeight); - if (source_window_rect.IntersectsWith(task_bar_rect)) { + // use counter just in case something goes awry (don't risk entering an infinite loop) + int counter = 0; + while (source_window_rect.IntersectsWith(task_bar_rect) && counter++ < 2) { + // we have some kind of intersection, let's figure out what kind var intersection = Rect.Intersect(task_bar_rect, source_window_rect); const double error_margin = 0.00005; int nudge_direction = 0; @@ -173,6 +176,8 @@ namespace mbts.ui nudge_direction = (task_bar_rect.Top == 0) ? 1 : -1; window.Top = window.Top + nudge_direction * intersection.Height; } + // update the rect w/ the new window position to see if we have to go another round + source_window_rect = new Rect(window.Left, window.Top, window.Width, window.Height); } } } From fb91206e0f0382eac47279560dc345cb4ca79730 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 18 Mar 2019 13:56:17 -0500 Subject: [PATCH 28/72] pr edit: get window dimensions with window.ActualWidth/Height --- src/client/spark/view/Extensions/WindowExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/spark/view/Extensions/WindowExtensions.cs b/src/client/spark/view/Extensions/WindowExtensions.cs index 59a78b179..5b4c15049 100644 --- a/src/client/spark/view/Extensions/WindowExtensions.cs +++ b/src/client/spark/view/Extensions/WindowExtensions.cs @@ -177,7 +177,7 @@ namespace mbts.ui window.Top = window.Top + nudge_direction * intersection.Height; } // update the rect w/ the new window position to see if we have to go another round - source_window_rect = new Rect(window.Left, window.Top, window.Width, window.Height); + source_window_rect = new Rect(window.Left, window.Top, window.ActualWidth, window.ActualHeight); } } } From 693910f093eb1f58f08d5f77d1f1898ca54944d6 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 19 Mar 2019 12:58:02 -0500 Subject: [PATCH 29/72] SPARK-2162 / SPARK-2163 GridSettingsManager/VM - replace IPredicateBuilder dependency with predicate-data factory(delegate) --- .../Modules/Trading/OrderBook/OrderBookVM.cs | 13 +-- .../DiscreteValues/DiscreteUIntPredicate.cs | 2 +- .../DiscreteValues/DiscreteValuesPredicate.cs | 2 +- .../Data/DiscreteValues/ExchangePredicate.cs | 2 +- .../DiscreteValues/OrderStatusPredicate.cs | 2 +- .../DiscreteValues/OrderSubTypePredicate.cs | 2 +- .../Data/DiscreteValues/OrderTypePredicate.cs | 2 +- .../DiscreteValues/TimeInForcePredicate.cs | 2 +- .../Events/OrderCanceledEventPredicate.cs | 5 +- .../Events/OrderCompletedEventPredicate.cs | 5 +- .../Data/Events/OrderEventPredicateHelper.cs | 4 +- .../Data/Events/OrderFilledEventPredicate.cs | 4 +- .../Data/OrderRecordTuplePredicate.cs | 54 +++++------ .../Data/Primitive/DoublePredicate.cs | 5 +- .../Data/Primitive/SidePredicate.cs | 5 +- .../Data/Primitive/StringPredicate.cs | 6 +- .../Data/Primitive/TimePredicate.cs | 5 +- .../Data/Primitive/UIntPredicate.cs | 5 +- .../Data/Primitive/UShortPredicate.cs | 3 +- .../Predicates/Data/SecurityPredicate.cs | 5 +- src/client/spark/Predicates/IPredicate.cs | 21 +---- .../spark/Predicates/IPredicateBuilderVM.cs | 51 +++++------ .../Animation/IPredicateAnimations.cs | 8 +- .../DIYGrid/Settings/GridColumnSettingsVM.cs | 38 ++++---- .../DIYGrid/Settings/GridSettingsManager.cs | 91 ++++++++----------- .../DIYGrid/Settings/GridSettingsVM.cs | 55 ++++++----- 26 files changed, 175 insertions(+), 222 deletions(-) diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs index d7e964708..88497c18e 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs @@ -19,12 +19,11 @@ using System.Windows.Controls; using System.Windows.Input; using static bts.shell.OrderBookWindowFactory; using static mbts.spark.OrderBookView; -using _GridSettingsManager = +using _GridSettingsManager = mbts.ui.GridSettingsManager< - mbts.spark.OrderBookRowVM, - bts.api.orderman.OrderSecurity, - bts.shell.INotificationServiceDataCache, - mbts.OrderRecordTuplePredicate, + mbts.spark.OrderBookRowVM, + bts.api.orderman.OrderSecurity, + mbts.OrderRecordTuplePredicate, bts.shell.OrderBookWindowFactory.OrderBookGridSettings>; namespace mbts.spark { @@ -232,6 +231,7 @@ namespace mbts.spark { } return new _GridSettingsManager( owner_title, bus, notification_service, model, rows, columns, + () => new OrderRecordTuplePredicate(), () => { var pvm = PredicateBuilderVMWrapper.create( OrderRecordTuplePredicateVMFactory.get_oneofs(bus, model), rp => rp.predicate_type_case); @@ -245,7 +245,8 @@ namespace mbts.spark { return pvm; }, (gen, anims) => new OrderBookGridSettings(gen, anims.Select(a => new OrderRecordTuplePredicateAnimations(a.predicate_builder, a.cell_animations, a.row_animations, a.sound_notifications))), - (notification_service == null) ? null : notification_service.data_cache, + p => p.create_predicate(notification_service.data_cache), + p => p.create_notification_predicate(notification_service.data_cache), col_settings_flags); } diff --git a/src/client/spark/Predicates/Data/DiscreteValues/DiscreteUIntPredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/DiscreteUIntPredicate.cs index 97514e6c7..b529d1f4c 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/DiscreteUIntPredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/DiscreteUIntPredicate.cs @@ -16,7 +16,7 @@ namespace mbts { public uint[] not_in_set { get => _get_set(true); set => _set(true, value); } public DiscreteValuesOneofCase predicate_type_case => DiscreteValuesPredicateUtils.get_predicate_type_case(_values, _negated); - public IPredicate create(object obj) => DiscreteValuesPredicateUtils.create(this); + public IPredicate create() => DiscreteValuesPredicateUtils.create(this); public bool Equals(DiscreteUIntPredicate other) => DiscreteValuesPredicateUtils.equals(this, other); public override bool Equals(object obj) => Equals(obj as DiscreteUIntPredicate); diff --git a/src/client/spark/Predicates/Data/DiscreteValues/DiscreteValuesPredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/DiscreteValuesPredicate.cs index f885c60e9..a0c63aa9a 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/DiscreteValuesPredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/DiscreteValuesPredicate.cs @@ -8,7 +8,7 @@ using System.Collections.Generic; using System.Linq; namespace mbts { - interface IDiscreteValuesPredicateBuilder : IPredicateBuilder { + interface IDiscreteValuesPredicateBuilder { TSingle is_value { get; set; } TSingle not_value { get; set; } TMulti in_set { get; set; } diff --git a/src/client/spark/Predicates/Data/DiscreteValues/ExchangePredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/ExchangePredicate.cs index b8d43d093..02826495c 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/ExchangePredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/ExchangePredicate.cs @@ -17,7 +17,7 @@ namespace mbts { public Venue[] not_in_set { get => _get_set(true); set => _set(true, value); } public DiscreteValuesOneofCase predicate_type_case => DiscreteValuesPredicateUtils.get_predicate_type_case(_values, _negated); - public IPredicate create(object obj) => DiscreteValuesPredicateUtils.create(this); + public IPredicate create() => DiscreteValuesPredicateUtils.create(this); public bool Equals(ExchangePredicate other) => DiscreteValuesPredicateUtils.equals(this, other); public override bool Equals(object obj) => Equals(obj as ExchangePredicate); diff --git a/src/client/spark/Predicates/Data/DiscreteValues/OrderStatusPredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/OrderStatusPredicate.cs index 8f30fb79f..d1199db78 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/OrderStatusPredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/OrderStatusPredicate.cs @@ -17,7 +17,7 @@ namespace mbts { public OrderStatus[] not_in_set { get => _get_set(true); set => _set(true, value); } public DiscreteValuesOneofCase predicate_type_case => DiscreteValuesPredicateUtils.get_predicate_type_case(_values, _negated); - public IPredicate create(object obj) => DiscreteValuesPredicateUtils.create(this); + public IPredicate create() => DiscreteValuesPredicateUtils.create(this); public bool Equals(OrderStatusPredicate other) => DiscreteValuesPredicateUtils.equals(this, other); public override bool Equals(object obj) => Equals(obj as OrderStatusPredicate); diff --git a/src/client/spark/Predicates/Data/DiscreteValues/OrderSubTypePredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/OrderSubTypePredicate.cs index c27537fde..df2d7df10 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/OrderSubTypePredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/OrderSubTypePredicate.cs @@ -17,7 +17,7 @@ namespace mbts { public OrderSubType[] not_in_set { get => _get_set(true); set => _set(true, value); } public DiscreteValuesOneofCase predicate_type_case => DiscreteValuesPredicateUtils.get_predicate_type_case(_values, _negated); - public IPredicate create(object obj) => DiscreteValuesPredicateUtils.create(this); + public IPredicate create() => DiscreteValuesPredicateUtils.create(this); public bool Equals(OrderSubTypePredicate other) => DiscreteValuesPredicateUtils.equals(this, other); public override bool Equals(object obj) => Equals(obj as OrderSubTypePredicate); diff --git a/src/client/spark/Predicates/Data/DiscreteValues/OrderTypePredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/OrderTypePredicate.cs index 9b88ab3a7..01be1ed21 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/OrderTypePredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/OrderTypePredicate.cs @@ -17,7 +17,7 @@ namespace mbts { public OrderType[] not_in_set { get => _get_set(true); set => _set(true, value); } public DiscreteValuesOneofCase predicate_type_case => DiscreteValuesPredicateUtils.get_predicate_type_case(_values, _negated); - public IPredicate create(object obj) => DiscreteValuesPredicateUtils.create(this); + public IPredicate create() => DiscreteValuesPredicateUtils.create(this); public bool Equals(OrderTypePredicate other) => DiscreteValuesPredicateUtils.equals(this, other); public override bool Equals(object obj) => Equals(obj as OrderTypePredicate); diff --git a/src/client/spark/Predicates/Data/DiscreteValues/TimeInForcePredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/TimeInForcePredicate.cs index e56b96d7d..77c105902 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/TimeInForcePredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/TimeInForcePredicate.cs @@ -17,7 +17,7 @@ namespace mbts { public TimeInForce[] not_in_set { get => _get_set(true); set => _set(true, value); } public DiscreteValuesOneofCase predicate_type_case => DiscreteValuesPredicateUtils.get_predicate_type_case(_values, _negate); - public IPredicate create(object obj) => DiscreteValuesPredicateUtils.create(this); + public IPredicate create() => DiscreteValuesPredicateUtils.create(this); public bool Equals(TimeInForcePredicate other) => DiscreteValuesPredicateUtils.equals(this, other); public override bool Equals(object obj) => Equals(obj as TimeInForcePredicate); diff --git a/src/client/spark/Predicates/Data/Events/OrderCanceledEventPredicate.cs b/src/client/spark/Predicates/Data/Events/OrderCanceledEventPredicate.cs index 9ed71bb6e..c478716b1 100644 --- a/src/client/spark/Predicates/Data/Events/OrderCanceledEventPredicate.cs +++ b/src/client/spark/Predicates/Data/Events/OrderCanceledEventPredicate.cs @@ -4,7 +4,6 @@ using bts.shell; using bts.utils; using mbts.spark; using mbts.ui.settings; -using mbts.utils; using ProtoBuf; using System; using System.Collections.Generic; @@ -26,7 +25,7 @@ namespace mbts { } [ProtoContract] - class OrderCanceledEventPredicate : IPredicateBuilder, IEquatable { + class OrderCanceledEventPredicate : IEquatable { public enum PredicateTypeOneofCase { [Description("(any order)")] AnyOrder, @@ -52,7 +51,7 @@ namespace mbts { OrderEventPredicateHelper.create_status_transition_predicate(OrderStatus.Canceled, security, data_cache); public INotificationPredicate create_toast(INotificationServiceDataCache data_cache) => - new MyToaster(security?.create(data_cache), data_cache); + new MyToaster(security?.create(), data_cache); public bool Equals(OrderCanceledEventPredicate other) => other != null && other.security.safe_equals(other.security); public override bool Equals(object obj) => Equals(obj as OrderCanceledEventPredicate); diff --git a/src/client/spark/Predicates/Data/Events/OrderCompletedEventPredicate.cs b/src/client/spark/Predicates/Data/Events/OrderCompletedEventPredicate.cs index f6942d908..ee8a4072e 100644 --- a/src/client/spark/Predicates/Data/Events/OrderCompletedEventPredicate.cs +++ b/src/client/spark/Predicates/Data/Events/OrderCompletedEventPredicate.cs @@ -4,7 +4,6 @@ using bts.shell; using bts.utils; using mbts.spark; using mbts.ui.settings; -using mbts.utils; using ProtoBuf; using System; using System.Collections.Generic; @@ -26,7 +25,7 @@ namespace mbts { } [ProtoContract] - class OrderCompletedEventPredicate : IPredicateBuilder, IEquatable { + class OrderCompletedEventPredicate : IEquatable { public enum PredicateTypeOneofCase { [Description("(any order)")] AnyOrder, @@ -52,7 +51,7 @@ namespace mbts { OrderEventPredicateHelper.create_status_transition_predicate(OrderStatus.Completed, security, data_cache); public INotificationPredicate create_toast(INotificationServiceDataCache data_cache) => - new MyToaster(security?.create(data_cache), data_cache); + new MyToaster(security?.create(), data_cache); public bool Equals(OrderCompletedEventPredicate other) => other != null && other.security.safe_equals(other.security); public override bool Equals(object obj) => Equals(obj as OrderCompletedEventPredicate); diff --git a/src/client/spark/Predicates/Data/Events/OrderEventPredicateHelper.cs b/src/client/spark/Predicates/Data/Events/OrderEventPredicateHelper.cs index f9e27e62f..e13a5a908 100644 --- a/src/client/spark/Predicates/Data/Events/OrderEventPredicateHelper.cs +++ b/src/client/spark/Predicates/Data/Events/OrderEventPredicateHelper.cs @@ -2,8 +2,6 @@ using bts.api.orderman; using bts.shell; using bts.utils; -using mbts.spark; -using mbts.utils; using System; namespace mbts { @@ -39,7 +37,7 @@ namespace mbts { } public static IPredicate create_status_transition_predicate(OrderStatus status, SecurityPredicate security_predicate, INotificationServiceDataCache data_cache) => - new OrderStatusTransitionPredicate(status, security_predicate?.create(data_cache), data_cache); + new OrderStatusTransitionPredicate(status, security_predicate?.create(), data_cache); class OrderStatusTransitionPredicate : IPredicate, IEquatable { readonly IPredicate _security_predicate; diff --git a/src/client/spark/Predicates/Data/Events/OrderFilledEventPredicate.cs b/src/client/spark/Predicates/Data/Events/OrderFilledEventPredicate.cs index 80767eec6..02567321d 100644 --- a/src/client/spark/Predicates/Data/Events/OrderFilledEventPredicate.cs +++ b/src/client/spark/Predicates/Data/Events/OrderFilledEventPredicate.cs @@ -24,7 +24,7 @@ namespace mbts { } [ProtoContract] - class OrderFilledEventPredicate : IPredicateBuilder, IEquatable { + class OrderFilledEventPredicate : IEquatable { public enum PredicateTypeOneofCase { [PredicateCase("(any order)")] AnyOrder, @@ -59,7 +59,7 @@ namespace mbts { public override int GetHashCode() => security == null ? 0 : security.GetHashCode(); FillTriggerModel _create_model(INotificationServiceDataCache nsdc) => - new FillTriggerModel(nsdc, security?.create(nsdc)); + new FillTriggerModel(nsdc, security?.create()); class FillTriggerModel { readonly IPredicate _security_predicate; diff --git a/src/client/spark/Predicates/Data/OrderRecordTuplePredicate.cs b/src/client/spark/Predicates/Data/OrderRecordTuplePredicate.cs index e12c4d480..fbc7d366b 100644 --- a/src/client/spark/Predicates/Data/OrderRecordTuplePredicate.cs +++ b/src/client/spark/Predicates/Data/OrderRecordTuplePredicate.cs @@ -61,7 +61,7 @@ namespace mbts { } [ProtoContract] - class OrderRecordTuplePredicate : INotificationPredicateBuilder, IEquatable { + class OrderRecordTuplePredicate : IEquatable { SecurityPredicate _security; SidePredicate _side; DoublePredicate _price, _last_price, _avg_price; @@ -208,39 +208,36 @@ namespace mbts { public IPredicate create_predicate(INotificationServiceDataCache data_cache) { switch (predicate_type_case) { - case PTOC.Security: return wrap(_security, r => r.security ?? SecurityDataHelper.Defaults.SecurityImmutable); - case PTOC.Time: return wrap(_time_created, r => r.order.created()); - case PTOC.LastChange: return wrap(_last_change, r => r.order.last_change()); - case PTOC.User: return wrap(_user, r => r.order.user_id()); - case PTOC.Account: return wrap(_account, r => r.order.account_id()); - case PTOC.Exchange: return wrap(_exchange, r => r.security.exchange_or_default()); - case PTOC.TimeInForce: return wrap(_time_in_force, r => r.order.time_in_force()); - case PTOC.OrderType: return wrap(_order_type, r => r.order.order_type()); - case PTOC.SubType: return wrap(_order_sub_type, r => r.order.sub_type()); - case PTOC.Side: return wrap(_side, r => r.order.side()); - case PTOC.Size: return wrap(_quantity, r => r.order.quantity()); - case PTOC.Price: return wrap(_price, r => r.order.price()); - case PTOC.Filled: return wrap(_filled_quantity, r => r.order.filled()); - case PTOC.AvgFilled: return wrap(_avg_price, r => r.order.avg_price()); - case PTOC.LastPrice: return wrap(_last_price, r => r.order.last_price()); - case PTOC.Status: return wrap(_order_status, r => r.order.status()); - case PTOC.LastMessage: return wrap(_last_message, r => r.order.last_msg()); - case PTOC.SecurityKey: return wrap(_security_key, r => r.order.security_key()); - case PTOC.OrderKey: return wrap(_order_key, r => r.order.Key); - case PTOC.ParentKey: return wrap(_parent_key, r => r.order.ParentKey); + case PTOC.Security: return wrap(_security.create(), r => r.security ?? SecurityDataHelper.Defaults.SecurityImmutable); + case PTOC.Time: return wrap(_time_created.create(), r => r.order.created()); + case PTOC.LastChange: return wrap(_last_change.create(), r => r.order.last_change()); + case PTOC.User: return wrap(_user.create(), r => r.order.user_id()); + case PTOC.Account: return wrap(_account.create(), r => r.order.account_id()); + case PTOC.Exchange: return wrap(_exchange.create(), r => r.security.exchange_or_default()); + case PTOC.TimeInForce: return wrap(_time_in_force.create(), r => r.order.time_in_force()); + case PTOC.OrderType: return wrap(_order_type.create(), r => r.order.order_type()); + case PTOC.SubType: return wrap(_order_sub_type.create(), r => r.order.sub_type()); + case PTOC.Side: return wrap(_side.create(), r => r.order.side()); + case PTOC.Size: return wrap(_quantity.create(), r => r.order.quantity()); + case PTOC.Price: return wrap(_price.create(), r => r.order.price()); + case PTOC.Filled: return wrap(_filled_quantity.create(), r => r.order.filled()); + case PTOC.AvgFilled: return wrap(_avg_price.create(), r => r.order.avg_price()); + case PTOC.LastPrice: return wrap(_last_price.create(), r => r.order.last_price()); + case PTOC.Status: return wrap(_order_status.create(), r => r.order.status()); + case PTOC.LastMessage: return wrap(_last_message.create(), r => r.order.last_msg()); + case PTOC.SecurityKey: return wrap(_security_key.create(), r => r.order.security_key()); + case PTOC.OrderKey: return wrap(_order_key.create(), r => r.order.Key); + case PTOC.ParentKey: return wrap(_parent_key.create(), r => r.order.ParentKey); case PTOC.FilledEvent: return _filled_event.create_predicate(data_cache); case PTOC.CompletedEvent: return _completed_event.create_predicate(data_cache); case PTOC.CanceledEvent: return _canceled_event.create(data_cache); default: return null; } // - IPredicate wrap(IPredicateBuilder trigger, Func select) => - trigger.create(data_cache).wrap(select); + IPredicate wrap(IPredicate trigger, Func select) => + trigger.wrap(select); } - IPredicate IPredicateBuilder.create(object obj) => - create_predicate((INotificationServiceDataCache)obj); - public INotificationPredicate create_notification_predicate(INotificationServiceDataCache notification_service_data_cache) { if (!is_toast_enabled) return null; @@ -252,9 +249,6 @@ namespace mbts { } } - INotificationPredicate INotificationPredicateBuilder.create_notification_predicate(object obj) => - create_notification_predicate((INotificationServiceDataCache)obj); - public bool Equals(OrderRecordTuplePredicate other) { if (other == null) return false; @@ -383,4 +377,4 @@ namespace mbts { public IReadOnlyList row_animations => _row_animations ?? (_row_animations = new List()); public IReadOnlyList sound_notifications => _sound_animations ?? (_sound_animations = new List()); } -} \ No newline at end of file +} diff --git a/src/client/spark/Predicates/Data/Primitive/DoublePredicate.cs b/src/client/spark/Predicates/Data/Primitive/DoublePredicate.cs index d0a5dfb16..814ba0b54 100644 --- a/src/client/spark/Predicates/Data/Primitive/DoublePredicate.cs +++ b/src/client/spark/Predicates/Data/Primitive/DoublePredicate.cs @@ -1,7 +1,6 @@ using bts.proto; using bts.utils; using mbts.spark; -using mbts.spark.utilities; using mbts.ui.spark; using ProtoBuf; using System; @@ -24,7 +23,7 @@ namespace mbts { } [ProtoContract] - class DoublePredicate : IPredicateBuilder, IEquatable { + class DoublePredicate : IEquatable { // not using a 'negate' flag here bc its meaning is not consistent for all value-types // greater than vs less than for specific values, or inside vs outside for value-ranges // trading a little more code for more clarity @@ -62,7 +61,7 @@ namespace mbts { } } - public IPredicate create(object obj) { + public IPredicate create() { switch (predicate_type_case) { case PredicateTypeOneofCase.GreaterThan: return PredicateBuilder.greater_than(_greater_than.Value); case PredicateTypeOneofCase.LessThan: return PredicateBuilder.less_than(_less_than.Value); diff --git a/src/client/spark/Predicates/Data/Primitive/SidePredicate.cs b/src/client/spark/Predicates/Data/Primitive/SidePredicate.cs index b15486b76..a08300e5a 100644 --- a/src/client/spark/Predicates/Data/Primitive/SidePredicate.cs +++ b/src/client/spark/Predicates/Data/Primitive/SidePredicate.cs @@ -1,7 +1,6 @@ using bts.api; using bts.utils; using mbts.spark; -using mbts.spark.utilities; using mbts.ui.spark; using mbts.ui.utility; using ProtoBuf; @@ -23,7 +22,7 @@ namespace mbts { } [ProtoContract] - class SidePredicate : IPredicateBuilder, IEquatable { + class SidePredicate : IEquatable { Side? _is_value; Side? _not_value; @@ -48,7 +47,7 @@ namespace mbts { } } - public IPredicate create(object obj) { + public IPredicate create() { switch (predicate_type_case) { case PredicateTypeOneofCase.IsValue: return PredicateBuilder.equals(_is_value.Value); case PredicateTypeOneofCase.NotValue: return PredicateBuilder.not_equals(_not_value.Value); diff --git a/src/client/spark/Predicates/Data/Primitive/StringPredicate.cs b/src/client/spark/Predicates/Data/Primitive/StringPredicate.cs index 3f7a9679f..f4e40eafd 100644 --- a/src/client/spark/Predicates/Data/Primitive/StringPredicate.cs +++ b/src/client/spark/Predicates/Data/Primitive/StringPredicate.cs @@ -1,9 +1,7 @@ using bts.proto; using bts.utils; using mbts.spark; -using mbts.spark.utilities; using mbts.ui.spark; -using mbts.utils; using ProtoBuf; using System; using System.Collections.Generic; @@ -27,7 +25,7 @@ namespace mbts { } [ProtoContract] - class StringPredicate : IPredicateBuilder, IEquatable { + class StringPredicate : IEquatable { StringIgnoreCase? _is_string, _not_string, _contains_string, _not_contains_string; public enum PredicateTypeOneofCase { @@ -61,7 +59,7 @@ namespace mbts { } } - public IPredicate create(object obj) { + public IPredicate create() { switch (predicate_type_case) { case PTOC.IsMatch: return PredicateBuilder.equals(_is_string.Value.text, _get_eq_comparer(_is_string)); case PTOC.NotMatch: return PredicateBuilder.not_equals(_not_string.Value.text, _get_eq_comparer(_not_string)); diff --git a/src/client/spark/Predicates/Data/Primitive/TimePredicate.cs b/src/client/spark/Predicates/Data/Primitive/TimePredicate.cs index 2ee8a55f7..cdaf5ab1a 100644 --- a/src/client/spark/Predicates/Data/Primitive/TimePredicate.cs +++ b/src/client/spark/Predicates/Data/Primitive/TimePredicate.cs @@ -1,7 +1,6 @@ using bts.proto; using bts.utils; using mbts.spark; -using mbts.spark.utilities; using mbts.ui.spark; using ProtoBuf; using System; @@ -21,7 +20,7 @@ namespace mbts { } [ProtoContract] - class TimePredicate : IPredicateBuilder, IEquatable { + class TimePredicate : IEquatable { // not using a 'negate' flag here bc its meaning is not consistent for all value-types // before vs after for specific times, or inside vs outside for time-ranges // trading a little more code for clarity @@ -59,7 +58,7 @@ namespace mbts { } } - public IPredicate create(object obj) { + public IPredicate create() { switch (predicate_type_case) { case PTOC.Before: return PredicateBuilder.less_than(_before.Value.get_date_time()); case PTOC.After: return PredicateBuilder.greater_than(_after.Value.get_date_time()); diff --git a/src/client/spark/Predicates/Data/Primitive/UIntPredicate.cs b/src/client/spark/Predicates/Data/Primitive/UIntPredicate.cs index 8d0df7dea..def76f26c 100644 --- a/src/client/spark/Predicates/Data/Primitive/UIntPredicate.cs +++ b/src/client/spark/Predicates/Data/Primitive/UIntPredicate.cs @@ -1,7 +1,6 @@ using bts.proto; using bts.utils; using mbts.spark; -using mbts.spark.utilities; using mbts.ui.spark; using ProtoBuf; using System; @@ -24,7 +23,7 @@ namespace mbts { } [ProtoContract] - class UIntPredicate : IPredicateBuilder, IEquatable { + class UIntPredicate : IEquatable { // not using a 'negate' flag here bc its meaning is not consistent for all value-types // greater than vs less than for specific values, or inside vs outside for value-ranges // trading a little more code for more clarity @@ -62,7 +61,7 @@ namespace mbts { } } - public IPredicate create(object obj) { + public IPredicate create() { switch (predicate_type_case) { case PredicateTypeOneofCase.GreaterThan: return PredicateBuilder.greater_than(_greater_than.Value); case PredicateTypeOneofCase.LessThan: return PredicateBuilder.less_than(_less_than.Value); diff --git a/src/client/spark/Predicates/Data/Primitive/UShortPredicate.cs b/src/client/spark/Predicates/Data/Primitive/UShortPredicate.cs index c3f61af67..5525aea19 100644 --- a/src/client/spark/Predicates/Data/Primitive/UShortPredicate.cs +++ b/src/client/spark/Predicates/Data/Primitive/UShortPredicate.cs @@ -1,7 +1,6 @@ using bts.proto; using bts.utils; using mbts.spark; -using mbts.spark.utilities; using mbts.ui.spark; using ProtoBuf; using System; @@ -24,7 +23,7 @@ namespace mbts { } [ProtoContract] - class UShortPredicate : IPredicateBuilder, IEquatable { + class UShortPredicate : IEquatable { // not using a 'negate' flag here bc its meaning is not consistent for all value-types // greater than vs less than for specific values, or inside vs outside for value-ranges // trading a little more code for more clarity diff --git a/src/client/spark/Predicates/Data/SecurityPredicate.cs b/src/client/spark/Predicates/Data/SecurityPredicate.cs index 0bdd2f3e6..95d2dc01e 100644 --- a/src/client/spark/Predicates/Data/SecurityPredicate.cs +++ b/src/client/spark/Predicates/Data/SecurityPredicate.cs @@ -23,7 +23,7 @@ namespace mbts { } [ProtoContract] - class SecurityPredicate : IPredicateBuilder, IEquatable { + class SecurityPredicate : IEquatable { [ProtoMember(1)] SecurityCriteria _criteria; [ProtoMember(2)] @@ -43,7 +43,8 @@ namespace mbts { _criteria == null ? PTOC.None : _negate ? PTOC.NotInCriteria : PTOC.InCriteria; - public IPredicate create(object obj) => _criteria.is_defined() ? new MyPredicate(_criteria, _negate) : null; + public IPredicate create() => _criteria.is_defined() ? new MyPredicate(_criteria, _negate) : null; + public bool Equals(SecurityPredicate other) => other != null && _negate == other._negate && diff --git a/src/client/spark/Predicates/IPredicate.cs b/src/client/spark/Predicates/IPredicate.cs index 5f1b376cc..bd881c697 100644 --- a/src/client/spark/Predicates/IPredicate.cs +++ b/src/client/spark/Predicates/IPredicate.cs @@ -1,6 +1,4 @@ -using bts.shell; -using bts.utils; -using mbts.utils; +using bts.utils; using System; using System.Collections.Generic; using System.ComponentModel; @@ -14,23 +12,6 @@ namespace mbts { bool trigger(T value); } - interface IPredicateBuilder { - IPredicate create(object obj); - } - - interface INotificationPredicateBuilder : IPredicateBuilder { - bool is_toast_enabled { get; set; } - INotificationPredicate create_notification_predicate(object obj); - } - - interface IPredicateBuilder : IPredicateBuilder { - IPredicate create_predicate(TArg arg); - } - - interface INotificationPredicateBuilder : IPredicateBuilder, INotificationPredicateBuilder { - INotificationPredicate create_notification_predicate(TArg arg); - } - public enum PredicateCategory { Normal, Event diff --git a/src/client/spark/Predicates/IPredicateBuilderVM.cs b/src/client/spark/Predicates/IPredicateBuilderVM.cs index 41e319b6c..46e7e08e6 100644 --- a/src/client/spark/Predicates/IPredicateBuilderVM.cs +++ b/src/client/spark/Predicates/IPredicateBuilderVM.cs @@ -13,9 +13,7 @@ using System.Reactive.Linq; using System.Windows.Data; namespace mbts.ui.settings { - interface IPredicateBuilderVM : ITemplatedPropertyWrapperVM - where TPredicateBuilder : IPredicateBuilder - where TPredicateBuilderOneof : struct { + interface IPredicateBuilderVM : ITemplatedPropertyWrapperVM where TPredicateBuilderOneof : struct { IReadOnlyCollection predicate_types { get; } ICollectionView predicate_types_view { get; } TPredicateBuilderOneof selected_predicate_type { get; set; } @@ -42,11 +40,14 @@ namespace mbts.ui.settings { new PredicateChildWrapperVM(get, set, get_child_oneof, oneof_vms); public static IPredicateBuilderVM create( - Dictionary> oneofs, Func key) - where TPredicateOneof : struct - where TPredicate : IPredicateBuilder, new() => + Dictionary> oneofs, Func key) where TPredicateOneof : struct => // - new PredicateWrapperVM(oneofs, key); + new PredicateWrapperVM(oneofs, key, _ => false, (p, b) => { }); + + public static IPredicateBuilderVM create( + Dictionary> oneofs, Func key, Func get_is_toast_enabled, Action set_is_toast_enabled) where TPredicateOneof : struct => + // + new PredicateWrapperVM(oneofs, key, get_is_toast_enabled, set_is_toast_enabled); public static ITemplatedPropertyWrapperVM create(Action set = null) => new PredicatePlaceholderVM(set); @@ -64,34 +65,29 @@ namespace mbts.ui.settings { } class PredicateWrapperVM : DisposableViewModelBase, IPredicateBuilderVM, ITemplatedPropertyWrapperVM - where TPredicateOneof : struct - where TPredicate : IPredicateBuilder, new() { + where TPredicateOneof : struct { readonly Dictionary> _oneofs; readonly Property _selected_predicate_type; readonly Property> _selected_predicate; readonly DelegateProperty _can_enable_toast_notifications; readonly Property _toast_notifications_enabled; readonly Func _key_selector; + readonly Func _get_is_toast_enabled; + readonly Action _set_is_toast_enabeled; - public PredicateWrapperVM(Dictionary> oneofs, Func key_selector) { + public PredicateWrapperVM(Dictionary> oneofs, Func key_selector, Func get_is_toast_enabled, Action set_is_toast_enabled) { _oneofs = oneofs; _key_selector = key_selector; + _get_is_toast_enabled = get_is_toast_enabled; + _set_is_toast_enabeled = set_is_toast_enabled; _selected_predicate = backing>(nameof(selected_predicate)); _selected_predicate_type = backing(nameof(selected_predicate_type)); predicate_types_view = _create_predicate_types_view(predicate_types); - if (typeof(TPredicate).GetInterfaces().Contains(typeof(INotificationPredicateBuilder))) { - // simple_predicates are only referred to when TPredicate is an INotificationPredicateBuilder, but does not support INotificationPredicates for every predicate-case - // (this way we can gradually add notifications as-needed beasis) - // for ex: we may release a cut that supports fill notifications without having to create a notification-predicate for every predicate-case in OrderRecordTuplePredicate. - // Note: it is assumed that all TPredicateOneof cases DO SUPPORT notification-predicates UNLESS THEY SPECIFY OTHERWISE IN A PREDICATECASEATTRIBUTE. - var simple_predicates = new HashSet(oneofs.Keys.Where(k => { - var pca = EnumHelper.get_attribute(k); - return pca != null && !pca.is_toastable; - })); - _can_enable_toast_notifications = backing(nameof(can_enable_toast_notifications), () => !simple_predicates.Contains(selected_predicate_type), nameof(selected_predicate_type)); - } else { - _can_enable_toast_notifications = backing(nameof(can_enable_toast_notifications), () => false); - } + var toastable_predicates = new HashSet(oneofs.Keys.Where(k => { + var pca = EnumHelper.get_attribute(k); + return pca != null && pca.is_toastable; + })); + _can_enable_toast_notifications = backing(nameof(can_enable_toast_notifications), () => toastable_predicates.Contains(selected_predicate_type), nameof(selected_predicate_type)); _toast_notifications_enabled = backing(nameof(toast_notifications_enabled)); selected_predicate_type = predicate_types.FirstOrDefault(); } @@ -118,15 +114,14 @@ namespace mbts.ui.settings { public void load_from(TPredicate value) { selected_predicate_type = _key_selector(value); selected_predicate?.load_from(value); - if (can_enable_toast_notifications) { - _toast_notifications_enabled.set(((INotificationPredicateBuilder)value).is_toast_enabled); - } + if (can_enable_toast_notifications) + _toast_notifications_enabled.set(_get_is_toast_enabled(value)); } public void assign_to(TPredicate value) { selected_predicate?.assign_to(value); - if (toast_notifications_enabled && value is INotificationPredicateBuilder tp) - tp.is_toast_enabled = true; + if (can_enable_toast_notifications) + _set_is_toast_enabeled(value, toast_notifications_enabled); } } diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/Animation/IPredicateAnimations.cs b/src/client/spark/view/Controls/DIYGrid/Settings/Animation/IPredicateAnimations.cs index 0601158dd..08a52bd1b 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/Animation/IPredicateAnimations.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/Animation/IPredicateAnimations.cs @@ -11,8 +11,8 @@ namespace mbts.ui { IReadOnlyList sound_notifications { get; } } - interface IPredicateAnimationsData where TPredicateBuilder : IPredicateBuilder { - TPredicateBuilder predicate_builder { get; } + interface IPredicateAnimationsData { + TPredicateData predicate_builder { get; } IReadOnlyList cell_animations { get; } IReadOnlyList row_animations { get; } IReadOnlyList sound_notifications { get; } @@ -20,9 +20,9 @@ namespace mbts.ui { static class PredicateAnimations { public static IPredicateAnimationsData create_data(TPredicateBuilder predicate_builder, IReadOnlyList cell_animations, IReadOnlyList row_animations, IReadOnlyList sounds) - where TPredicateBuilder : IPredicateBuilder => new PredicateAnimationsData(predicate_builder, cell_animations, row_animations, sounds); + => new PredicateAnimationsData(predicate_builder, cell_animations, row_animations, sounds); - class PredicateAnimationsData : IPredicateAnimationsData where TPredicateBuilder : IPredicateBuilder { + class PredicateAnimationsData : IPredicateAnimationsData { public PredicateAnimationsData(TPredicateBuilder predicate_builder, IReadOnlyList cell_animations, IReadOnlyList row_animations, IReadOnlyList sound_notifications) { this.predicate_builder = predicate_builder; this.cell_animations = cell_animations; diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs index 8e042dcc6..dd05d5978 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs @@ -27,15 +27,15 @@ namespace mbts.spark { ImmutableFontWeight } - partial class GridSettingsVM { - public interface IColumnVM : ISimpleColumnVM, IValueFactory<(GridColumnSettings settings, ILookup animations)>, IDisposable { + partial class GridSettingsVM { + public interface IColumnVM : ISimpleColumnVM, IValueFactory<(GridColumnSettings settings, ILookup animations)>, IDisposable { ObservableEditableCollection predicate_animations { get; } - new (GridColumnSettings settings, ILookup animations) create(); - new void load_from((GridColumnSettings settings, ILookup animations) args); + new (GridColumnSettings settings, ILookup animations) create(); + new void load_from((GridColumnSettings settings, ILookup animations) args); } public class ColumnVM : DisposableViewModelBase, IColumnVM { - public readonly GridSettingsVM owner; + public readonly GridSettingsVM owner; readonly Property _id, _display_name; readonly Property _width; @@ -44,7 +44,7 @@ namespace mbts.spark { readonly Property _font_weight_override; GridColumnSettings _settings; - public ColumnVM(GridSettingsVM owner) { + public ColumnVM(GridSettingsVM owner) { this.owner = owner; _id = backing(nameof(id), string.Empty); _display_name = backing(nameof(display_name), string.Empty); @@ -60,7 +60,7 @@ namespace mbts.spark { _font_weight_override = backing(nameof(font_weight_override), FontWeights.Normal); // animations predicate_animations = new ObservableEditableCollection(() => - new PredicateCellAnimationVM(id, owner._create_column_predicate_vm(id)), true); + new PredicateCellAnimationVM(id, owner._create_column_predicate_vm(id), owner._predicate_data_factory), true); predicate_animations.CollectionChanged += WPFHelper.create_collection_changed_cb(on_items_added: (_, __) => owner.show_cell_predicate_animations = true); _dispose = Disposable.Create(() => predicate_animations.OfType().DisposeAll()); } @@ -81,17 +81,17 @@ namespace mbts.spark { // animations public ObservableEditableCollection predicate_animations { get; } - public (GridColumnSettings settings, ILookup animations) create() { + public (GridColumnSettings settings, ILookup animations) create() { var settings = _settings.with(display_name, is_visible, null, is_font_weight_overridden ? new NullableFontWeightProto(font_weight_override) : default, is_font_color_overridden ? new NullableColorProto(font_color_override.color) : default, width, horizontal_alignment); - var animations_lookup = predicate_animations.ToFlatLookup(pa => pa.predicate.create_assigned(), pa => pa.animations.Select(a => a.create())); + var animations_lookup = predicate_animations.ToFlatLookup(pa => pa.predicate.create_assigned(owner._predicate_data_factory), pa => pa.animations.Select(a => a.create())); return (settings, animations_lookup); } - public void load_from((GridColumnSettings settings, ILookup animations) value) { + public void load_from((GridColumnSettings settings, ILookup animations) value) { _settings = value.settings; _id.set(_settings.id); _display_name.set(_settings.display_name); @@ -107,7 +107,7 @@ namespace mbts.spark { font_color_override.load_from(new SolidColorBrush(_settings.font_color_override.Value)); } predicate_animations.SetItems(value.animations.empty_if_null().Select(g => { - var vm = new PredicateCellAnimationVM(id, owner._create_column_predicate_vm(id)); + var vm = new PredicateCellAnimationVM(id, owner._create_column_predicate_vm(id), owner._predicate_data_factory); vm.load_from((g.Key, g)); return vm; })); @@ -131,17 +131,19 @@ namespace mbts.spark { create().settings; void IValueFactory.load_from(GridColumnSettings value) => - load_from((value, new Dictionary().ToLookup(kv => kv.Key, kv => kv.Value))); + load_from((value, new Dictionary().ToLookup(kv => kv.Key, kv => kv.Value))); } - public class PredicateCellAnimationVM : DisposableViewModelBase, IValueFactory<(TPredicateBuilder predicate, IEnumerable animations)> { + public class PredicateCellAnimationVM : DisposableViewModelBase, IValueFactory<(TPredicateData predicate, IEnumerable animations)> { // readonly string _col_id; readonly Property _show_animations; + readonly Func _predicate_data_factory; - public PredicateCellAnimationVM(string col_id, IPropertyWrapperVM predicate) { + public PredicateCellAnimationVM(string col_id, IPropertyWrapperVM predicate, Func predicate_data_factory) { _col_id = col_id; this.predicate = predicate; + _predicate_data_factory = predicate_data_factory; _show_animations = backing(nameof(show_animations), true); animations = new ObservableEditableCollection(() => { var vm = new CellAnimationVM(col_id); @@ -152,15 +154,15 @@ namespace mbts.spark { _dispose = predicate as IDisposable; } - public IPropertyWrapperVM predicate { get; } + public IPropertyWrapperVM predicate { get; } public ObservableEditableCollection animations { get; } public IEnumerable animation_types { get; } = EnumHelper.get_values_except(CellAnimation.AnimationTypeOneofCase.None); public bool show_animations { get => _show_animations.Value; set => _show_animations.set(value); } - public (TPredicateBuilder predicate, IEnumerable animations) create() => - (predicate.create_assigned(), animations.Select(a => a.create())); + public (TPredicateData predicate, IEnumerable animations) create() => + (predicate.create_assigned(_predicate_data_factory), animations.Select(a => a.create())); - public void load_from((TPredicateBuilder predicate, IEnumerable animations) args) { + public void load_from((TPredicateData predicate, IEnumerable animations) args) { predicate.load_from(args.predicate); animations.SetItems(args.animations.Select(a => { var vm = new CellAnimationVM(_col_id); diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs index b3c153195..3b129031c 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs @@ -5,8 +5,6 @@ using mbts.collections; using mbts.spark; using mbts.ui.settings; using mbts.ui.shell; -using mbts.ui.spark; -using mbts.ui.utility; using mbts.utils; using System; using System.Collections.Generic; @@ -17,16 +15,15 @@ using System.Windows.Media; using static mbts.ui.controls.DIYGrid; namespace mbts.ui { - class GridSettingsManager : + class GridSettingsManager : ViewModelBase, IValueFactory, IObserver, IDisposable where TRow : IRowVM - where TPredicateBuilder : IPredicateBuilder, new() - where TSettingsData : class, IGridSettingsWithNotifications { + where TSettingsData : class, IGridSettingsWithNotifications { // readonly IBus _bus; readonly OrdersModel _orders_model; readonly INotificationService _notification_service; - readonly List _resources, _notification_subs = new List(); + readonly List _notification_subs = new List(); readonly ObservableCollection _columns; readonly ObservableCollection _rows; readonly Property _grid_settings; @@ -35,30 +32,41 @@ namespace mbts.ui { readonly DelegateProperty _font_size; readonly DelegateProperty _font_color, _selection_highlight; readonly SetMap, AnimationDefinitionWrapper> _animation_defs = new SetMap, AnimationDefinitionWrapper>(); - readonly TPredicateBuilderArg _arg; - readonly Func> _create_predicate_vm; - readonly Func> _create_column_predicate_vm; - readonly Func>, TSettingsData> _create_settings_obj; + readonly Func _predicate_data_factory; + readonly Func> _predicate_factory; + readonly Func> _notification_predicate_factory; + readonly Func> _create_predicate_vm; + readonly Func> _create_column_predicate_vm; + readonly Func>, TSettingsData> _create_settings_obj; readonly IReadOnlyDictionary _column_flags; - IEnumerable> _predicate_animations_data; + IEnumerable> _predicate_animations_data; public GridSettingsManager( - IObservable owner_title, IBus bus, INotificationService notification_service, OrdersModel orders_model, - ObservableCollection rows, ObservableCollection columns, - Func> create_predicate_vm, - Func> create_column_predicate_vm, - Func>, TSettingsData> create_settings_obj, - TPredicateBuilderArg arg, IReadOnlyDictionary column_flags = null) { + IObservable owner_title, + IBus bus, + INotificationService notification_service, + OrdersModel orders_model, + ObservableCollection rows, + ObservableCollection columns, + Func predicate_data_factory, + Func> create_predicate_vm, + Func> create_column_predicate_vm, + Func>, TSettingsData> create_settings_obj, + Func> predicate_factory, + Func> notification_predicate_factory, + IReadOnlyDictionary column_flags = null) { // _bus = bus; _notification_service = notification_service; _orders_model = orders_model; _rows = rows; _columns = columns; + _predicate_data_factory = predicate_data_factory; + _predicate_factory = predicate_factory; + _notification_predicate_factory = notification_predicate_factory; _create_predicate_vm = create_predicate_vm; _create_column_predicate_vm = create_column_predicate_vm; _create_settings_obj = create_settings_obj; - _arg = arg; _column_flags = column_flags.ToDictionary(kv => kv.Key, kv => ImmutableColumnSettingStore.create(kv.Value)); _grid_settings = backing(nameof(grid_settings), GridSettings.Default); _font_family = backing(nameof(font_family), () => new FontFamily(grid_settings.font_family), nameof(grid_settings)); @@ -66,32 +74,10 @@ namespace mbts.ui { _font_size = backing(nameof(font_size), () => grid_settings.font_size, nameof(font_size)); _font_color = backing(nameof(font_color), () => grid_settings.font_color.rgb_solid_brush().frozen(), nameof(grid_settings)); _selection_highlight = backing(nameof(selection_highlight), () => grid_settings.selection_highlight.to_brush().frozen(), nameof(grid_settings)); - _resources = new List { - (launch_settings_editor = new DialogCommand(create_settings_view)) - }; - // local methods - Window create_settings_view() { - var vm = new GridSettingsVM(owner_title, _bus, _orders_model, create_predicate_vm, create_column_predicate_vm, _create_settings_obj); - // need to refresh before launching the settings-view bc users can chanve some grid-column-settings properties directly from the grid (e.g. width, is_collapsed, etc.) - _grid_settings.set(grid_settings.with(columns.Select(c => c.create()))); - vm.load(_create_settings_obj(grid_settings, _predicate_animations_data)); - if (column_flags != null) { - foreach (var col in vm.columns) { - if (column_flags.TryGetValue(col.id, out GridColumnSettingsFeatureFlags f)) - col.apply_flags(f); - } - } - var window = new GridSettingsDialog { DataContext = vm }; - vm.committed += () => load_from(vm.get_result()); - vm.RequestClose += (s, e) => WindowUtilities.force_close(window); - return window; - } } - public void Dispose() { - Disposable.dispose(_resources); + public void Dispose() => Disposable.dispose(_notification_subs); - } public GridSettings grid_settings => _grid_settings.Value; public FontFamily font_family => _font_family.Value; @@ -99,10 +85,9 @@ namespace mbts.ui { public double font_size => _font_size.Value; public SolidColorBrush font_color => _font_color.Value; public SolidColorBrush selection_highlight => _selection_highlight.Value; - public IDialogCommand launch_settings_editor { get; } - public GridSettingsVM create_vm(GridSettings settings, IObservable title) { - var vm = new GridSettingsVM(title, _bus, _orders_model, _create_predicate_vm, _create_column_predicate_vm, _create_settings_obj, _column_flags.ToDictionary(kv => kv.Key, kv => kv.Value.flags)); + public GridSettingsVM create_vm(GridSettings settings, IObservable title) { + var vm = new GridSettingsVM(title, _bus, _orders_model, _predicate_data_factory, _notification_predicate_factory, _create_predicate_vm, _create_column_predicate_vm, _create_settings_obj, _column_flags.ToDictionary(kv => kv.Key, kv => kv.Value.flags)); vm.load(_create_settings_obj(settings, _predicate_animations_data)); return vm; } @@ -127,16 +112,16 @@ namespace mbts.ui { col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight); _predicate_animations_data = value.predicate_animations; _animation_defs.clear(); - if (_notification_service != null && _arg != null) { - foreach (var pa in _predicate_animations_data) { - var predicate = pa.predicate_builder.create_predicate(_arg); - foreach (var s in pa.sound_notifications) { - _notification_subs.Add(_notification_service.link(predicate, s)); - } - if (pa.predicate_builder is INotificationPredicateBuilder tpb && tpb.is_toast_enabled) { - _notification_subs.Add(_notification_service.link(tpb.create_notification_predicate(_arg))); - } + foreach (var pa in _predicate_animations_data) { + var predicate = _predicate_factory(pa.predicate_builder); + if (predicate == null) + continue; + foreach (var s in pa.sound_notifications) { + _notification_subs.Add(_notification_service.link(predicate, s)); } + var notification_predicate = _notification_predicate_factory(pa.predicate_builder); + if (notification_predicate != null) + _notification_subs.Add(_notification_service.link(notification_predicate)); } // ** in the unfortunate event that we botch backwards compatability, and the columns don't bear a 1:1 relationship with the column-settings // don't add insult to injury by crashing ** diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs index 1666e0fc0..7037bb93a 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs @@ -19,12 +19,12 @@ using CellAnimation = mbts.ui.CellAnimation; using FontFamily = System.Windows.Media.FontFamily; namespace mbts.spark { - interface IGridSettingsWithNotifications where TPredicateBuilder : IPredicateBuilder { + interface IGridSettingsWithNotifications { GridSettings general { get; } - IEnumerable> predicate_animations { get; } + IEnumerable> predicate_animations { get; } } - class GridSettingsWithNotifications : IEquatable> where TPredicateBuilder : IPredicateBuilder { + class GridSettingsWithNotifications : IEquatable> { public readonly GridSettings grid; public readonly IEnumerable> predicate_animations_data; public GridSettingsWithNotifications(GridSettings grid, IEnumerable> predicate_animations_data) { @@ -44,13 +44,13 @@ namespace mbts.spark { EqualityComparer.safe_aggregate_hash(predicate_animations_data)); } - partial class GridSettingsVM : DisposableViewModelBase, IRequestViewClose, IWindowSettingsVM, ITemplateSelectorKey - where TPredicateBuilder : IPredicateBuilder, new() - where TSettingsData :class, IGridSettingsWithNotifications { + partial class GridSettingsVM : DisposableViewModelBase, IRequestViewClose, IWindowSettingsVM, ITemplateSelectorKey + where TSettingsData :class, IGridSettingsWithNotifications { // - protected readonly Func> _create_predicate_vm; - protected readonly Func> _create_column_predicate_vm; - readonly Func>, TSettingsData> _create_settings_obj; + protected readonly Func> _create_predicate_vm; + protected readonly Func> _create_column_predicate_vm; + readonly Func _predicate_data_factory; + readonly Func>, TSettingsData> _create_settings_obj; readonly Property _current_column; readonly Property _font_family; readonly Property _font_weight; @@ -62,14 +62,17 @@ namespace mbts.spark { public GridSettingsVM( IObservable owner_title, IBus bus, OrdersModel orders_model, - Func> create_predicate_vm, - Func> create_column_predicate_vm, - Func>, TSettingsData> create_settings_obj, + Func predicate_data_factory, + Func> notification_predicate_factory, + Func> create_predicate_vm, + Func> create_column_predicate_vm, + Func>, TSettingsData> create_settings_obj, IReadOnlyDictionary column_flags = null) { // _owner_title = backing(nameof(owner_title), owner_title); this.bus = bus; _orders_model = orders_model; + _predicate_data_factory = predicate_data_factory; _create_predicate_vm = create_predicate_vm; _create_column_predicate_vm = create_column_predicate_vm; _create_settings_obj = create_settings_obj; @@ -82,7 +85,7 @@ namespace mbts.spark { _show_cell_predicate_animations = backing(nameof(show_cell_predicate_animations), true); _current_column = backing(nameof(current_column)); predicate_animations = new ObservableEditableCollection(() => - new PredicateRowAnimationVM(_create_predicate_vm()), true); + new PredicateRowAnimationVM(_create_predicate_vm(), _predicate_data_factory), true); predicate_animations.CollectionChanged += WPFHelper.create_collection_changed_cb(on_items_added: (_, __) => _show_predicate_animations.set(true)); } @@ -125,13 +128,13 @@ namespace mbts.spark { foreach (var c in columns) { var (settings, animations) = c.create(); col_settings.Add(settings); - foreach (IGrouping g in animations) + foreach (IGrouping g in animations) animation_map.AddOrUpdate(g.Key, p => animation_tuple(c: g), (p, t) => t.cell_animations.AddRange(g)); } return _create_settings_obj(new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), col_settings), - animation_map.Select(kv => PredicateAnimations.create_data(kv.Key, kv.Value.cell_animations, kv.Value.row_animations, kv.Value.sounds))); + animation_map.Select(kv => PredicateAnimations.create_data(kv.Key, kv.Value.cell_animations, kv.Value.row_animations, kv.Value.sounds))); // - (List row_animations, List sounds, List cell_animations) animation_tuple(IEnumerable r = null, IEnumerable s = null, IGrouping c = null) => + (List row_animations, List sounds, List cell_animations) animation_tuple(IEnumerable r = null, IEnumerable s = null, IGrouping c = null) => (r?.ToList() ?? new List(), s?.ToList() ?? new List(), c?.ToList() ?? new List()); } @@ -141,17 +144,17 @@ namespace mbts.spark { font_color.load_from(sd.general.font_color.rgb_solid_brush()); selection_highlight.load_from(sd.general.selection_highlight.to_brush()); _font_size.set(sd.general.font_size); - var col_animations = new Dictionary>>(); + var col_animations = new Dictionary>>(); predicate_animations.Clear(); foreach (var pa in sd.predicate_animations) { if (pa.row_animations.Count > 0 || pa.sound_notifications.Count > 0) { - var vm = new PredicateRowAnimationVM(_create_predicate_vm()); + var vm = new PredicateRowAnimationVM(_create_predicate_vm(), _predicate_data_factory); vm.load_from((pa.predicate_builder, pa.row_animations, pa.sound_notifications)); predicate_animations.Add(vm); } foreach (var ca in pa.cell_animations) { col_animations.AddOrUpdate(ca.column_id, - col => new Dictionary> { { pa.predicate_builder, new List { ca } } }, + col => new Dictionary> { { pa.predicate_builder, new List { ca } } }, (col, d) => d.AddOrUpdate(pa.predicate_builder, p => new List { ca }, (p, l) => l.Add(ca))); } } @@ -171,11 +174,13 @@ namespace mbts.spark { _current_column.set(curr_column); } - public class PredicateRowAnimationVM : DisposableViewModelBase, IValueFactory<(TPredicateBuilder predicate, IEnumerable animations, IEnumerable sounds)> { + public class PredicateRowAnimationVM : DisposableViewModelBase, IValueFactory<(TPredicateData predicate, IEnumerable animations, IEnumerable sounds)> { readonly Property _show_animations/*, _play_sound*/; + readonly Func _predicate_state_factory; - public PredicateRowAnimationVM(IPropertyWrapperVM predicate) { + public PredicateRowAnimationVM(IPropertyWrapperVM predicate, Func predicate_state_factory) { this.predicate = predicate; + _predicate_state_factory = predicate_state_factory; _show_animations = backing(nameof(show_animations), true); //_play_sound = backing(nameof(play_sound), true); animations = new ObservableEditableCollection(() => { @@ -187,20 +192,20 @@ namespace mbts.spark { _dispose = predicate as IDisposable; } - public IPropertyWrapperVM predicate { get; } + public IPropertyWrapperVM predicate { get; } public ObservableEditableCollection animations { get; } public IEnumerable animation_types { get; } = EnumHelper.get_values_except(CellAnimation.AnimationTypeOneofCase.None); public bool show_animations { get => _show_animations.Value; set => _show_animations.set(value); } //public bool play_sound { get => _play_sound.Value; set => _play_sound.set(value); } public IPropertyWrapperVM sound { get; } = SoundAnimationVM.create_system_sound_vm(); - public (TPredicateBuilder predicate, IEnumerable animations, IEnumerable sounds) create() => - (predicate.create_assigned(), + public (TPredicateData predicate, IEnumerable animations, IEnumerable sounds) create() => + (predicate.create_assigned(_predicate_state_factory), animations.Select(a => a.create_assigned()), new[] { sound.create_assigned() }); //EnumerableExtensions.return_if(play_sound, () => sound.create_assigned())); - public void load_from((TPredicateBuilder predicate, IEnumerable animations, IEnumerable sounds) args) { + public void load_from((TPredicateData predicate, IEnumerable animations, IEnumerable sounds) args) { predicate.load_from(args.predicate); animations.SetItems(args.animations.Select(a => { var vm = new RowAnimationVM(); From 1c65b1d87a37f24ce2aeda435d6843a80d159e9a Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 19 Mar 2019 13:00:25 -0500 Subject: [PATCH 30/72] rename generic type arg 'TPredicateBuilder' -> 'TPredicateData' --- .../Modules/Trading/OrderBook/OrderBookVM.cs | 6 ++-- .../DiscreteValues/DiscreteStringPredicate.cs | 2 +- .../DiscreteValues/DiscreteUIntPredicate.cs | 2 +- .../DiscreteValues/DiscreteValuesPredicate.cs | 30 ++++++++-------- .../Data/DiscreteValues/ExchangePredicate.cs | 2 +- .../DiscreteValues/OrderStatusPredicate.cs | 2 +- .../DiscreteValues/OrderSubTypePredicate.cs | 2 +- .../Data/DiscreteValues/OrderTypePredicate.cs | 2 +- .../DiscreteValues/TimeInForcePredicate.cs | 2 +- .../Events/OrderCanceledEventPredicate.cs | 2 +- .../Events/OrderCompletedEventPredicate.cs | 2 +- .../Data/Events/OrderFilledEventPredicate.cs | 2 +- .../Data/OrderRecordTuplePredicate.cs | 4 +-- ...IPredicateBuilderVM.cs => IPredicateVM.cs} | 36 +++++++++---------- .../Animation/IPredicateAnimations.cs | 14 ++++---- .../DIYGrid/Settings/GridSettingsManager.cs | 4 +-- .../DIYGrid/Settings/GridSettingsVM.cs | 16 ++++----- 17 files changed, 65 insertions(+), 65 deletions(-) rename src/client/spark/Predicates/{IPredicateBuilderVM.cs => IPredicateVM.cs} (78%) diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs index 88497c18e..d16383702 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs @@ -233,18 +233,18 @@ namespace mbts.spark { owner_title, bus, notification_service, model, rows, columns, () => new OrderRecordTuplePredicate(), () => { - var pvm = PredicateBuilderVMWrapper.create( + var pvm = PredicateVMWrapper.create( OrderRecordTuplePredicateVMFactory.get_oneofs(bus, model), rp => rp.predicate_type_case); pvm.selected_predicate_type = pvm.predicate_types.FirstOrDefault(); return pvm; }, col_id => { - var pvm = PredicateBuilderVMWrapper.create( + var pvm = PredicateVMWrapper.create( OrderRecordTuplePredicateVMFactory.get_oneofs(bus, model), rp => rp.predicate_type_case); pvm.selected_predicate_type = _corresponding_predicate_type(EnumHelper.parse_or_default(col_id)); return pvm; }, - (gen, anims) => new OrderBookGridSettings(gen, anims.Select(a => new OrderRecordTuplePredicateAnimations(a.predicate_builder, a.cell_animations, a.row_animations, a.sound_notifications))), + (gen, anims) => new OrderBookGridSettings(gen, anims.Select(a => new OrderRecordTuplePredicateAnimations(a.predicate_data, a.cell_animations, a.row_animations, a.sound_notifications))), p => p.create_predicate(notification_service.data_cache), p => p.create_notification_predicate(notification_service.data_cache), col_settings_flags); diff --git a/src/client/spark/Predicates/Data/DiscreteValues/DiscreteStringPredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/DiscreteStringPredicate.cs index afba058c3..34e077f30 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/DiscreteStringPredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/DiscreteStringPredicate.cs @@ -4,7 +4,7 @@ using System; namespace mbts { [ProtoContract] - class DiscreteStringPredicate : IDiscreteValuesPredicateBuilder, IEquatable { + class DiscreteStringPredicate : IDiscreteValuesPredicateData, IEquatable { [ProtoMember(1)] string[] _values; [ProtoMember(2)] diff --git a/src/client/spark/Predicates/Data/DiscreteValues/DiscreteUIntPredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/DiscreteUIntPredicate.cs index b529d1f4c..af8ef653b 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/DiscreteUIntPredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/DiscreteUIntPredicate.cs @@ -4,7 +4,7 @@ using System; namespace mbts { [ProtoContract] - class DiscreteUIntPredicate : IDiscreteValuesPredicateBuilder, IEquatable { + class DiscreteUIntPredicate : IDiscreteValuesPredicateData, IEquatable { [ProtoMember(1)] uint[] _values; [ProtoMember(2)] diff --git a/src/client/spark/Predicates/Data/DiscreteValues/DiscreteValuesPredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/DiscreteValuesPredicate.cs index a0c63aa9a..478eda180 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/DiscreteValuesPredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/DiscreteValuesPredicate.cs @@ -8,14 +8,14 @@ using System.Collections.Generic; using System.Linq; namespace mbts { - interface IDiscreteValuesPredicateBuilder { + interface IDiscreteValuesPredicateData { TSingle is_value { get; set; } TSingle not_value { get; set; } TMulti in_set { get; set; } TMulti not_in_set { get; set; } DiscreteValuesOneofCase predicate_type_case { get; } } - interface IDiscreteValuesPredicateBuilder : IDiscreteValuesPredicateBuilder { } + interface IDiscreteValuesPredicateData : IDiscreteValuesPredicateData { } public enum DiscreteValuesOneofCase { None, @@ -32,8 +32,8 @@ namespace mbts { namespace mbts.ui.settings { static class DiscreteValuesPredicateUtils { - public static bool equals(IDiscreteValuesPredicateBuilder a, IDiscreteValuesPredicateBuilder b) => a.safe_equals(b, _equals); - static bool _equals(IDiscreteValuesPredicateBuilder a, IDiscreteValuesPredicateBuilder b) { + public static bool equals(IDiscreteValuesPredicateData a, IDiscreteValuesPredicateData b) => a.safe_equals(b, _equals); + static bool _equals(IDiscreteValuesPredicateData a, IDiscreteValuesPredicateData b) { var dvoc = a.predicate_type_case; if (dvoc != b.predicate_type_case) return false; @@ -47,8 +47,8 @@ namespace mbts.ui.settings { } } - public static bool equals(IDiscreteValuesPredicateBuilder a, IDiscreteValuesPredicateBuilder b) => a.safe_equals(b, _equals); - public static bool _equals(IDiscreteValuesPredicateBuilder a, IDiscreteValuesPredicateBuilder b) { + public static bool equals(IDiscreteValuesPredicateData a, IDiscreteValuesPredicateData b) => a.safe_equals(b, _equals); + public static bool _equals(IDiscreteValuesPredicateData a, IDiscreteValuesPredicateData b) { var dvoc = a.predicate_type_case; if (dvoc != b.predicate_type_case) return false; @@ -62,7 +62,7 @@ namespace mbts.ui.settings { } } - public static int hash(IDiscreteValuesPredicateBuilder a) { + public static int hash(IDiscreteValuesPredicateData a) { switch (a.predicate_type_case) { case DiscreteValuesOneofCase.IsValue: return a.is_value.GetHashCode() % MathUtils.Primes.P_17191; case DiscreteValuesOneofCase.NotValue: return a.not_value.GetHashCode() % MathUtils.Primes.P_83987; @@ -72,7 +72,7 @@ namespace mbts.ui.settings { } } - public static int hash(IDiscreteValuesPredicateBuilder a) { + public static int hash(IDiscreteValuesPredicateData a) { switch (a.predicate_type_case) { case DiscreteValuesOneofCase.IsValue: return a.is_value.GetHashCode() % MathUtils.Primes.P_17191; case DiscreteValuesOneofCase.NotValue: return a.not_value.GetHashCode() % MathUtils.Primes.P_83987; @@ -88,7 +88,7 @@ namespace mbts.ui.settings { (negated ? DiscreteValuesOneofCase.NotValue : DiscreteValuesOneofCase.IsValue) : (negated ? DiscreteValuesOneofCase.NotInSet : DiscreteValuesOneofCase.IsInSet); - public static DiscreteValuesOneofCase get_predicate_type_case(IDiscreteValuesPredicateBuilder predicate_builder) { + public static DiscreteValuesOneofCase get_predicate_type_case(IDiscreteValuesPredicateData predicate_builder) { if (predicate_builder.is_value != null) return DiscreteValuesOneofCase.IsValue; if (predicate_builder.not_value != null) return DiscreteValuesOneofCase.NotValue; if (predicate_builder.in_set != null) return DiscreteValuesOneofCase.IsInSet; @@ -96,7 +96,7 @@ namespace mbts.ui.settings { return DiscreteValuesOneofCase.None; } - public static IPredicate create(IDiscreteValuesPredicateBuilder predicate_builder) { + public static IPredicate create(IDiscreteValuesPredicateData predicate_builder) { switch (predicate_builder.predicate_type_case) { case DiscreteValuesOneofCase.IsValue: return PredicateBuilder.equals(predicate_builder.is_value); case DiscreteValuesOneofCase.NotValue: return PredicateBuilder.not_equals(predicate_builder.not_value); @@ -106,7 +106,7 @@ namespace mbts.ui.settings { } } - public static IPredicate create(IDiscreteValuesPredicateBuilder predicate_builder) where T : struct { + public static IPredicate create(IDiscreteValuesPredicateData predicate_builder) where T : struct { switch (predicate_builder.predicate_type_case) { case DiscreteValuesOneofCase.IsValue: return PredicateBuilder.equals(predicate_builder.is_value.Value); case DiscreteValuesOneofCase.NotValue: return PredicateBuilder.not_equals(predicate_builder.not_value.Value); @@ -118,13 +118,13 @@ namespace mbts.ui.settings { } static class DiscreteValuesPredicateVMFactory { public static Dictionary> get_oneofs_value_type(IEnumerable items) - where T : struct where TPredicate : IDiscreteValuesPredicateBuilder => + where T : struct where TPredicate : IDiscreteValuesPredicateData => // get_oneofs(identity_view_value_collection(items), val => val.Value, val => val, vals => vals ?? Enumerable.Empty(), vals => vals?.ToArray() ?? new T[0], get_identity_view); public static Dictionary> get_oneofs( IObservableCollection> items, Func from_single, Func to_single, Func> from_multi, Func, TMulti> to_multi, Func get_view) - where TPredicate : IDiscreteValuesPredicateBuilder { + where TPredicate : IDiscreteValuesPredicateData { // return new Dictionary> { { DiscreteValuesOneofCase.IsValue, PropertyWrapperVMUtils.create_selector_vm( @@ -153,14 +153,14 @@ namespace mbts.ui.settings { public static Dictionary> get_oneofs( IEnumerable items, Func key, Func from_single, Func to_single, Func> from_multi, Func, TMulti> to_multi) where TKey : struct, IEquatable - where TPredicate : IDiscreteValuesPredicateBuilder => + where TPredicate : IDiscreteValuesPredicateData => // get_oneofs(RXCollection.from_enumerable(items.Select>(v => new ViewValueTuple(v, v))), key, from_single, to_single, from_multi, to_multi); public static Dictionary> get_oneofs( IObservableCollection> items, Func key, Func from_single, Func to_single, Func> from_multi, Func, TMulti> to_multi) where TKey : struct, IEquatable - where TPredicate : IDiscreteValuesPredicateBuilder { + where TPredicate : IDiscreteValuesPredicateData { // return new Dictionary> { { DiscreteValuesOneofCase.IsValue, PropertyWrapperVMUtils.create_keyed_selector_vm, TKey>( diff --git a/src/client/spark/Predicates/Data/DiscreteValues/ExchangePredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/ExchangePredicate.cs index 02826495c..61d07f88f 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/ExchangePredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/ExchangePredicate.cs @@ -5,7 +5,7 @@ using System; namespace mbts { [ProtoContract] - class ExchangePredicate : IDiscreteValuesPredicateBuilder, IEquatable { + class ExchangePredicate : IDiscreteValuesPredicateData, IEquatable { [ProtoMember(1)] Venue[] _values; [ProtoMember(2)] diff --git a/src/client/spark/Predicates/Data/DiscreteValues/OrderStatusPredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/OrderStatusPredicate.cs index d1199db78..441b0f557 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/OrderStatusPredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/OrderStatusPredicate.cs @@ -5,7 +5,7 @@ using System; namespace mbts { [ProtoContract] - class OrderStatusPredicate : IDiscreteValuesPredicateBuilder, IEquatable { + class OrderStatusPredicate : IDiscreteValuesPredicateData, IEquatable { [ProtoMember(1)] OrderStatus[] _values; [ProtoMember(2)] diff --git a/src/client/spark/Predicates/Data/DiscreteValues/OrderSubTypePredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/OrderSubTypePredicate.cs index df2d7df10..8a8e10f48 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/OrderSubTypePredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/OrderSubTypePredicate.cs @@ -5,7 +5,7 @@ using System; namespace mbts { [ProtoContract] - class OrderSubTypePredicate : IDiscreteValuesPredicateBuilder, IEquatable { + class OrderSubTypePredicate : IDiscreteValuesPredicateData, IEquatable { [ProtoMember(1)] OrderSubType[] _values; [ProtoMember(2)] diff --git a/src/client/spark/Predicates/Data/DiscreteValues/OrderTypePredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/OrderTypePredicate.cs index 01be1ed21..719e39fa8 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/OrderTypePredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/OrderTypePredicate.cs @@ -5,7 +5,7 @@ using OrderType = bts.api.orderman.CustomOrderDefinition.CustomOneofCase; namespace mbts { [ProtoContract] - class OrderTypePredicate : IDiscreteValuesPredicateBuilder, IEquatable { + class OrderTypePredicate : IDiscreteValuesPredicateData, IEquatable { [ProtoMember(1)] OrderType[] _values; [ProtoMember(2)] diff --git a/src/client/spark/Predicates/Data/DiscreteValues/TimeInForcePredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/TimeInForcePredicate.cs index 77c105902..98e5c84e4 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/TimeInForcePredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/TimeInForcePredicate.cs @@ -5,7 +5,7 @@ using System; namespace mbts { [ProtoContract] - class TimeInForcePredicate : IDiscreteValuesPredicateBuilder, IEquatable { + class TimeInForcePredicate : IDiscreteValuesPredicateData, IEquatable { [ProtoMember(1)] TimeInForce[] _values; [ProtoMember(2)] diff --git a/src/client/spark/Predicates/Data/Events/OrderCanceledEventPredicate.cs b/src/client/spark/Predicates/Data/Events/OrderCanceledEventPredicate.cs index c478716b1..ea9172dd1 100644 --- a/src/client/spark/Predicates/Data/Events/OrderCanceledEventPredicate.cs +++ b/src/client/spark/Predicates/Data/Events/OrderCanceledEventPredicate.cs @@ -13,7 +13,7 @@ namespace mbts { static class OrderCanceledEventPredicateVMFactory { public static Dictionary> get_oneofs(IBus bus) => new Dictionary> { - { OrderCanceledEventPredicate.PredicateTypeOneofCase.AnyOrder, PredicateBuilderVMWrapper.create(p => p.security = null) }, + { OrderCanceledEventPredicate.PredicateTypeOneofCase.AnyOrder, PredicateVMWrapper.create(p => p.security = null) }, { OrderCanceledEventPredicate.PredicateTypeOneofCase.SecurityOrder, SecurityCriteriaVMFactory.create(bus, o => o.security?.is_value ?? new SecurityCriteria(), (p, s) => { if (p.security == null) diff --git a/src/client/spark/Predicates/Data/Events/OrderCompletedEventPredicate.cs b/src/client/spark/Predicates/Data/Events/OrderCompletedEventPredicate.cs index ee8a4072e..a543fecb4 100644 --- a/src/client/spark/Predicates/Data/Events/OrderCompletedEventPredicate.cs +++ b/src/client/spark/Predicates/Data/Events/OrderCompletedEventPredicate.cs @@ -13,7 +13,7 @@ namespace mbts { static class OrderCompletedEventPredicateVMFactory { public static Dictionary> get_oneofs(IBus bus) => new Dictionary> { - { OrderCompletedEventPredicate.PredicateTypeOneofCase.AnyOrder, PredicateBuilderVMWrapper.create(p => p.security = null) }, + { OrderCompletedEventPredicate.PredicateTypeOneofCase.AnyOrder, PredicateVMWrapper.create(p => p.security = null) }, { OrderCompletedEventPredicate.PredicateTypeOneofCase.SecurityOrder, SecurityCriteriaVMFactory.create(bus, o => o.security?.is_value ?? new SecurityCriteria(), (p, s) => { if (p.security == null) diff --git a/src/client/spark/Predicates/Data/Events/OrderFilledEventPredicate.cs b/src/client/spark/Predicates/Data/Events/OrderFilledEventPredicate.cs index 02567321d..f8ca8f2ab 100644 --- a/src/client/spark/Predicates/Data/Events/OrderFilledEventPredicate.cs +++ b/src/client/spark/Predicates/Data/Events/OrderFilledEventPredicate.cs @@ -11,7 +11,7 @@ namespace mbts { static class OrderFilledEventPredicateVMFactory { public static Dictionary> get_oneofs(IBus bus) => new Dictionary> { - { OrderFilledEventPredicate.PredicateTypeOneofCase.AnyOrder, PredicateBuilderVMWrapper.create(p => p.security = null) }, + { OrderFilledEventPredicate.PredicateTypeOneofCase.AnyOrder, PredicateVMWrapper.create(p => p.security = null) }, { OrderFilledEventPredicate.PredicateTypeOneofCase.SecurityOrder, SecurityCriteriaVMFactory.create(bus, o => o.security?.is_value ?? new SecurityCriteria(), (p, s) => { if (p.security == null) { diff --git a/src/client/spark/Predicates/Data/OrderRecordTuplePredicate.cs b/src/client/spark/Predicates/Data/OrderRecordTuplePredicate.cs index fbc7d366b..3c2323103 100644 --- a/src/client/spark/Predicates/Data/OrderRecordTuplePredicate.cs +++ b/src/client/spark/Predicates/Data/OrderRecordTuplePredicate.cs @@ -56,7 +56,7 @@ namespace mbts { Func key, Dictionary> oneofs) where TChildPredicateOneof : struct where TChildPredicate : new() => // - PredicateBuilderVMWrapper.wrap_child_oneof(get, set, key, oneofs); + PredicateVMWrapper.wrap_child_oneof(get, set, key, oneofs); } } @@ -372,7 +372,7 @@ namespace mbts { _sound_animations = new List ( sound_animations ); } - public OrderRecordTuplePredicate predicate_builder => _predicate; + public OrderRecordTuplePredicate predicate_data => _predicate; public IReadOnlyList cell_animations => _cell_animations ?? (_cell_animations = new List()); public IReadOnlyList row_animations => _row_animations ?? (_row_animations = new List()); public IReadOnlyList sound_notifications => _sound_animations ?? (_sound_animations = new List()); diff --git a/src/client/spark/Predicates/IPredicateBuilderVM.cs b/src/client/spark/Predicates/IPredicateVM.cs similarity index 78% rename from src/client/spark/Predicates/IPredicateBuilderVM.cs rename to src/client/spark/Predicates/IPredicateVM.cs index 46e7e08e6..d98708ca8 100644 --- a/src/client/spark/Predicates/IPredicateBuilderVM.cs +++ b/src/client/spark/Predicates/IPredicateVM.cs @@ -13,23 +13,23 @@ using System.Reactive.Linq; using System.Windows.Data; namespace mbts.ui.settings { - interface IPredicateBuilderVM : ITemplatedPropertyWrapperVM where TPredicateBuilderOneof : struct { - IReadOnlyCollection predicate_types { get; } + interface IPredicateVM : ITemplatedPropertyWrapperVM where TPredicateDataOneof : struct { + IReadOnlyCollection predicate_types { get; } ICollectionView predicate_types_view { get; } - TPredicateBuilderOneof selected_predicate_type { get; set; } - ITemplatedPropertyWrapperVM selected_predicate { get; } + TPredicateDataOneof selected_predicate_type { get; set; } + ITemplatedPropertyWrapperVM selected_predicate { get; } bool can_enable_toast_notifications { get; } bool toast_notifications_enabled { get; } } - interface IChildPredicateBuilderVM : ITemplatedPropertyWrapperVM where TChildPredicateBuilderOneof : struct { - IReadOnlyCollection predicate_types { get; } + interface IChildPredicateVM : ITemplatedPropertyWrapperVM where TChildPredicateOneof : struct { + IReadOnlyCollection predicate_types { get; } ICollectionView predicate_types_view { get; } - TChildPredicateBuilderOneof selected_predicate_type { get; set; } - ITemplatedPropertyWrapperVM selected_predicate { get; } + TChildPredicateOneof selected_predicate_type { get; set; } + ITemplatedPropertyWrapperVM selected_predicate { get; } } - static class PredicateBuilderVMWrapper { + static class PredicateVMWrapper { static readonly bool _toast_notifications_enabled_global = Configuration.get().enabled; public static ITemplatedPropertyWrapperVM wrap_child_oneof( @@ -37,17 +37,17 @@ namespace mbts.ui.settings { where TChildOneof : struct where TChild : new() => // - new PredicateChildWrapperVM(get, set, get_child_oneof, oneof_vms); + new ChildImpl(get, set, get_child_oneof, oneof_vms); - public static IPredicateBuilderVM create( + public static IPredicateVM create( Dictionary> oneofs, Func key) where TPredicateOneof : struct => // - new PredicateWrapperVM(oneofs, key, _ => false, (p, b) => { }); + new Impl(oneofs, key, _ => false, (p, b) => { }); - public static IPredicateBuilderVM create( + public static IPredicateVM create( Dictionary> oneofs, Func key, Func get_is_toast_enabled, Action set_is_toast_enabled) where TPredicateOneof : struct => // - new PredicateWrapperVM(oneofs, key, get_is_toast_enabled, set_is_toast_enabled); + new Impl(oneofs, key, get_is_toast_enabled, set_is_toast_enabled); public static ITemplatedPropertyWrapperVM create(Action set = null) => new PredicatePlaceholderVM(set); @@ -64,7 +64,7 @@ namespace mbts.ui.settings { return cv; } - class PredicateWrapperVM : DisposableViewModelBase, IPredicateBuilderVM, ITemplatedPropertyWrapperVM + class Impl : DisposableViewModelBase, IPredicateVM, ITemplatedPropertyWrapperVM where TPredicateOneof : struct { readonly Dictionary> _oneofs; readonly Property _selected_predicate_type; @@ -75,7 +75,7 @@ namespace mbts.ui.settings { readonly Func _get_is_toast_enabled; readonly Action _set_is_toast_enabeled; - public PredicateWrapperVM(Dictionary> oneofs, Func key_selector, Func get_is_toast_enabled, Action set_is_toast_enabled) { + public Impl(Dictionary> oneofs, Func key_selector, Func get_is_toast_enabled, Action set_is_toast_enabled) { _oneofs = oneofs; _key_selector = key_selector; _get_is_toast_enabled = get_is_toast_enabled; @@ -125,7 +125,7 @@ namespace mbts.ui.settings { } } - class PredicateChildWrapperVM : DisposableViewModelBase, IChildPredicateBuilderVM where TChildKey : struct where TChild : new() { + class ChildImpl : DisposableViewModelBase, IChildPredicateVM where TChildKey : struct where TChild : new() { readonly Property> _selected_predicate; readonly Property _selected_predicate_type; readonly Dictionary> _children; @@ -134,7 +134,7 @@ namespace mbts.ui.settings { readonly Func _key; readonly string _template_key; - public PredicateChildWrapperVM(Func get, Action set, Func key, + public ChildImpl(Func get, Action set, Func key, Dictionary> oneofs, string template = PredicateTemplateKeys.Recursive) { _get = get; _set = set; diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/Animation/IPredicateAnimations.cs b/src/client/spark/view/Controls/DIYGrid/Settings/Animation/IPredicateAnimations.cs index 08a52bd1b..2c40bbb28 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/Animation/IPredicateAnimations.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/Animation/IPredicateAnimations.cs @@ -12,25 +12,25 @@ namespace mbts.ui { } interface IPredicateAnimationsData { - TPredicateData predicate_builder { get; } + TPredicateData predicate_data { get; } IReadOnlyList cell_animations { get; } IReadOnlyList row_animations { get; } IReadOnlyList sound_notifications { get; } } static class PredicateAnimations { - public static IPredicateAnimationsData create_data(TPredicateBuilder predicate_builder, IReadOnlyList cell_animations, IReadOnlyList row_animations, IReadOnlyList sounds) - => new PredicateAnimationsData(predicate_builder, cell_animations, row_animations, sounds); + public static IPredicateAnimationsData create_data(TPredicateData predicate_data, IReadOnlyList cell_animations, IReadOnlyList row_animations, IReadOnlyList sounds) + => new PredicateAnimationsData(predicate_data, cell_animations, row_animations, sounds); - class PredicateAnimationsData : IPredicateAnimationsData { - public PredicateAnimationsData(TPredicateBuilder predicate_builder, IReadOnlyList cell_animations, IReadOnlyList row_animations, IReadOnlyList sound_notifications) { - this.predicate_builder = predicate_builder; + class PredicateAnimationsData : IPredicateAnimationsData { + public PredicateAnimationsData(TPredicateData predicate_data, IReadOnlyList cell_animations, IReadOnlyList row_animations, IReadOnlyList sound_notifications) { + this.predicate_data = predicate_data; this.cell_animations = cell_animations; this.row_animations = row_animations; this.sound_notifications = sound_notifications; } - public TPredicateBuilder predicate_builder { get; } + public TPredicateData predicate_data { get; } public IReadOnlyList cell_animations { get; } public IReadOnlyList row_animations { get; } public IReadOnlyList sound_notifications { get; } diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs index 3b129031c..2b6d7a645 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs @@ -113,13 +113,13 @@ namespace mbts.ui { _predicate_animations_data = value.predicate_animations; _animation_defs.clear(); foreach (var pa in _predicate_animations_data) { - var predicate = _predicate_factory(pa.predicate_builder); + var predicate = _predicate_factory(pa.predicate_data); if (predicate == null) continue; foreach (var s in pa.sound_notifications) { _notification_subs.Add(_notification_service.link(predicate, s)); } - var notification_predicate = _notification_predicate_factory(pa.predicate_builder); + var notification_predicate = _notification_predicate_factory(pa.predicate_data); if (notification_predicate != null) _notification_subs.Add(_notification_service.link(notification_predicate)); } diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs index 7037bb93a..a7bc55036 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs @@ -24,20 +24,20 @@ namespace mbts.spark { IEnumerable> predicate_animations { get; } } - class GridSettingsWithNotifications : IEquatable> { + class GridSettingsWithNotifications : IEquatable> { public readonly GridSettings grid; - public readonly IEnumerable> predicate_animations_data; - public GridSettingsWithNotifications(GridSettings grid, IEnumerable> predicate_animations_data) { + public readonly IEnumerable> predicate_animations_data; + public GridSettingsWithNotifications(GridSettings grid, IEnumerable> predicate_animations_data) { this.grid = grid; this.predicate_animations_data = predicate_animations_data; } - public bool Equals(GridSettingsWithNotifications other) => + public bool Equals(GridSettingsWithNotifications other) => other != null && EqualityComparer.null_check_equals(grid, other.grid) && EqualityComparer.safe_sequence_equals(predicate_animations_data, other.predicate_animations_data); - public override bool Equals(object obj) => Equals(obj as GridSettingsWithNotifications); + public override bool Equals(object obj) => Equals(obj as GridSettingsWithNotifications); public override int GetHashCode() => EqualityComparer.aggregate_hash( EqualityComparer.safe_get_hash_code(grid), @@ -149,13 +149,13 @@ namespace mbts.spark { foreach (var pa in sd.predicate_animations) { if (pa.row_animations.Count > 0 || pa.sound_notifications.Count > 0) { var vm = new PredicateRowAnimationVM(_create_predicate_vm(), _predicate_data_factory); - vm.load_from((pa.predicate_builder, pa.row_animations, pa.sound_notifications)); + vm.load_from((pa.predicate_data, pa.row_animations, pa.sound_notifications)); predicate_animations.Add(vm); } foreach (var ca in pa.cell_animations) { col_animations.AddOrUpdate(ca.column_id, - col => new Dictionary> { { pa.predicate_builder, new List { ca } } }, - (col, d) => d.AddOrUpdate(pa.predicate_builder, p => new List { ca }, (p, l) => l.Add(ca))); + col => new Dictionary> { { pa.predicate_data, new List { ca } } }, + (col, d) => d.AddOrUpdate(pa.predicate_data, p => new List { ca }, (p, l) => l.Add(ca))); } } var curr_col_id = current_column?.id; From 56d3a27e7fd5a70dbab1bd60957592fde0e667b1 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 19 Mar 2019 13:12:04 -0500 Subject: [PATCH 31/72] SPARK-2162 / SPARK-2164 INotificationService - remove fake strongly typed 'link' extension method --- .../Modules/Trading/OrderBook/OrderBookVM.cs | 6 ++- .../Notifications/INotificationService.cs | 39 +++---------------- .../DIYGrid/Settings/GridSettingsManager.cs | 13 ++++--- 3 files changed, 18 insertions(+), 40 deletions(-) diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs index d16383702..d0a721479 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs @@ -230,7 +230,7 @@ namespace mbts.spark { col_settings_flags[c.ToString()] = GridColumnSettingsFeatureFlags.ImmutableFontColor | GridColumnSettingsFeatureFlags.ImmutableFontWeight; } return new _GridSettingsManager( - owner_title, bus, notification_service, model, rows, columns, + owner_title, bus, model, rows, columns, () => new OrderRecordTuplePredicate(), () => { var pvm = PredicateVMWrapper.create( @@ -247,6 +247,8 @@ namespace mbts.spark { (gen, anims) => new OrderBookGridSettings(gen, anims.Select(a => new OrderRecordTuplePredicateAnimations(a.predicate_data, a.cell_animations, a.row_animations, a.sound_notifications))), p => p.create_predicate(notification_service.data_cache), p => p.create_notification_predicate(notification_service.data_cache), + notification_service.link_to_order, + notification_service.link_to_order, col_settings_flags); } @@ -276,4 +278,4 @@ namespace mbts.spark { } } } -} +} \ No newline at end of file diff --git a/src/client/spark/Notifications/INotificationService.cs b/src/client/spark/Notifications/INotificationService.cs index 7f5decc95..a95ac2048 100644 --- a/src/client/spark/Notifications/INotificationService.cs +++ b/src/client/spark/Notifications/INotificationService.cs @@ -12,7 +12,6 @@ using System.Collections.Generic; using System.ComponentModel.Composition; using System.Linq; using System.Reactive.Linq; -using OrderTuple = System.ValueTuple; namespace bts.shell { interface INotificationService { @@ -20,40 +19,14 @@ namespace bts.shell { INotificationServiceDataCache data_cache { get; } IDisposable link_to_activity(IPredicate predicate, SoundNotification sound); IDisposable link_to_activity(INotificationPredicate toast_notification_predicate); - IDisposable link_to_order(IPredicate predicate, SoundNotification sound); - IDisposable link_to_order(INotificationPredicate toast_notification_predicate); - } - - static class NotificationServiceExtensions { - /// TODO: remove this extension and force callers to use the appropriate 'link' method in (it is smelly, and is NOT ACTUALLY STRONGLY TYPED) - public static IDisposable link(this INotificationService notification_service, IPredicate predicate, SoundNotification sound) { - if (predicate is IPredicate orp) - return notification_service.link_to_order(orp, sound); - if (predicate is IPredicate osp) { - // Note: watch out for implicit types as generic type arguments (although OrderSecurity can be implicitly cast to OrderTuple, IPredicate CANNOT be implicitly cast to IPredicate) - return notification_service.link_to_order(PredicateBuilder.create(ot => osp.trigger(new OrderSecurity(ot.Item1, ot.Item2))), sound); - } - if (predicate is IPredicate ap) - return notification_service.link_to_activity(ap, sound); - Log.Ui.error($"Unable to activate sound-trigger (unrecognized predicate type '{typeof(T)}')."); - return Disposable.empty; - } - - /// TODO: remove this extension and force callers to use the appropriate 'link' method in (it is smelly, and is NOT ACTUALLY STRONGLY TYPED) - public static IDisposable link(this INotificationService notification_service, INotificationPredicate toast_notification_predicate) { - if (toast_notification_predicate is INotificationPredicate orp) - return notification_service.link_to_order(orp); - if (toast_notification_predicate is INotificationPredicate ap) - return notification_service.link_to_activity(ap); - Log.Ui.error($"Unable to activate toast-notification-trigger (unrecognized predicate type '{typeof(T)}')."); - return Disposable.empty; - } + IDisposable link_to_order(IPredicate predicate, SoundNotification sound); + IDisposable link_to_order(INotificationPredicate toast_notification_predicate); } [Export(typeof(INotificationService))] partial class NotificationService : INotificationService, IDisposable { readonly NotificationProcessor _activity_notifications; - readonly NotificationProcessor _order_notifications; + readonly NotificationProcessor _order_notifications; readonly DataCache _data_cache = new DataCache(); IDisposable _dispose; @@ -62,7 +35,7 @@ namespace bts.shell { public NotificationService(IBus bus, INotifier notifier, OrdersModel orders_model) { this.notifier = notifier; _activity_notifications = new NotificationProcessor(notifier); - _order_notifications = new NotificationProcessor(notifier); + _order_notifications = new NotificationProcessor(notifier); _dispose = Disposable.Create( bus.subscribe(SparkTags.LogActivity).Subscribe(_on_activity), orders_model.on_orders.Subscribe(_on_orders) @@ -75,8 +48,8 @@ namespace bts.shell { public IDisposable link_to_activity(IPredicate predicate, SoundNotification sound) => _activity_notifications.link(predicate, sound); public IDisposable link_to_activity(INotificationPredicate toast_notification_predicate) => _activity_notifications.link(toast_notification_predicate); - public IDisposable link_to_order(IPredicate predicate, SoundNotification sound) => _order_notifications.link(predicate, sound); - public IDisposable link_to_order(INotificationPredicate toast_notification_predicate) => _order_notifications.link(toast_notification_predicate); + public IDisposable link_to_order(IPredicate predicate, SoundNotification sound) => _order_notifications.link(predicate, sound); + public IDisposable link_to_order(INotificationPredicate toast_notification_predicate) => _order_notifications.link(toast_notification_predicate); public void Dispose() => Disposable.dispose(ref _dispose); void _on_activity(Activity activity) => diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs index 2b6d7a645..ee9025e06 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs @@ -22,7 +22,6 @@ namespace mbts.ui { // readonly IBus _bus; readonly OrdersModel _orders_model; - readonly INotificationService _notification_service; readonly List _notification_subs = new List(); readonly ObservableCollection _columns; readonly ObservableCollection _rows; @@ -38,13 +37,14 @@ namespace mbts.ui { readonly Func> _create_predicate_vm; readonly Func> _create_column_predicate_vm; readonly Func>, TSettingsData> _create_settings_obj; + readonly Func, SoundNotification, IDisposable> _link_sound; + readonly Func, IDisposable> _link_toast_notification; readonly IReadOnlyDictionary _column_flags; IEnumerable> _predicate_animations_data; public GridSettingsManager( IObservable owner_title, IBus bus, - INotificationService notification_service, OrdersModel orders_model, ObservableCollection rows, ObservableCollection columns, @@ -54,10 +54,11 @@ namespace mbts.ui { Func>, TSettingsData> create_settings_obj, Func> predicate_factory, Func> notification_predicate_factory, + Func, SoundNotification, IDisposable> link_sound, + Func, IDisposable> link_toast_notification, IReadOnlyDictionary column_flags = null) { // _bus = bus; - _notification_service = notification_service; _orders_model = orders_model; _rows = rows; _columns = columns; @@ -67,6 +68,8 @@ namespace mbts.ui { _create_predicate_vm = create_predicate_vm; _create_column_predicate_vm = create_column_predicate_vm; _create_settings_obj = create_settings_obj; + _link_sound = link_sound; + _link_toast_notification = link_toast_notification; _column_flags = column_flags.ToDictionary(kv => kv.Key, kv => ImmutableColumnSettingStore.create(kv.Value)); _grid_settings = backing(nameof(grid_settings), GridSettings.Default); _font_family = backing(nameof(font_family), () => new FontFamily(grid_settings.font_family), nameof(grid_settings)); @@ -117,11 +120,11 @@ namespace mbts.ui { if (predicate == null) continue; foreach (var s in pa.sound_notifications) { - _notification_subs.Add(_notification_service.link(predicate, s)); + _notification_subs.Add(_link_sound(predicate, s)); } var notification_predicate = _notification_predicate_factory(pa.predicate_data); if (notification_predicate != null) - _notification_subs.Add(_notification_service.link(notification_predicate)); + _notification_subs.Add(_link_toast_notification(notification_predicate)); } // ** in the unfortunate event that we botch backwards compatability, and the columns don't bear a 1:1 relationship with the column-settings // don't add insult to injury by crashing ** From 1fd5e51b9e5068b5ab88355c4145d255a82c86d3 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Tue, 19 Mar 2019 15:23:40 -0400 Subject: [PATCH 32/72] reenabled cme, now we can get both ice and cme --- src/lib/config/defaults/MarketData.conf | 9 +++- src/lib/config/defaults/Symbols.conf | 44 +++++++++---------- .../sparkd/md/platforms/IMDPlatform.cpp | 8 ++++ src/server/sparkd/md/platforms/IMDPlatform.h | 12 +++++ .../sparkd/md/platforms/ice_onixs/ICEMain.cpp | 19 +++----- .../sparkd/md/platforms/ice_onixs/ICEMain.h | 8 ++-- .../md/platforms/mdp3_onixs/MDP3Main.cpp | 27 ++++-------- .../sparkd/md/platforms/mdp3_onixs/MDP3Main.h | 7 ++- src/server/sparkd/md/run_md.cpp | 30 ++++++++++--- 9 files changed, 100 insertions(+), 64 deletions(-) create mode 100644 src/server/sparkd/md/platforms/IMDPlatform.cpp create mode 100644 src/server/sparkd/md/platforms/IMDPlatform.h diff --git a/src/lib/config/defaults/MarketData.conf b/src/lib/config/defaults/MarketData.conf index 80a42b405..94b3ba277 100644 --- a/src/lib/config/defaults/MarketData.conf +++ b/src/lib/config/defaults/MarketData.conf @@ -44,10 +44,17 @@ ICEPublisherOptions { } } +#to make this work in dev clone the operations repo +#go here: c:\\code\\bts\\operations\\ice\\ICE_iMpactMulticastFeed_GettingStarted-1_1_36\\bin\\easyTunnel> +#modify the easyTunnelProxy.properties file to replace +#tunnel.multicast.interface=10.96.18.37 with your local ip +#run easyTunnelProxy.bat BRENT-FI for Brent Full implied +#you should see ice data + ICEOptions { value { channel { - name: "oil" + name: "oil" #these names are arbitrary and are for debugging market_type: 5 #ICE Futures Brent, IPE Brent Futures market_type: 9 #ICE Futures WTI, ICE WTI Crude Futures #udp_buffer_size: 33554432 #32mb diff --git a/src/lib/config/defaults/Symbols.conf b/src/lib/config/defaults/Symbols.conf index c58ac27e2..8ee2ab389 100644 --- a/src/lib/config/defaults/Symbols.conf +++ b/src/lib/config/defaults/Symbols.conf @@ -14,28 +14,28 @@ SymbolLists { key: "GLBX" - # symbol: "HE" - # symbol: "LE" - # symbol: "CL" - # symbol: "RB" - # symbol: "HO" - # symbol: "BZ" - # symbol: "NG" - # symbol: "GC" - # symbol: "SI" - # symbol: "HG" - # symbol: "ZW" - # symbol: "ZC" - # symbol: "ZS" - # symbol: "ZM" - # symbol: "ZL" - # symbol: "ZO" - # symbol: "ZR" - # symbol: "ZB" - # symbol: "ZN" - # symbol: "ZF" - # symbol: "ZT" - # symbol: "UB" + symbol: "HE" + symbol: "LE" + symbol: "CL" + symbol: "RB" + symbol: "HO" + symbol: "BZ" + symbol: "NG" + symbol: "GC" + symbol: "SI" + symbol: "HG" + symbol: "ZW" + symbol: "ZC" + symbol: "ZS" + symbol: "ZM" + symbol: "ZL" + symbol: "ZO" + symbol: "ZR" + symbol: "ZB" + symbol: "ZN" + symbol: "ZF" + symbol: "ZT" + symbol: "UB" } } } diff --git a/src/server/sparkd/md/platforms/IMDPlatform.cpp b/src/server/sparkd/md/platforms/IMDPlatform.cpp new file mode 100644 index 000000000..3c0949e1d --- /dev/null +++ b/src/server/sparkd/md/platforms/IMDPlatform.cpp @@ -0,0 +1,8 @@ +#include "IMDPlatform.h" + +namespace bts { +namespace md { + +void IMDPlatform::send_heartbeats() {} + +}} \ No newline at end of file diff --git a/src/server/sparkd/md/platforms/IMDPlatform.h b/src/server/sparkd/md/platforms/IMDPlatform.h new file mode 100644 index 000000000..df4840f30 --- /dev/null +++ b/src/server/sparkd/md/platforms/IMDPlatform.h @@ -0,0 +1,12 @@ +#pragma once + +namespace bts { +namespace md { + +class IMDPlatform +{ +public: + virtual void send_heartbeats(); +}; + +}} \ No newline at end of file diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp index 794029456..c44ad0d3a 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp @@ -82,7 +82,7 @@ onixs_ice::MarketSubscriptions market_subcription_for_channel(const ICEChannel& } -void ICEMain::run(std::vector& symbols) +void ICEMain::start(std::vector& symbols) { // License path and config file auto license_location = os::bts_data_path() + "/licenses/"; @@ -120,18 +120,13 @@ void ICEMain::run(std::vector& symbols) onixs_ice::MarketSubscriptions subs = market_subcription_for_channel(pair.first); pair.second->start(subs); } - - // - // Timers - auto& disp = utils::Dispatcher::current(); - utils::DispatcherTimer heartbeat_timer(disp, 250, [&]() - { - for (const auto& listener: _listeners) - listener->heartbeat(); - }); - heartbeat_timer.start(); LOG(md,Info, "** ICE Publisher started **"); - disp.run(); +} + +void ICEMain::send_heartbeats() +{ + for (const auto& listener: _listeners) + listener->heartbeat(); } // // diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h index 4b974a9d5..ec6f1dfb8 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h @@ -4,6 +4,7 @@ #include "lib/md/coconut2.h" #include "ICEListener.h" #include "ICESecurityIndex.h" +#include "server/sparkd/md/platforms/IMDPlatform.h" #include "onixs.h" #include @@ -24,14 +25,15 @@ struct ICEChannel; * There is a single listener for all callbacks which maps the exchange id to the MDProducerHandle and writes * the data to it. */ -class ICEMain +class ICEMain : public IMDPlatform { public: ICEMain(); ~ICEMain(); - void run(std::vector&); - void initialize(); + void start(std::vector&); + void send_heartbeats() override; + std::unique_ptr prepare_handler(const ICEChannel& channel); std::unique_ptr prepare_listener(onixs_ice::Handler& handler, const ICEChannel& channel); diff --git a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.cpp b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.cpp index 7c0db2832..0ea409588 100644 --- a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.cpp +++ b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.cpp @@ -130,7 +130,7 @@ onixs::SessionSettings session_settings_for_channel(const string& channel_id) { return settings; } -void MDP3Main::run(std::vector& symbols) { +void MDP3Main::start(std::vector& symbols) { await_cme_config(); initialize(); const auto& channels = parse_channels(symbols); @@ -148,30 +148,19 @@ void MDP3Main::run(std::vector& symbols) { onixs::SessionSettings settings = session_settings_for_channel(pair.first); pair.second->start(settings); } + LOG(md,Info, "** CME MDP3 Publisher started **"); +} - // - // Timers - - auto& disp = utils::Dispatcher::current(); - +void MDP3Main::send_heartbeats() { + for (const auto& listener: _listeners) + listener->heartbeat(); + // utils::DispatcherTimer settlement_timer(disp, 100, [&]() { // _settlement_recorder.do_work(); // }); - // settlement_timer.start(); - - utils::DispatcherTimer heartbeat_timer(disp, 250, [&]() { - for (const auto& listener: _listeners) { - listener->heartbeat(); - } - }); - heartbeat_timer.start(); - - LOG(md,Info, "** CME MDP3 Publisher started **"); - - disp.run(); + // settlement_timer.start(); } - void MDP3Main::initialize() { const auto& options = config::get(); auto license_location = os::bts_data_path() + "/licenses/"; diff --git a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.h b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.h index 4eb1fbf62..974d01bc8 100644 --- a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.h +++ b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.h @@ -4,6 +4,7 @@ #include "lib/md/coconut2.h" #include "MDP3Listener.h" #include "CMESecurityIndex.h" +#include "server/sparkd/md/platforms/IMDPlatform.h" #include "onixs.h" #include @@ -23,13 +24,15 @@ struct CMEChannel; * There is a single listener for all callbacks which maps the exchange id to the MDProducerHandle and writes * the data to it. */ -class MDP3Main +class MDP3Main : public IMDPlatform { public: MDP3Main(); ~MDP3Main(); - void run(std::vector&); + void start(std::vector&); + void send_heartbeats() override; + void initialize(); std::unique_ptr prepare_handler(const std::string& channel); std::unique_ptr prepare_listener(onixs::Handler& handler, const CMEChannel& channel); diff --git a/src/server/sparkd/md/run_md.cpp b/src/server/sparkd/md/run_md.cpp index 16d13a876..89994f057 100644 --- a/src/server/sparkd/md/run_md.cpp +++ b/src/server/sparkd/md/run_md.cpp @@ -12,6 +12,7 @@ #include "lib/md/cme/MDP3Utils.h" #include "platforms/mdp3_onixs/MDP3Main.h" #include "platforms/ice_onixs/ICEMain.h" +#include "platforms/IMDPlatform.h" #include "lib/md/SecurityDB.h" #include "server/sparkd/exchange_sim/ExchangeSim.h" #include "lib/utils/thread_manager.h" @@ -20,6 +21,7 @@ #include #include #include +#include #include using namespace bts; @@ -66,23 +68,41 @@ void run_replay() { replay_recording(file, naggle_ms, fallback_path); } -void run_onixs() { +void run_onixs() +{ + std::vector> platforms; // get all glbx symbols std::vector cme_symbols; get_system_md_symbols(api::VENUE_GLBX, api::SECURITYTYPE_UNSET, &cme_symbols); if(cme_symbols.size() > 0) { - MDP3Main main; - //main.run(symbols); TODO + MDP3Main* main = new MDP3Main(); + std::shared_ptr ptr(main); + main->start(cme_symbols); + platforms.push_back(ptr); } std::vector ice_symbols; get_system_md_symbols(api::VENUE_ICE, api::SECURITYTYPE_UNSET, &ice_symbols); if(ice_symbols.size() > 0) { - ice::ICEMain imain; - imain.run(ice_symbols); + ice::ICEMain* imain = new ice::ICEMain(); + std::shared_ptr ptr(imain); + imain->start(ice_symbols); + platforms.push_back(ptr); } + + // + // Timers + auto& disp = utils::Dispatcher::current(); + utils::DispatcherTimer heartbeat_timer(disp, 250, [&]() + { + for (auto& p: platforms) + p->send_heartbeats(); + }); + heartbeat_timer.start(); + + disp.run(); } void run_cleanup() { From c1887b97864b6345c90c31a663f3a8bf187578db Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Tue, 19 Mar 2019 15:28:11 -0400 Subject: [PATCH 33/72] launch.json --- .vscode/launch.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 84ec3ec01..040301b9c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -80,9 +80,7 @@ "args": ["run"], "stopAtEntry": false, "cwd": "/home/bts/spark/build/ninja_debug/server/", - "environment": [ - {"name":"LD_LIBRARY_PATH", "value": "."} - ], + "environment": [], "externalConsole": true, "MIMode": "gdb", "preLaunchTask": "", From ee2f76553b402dc000a43906fe7f53d3aa59c94c Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Tue, 19 Mar 2019 17:54:37 -0400 Subject: [PATCH 34/72] tests pass --- .vscode/launch.json | 4 ++-- src/client/spark_api/Co2/MDConsumerHandle.cs | 2 +- src/lib/config/protos/MarketData.proto | 2 +- src/lib/md/PlatformLoader.cpp | 6 ++++-- src/lib/md/Shm/FixedSecurity.cpp | 2 ++ src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 040301b9c..fd68a6626 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -214,10 +214,10 @@ "name": "MD Tests", "type": "cppdbg", "request": "launch", - "program": "/home/bts/spark/build/ninja_debug/src/server/sparkd/sparkd", + "program": "/home/bts/spark/build/ninja_debug/server/sparkd", "args": ["test", "[md]"], "stopAtEntry": false, - "cwd": "/home/bts/spark/build/ninja_debug/src/server/sparkd/", + "cwd": "/home/bts/spark/build/ninja_debug/server/", "environment": [], "externalConsole": true, "MIMode": "gdb", diff --git a/src/client/spark_api/Co2/MDConsumerHandle.cs b/src/client/spark_api/Co2/MDConsumerHandle.cs index 3f5c6502e..4a12f2f99 100644 --- a/src/client/spark_api/Co2/MDConsumerHandle.cs +++ b/src/client/spark_api/Co2/MDConsumerHandle.cs @@ -244,7 +244,7 @@ namespace mbts.co2 { } } - [StructLayout(LayoutKind.Sequential, Size = 376)] + [StructLayout(LayoutKind.Sequential, Size = 704)] internal struct ColdEntry { public int exchange_status; // Last trade diff --git a/src/lib/config/protos/MarketData.proto b/src/lib/config/protos/MarketData.proto index 175f3a33f..be967e9d4 100755 --- a/src/lib/config/protos/MarketData.proto +++ b/src/lib/config/protos/MarketData.proto @@ -136,7 +136,7 @@ message CMEOptions } // -// CME Options +// ICE Options // message ICEOptions { diff --git a/src/lib/md/PlatformLoader.cpp b/src/lib/md/PlatformLoader.cpp index 87475254d..4188210f5 100644 --- a/src/lib/md/PlatformLoader.cpp +++ b/src/lib/md/PlatformLoader.cpp @@ -208,11 +208,13 @@ extern "C" BTS_EXPORT Platform platform_for_exchange(Venue v) { co2::Platform platform; if (v == VENUE_SIM) return PLATFORM_SIM; - if (v == VENUE_GLBX && co2::Platform_Parse(pmap.glbx_platform(), &platform)) - return platform; if (v == VENUE_ICE && co2::Platform_Parse(pmap.ice_platform(), &platform)) return platform; + //md2_tests.cpp depends on this fall through to yield SIM as the GLBX platform + if (co2::Platform_Parse(pmap.glbx_platform(), &platform)) + return platform; + return PLATFORM_UNSET; } diff --git a/src/lib/md/Shm/FixedSecurity.cpp b/src/lib/md/Shm/FixedSecurity.cpp index 14f9da614..a159e291a 100644 --- a/src/lib/md/Shm/FixedSecurity.cpp +++ b/src/lib/md/Shm/FixedSecurity.cpp @@ -31,6 +31,8 @@ FixedSecurity::FixedSecurity() : cme_main_fraction(0), cme_sub_fraction(0), cme_price_display_format(0), + ice_deal_display_factor(0), + ice_settle_display_factor(0), _symbol(), _cfi_code(), _security_desc(), diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp index 1d91cfe5b..922ed11da 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp @@ -241,7 +241,7 @@ void ICEListener::onRfq(const onixs_ice::Rfq& msg, const onixs_ice::MessageInfo& long long rfqid = msg.rfqSystemId; message.set_request_id(std::to_string(rfqid)); - // https://www.cmegroup.com/confluence/display/EPICSANDBOX/MDP+3.0+-+Request+for+Quote + //https://ref.onixs.biz/cpp-ice-impact-handler-guide/struct_onix_s_1_1_i_c_e_1_1i_mpact_1_1_market_data_1_1_side.html#a8150b7776c2a1749101acf22e868d091 switch(msg.side) { case ' ': From 0ef44e92aab251919bddc6f2d0f838354aa383fb Mon Sep 17 00:00:00 2001 From: John Colvin Date: Wed, 20 Mar 2019 10:46:47 -0500 Subject: [PATCH 35/72] SPARK-2160 pr edit: refer to 'source_window_rect' for width/height params instead of window (easy way to avoid extra dp lookups) --- src/client/spark/view/Extensions/WindowExtensions.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/spark/view/Extensions/WindowExtensions.cs b/src/client/spark/view/Extensions/WindowExtensions.cs index 5b4c15049..dd2608223 100644 --- a/src/client/spark/view/Extensions/WindowExtensions.cs +++ b/src/client/spark/view/Extensions/WindowExtensions.cs @@ -164,17 +164,17 @@ namespace mbts.ui var intersection = Rect.Intersect(task_bar_rect, source_window_rect); const double error_margin = 0.00005; int nudge_direction = 0; - if ((window.Width - intersection.Width) > error_margin) { + if ((source_window_rect.Width - intersection.Width) > error_margin) { // 1 = task bar on left, so nudge right // -1 = task on right, so nuedge left nudge_direction = (task_bar_rect.Left == 0) ? 1 : -1; - window.Left = window.Left + nudge_direction * intersection.Width; + window.Left = source_window_rect.Left + nudge_direction * intersection.Width; } - if ((window.Height - intersection.Height) > error_margin) { + if ((source_window_rect.Height - intersection.Height) > error_margin) { // 1 = task bar on top, so nudge down // -1 = task on bottom, so nuedge up nudge_direction = (task_bar_rect.Top == 0) ? 1 : -1; - window.Top = window.Top + nudge_direction * intersection.Height; + window.Top = source_window_rect.Top + nudge_direction * intersection.Height; } // update the rect w/ the new window position to see if we have to go another round source_window_rect = new Rect(window.Left, window.Top, window.ActualWidth, window.ActualHeight); From 5d6421345556e5395e35e4c1493a7f7b057d8b9b Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 21 Mar 2019 13:40:21 -0500 Subject: [PATCH 36/72] Adding new SparkConfirmationCommandParamObserver, which adds a confirmation func to SparkCommandParamObserver --- src/client/spark/core/Bus/SparkCommand.cs | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/client/spark/core/Bus/SparkCommand.cs b/src/client/spark/core/Bus/SparkCommand.cs index c648f0fe1..b99a6930c 100644 --- a/src/client/spark/core/Bus/SparkCommand.cs +++ b/src/client/spark/core/Bus/SparkCommand.cs @@ -78,11 +78,17 @@ namespace bts.spark { public static SparkCommandParamObserver create(string title, ImageSource icon, ITag tag, IObservable parameter, Func can_execute) => create(title, icon, tag, parameter, parameter.Select(can_execute)); + public static SparkConfirmationCommandParamObserver create(string title, ImageSource icon, ITag tag, (Func confirm, IObservable source) confirm_and_source, Func can_execute) => + create(title, icon, tag, confirm_and_source, confirm_and_source.source.Select(can_execute)); + public static SparkCommandParamObserver create(string title, ImageSource icon, ITag tag, IObservable parameter_source, Func parameter_source_where, Func parameter_selector) => create(title, icon, tag, parameter_source.Select(parameter_selector), parameter_source.Select(parameter_source_where)); public static SparkCommandParamObserver create(string title, ImageSource icon, ITag tag, IObservable parameter, IObservable can_execute) => new SparkCommandParamObserver(title, icon, tag, parameter, can_execute); + + public static SparkConfirmationCommandParamObserver create(string title, ImageSource icon, ITag tag, (Func confirm, IObservable source) confirm_and_source, IObservable can_execute) => + new SparkConfirmationCommandParamObserver(title, icon, tag, confirm_and_source, can_execute); } public static class SparkCommandExtensions { @@ -132,11 +138,17 @@ namespace bts.spark { public SparkCommandParamObserver complete(IObservable value, Func can_execute) => SparkCommand.create(title, icon, tag, value, can_execute); + public SparkConfirmationCommandParamObserver complete((Func confirm, IObservable source) confirm_and_source, Func can_execute) => + SparkCommand.create(title, icon, tag, confirm_and_source, can_execute); + public SparkCommandParamObserver complete(IObservable value_source, Func value_source_where, Func value_selector) => SparkCommand.create(title, icon, tag, value_source, value_source_where, value_selector); public SparkCommandParamObserver complete(IObservable parameter, IObservable can_execute) => SparkCommand.create(title, icon, tag, parameter, can_execute); + + public SparkConfirmationCommandParamObserver complete((Func confirm, IObservable source) confirm_and_source, IObservable can_execute) => + SparkCommand.create(title, icon, tag, confirm_and_source, can_execute); } public class SparkCommandWrapper : SparkCommand, IDisposable { @@ -221,6 +233,38 @@ namespace bts.spark { } } + public class SparkConfirmationCommandParamObserver : SparkCommand, IDisposable { + public SparkConfirmationCommandParamObserver(string title, ImageSource icon, ITag tag, (Func confirm, IObservable source) confirm_and_source, IObservable can_execute) : base(title, icon) { + _tag = tag; + _confirm_execute = confirm_and_source.confirm; + _subs = Disposable.Create( + confirm_and_source.source.OnDispatcher().Subscribe(p => _parameter = p), + can_execute.OnDispatcher().Subscribe(ce => { + _can_execute = ce; + raiseCanExecuteChanged(); + }) + ); + } + + readonly ITag _tag; + IDisposable _subs; + T _parameter; + bool _can_execute; + Func _confirm_execute; + + public override bool canExecute() => _can_execute; + public override void execute(IBus bus) { + if (_can_execute && _confirm_execute()) { + try { + bus.post(_tag, _parameter); + } catch (Exception e) { + Log.Ui.warn($"Error invoking command '{title}' - Exception: '{e}'"); + } + } + } + public void Dispose() => Disposable.dispose(ref _subs); + } + public class SparkCommandParamObserver : SparkCommand, IDisposable { public SparkCommandParamObserver(string title, ImageSource icon, ITag tag, IObservable parameter, IObservable can_execute) : base(title, icon) { _tag = tag; From 6b17efee6093fc4225d922d0fdb1115249a10ff8 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 21 Mar 2019 13:44:17 -0500 Subject: [PATCH 37/72] Converting cancel all command to new SparkConfirmationCommandParamObserver --- .../Modules/Trading/OrderBook/OrderBookWindow.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs index d0a878a08..028083b36 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs @@ -96,7 +96,17 @@ namespace mbts.spark { ); _cancel_all_orders_command = SparkCommands.CancelOrders.complete( - _model.working_orders.Select(os => os.Select(o => o.Key)), + ( + () => { + var resp = BTSMessageBox.Show( + "Are you sure you want to cancel all working orders?", + "Cancel Orders", + BTSMessageBoxButtons.Yes | BTSMessageBoxButtons.No, + MessageBoxImage.Question); + return resp == BTSMessageBoxButtons.Yes; + }, + _model.working_orders.Select(os => os.Select(o => o.Key)) + ), worders => worders.Any() ); From 16cf4554c519a38dfe875159d71d0e5942456dcd Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 21 Mar 2019 14:24:32 -0500 Subject: [PATCH 38/72] refactoring into a much simpler implementation --- .../Trading/OrderBook/OrderBookWindow.cs | 22 ++++---- src/client/spark/core/Bus/SparkCommand.cs | 55 ++++--------------- 2 files changed, 21 insertions(+), 56 deletions(-) diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs index 028083b36..4330da734 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs @@ -96,18 +96,16 @@ namespace mbts.spark { ); _cancel_all_orders_command = SparkCommands.CancelOrders.complete( - ( - () => { - var resp = BTSMessageBox.Show( - "Are you sure you want to cancel all working orders?", - "Cancel Orders", - BTSMessageBoxButtons.Yes | BTSMessageBoxButtons.No, - MessageBoxImage.Question); - return resp == BTSMessageBoxButtons.Yes; - }, - _model.working_orders.Select(os => os.Select(o => o.Key)) - ), - worders => worders.Any() + _model.working_orders.Select(os => os.Select(o => o.Key)), + worders => worders.Any(), + () => { + var resp = BTSMessageBox.Show( + "Are you sure you want to cancel all working orders?", + "Cancel Orders", + BTSMessageBoxButtons.Yes | BTSMessageBoxButtons.No, + MessageBoxImage.Question); + return resp == BTSMessageBoxButtons.Yes; + } ); _cancel_selected_orders_command = SparkCommands.CancelSelectedOrders.complete( diff --git a/src/client/spark/core/Bus/SparkCommand.cs b/src/client/spark/core/Bus/SparkCommand.cs index b99a6930c..e3ecd67fe 100644 --- a/src/client/spark/core/Bus/SparkCommand.cs +++ b/src/client/spark/core/Bus/SparkCommand.cs @@ -78,17 +78,15 @@ namespace bts.spark { public static SparkCommandParamObserver create(string title, ImageSource icon, ITag tag, IObservable parameter, Func can_execute) => create(title, icon, tag, parameter, parameter.Select(can_execute)); - public static SparkConfirmationCommandParamObserver create(string title, ImageSource icon, ITag tag, (Func confirm, IObservable source) confirm_and_source, Func can_execute) => - create(title, icon, tag, confirm_and_source, confirm_and_source.source.Select(can_execute)); + public static SparkCommandParamObserver create(string title, ImageSource icon, ITag tag, IObservable parameter, Func can_execute, Func is_confirmation_affirmed) => + create(title, icon, tag, parameter, parameter.Select(can_execute), is_confirmation_affirmed); public static SparkCommandParamObserver create(string title, ImageSource icon, ITag tag, IObservable parameter_source, Func parameter_source_where, Func parameter_selector) => create(title, icon, tag, parameter_source.Select(parameter_selector), parameter_source.Select(parameter_source_where)); - public static SparkCommandParamObserver create(string title, ImageSource icon, ITag tag, IObservable parameter, IObservable can_execute) => - new SparkCommandParamObserver(title, icon, tag, parameter, can_execute); + public static SparkCommandParamObserver create(string title, ImageSource icon, ITag tag, IObservable parameter, IObservable can_execute, Func is_confirmation_affirmed = null) => + new SparkCommandParamObserver(title, icon, tag, parameter, can_execute, is_confirmation_affirmed); - public static SparkConfirmationCommandParamObserver create(string title, ImageSource icon, ITag tag, (Func confirm, IObservable source) confirm_and_source, IObservable can_execute) => - new SparkConfirmationCommandParamObserver(title, icon, tag, confirm_and_source, can_execute); } public static class SparkCommandExtensions { @@ -138,8 +136,8 @@ namespace bts.spark { public SparkCommandParamObserver complete(IObservable value, Func can_execute) => SparkCommand.create(title, icon, tag, value, can_execute); - public SparkConfirmationCommandParamObserver complete((Func confirm, IObservable source) confirm_and_source, Func can_execute) => - SparkCommand.create(title, icon, tag, confirm_and_source, can_execute); + public SparkCommandParamObserver complete(IObservable value, Func can_execute, Func is_confirmation_affirmed) => + SparkCommand.create(title, icon, tag, value, can_execute, is_confirmation_affirmed); public SparkCommandParamObserver complete(IObservable value_source, Func value_source_where, Func value_selector) => SparkCommand.create(title, icon, tag, value_source, value_source_where, value_selector); @@ -147,8 +145,6 @@ namespace bts.spark { public SparkCommandParamObserver complete(IObservable parameter, IObservable can_execute) => SparkCommand.create(title, icon, tag, parameter, can_execute); - public SparkConfirmationCommandParamObserver complete((Func confirm, IObservable source) confirm_and_source, IObservable can_execute) => - SparkCommand.create(title, icon, tag, confirm_and_source, can_execute); } public class SparkCommandWrapper : SparkCommand, IDisposable { @@ -233,41 +229,10 @@ namespace bts.spark { } } - public class SparkConfirmationCommandParamObserver : SparkCommand, IDisposable { - public SparkConfirmationCommandParamObserver(string title, ImageSource icon, ITag tag, (Func confirm, IObservable source) confirm_and_source, IObservable can_execute) : base(title, icon) { - _tag = tag; - _confirm_execute = confirm_and_source.confirm; - _subs = Disposable.Create( - confirm_and_source.source.OnDispatcher().Subscribe(p => _parameter = p), - can_execute.OnDispatcher().Subscribe(ce => { - _can_execute = ce; - raiseCanExecuteChanged(); - }) - ); - } - - readonly ITag _tag; - IDisposable _subs; - T _parameter; - bool _can_execute; - Func _confirm_execute; - - public override bool canExecute() => _can_execute; - public override void execute(IBus bus) { - if (_can_execute && _confirm_execute()) { - try { - bus.post(_tag, _parameter); - } catch (Exception e) { - Log.Ui.warn($"Error invoking command '{title}' - Exception: '{e}'"); - } - } - } - public void Dispose() => Disposable.dispose(ref _subs); - } - public class SparkCommandParamObserver : SparkCommand, IDisposable { - public SparkCommandParamObserver(string title, ImageSource icon, ITag tag, IObservable parameter, IObservable can_execute) : base(title, icon) { + public SparkCommandParamObserver(string title, ImageSource icon, ITag tag, IObservable parameter, IObservable can_execute, Func is_confirmation_affirmed = null) : base(title, icon) { _tag = tag; + _is_confirmation_affirmed = is_confirmation_affirmed; _subs = Disposable.Create( parameter.OnDispatcher().Subscribe(p => _parameter = p), can_execute.OnDispatcher().Subscribe(ce => { @@ -281,10 +246,12 @@ namespace bts.spark { IDisposable _subs; T _parameter; bool _can_execute; + Func _is_confirmation_affirmed; + public override bool canExecute() => _can_execute; public override void execute(IBus bus) { - if (_can_execute) { + if (_can_execute && _is_confirmation_affirmed == null || _can_execute && _is_confirmation_affirmed()) { try { bus.post(_tag, _parameter); } catch (Exception e) { From 8d49de3f611c00e794823c2c95fbb39952d82c21 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 21 Mar 2019 14:31:59 -0500 Subject: [PATCH 39/72] simplying boolean comparison --- src/client/spark/core/Bus/SparkCommand.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/spark/core/Bus/SparkCommand.cs b/src/client/spark/core/Bus/SparkCommand.cs index e3ecd67fe..52ba97d10 100644 --- a/src/client/spark/core/Bus/SparkCommand.cs +++ b/src/client/spark/core/Bus/SparkCommand.cs @@ -251,7 +251,7 @@ namespace bts.spark { public override bool canExecute() => _can_execute; public override void execute(IBus bus) { - if (_can_execute && _is_confirmation_affirmed == null || _can_execute && _is_confirmation_affirmed()) { + if (_can_execute && (_is_confirmation_affirmed == null || _is_confirmation_affirmed())) { try { bus.post(_tag, _parameter); } catch (Exception e) { From 766116eac453ed77dbcadf7d040ac148b94ab0cf Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Fri, 22 Mar 2019 09:33:49 -0500 Subject: [PATCH 40/72] adding confirmation to OB cancel buys and cancel sells --- .../Trading/OrderBook/OrderBookWindow.cs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs index 4330da734..d1472349d 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs @@ -87,12 +87,28 @@ namespace mbts.spark { _cancel_buy_orders_command = SparkCommands.CancelBuyOrders.complete( _model.working_orders.Select(os => os.Values.Where(o => o.order.side() == Side.Buy).Select(o => o.order.Key)), - wbids => wbids.Any() + wbids => wbids.Any(), + () => { + var resp = BTSMessageBox.Show( + "Are you sure you want to cancel all working buy orders?", + "Cancel Buy Orders", + BTSMessageBoxButtons.Yes | BTSMessageBoxButtons.No, + MessageBoxImage.Question); + return resp == BTSMessageBoxButtons.Yes; + } ); _cancel_sell_orders_command = SparkCommands.CancelSellOrders.complete( _model.working_orders.Select(os => os.Values.Where(o => o.order.side() == Side.Sell).Select(o => o.order.Key)), - wasks => wasks.Any() + wasks => wasks.Any(), + () => { + var resp = BTSMessageBox.Show( + "Are you sure you want to cancel all working sell orders?", + "Cancel Sell Orders", + BTSMessageBoxButtons.Yes | BTSMessageBoxButtons.No, + MessageBoxImage.Question); + return resp == BTSMessageBoxButtons.Yes; + } ); _cancel_all_orders_command = SparkCommands.CancelOrders.complete( @@ -101,7 +117,7 @@ namespace mbts.spark { () => { var resp = BTSMessageBox.Show( "Are you sure you want to cancel all working orders?", - "Cancel Orders", + "Cancel All Orders", BTSMessageBoxButtons.Yes | BTSMessageBoxButtons.No, MessageBoxImage.Question); return resp == BTSMessageBoxButtons.Yes; From ef60d4200a6e172a3630c4c20c23cbfb46e16705 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Fri, 22 Mar 2019 17:56:19 -0400 Subject: [PATCH 41/72] Fix ladder highlighting and aggressor marking in sim --- .../sparkd/exchange_sim/ExchangeSim.cpp | 13 +++--- .../exchange_sim/ExchangeSimApplication.cpp | 43 +++++++++++++++++-- .../exchange_sim/ExchangeSimApplication.h | 6 ++- .../sparkd/exchange_sim/IMDPlayerObserver.h | 6 ++- .../sparkd/exchange_sim/book/OrderMatcher.cpp | 12 ++++-- .../sparkd/exchange_sim/book/OrderMatcher.h | 3 +- 6 files changed, 69 insertions(+), 14 deletions(-) diff --git a/src/server/sparkd/exchange_sim/ExchangeSim.cpp b/src/server/sparkd/exchange_sim/ExchangeSim.cpp index d457d53d5..a60118485 100644 --- a/src/server/sparkd/exchange_sim/ExchangeSim.cpp +++ b/src/server/sparkd/exchange_sim/ExchangeSim.cpp @@ -107,11 +107,14 @@ struct MDPlayer : md::IRelayWriter obs.on_depth(*sec_ptr, bids, asks, nullptr, nullptr); } - if (cr.has_misc()) { - if (cr.misc().has_settlement()) { - const auto& s = cr.misc().settlement(); - obs.on_settlement(*sec_ptr, { s.mantissa(), (int8_t)s.exponent() }); - } + if (cr.has_misc()) { + const auto& s = cr.misc(); + obs.on_high(*sec_ptr, s.session_high()); + obs.on_low(*sec_ptr, s.session_low()); + obs.on_open(*sec_ptr, s.open_price()); + obs.on_close(*sec_ptr, s.close_price()); + if (cr.misc().has_settlement()) + obs.on_settlement(*sec_ptr, { s.settlement().mantissa(), (int8_t)s.settlement().exponent() }); } } } diff --git a/src/server/sparkd/exchange_sim/ExchangeSimApplication.cpp b/src/server/sparkd/exchange_sim/ExchangeSimApplication.cpp index d1863fbaf..64fc7b57b 100644 --- a/src/server/sparkd/exchange_sim/ExchangeSimApplication.cpp +++ b/src/server/sparkd/exchange_sim/ExchangeSimApplication.cpp @@ -483,10 +483,11 @@ void ExchangeSimApplication::update_md(std::string const &sec_desc) { for (auto &t : new_trades) handle.add_trade( utils::TimeStamp::now(), - md::PriceSize_from_double<7>(t.price.value() * price_factor, - t.quantity.value()), + md::PriceSize_from_double(t.price.value() * price_factor,t.quantity.value()), datetime::ll_now(), - co2::AGGRESSOR_SIDE_NONE); + t.bid_aggressor ? co2::AGGRESSOR_SIDE_BUY + : ( t.ask_aggressor ? co2::AGGRESSOR_SIDE_SELL + : co2::AGGRESSOR_SIDE_NONE) ); } } @@ -540,6 +541,42 @@ void ExchangeSimApplication::on_settlement(md::Security const& sec, md::IntPrice } } +void ExchangeSimApplication::on_high(md::Security const& sec, md::Price price) { + auto sec_desc = get_sim_sec_desc(sec); + auto iter = me->md_producer_handles.find(sec_desc); + if (iter != me->md_producer_handles.end()) { + auto &handle = iter->second; + handle.update_session_high(utils::TimeStamp::now(), price); + } +} + +void ExchangeSimApplication::on_low(md::Security const& sec, md::Price price) { + auto sec_desc = get_sim_sec_desc(sec); + auto iter = me->md_producer_handles.find(sec_desc); + if (iter != me->md_producer_handles.end()) { + auto &handle = iter->second; + handle.update_session_low(utils::TimeStamp::now(), price); + } +} + +void ExchangeSimApplication::on_open(md::Security const& sec, md::Price price) { + auto sec_desc = get_sim_sec_desc(sec); + auto iter = me->md_producer_handles.find(sec_desc); + if (iter != me->md_producer_handles.end()) { + auto &handle = iter->second; + handle.update_opening(utils::TimeStamp::now(), price, datetime::today()); + } +} + +void ExchangeSimApplication::on_close(md::Security const& sec, md::Price price) { + auto sec_desc = get_sim_sec_desc(sec); + auto iter = me->md_producer_handles.find(sec_desc); + if (iter != me->md_producer_handles.end()) { + auto &handle = iter->second; + handle.update_closing(utils::TimeStamp::now(), price, datetime::today()); + } +} + void ExchangeSimApplication::on_depth( md::Security const &sec, md::PriceSize bids[md::COCONUT_MAX_DEPTH], diff --git a/src/server/sparkd/exchange_sim/ExchangeSimApplication.h b/src/server/sparkd/exchange_sim/ExchangeSimApplication.h index 90bfa7edf..5261df51f 100644 --- a/src/server/sparkd/exchange_sim/ExchangeSimApplication.h +++ b/src/server/sparkd/exchange_sim/ExchangeSimApplication.h @@ -100,7 +100,11 @@ public: void persist_book(OrderBook const &b); void on_new_security(md::Security const&) override; - void on_settlement(md::Security const&, md::IntPrice) override; + void on_high(md::Security const& sec, md::Price price) override; + void on_low(md::Security const& sec, md::Price price) override; + void on_open(md::Security const& sec, md::Price price) override; + void on_close(md::Security const& sec, md::Price price) override; + void on_settlement(md::Security const&, md::IntPrice) override; void on_depth(md::Security const&s, md::PriceSize bids[md::COCONUT_MAX_DEPTH], md::PriceSize asks[md::COCONUT_MAX_DEPTH], diff --git a/src/server/sparkd/exchange_sim/IMDPlayerObserver.h b/src/server/sparkd/exchange_sim/IMDPlayerObserver.h index b2e194b34..9708d2e75 100644 --- a/src/server/sparkd/exchange_sim/IMDPlayerObserver.h +++ b/src/server/sparkd/exchange_sim/IMDPlayerObserver.h @@ -9,7 +9,11 @@ namespace sim { struct IMDPlayerObserver { virtual void on_new_security(md::Security const&) = 0; - virtual void on_settlement(const md::Security&, md::IntPrice) = 0; + virtual void on_high(const md::Security&, md::Price) = 0; + virtual void on_low(const md::Security&, md::Price) = 0; + virtual void on_open(const md::Security&, md::Price) = 0; + virtual void on_close(const md::Security&, md::Price) = 0; + virtual void on_settlement(const md::Security&, md::IntPrice) = 0; virtual void on_depth(md::Security const&s, md::PriceSize bids[md::COCONUT_MAX_DEPTH], md::PriceSize asks[md::COCONUT_MAX_DEPTH], diff --git a/src/server/sparkd/exchange_sim/book/OrderMatcher.cpp b/src/server/sparkd/exchange_sim/book/OrderMatcher.cpp index a4a5c0977..03681b315 100644 --- a/src/server/sparkd/exchange_sim/book/OrderMatcher.cpp +++ b/src/server/sparkd/exchange_sim/book/OrderMatcher.cpp @@ -195,12 +195,18 @@ void OrderMatcher::match(std::vector *out) { void OrderMatcher::match(Order *bid, Order *ask) { Price price(0); - + bool bid_aggressor = false, ask_aggressor = false; if (utils::pb::greater(bid->last_update_time(), ask->last_update_time())) + { price = Price(ask->price()); + bid_aggressor = true; + } else + { price = Price(bid->price()); - + if(utils::pb::smaller(bid->last_update_time(), ask->last_update_time())) + ask_aggressor = true; + } Quantity quantity; if (bid->open_quantity() > ask->open_quantity()) @@ -208,7 +214,7 @@ void OrderMatcher::match(Order *bid, Order *ask) { else quantity = Quantity(bid->open_quantity()); - me->pending_trades.push_back(Trade{price, quantity}); + me->pending_trades.push_back(Trade{price, quantity, bid_aggressor, ask_aggressor}); execute(bid, price, quantity); execute(ask, price, quantity); } diff --git a/src/server/sparkd/exchange_sim/book/OrderMatcher.h b/src/server/sparkd/exchange_sim/book/OrderMatcher.h index 352afc33a..5c8a93d57 100644 --- a/src/server/sparkd/exchange_sim/book/OrderMatcher.h +++ b/src/server/sparkd/exchange_sim/book/OrderMatcher.h @@ -38,7 +38,8 @@ class OrderMatcher { struct Trade { Price price; - Quantity quantity; + Quantity quantity; + bool bid_aggressor, ask_aggressor; }; std::vector get_new_trades(); std::tuple size() const; From b30f59227e42c1b80101922cda82653785633035 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Fri, 22 Mar 2019 23:11:01 -0400 Subject: [PATCH 42/72] note to reference jetfix on the precision --- src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h index aff669a64..7efa7b049 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h @@ -26,7 +26,7 @@ template IntPrice convert_price(const OnixsPrice& price, int8_t display_factor) { double dbl = double_of_price(price, display_factor); - const int PRECISION = 7; + const int PRECISION = 7; //TODO config::get().connection() case ICE auto intpx = md::IntPrice_from_double(dbl); return intpx; } From d75ab3a63fb692ac912af5a0a41a41ed2cae1e1c Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Fri, 22 Mar 2019 23:12:24 -0400 Subject: [PATCH 43/72] default to no ice symbols --- src/lib/config/defaults/Symbols.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/config/defaults/Symbols.conf b/src/lib/config/defaults/Symbols.conf index 8ee2ab389..c1edec1bd 100644 --- a/src/lib/config/defaults/Symbols.conf +++ b/src/lib/config/defaults/Symbols.conf @@ -6,9 +6,9 @@ SymbolLists { key: "ICE" - symbol: "BRN" - symbol: "WBS" - symbol: "OJ" + # symbol: "BRN" + # symbol: "WBS" + # symbol: "OJ" } list { From f347fda47f84aebbba4adac6693d8d703e9b3712 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Mon, 25 Mar 2019 10:09:37 -0400 Subject: [PATCH 44/72] PR details --- src/lib/md/ice/ICEUtils.cpp | 16 +------------ src/lib/md/relay/QueryServer.cpp | 4 +++- .../md/platforms/ice_onixs/ICEListener.cpp | 24 ++++++++++++------- .../md/platforms/ice_onixs/ICESecurityIndex.h | 4 ++-- 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/lib/md/ice/ICEUtils.cpp b/src/lib/md/ice/ICEUtils.cpp index 0a54775fa..d25fb696a 100644 --- a/src/lib/md/ice/ICEUtils.cpp +++ b/src/lib/md/ice/ICEUtils.cpp @@ -90,7 +90,7 @@ void await_ice_config() { std::string config_url; if (config::get().type() != "dev") { - config_url = "https://community.theice.com/docs/DOC-19989"; + config_url = "https://drive.google.com/open?id=13_eyF2pKtn3F7chgsa_75ftUdf7emMbp"; } else { config_url = "https://community.theice.com/docs/DOC-19989"; @@ -113,20 +113,6 @@ void await_ice_config() { } } -SecurityType infer_security_type(const string& label) { - if (label.find("Option") != std::string::npos) { - return SECURITYTYPE_OPTION; - } - - if (label.find("Future") != std::string::npos) { - return SECURITYTYPE_FUTURE; - } - - // TODO: Allow configuration to override this? - LOG(md,Warn,"Unable to guess security type from label: '{}" - "' Treating as FUTURE.",label); - return SECURITYTYPE_FUTURE; -} const std::vector get_configured_ice_channels() { std::vector symbols; diff --git a/src/lib/md/relay/QueryServer.cpp b/src/lib/md/relay/QueryServer.cpp index 1d2a5ac3c..7b409662f 100644 --- a/src/lib/md/relay/QueryServer.cpp +++ b/src/lib/md/relay/QueryServer.cpp @@ -381,7 +381,9 @@ public: x->insert(v); } else - bts_assert_msg(false, "exchange case"); + { + LOG(md,Error, "Invalid ExchangeData_case {}", security.ExchangeData_case()); + } } } } diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp index 922ed11da..df13de9bb 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp @@ -90,13 +90,19 @@ void ICEListener::onNewExpiry(const onixs_ice::NewExpiry& msg, bool& is_interest void ICEListener::onFuturesStrategyDefinition(const onixs_ice::FuturesStrategyDefinition& def, bool& is_interested) { tracepoint (bts_trace,trace_order,(char*) "onFuturesStrategyDefinition", 0, (uint16_t) 0, 0); - on_uds_future_spread(def, is_interested); + //TODO need to find out how to produce data for testing + //on_uds_future_spread(def, is_interested); + UNUSED(def); + UNUSED(is_interested); } //This is only for UDS void ICEListener::onNewFuturesStrategyDefinition(const onixs_ice::NewFuturesStrategyDefinition& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) { tracepoint (bts_trace,trace_order,(char*) "onFuturesStrategyDefinition", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); - on_uds_future_spread(msg, is_interested); + //TODO need to find out how to produce data for testing + //on_uds_future_spread(msg, is_interested); + UNUSED(msg); + UNUSED(is_interested); } void ICEListener::onOptionsProductDefinition(const onixs_ice::OptionsProductDefinition& msg, bool& is_interested) @@ -151,7 +157,7 @@ void ICEListener::onOrderBookUpdated(const onixs_ice::OrderBook& onixs_book, con auto data = _index.get_security(onixs_book.marketId()); if (data == nullptr) return; - bts_assert(data->id == (uint32_t)onixs_book.marketId()); + bts_assert(data->id == onixs_book.marketId()); auto display_factor = data->handle.security().display_factor; // Overwrite all entries every time @@ -214,7 +220,7 @@ void ICEListener::onTrade(const onixs_ice::Trade& msg, const onixs_ice::MessageI auto* data = _index.get_security(msg.marketId); if (data != NULL) { - bts_assert(data->id == (uint32_t)msg.marketId); + bts_assert(data->id == msg.marketId); auto size = msg.quantity; auto price = msg.price; onixs_ice::AggressorSide::Enum agside = msg.aggressorSide; @@ -230,7 +236,7 @@ void ICEListener::onRfq(const onixs_ice::Rfq& msg, const onixs_ice::MessageInfo& auto* data = _index.get_security(msg.marketId); if (data != nullptr) { - bts_assert(data->id == (uint32_t)msg.marketId); + bts_assert(data->id == msg.marketId); auto ts = utils::TimeStamp::now(); co2::QuoteRequestMessage message; message.set_key(data->handle.key()); @@ -267,7 +273,7 @@ void ICEListener::onSettlementPrice(const onixs_ice::SettlementPrice& msg, const auto* data = _index.get_security(msg.marketId); if (data != nullptr) { - bts_assert(data->id == (uint32_t)msg.marketId); + bts_assert(data->id == msg.marketId); onixs_ice::Price price = msg.settlementPrice; onixs_ice::DateTime time = msg.dateTime; auto display_factor = data->handle.security().display_factor; @@ -287,7 +293,7 @@ void ICEListener::onOpenPrice(const onixs_ice::OpenPrice& msg, const onixs_ice:: auto* data = _index.get_security(msg.marketId); if (data != nullptr) { - bts_assert(data->id == (uint32_t)msg.marketId); + bts_assert(data->id == msg.marketId); onixs_ice::Price price = msg.openPrice; onixs_ice::DateTime time = msg.dateTime; auto display_factor = data->handle.security().display_factor; @@ -301,7 +307,7 @@ void ICEListener::onClosePrice(const onixs_ice::ClosePrice& msg, const onixs_ice auto* data = _index.get_security(msg.marketId); if (data != nullptr) { - bts_assert(data->id == (uint32_t)msg.marketId); + bts_assert(data->id == msg.marketId); onixs_ice::Price price = msg.closePrice; onixs_ice::DateTime time = msg.dateTime; auto display_factor = data->handle.security().display_factor; @@ -315,7 +321,7 @@ void ICEListener::onEndOfDayMarketSummary(const onixs_ice::EndOfDayMarketSummary auto* data = _index.get_security(msg.marketId); if (data != nullptr) { - bts_assert(data->id == (uint32_t)msg.marketId); + bts_assert(data->id == msg.marketId); onixs_ice::DateTime time = msg.dateTime; auto display_factor = data->handle.security().display_factor; data->handle.update_opening( utils::TimeStamp::now(), double_of_price(msg.openingPrice, display_factor), date_of_timestamp(time) ); diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICESecurityIndex.h b/src/server/sparkd/md/platforms/ice_onixs/ICESecurityIndex.h index e774bbb04..50a138485 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICESecurityIndex.h +++ b/src/server/sparkd/md/platforms/ice_onixs/ICESecurityIndex.h @@ -9,11 +9,11 @@ namespace md { struct ICESecurityData { ICESecurityData(uint32_t id, MDProducerHandle& h) : id(id), handle(h) {} - uint32_t id; // exchange id + int id; // exchange id MDProducerHandle handle; }; -typedef ConcurrentSecurityIndex ICESecurityIndex; +typedef ConcurrentSecurityIndex ICESecurityIndex; }}//namespace From 95939a5534839a7877dbf04c5d391781591d15f7 Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Mon, 25 Mar 2019 10:22:52 -0400 Subject: [PATCH 45/72] SPARK-2087 add GE to default symbol list --- src/lib/config/defaults/Symbols.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/config/defaults/Symbols.conf b/src/lib/config/defaults/Symbols.conf index e29ad43d0..865da5de3 100644 --- a/src/lib/config/defaults/Symbols.conf +++ b/src/lib/config/defaults/Symbols.conf @@ -23,6 +23,7 @@ SymbolList { symbol: "ZF" symbol: "ZT" symbol: "UB" + symbol: "GE" } } From c958f4bf1ae09596bb32eba667f331031c4b339d Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 26 Mar 2019 11:15:15 -0500 Subject: [PATCH 46/72] PR suggestion - making row_vm -> communication a bit more flexibile --- .../Trading/OrderBook/OrderBookRowVM.cs | 27 ++++++++++++------- .../Modules/Trading/OrderBook/OrderBookVM.cs | 8 +++++- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs index 407f5a8d1..54d66cd91 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs @@ -6,11 +6,13 @@ using mbts.ui; using mbts.ui.controls; using mbts.ui.shell; using System; +using System.Reactive; using System.Linq; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Media; +using System.Reactive.Linq; namespace mbts.spark { partial class OrderBookRowVM : DisposableViewModelBase, IEquatable, DIYGrid.IRowVM, DIYGrid.IActionableRowVM { @@ -43,15 +45,22 @@ namespace mbts.spark { modify_order_quantity?.TryRaiseCanExecuteChanged(); modify_order_price?.TryRaiseCanExecuteChanged(); - // This takes care of the case where the OB has all rows visible - // and an order is cancelled outside of the OB (say via the ladder). - // Since the OB window Commands only revaluate their CanExecuteChanged - // when the OrderBookVM.selected_order_changes, this emulates the selected - // order changing since the current_row setter invokes the selected_order_changed - // handler - if (_owner.current_row == this) { - _owner.current_row = this; - } + //// This takes care of the case where the OB has all rows visible + //// and an order is cancelled outside of the OB (say via the ladder). + //// Since the OB window Commands only revaluate their CanExecuteChanged + //// when the OrderBookVM.selected_order_changes, this emulates the selected + //// order changing since the current_row setter invokes the selected_order_changed + //// handler + //if (_owner.current_row == this) { + // _owner.current_row = this; + //} + } + + public IObservable subscribe_data() { + return Observable.FromEvent( + cb => () => cb(order_tuple), + cb => invalidated += cb, + cb => invalidated -= cb); } protected override void Dispose(bool disposing) { diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs index d7e964708..6a7fb5c6b 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs @@ -54,6 +54,7 @@ namespace mbts.spark { collapse_all_rows_command = new DelegateCommand(_row_collection.collapse_all); expand_all_rows_command = new DelegateCommand(_row_collection.expand_all); grid_settings_manager = _create_grid_settings_manager(owner_title, bus, notification_service, model, rows, core_columns); + _resources = new List { model.on_order_tuples.OnDispatcher().Subscribe(_row_collection.update), grid_settings_manager, @@ -62,7 +63,12 @@ namespace mbts.spark { _row_collection.CollectionChanged -= _row_collection_CollectionChanged; Disposable.dispose(_row_collection); }), - _columns + _columns, + _current_row.SubscribeHookLatest( + r => r.newval.subscribe_data().Subscribe( + data => selected_order_changed?.Invoke(data.order) + ) + ) }; if (settings_manager != null) { _resources.Add(settings_manager.subscribe_current().OnDispatcher().Subscribe(grid_settings_manager)); From f5e79a65a3eb9b0ba03f3d8b7afb1cc25f078868 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 26 Mar 2019 11:17:37 -0500 Subject: [PATCH 47/72] relocating comment after PR edit --- .../Modules/Trading/OrderBook/OrderBookRowVM.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs index 54d66cd91..22fc30a8c 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs @@ -44,18 +44,14 @@ namespace mbts.spark { private void OrderBookRowVM_invalidated() { modify_order_quantity?.TryRaiseCanExecuteChanged(); modify_order_price?.TryRaiseCanExecuteChanged(); - - //// This takes care of the case where the OB has all rows visible - //// and an order is cancelled outside of the OB (say via the ladder). - //// Since the OB window Commands only revaluate their CanExecuteChanged - //// when the OrderBookVM.selected_order_changes, this emulates the selected - //// order changing since the current_row setter invokes the selected_order_changed - //// handler - //if (_owner.current_row == this) { - // _owner.current_row = this; - //} } + //// This takes care of the case where the OB has all rows visible + //// and an order is cancelled outside of the OB (say via the ladder). + //// Since the OB window Commands only revaluate their CanExecuteChanged + //// when the OrderBookVM.selected_order_changes, this emulates the selected + //// order changing since the current_row setter invokes the selected_order_changed + //// handler public IObservable subscribe_data() { return Observable.FromEvent( cb => () => cb(order_tuple), From 95e96a6afca75cecb9153aecc074289632dea67e Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 28 Mar 2019 13:52:29 -0500 Subject: [PATCH 48/72] remove pnl rows from which there is no net pos or day pos --- src/client/spark/view/Spark/PAndL/PAndLVM.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/client/spark/view/Spark/PAndL/PAndLVM.cs b/src/client/spark/view/Spark/PAndL/PAndLVM.cs index a5ca17a3a..5c7c3c4d8 100644 --- a/src/client/spark/view/Spark/PAndL/PAndLVM.cs +++ b/src/client/spark/view/Spark/PAndL/PAndLVM.cs @@ -42,6 +42,10 @@ namespace mbts.spark { if (p != null) { PnLCalculator calc = new PnLCalculator(p.state.Values, _selected_pnl_calc_type.Value); var summary_position_rows = calc.get_summary_position(); + // remove rows for which there is no net pos or no day pos + summary_position_rows = summary_position_rows.Where(r => + !(r.start_net_position == 0 && r.day_long_quantity == 0 && r.day_short_quantity == 0) + ); _pnl_data.sync_with(summary_position_rows); _last_pnl_update_time = DateTime.Now; } From 635163c895a4bf2e407f2d18f689ce8118760640 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 28 Mar 2019 15:03:54 -0500 Subject: [PATCH 49/72] hiding exch, start pnl, total net pos, and total net pnl by default --- src/client/spark/Modules/Trading/PAndLWindowFactory.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/spark/Modules/Trading/PAndLWindowFactory.cs b/src/client/spark/Modules/Trading/PAndLWindowFactory.cs index 27eba0300..e8fd660b8 100644 --- a/src/client/spark/Modules/Trading/PAndLWindowFactory.cs +++ b/src/client/spark/Modules/Trading/PAndLWindowFactory.cs @@ -84,17 +84,17 @@ namespace bts.shell { static class DefaultColumns { public static GridColumnSettings account => new GridColumnSettings(col_id(Columns.Account), DefaultColumnHeaders.Account, width: DefaultColumnWidths.Account); - public static GridColumnSettings exchange => new GridColumnSettings(col_id(Columns.Exchange), DefaultColumnHeaders.Exchange, width: DefaultColumnWidths.Exchange); + public static GridColumnSettings exchange => new GridColumnSettings(col_id(Columns.Exchange), DefaultColumnHeaders.Exchange, false, width: DefaultColumnWidths.Exchange); public static GridColumnSettings symbol => new GridColumnSettings(col_id(Columns.Symbol), DefaultColumnHeaders.Symbol, width: DefaultColumnWidths.Symbol); public static GridColumnSettings security => new GridColumnSettings(col_id(Columns.Security), DefaultColumnHeaders.Security, width: DefaultColumnWidths.Security); public static GridColumnSettings security_type => new GridColumnSettings(col_id(Columns.SecurityType), DefaultColumnHeaders.SecurityType, width: DefaultColumnWidths.SecurityType); public static GridColumnSettings start_net_position => new GridColumnSettings(col_id(Columns.StartNetPos), DefaultColumnHeaders.StartNetPos, width: DefaultColumnWidths.Start_Net_Pos, horizontal_alignment: System.Windows.HorizontalAlignment.Right); - public static GridColumnSettings start_pnl => new GridColumnSettings(col_id(Columns.StartPNL), DefaultColumnHeaders.StartPnL, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right); + public static GridColumnSettings start_pnl => new GridColumnSettings(col_id(Columns.StartPNL), DefaultColumnHeaders.StartPnL, false, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings day_long_pnl => new GridColumnSettings(col_id(Columns.DayLong), DefaultColumnHeaders.DayLong, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings day_short_pnl => new GridColumnSettings(col_id(Columns.DayShort), DefaultColumnHeaders.DayShort, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings day_pnl => new GridColumnSettings(col_id(Columns.DayPNL), DefaultColumnHeaders.DayPnL, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right); - public static GridColumnSettings total_net_pos => new GridColumnSettings(col_id(Columns.TotalNetPos), DefaultColumnHeaders.TotalNetPos, width: DefaultColumnWidths.Total_Net_Pos, horizontal_alignment: System.Windows.HorizontalAlignment.Right); - public static GridColumnSettings total_pnl => new GridColumnSettings(col_id(Columns.TotalPNL), DefaultColumnHeaders.TotalPnL, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right); + public static GridColumnSettings total_net_pos => new GridColumnSettings(col_id(Columns.TotalNetPos), DefaultColumnHeaders.TotalNetPos, false, width: DefaultColumnWidths.Total_Net_Pos, horizontal_alignment: System.Windows.HorizontalAlignment.Right); + public static GridColumnSettings total_pnl => new GridColumnSettings(col_id(Columns.TotalPNL), DefaultColumnHeaders.TotalPnL, false, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings pnl_price => new GridColumnSettings(col_id(Columns.PNLPrice), DefaultColumnHeaders.PnLPrice, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static IEnumerable default_sorting_criterion { From 009e72953c06829ad34eecd4f01502c620f21cb1 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 28 Mar 2019 15:31:56 -0500 Subject: [PATCH 50/72] adding SecurityType default fitler; technical_debt++ --- src/client/spark/view/Spark/PAndL/PAndLVM.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/client/spark/view/Spark/PAndL/PAndLVM.cs b/src/client/spark/view/Spark/PAndL/PAndLVM.cs index 5c7c3c4d8..f79228e70 100644 --- a/src/client/spark/view/Spark/PAndL/PAndLVM.cs +++ b/src/client/spark/view/Spark/PAndL/PAndLVM.cs @@ -68,6 +68,10 @@ namespace mbts.spark { total_pnl_filter.load_state(fs.total_pnl); pnl_price_filter.load_state(fs.pnl_price); security_type_filter.load_state(fs.security_types); + } else { + // this is debt that will have to be paid down at some point, similar to the pnl_calc_type thing above + // these should come from the default startup_data. + security_type_filter.load_state(new[] { SecurityType.Future }); } pnl_view.CollectionChanged += Pnl_view_CollectionChanged; From 39c71d0c16b422f5b5f397ec2801b6642ffee86e Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Fri, 29 Mar 2019 09:39:21 -0500 Subject: [PATCH 51/72] adding has day trades field to pnl's FilterState proto --- src/client/spark/Modules/Trading/PAndLWindowFactory.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/client/spark/Modules/Trading/PAndLWindowFactory.cs b/src/client/spark/Modules/Trading/PAndLWindowFactory.cs index e8fd660b8..486e261a9 100644 --- a/src/client/spark/Modules/Trading/PAndLWindowFactory.cs +++ b/src/client/spark/Modules/Trading/PAndLWindowFactory.cs @@ -158,6 +158,8 @@ namespace bts.shell { // ProtoMember 13 cannot be used further [ProtoMember(14)] public SecurityType[] security_types; + [ProtoMember(15)] + public bool[] has_day_trades; } } From dff57a43dd4d2be334920ddd793e1e25b0d9fe66 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Fri, 29 Mar 2019 09:43:53 -0500 Subject: [PATCH 52/72] Adding TradedToday to Column enum --- src/client/spark/view/Spark/PAndL/PAndLView.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/spark/view/Spark/PAndL/PAndLView.xaml.cs b/src/client/spark/view/Spark/PAndL/PAndLView.xaml.cs index 19871786a..04ceb59d0 100644 --- a/src/client/spark/view/Spark/PAndL/PAndLView.xaml.cs +++ b/src/client/spark/view/Spark/PAndL/PAndLView.xaml.cs @@ -3,7 +3,7 @@ using System.Windows.Controls; namespace mbts.spark { internal partial class PAndLView : UserControl { - public enum Columns { Account, Exchange, Symbol, Security, SecurityType, StartNetPos, StartPNL, DayLong, DayShort, DayPNL, TotalNetPos, TotalPNL, PNLPrice } + public enum Columns { Account, Exchange, Symbol, Security, SecurityType, StartNetPos, StartPNL, DayLong, DayShort, DayPNL, TotalNetPos, TotalPNL, PNLPrice, TradedToday } public PAndLView(PAndLVM vm) { InitializeComponent(); From c277fcd503aa2858a337175501e5acd3f942a675 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Fri, 29 Mar 2019 09:44:55 -0500 Subject: [PATCH 53/72] adding has_day_trades property --- src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs b/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs index 0b276cc26..5d4d12c92 100644 --- a/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs +++ b/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs @@ -184,6 +184,8 @@ namespace mbts.spark { public string weighted_average_buy_text => _weighted_average_buy.text; public double weighted_average_sell => _weighted_average_sell.value; public string weighted_average_sell_text => _weighted_average_sell.text; + // + public bool has_day_trades => day_long_quantity != 0 || day_short_quantity != 0; public void raise_invalidated() => invalidated?.Invoke(); From bf4953f6dcac723e0167cda2af854069b87194fd Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Fri, 29 Mar 2019 09:45:32 -0500 Subject: [PATCH 54/72] adding TradedToday column to pnl --- src/client/spark/view/Spark/PAndL/PAndLVM.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/client/spark/view/Spark/PAndL/PAndLVM.cs b/src/client/spark/view/Spark/PAndL/PAndLVM.cs index f79228e70..27aa8ff05 100644 --- a/src/client/spark/view/Spark/PAndL/PAndLVM.cs +++ b/src/client/spark/view/Spark/PAndL/PAndLVM.cs @@ -68,6 +68,7 @@ namespace mbts.spark { total_pnl_filter.load_state(fs.total_pnl); pnl_price_filter.load_state(fs.pnl_price); security_type_filter.load_state(fs.security_types); + has_day_trades_filter.load_state(fs.has_day_trades); } else { // this is debt that will have to be paid down at some point, similar to the pnl_calc_type thing above // these should come from the default startup_data. @@ -85,6 +86,7 @@ namespace mbts.spark { add_col(Columns.DayLong, DefaultColumnHeaders.DayLong, r => r.day_long_quantity.ToString(), nameof(PnLSummaryRow.day_long_quantity), DefaultColumnWidths.PnL_Generic, day_long_quantity_filter, DataGridFilterKnownTemplates.UIntMinMax, HorizontalAlignment.Right); add_col(Columns.DayShort, DefaultColumnHeaders.DayShort, r => r.day_short_quantity.ToString(), nameof(PnLSummaryRow.day_short_quantity), DefaultColumnWidths.PnL_Generic, day_short_quantity_filter, DataGridFilterKnownTemplates.UIntMinMax, HorizontalAlignment.Right); add_col(Columns.DayPNL, DefaultColumnHeaders.DayPnL, r => r.day_pnl_text, nameof(PnLSummaryRow.day_pnl), 90, day_pnl_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right, r => r.day_pnl_background); + add_col(Columns.TradedToday, "Traded Today", r => r.has_day_trades.ToString(), nameof(PnLSummaryRow.has_day_trades), 100, has_day_trades_filter, DataGridFilterKnownTemplates.DiscreteValues, HorizontalAlignment.Center); add_col(Columns.TotalNetPos, DefaultColumnHeaders.TotalNetPos, r => r.total_net_position.ToString(), nameof(PnLSummaryRow.total_net_position), DefaultColumnWidths.Total_Net_Pos, total_net_position_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right); add_col(Columns.TotalPNL, DefaultColumnHeaders.TotalPnL, r => r.total_pnl_text, nameof(PnLSummaryRow.total_pnl), DefaultColumnWidths.PnL_Generic, total_pnl_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right, r => r.total_pnl_background); add_col(Columns.PNLPrice, DefaultColumnHeaders.PnLPrice, r => r.pnl_price_text, nameof(PnLSummaryRow.pnl_price), DefaultColumnWidths.PnL_Generic, pnl_price_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right); @@ -133,7 +135,8 @@ namespace mbts.spark { pnl_price_filter, weighted_average_buy_filter, weighted_average_sell_filter, - security_type_filter), + security_type_filter, + has_day_trades_filter), WorkLoop.Start("PAndL", _UPDATE_PERIOD, _calculate_pnl) ); } @@ -253,6 +256,7 @@ namespace mbts.spark { public IDataGridColumnPersistentFilter weighted_average_buy_filter { get; } = new DoubleMinMax(r => r.weighted_average_buy, nameof(PnLSummaryRow.weighted_average_buy)); public IDataGridColumnPersistentFilter weighted_average_sell_filter { get; } = new DoubleMinMax(r => r.weighted_average_sell, nameof(PnLSummaryRow.weighted_average_sell)); public IDataGridColumnPersistentFilter security_type_filter { get; } = DiscreteValuesFilterVM.Create(EnumHelper.get_values_except(SecurityType.Option, SecurityType.Stock, SecurityType.Synthetic).ToArray(), r => r.security_type, nameof(PnLSummaryRow.security_type)); + public IDataGridColumnPersistentFilter has_day_trades_filter { get; } = DiscreteValuesFilterVM.Create(new[] { true, false }, r => r.has_day_trades, nameof(PnLSummaryRow.has_day_trades)); public FilterStates get_filters_states() => new FilterStates { account_regex = account_filter.get_state(), @@ -267,7 +271,8 @@ namespace mbts.spark { total_net_pos = total_net_position_filter.get_state(), total_pnl = total_pnl_filter.get_state(), pnl_price = pnl_price_filter.get_state(), - security_types = security_type_filter.get_state() + security_types = security_type_filter.get_state(), + has_day_trades = has_day_trades_filter.get_state(), }; #endregion From 57ca9596c8d29fde242471e671845ca7bd72fc13 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Fri, 29 Mar 2019 11:05:15 -0500 Subject: [PATCH 55/72] changing column name --- src/client/spark/view/Spark/PAndL/PAndLVM.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/spark/view/Spark/PAndL/PAndLVM.cs b/src/client/spark/view/Spark/PAndL/PAndLVM.cs index 27aa8ff05..921b53c96 100644 --- a/src/client/spark/view/Spark/PAndL/PAndLVM.cs +++ b/src/client/spark/view/Spark/PAndL/PAndLVM.cs @@ -86,7 +86,7 @@ namespace mbts.spark { add_col(Columns.DayLong, DefaultColumnHeaders.DayLong, r => r.day_long_quantity.ToString(), nameof(PnLSummaryRow.day_long_quantity), DefaultColumnWidths.PnL_Generic, day_long_quantity_filter, DataGridFilterKnownTemplates.UIntMinMax, HorizontalAlignment.Right); add_col(Columns.DayShort, DefaultColumnHeaders.DayShort, r => r.day_short_quantity.ToString(), nameof(PnLSummaryRow.day_short_quantity), DefaultColumnWidths.PnL_Generic, day_short_quantity_filter, DataGridFilterKnownTemplates.UIntMinMax, HorizontalAlignment.Right); add_col(Columns.DayPNL, DefaultColumnHeaders.DayPnL, r => r.day_pnl_text, nameof(PnLSummaryRow.day_pnl), 90, day_pnl_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right, r => r.day_pnl_background); - add_col(Columns.TradedToday, "Traded Today", r => r.has_day_trades.ToString(), nameof(PnLSummaryRow.has_day_trades), 100, has_day_trades_filter, DataGridFilterKnownTemplates.DiscreteValues, HorizontalAlignment.Center); + add_col(Columns.TradedToday, "Traded Today?", r => r.has_day_trades.ToString(), nameof(PnLSummaryRow.has_day_trades), 100, has_day_trades_filter, DataGridFilterKnownTemplates.DiscreteValues, HorizontalAlignment.Center); add_col(Columns.TotalNetPos, DefaultColumnHeaders.TotalNetPos, r => r.total_net_position.ToString(), nameof(PnLSummaryRow.total_net_position), DefaultColumnWidths.Total_Net_Pos, total_net_position_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right); add_col(Columns.TotalPNL, DefaultColumnHeaders.TotalPnL, r => r.total_pnl_text, nameof(PnLSummaryRow.total_pnl), DefaultColumnWidths.PnL_Generic, total_pnl_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right, r => r.total_pnl_background); add_col(Columns.PNLPrice, DefaultColumnHeaders.PnLPrice, r => r.pnl_price_text, nameof(PnLSummaryRow.pnl_price), DefaultColumnWidths.PnL_Generic, pnl_price_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right); From 2540dc0510e02bb2808773b1befe6274fef8b0bd Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Fri, 29 Mar 2019 15:20:35 -0400 Subject: [PATCH 56/72] ops notes --- ops_notes.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ops_notes.txt b/ops_notes.txt index 1975dd799..2f9b5a6d5 100644 --- a/ops_notes.txt +++ b/ops_notes.txt @@ -1,3 +1,6 @@ +1.5.7 +- Fixed Aggressor coloring and ladder high/low coloring in SIM + 1.4.2 - Be sure the system has a bts user before deployment. bts is the superuser, he has all permissions and can see all market data - After deployment re-permission all existing users for trading, riskadmin, and/or md admin permissions as appropriate From 76466e83f0fc9a7309dcec3a28563c183347723f Mon Sep 17 00:00:00 2001 From: Taha Afzal Date: Fri, 29 Mar 2019 17:26:36 -0400 Subject: [PATCH 57/72] changing hedger addiiton log from error to info --- .../orders/spreader_orders/spreader/hedger/HedgerManager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/orderman/orders/spreader_orders/spreader/hedger/HedgerManager.h b/src/lib/orderman/orders/spreader_orders/spreader/hedger/HedgerManager.h index 8708c1d3e..6827ac7d2 100644 --- a/src/lib/orderman/orders/spreader_orders/spreader/hedger/HedgerManager.h +++ b/src/lib/orderman/orders/spreader_orders/spreader/hedger/HedgerManager.h @@ -33,7 +33,7 @@ public: for (auto& h : _hedgers) if(h.is_free()) return h; - LOG(OrderMan, Error, "HedgerManager::get_hedger allocating new hedger {} ", + LOG(OrderMan, Info, "HedgerManager::get_hedger allocating new hedger {} ", _hedgers.size()); _hedgers.emplace_back(_spreader_manager, _leg_property_data, From b08e2c2ee608c57641c419a8ba9b1bff5da7dec4 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 1 Apr 2019 09:08:58 -0400 Subject: [PATCH 58/72] Updated release notes. --- doc/user/content/release_notes/_index.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index d8d3199cd..844cf2fa1 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -4,6 +4,10 @@ weight = 3 sort_by = "weight" insert_anchor_links = "right" +++ +## 1.5.7 +### User Visible Changes + - New videos have been added to the manual describing the [Algo Studio](./bts_spark/Trading/index.md#algo-studio) and [Spreader](./bts_spark/Spreader/index.md) + ## 1.5.6 ### User Visible Changes - Fixed a bug that could cause limits to be erroneously enforced From 6a52fff3d5a1f541ba32d76b26c9229c78ddba1e Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 1 Apr 2019 09:28:33 -0400 Subject: [PATCH 59/72] Updated release notes. --- doc/user/content/release_notes/_index.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index 844cf2fa1..7ae040ec5 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -7,7 +7,8 @@ insert_anchor_links = "right" ## 1.5.7 ### User Visible Changes - New videos have been added to the manual describing the [Algo Studio](./bts_spark/Trading/index.md#algo-studio) and [Spreader](./bts_spark/Spreader/index.md) - + - Fixed a bug that occasionally would cause windows to be position outside the visible screen on startup + ## 1.5.6 ### User Visible Changes - Fixed a bug that could cause limits to be erroneously enforced From 292873b18964ec43b81550d5a6855fc61b15a95c Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 1 Apr 2019 09:37:01 -0400 Subject: [PATCH 60/72] Update release notes. --- doc/user/content/release_notes/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index 7ae040ec5..564262e2a 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -8,7 +8,7 @@ insert_anchor_links = "right" ### User Visible Changes - New videos have been added to the manual describing the [Algo Studio](./bts_spark/Trading/index.md#algo-studio) and [Spreader](./bts_spark/Spreader/index.md) - Fixed a bug that occasionally would cause windows to be position outside the visible screen on startup - + - Fixed a bug in the order book form that would occasionally cause the Recreate Order option to be unavailable ## 1.5.6 ### User Visible Changes - Fixed a bug that could cause limits to be erroneously enforced From 6b19119ab2df921826e992ccd2d9c2fb6b2aa822 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 1 Apr 2019 09:54:11 -0400 Subject: [PATCH 61/72] Updated release notes --- doc/user/content/release_notes/_index.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index 564262e2a..7b9b35c37 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -9,6 +9,11 @@ insert_anchor_links = "right" - New videos have been added to the manual describing the [Algo Studio](./bts_spark/Trading/index.md#algo-studio) and [Spreader](./bts_spark/Spreader/index.md) - Fixed a bug that occasionally would cause windows to be position outside the visible screen on startup - Fixed a bug in the order book form that would occasionally cause the Recreate Order option to be unavailable + - Improved the PnL report UI, specifically: + - We now only show rows for which there is a net or day position + - Added a new column which allows the user to filter on the existance of day trades + - Added a default filter to show Futures only + - Hid exchange, start pnl, total net position and total net pnl columns by default ## 1.5.6 ### User Visible Changes - Fixed a bug that could cause limits to be erroneously enforced From 964274f5c45889f00c7aba26970bd47b365d27e5 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 1 Apr 2019 10:02:45 -0400 Subject: [PATCH 62/72] Updated release notes. --- doc/user/content/release_notes/_index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index 7b9b35c37..d4aff1a21 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -14,6 +14,7 @@ insert_anchor_links = "right" - Added a new column which allows the user to filter on the existance of day trades - Added a default filter to show Futures only - Hid exchange, start pnl, total net position and total net pnl columns by default + - Added a confirmation step to Cancel All, Cancel Buys and Cancel Sells commands ## 1.5.6 ### User Visible Changes - Fixed a bug that could cause limits to be erroneously enforced From b07eec08b4e4949dc386a7af5e13b6fea44e9e4a Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Mon, 1 Apr 2019 10:36:25 -0500 Subject: [PATCH 63/72] Yes No formatting in row --- .../Filters/DataGridFilterHelper.cs | 3 ++- .../Filters/Views/FilterTemplates.xaml | 21 +++++++++++++++++++ .../spark/view/Resources/Converters.xaml | 3 +++ .../spark/view/Spark/PAndL/PnLSummaryRow.cs | 2 ++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/client/spark/view/Controls/DataGridEx/Filters/DataGridFilterHelper.cs b/src/client/spark/view/Controls/DataGridEx/Filters/DataGridFilterHelper.cs index 864026520..96308bbda 100644 --- a/src/client/spark/view/Controls/DataGridEx/Filters/DataGridFilterHelper.cs +++ b/src/client/spark/view/Controls/DataGridEx/Filters/DataGridFilterHelper.cs @@ -63,6 +63,7 @@ namespace mbts.spark.filters { TimeFilter = "TimeFilterTemplate", DiscreteValues = "DiscreteValuesTemplate", EnumValues = "EnumValuesTemplate", - Regex = "RegexTemplate"; + Regex = "RegexTemplate", + YesNo = "YesNoTemplate"; } } \ No newline at end of file diff --git a/src/client/spark/view/Controls/DataGridEx/Filters/Views/FilterTemplates.xaml b/src/client/spark/view/Controls/DataGridEx/Filters/Views/FilterTemplates.xaml index 925c3958a..26ff10f0a 100644 --- a/src/client/spark/view/Controls/DataGridEx/Filters/Views/FilterTemplates.xaml +++ b/src/client/spark/view/Controls/DataGridEx/Filters/Views/FilterTemplates.xaml @@ -146,6 +146,27 @@ /> + + + + + + + + + + + + + + diff --git a/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs b/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs index 5d4d12c92..fa9dc2ec8 100644 --- a/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs +++ b/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs @@ -186,6 +186,8 @@ namespace mbts.spark { public string weighted_average_sell_text => _weighted_average_sell.text; // public bool has_day_trades => day_long_quantity != 0 || day_short_quantity != 0; + public string has_day_trades_text => has_day_trades ? "Yes" : "No"; + public void raise_invalidated() => invalidated?.Invoke(); From 8afee21df7d75b84f8f90dfaca4d16090b4a66eb Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Mon, 1 Apr 2019 11:21:02 -0500 Subject: [PATCH 64/72] hooking up the yes/no filter to the column --- src/client/spark/view/Spark/PAndL/PAndLVM.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/spark/view/Spark/PAndL/PAndLVM.cs b/src/client/spark/view/Spark/PAndL/PAndLVM.cs index 921b53c96..a694a41e1 100644 --- a/src/client/spark/view/Spark/PAndL/PAndLVM.cs +++ b/src/client/spark/view/Spark/PAndL/PAndLVM.cs @@ -20,6 +20,7 @@ using mbts.ui.settings; namespace mbts.spark { class PAndLVM : DisposableViewModelBase { + public PAndLVM(IBus bus, PAndLModel model, PAndLStartupData startup_data, IWindowSettingsManager settings_manager) { _bus = bus; _model = model; @@ -86,7 +87,7 @@ namespace mbts.spark { add_col(Columns.DayLong, DefaultColumnHeaders.DayLong, r => r.day_long_quantity.ToString(), nameof(PnLSummaryRow.day_long_quantity), DefaultColumnWidths.PnL_Generic, day_long_quantity_filter, DataGridFilterKnownTemplates.UIntMinMax, HorizontalAlignment.Right); add_col(Columns.DayShort, DefaultColumnHeaders.DayShort, r => r.day_short_quantity.ToString(), nameof(PnLSummaryRow.day_short_quantity), DefaultColumnWidths.PnL_Generic, day_short_quantity_filter, DataGridFilterKnownTemplates.UIntMinMax, HorizontalAlignment.Right); add_col(Columns.DayPNL, DefaultColumnHeaders.DayPnL, r => r.day_pnl_text, nameof(PnLSummaryRow.day_pnl), 90, day_pnl_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right, r => r.day_pnl_background); - add_col(Columns.TradedToday, "Traded Today?", r => r.has_day_trades.ToString(), nameof(PnLSummaryRow.has_day_trades), 100, has_day_trades_filter, DataGridFilterKnownTemplates.DiscreteValues, HorizontalAlignment.Center); + add_col(Columns.TradedToday, "Traded Today", r => r.has_day_trades_text, nameof(PnLSummaryRow.has_day_trades), 100, has_day_trades_filter, DataGridFilterKnownTemplates.YesNo, HorizontalAlignment.Center); add_col(Columns.TotalNetPos, DefaultColumnHeaders.TotalNetPos, r => r.total_net_position.ToString(), nameof(PnLSummaryRow.total_net_position), DefaultColumnWidths.Total_Net_Pos, total_net_position_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right); add_col(Columns.TotalPNL, DefaultColumnHeaders.TotalPnL, r => r.total_pnl_text, nameof(PnLSummaryRow.total_pnl), DefaultColumnWidths.PnL_Generic, total_pnl_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right, r => r.total_pnl_background); add_col(Columns.PNLPrice, DefaultColumnHeaders.PnLPrice, r => r.pnl_price_text, nameof(PnLSummaryRow.pnl_price), DefaultColumnWidths.PnL_Generic, pnl_price_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right); From 938caf9a4f9c9de68f18da510111f5f55bebbea3 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 1 Apr 2019 12:55:51 -0400 Subject: [PATCH 65/72] Updated release notes. --- doc/user/content/release_notes/_index.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index d4aff1a21..8065067be 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -9,12 +9,15 @@ insert_anchor_links = "right" - New videos have been added to the manual describing the [Algo Studio](./bts_spark/Trading/index.md#algo-studio) and [Spreader](./bts_spark/Spreader/index.md) - Fixed a bug that occasionally would cause windows to be position outside the visible screen on startup - Fixed a bug in the order book form that would occasionally cause the Recreate Order option to be unavailable - - Improved the PnL report UI, specifically: - - We now only show rows for which there is a net or day position - - Added a new column which allows the user to filter on the existance of day trades - - Added a default filter to show Futures only - - Hid exchange, start pnl, total net position and total net pnl columns by default - Added a confirmation step to Cancel All, Cancel Buys and Cancel Sells commands + - In an effort to streamline the PnL report we've made the following changes: + - The PnL report will by default filter for Futures contracts only + - If you wish to see Spread contracts again you may change Security Type column filter + - The PnL report will now only show rows in which there is a position (net and/or day) + - The Exchange, Start PnL, Total Net Pos, and Total Net PnL columns are now hidden by default + - These columns can be restored by toggling their visibility within the PnL's Settings form + - A new Traded Today column has been added to the PnL + - Filtering on this column will allow a user to restrict the report to only show today's position ## 1.5.6 ### User Visible Changes - Fixed a bug that could cause limits to be erroneously enforced From 59c1f6a5118f599c9589eb6bb187a86b39e851f5 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 1 Apr 2019 12:58:44 -0400 Subject: [PATCH 66/72] Updated release notes --- doc/user/content/release_notes/_index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index 8065067be..7958ed72d 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -18,6 +18,7 @@ insert_anchor_links = "right" - These columns can be restored by toggling their visibility within the PnL's Settings form - A new Traded Today column has been added to the PnL - Filtering on this column will allow a user to restrict the report to only show today's position + ## 1.5.6 ### User Visible Changes - Fixed a bug that could cause limits to be erroneously enforced From ce4c46da04b822cb7ac9389009fdf4230d899ba4 Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Mon, 1 Apr 2019 14:03:09 -0400 Subject: [PATCH 67/72] Add some logging to spark shell shutdown sequence --- src/client/spark/App.xaml.cs | 1 + src/lib/utils/init_spark_lib.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/client/spark/App.xaml.cs b/src/client/spark/App.xaml.cs index 196a404c2..d19652c96 100644 --- a/src/client/spark/App.xaml.cs +++ b/src/client/spark/App.xaml.cs @@ -66,6 +66,7 @@ namespace mbts.ui.shell protected override void OnExit(ExitEventArgs e) { + Log.Gen.info("Application.OnExit"); if (_runtime != null) _runtime.Dispose(); utils.BTSNativeMethods.finit_spark_lib(); base.OnExit(e); diff --git a/src/lib/utils/init_spark_lib.cpp b/src/lib/utils/init_spark_lib.cpp index d9dc6fab9..452936018 100644 --- a/src/lib/utils/init_spark_lib.cpp +++ b/src/lib/utils/init_spark_lib.cpp @@ -17,6 +17,7 @@ void init_spark_lib() void finit_spark_lib() { + LOG(Gen, Info, "finit_spark_lib"); if (poller) { delete poller; } From 7dc9aa07106f8add47a0e9e6e63ed12f1f3b7f4e Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 1 Apr 2019 14:17:02 -0400 Subject: [PATCH 68/72] Uppdate release notes. --- doc/user/content/release_notes/_index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index 7958ed72d..54067bfb5 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -18,6 +18,8 @@ insert_anchor_links = "right" - These columns can be restored by toggling their visibility within the PnL's Settings form - A new Traded Today column has been added to the PnL - Filtering on this column will allow a user to restrict the report to only show today's position +### Internal changes + - Improved organizatio of the shell notification architecture ## 1.5.6 ### User Visible Changes From 693c730f516fff3156ba40c8fb688459068e3369 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 1 Apr 2019 14:24:44 -0400 Subject: [PATCH 69/72] Update release notes. --- doc/user/content/release_notes/_index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index 54067bfb5..cecad45a9 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -10,6 +10,7 @@ insert_anchor_links = "right" - Fixed a bug that occasionally would cause windows to be position outside the visible screen on startup - Fixed a bug in the order book form that would occasionally cause the Recreate Order option to be unavailable - Added a confirmation step to Cancel All, Cancel Buys and Cancel Sells commands + - Fixed Aggressor coloring and ladder high/low coloring in SIM - In an effort to streamline the PnL report we've made the following changes: - The PnL report will by default filter for Futures contracts only - If you wish to see Spread contracts again you may change Security Type column filter @@ -19,7 +20,8 @@ insert_anchor_links = "right" - A new Traded Today column has been added to the PnL - Filtering on this column will allow a user to restrict the report to only show today's position ### Internal changes - - Improved organizatio of the shell notification architecture + - Improved organization of the shell notification architecture + - Added logging to help troubleshoot shell exit hang ## 1.5.6 ### User Visible Changes From 04beea61ebccf63110746365e240ec04246e64b1 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 1 Apr 2019 14:34:03 -0400 Subject: [PATCH 70/72] Updated release notes. --- doc/user/content/release_notes/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index cecad45a9..64ff31654 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -10,7 +10,7 @@ insert_anchor_links = "right" - Fixed a bug that occasionally would cause windows to be position outside the visible screen on startup - Fixed a bug in the order book form that would occasionally cause the Recreate Order option to be unavailable - Added a confirmation step to Cancel All, Cancel Buys and Cancel Sells commands - - Fixed Aggressor coloring and ladder high/low coloring in SIM + - Fixed Aggressor coloring and ladder high/low coloring in the SIM execution gateway - In an effort to streamline the PnL report we've made the following changes: - The PnL report will by default filter for Futures contracts only - If you wish to see Spread contracts again you may change Security Type column filter From f871dfe14222d7a37c9849e8cbd914a73b88d0f0 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 1 Apr 2019 14:48:40 -0400 Subject: [PATCH 71/72] Merged. --- doc/user/content/release_notes/_index.md | 1 + docker/linux | 2 +- src/data_files/CMakeDeps.cmake | 2 +- src/lib/CMakeDeps.cmake | 2 +- src/server/sparkd/CMakeDeps.cmake | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index 64ff31654..71d637fd7 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -11,6 +11,7 @@ insert_anchor_links = "right" - Fixed a bug in the order book form that would occasionally cause the Recreate Order option to be unavailable - Added a confirmation step to Cancel All, Cancel Buys and Cancel Sells commands - Fixed Aggressor coloring and ladder high/low coloring in the SIM execution gateway + - Added initial support for ICE market data - In an effort to streamline the PnL report we've made the following changes: - The PnL report will by default filter for Futures contracts only - If you wish to see Spread contracts again you may change Security Type column filter diff --git a/docker/linux b/docker/linux index f6d8d5986..ce08a5129 160000 --- a/docker/linux +++ b/docker/linux @@ -1 +1 @@ -Subproject commit f6d8d59860bc40672a4ac9ab4e69a54541c4d236 +Subproject commit ce08a5129f14af0d1bb9fa569d1e721b694964fe diff --git a/src/data_files/CMakeDeps.cmake b/src/data_files/CMakeDeps.cmake index db22eba31..c72de1cbb 100644 --- a/src/data_files/CMakeDeps.cmake +++ b/src/data_files/CMakeDeps.cmake @@ -1 +1 @@ -set(sources files/Onixs.BTS.lic;files/cert_secure_logon.txt;files/futures.coconut.xz;files/perf_trace/compiled.css;files/perf_trace/index.html;files/perf_trace/jquery-3.3.1.min.js;files/perf_trace/main.js;files/perf_trace/perf_log.sql;files/perf_trace/perf_trace_analysis.sql;files/perf_trace/plotly-latest.min.js) \ No newline at end of file +set(sources files/Onixs.BTS.lic;files/cert_secure_logon.txt;files/futures.coconut.xz;files/onixs_ice/ConnectivityConfiguration.APITest.xml;files/onixs_ice/ConnectivityConfiguration.PerfTest.xml;files/onixs_ice/ConnectivityConfiguration.Production.xml;files/perf_trace/compiled.css;files/perf_trace/index.html;files/perf_trace/jquery-3.3.1.min.js;files/perf_trace/main.js;files/perf_trace/perf_log.sql;files/perf_trace/perf_trace_analysis.sql;files/perf_trace/plotly-latest.min.js) \ No newline at end of file diff --git a/src/lib/CMakeDeps.cmake b/src/lib/CMakeDeps.cmake index c6df81ce3..c9d142ec6 100644 --- a/src/lib/CMakeDeps.cmake +++ b/src/lib/CMakeDeps.cmake @@ -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/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.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/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.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/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/quickbus_cfg.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/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/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/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.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/md2_tests.cpp;md/test/synthetic_book_merge_tests.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/ExecutionGateway.cpp;orderman/actors/FillStore.cpp;orderman/actors/MDSupplementarySource.cpp;orderman/actors/OrderStore.cpp;orderman/actors/SODPosition.cpp;orderman/actors/SecuritySrc.cpp;orderman/actors/ServiceBridge.cpp;orderman/actors/order_manager/OrderBuilder.cpp;orderman/actors/order_manager/OrderManager.cpp;orderman/actors/order_manager/OrderServicesData.cpp;orderman/events/CancelRejectEvent.cpp;orderman/events/NewExecutionReportEvent.cpp;orderman/limiter/LimitStore.cpp;orderman/limiter/Limiter.cpp;orderman/limiter/ProductLimitNode.cpp;orderman/limiter/ProductLimitTree.cpp;orderman/limiter/SecurityLimitNode.cpp;orderman/limiter/SecurityLimitTree.cpp;orderman/limiter/tests/limit_tests.cpp;orderman/order_factory/DynamicOrderRegistry.cpp;orderman/order_factory/OrderFactory.cpp;orderman/order_router/OrderRouter.cpp;orderman/orderman_utils/fix_order_codec.cpp;orderman/orders/DynamicOrder.cpp;orderman/orders/IcebergOrder.cpp;orderman/orders/NativeOrder.cpp;orderman/orders/Order.cpp;orderman/orders/TimeBoxOrder.cpp;orderman/orders/TriggerOrder.cpp;orderman/orders/book_algos/BookAlgo.cpp;orderman/orders/book_algos/CoverOrder.cpp;orderman/orders/book_algos/JoinOrder.cpp;orderman/orders/book_algos/LeanOrder.cpp;orderman/orders/book_algos/OCOOrder.cpp;orderman/orders/book_algos/OffsetOrder.cpp;orderman/orders/book_algos/PricerOrder.cpp;orderman/orders/book_algos/TopOrder.cpp;orderman/orders/spreader_orders/SpreaderOrder.cpp;orderman/orders/spreader_orders/spreader/LegFillState.cpp;orderman/orders/spreader_orders/spreader/LegPropertyData.cpp;orderman/orders/spreader_orders/spreader/QuoteLegPriceQuantityState.cpp;orderman/orders/spreader_orders/spreader/SingleFillHedger.cpp;orderman/orders/spreader_orders/spreader/SingleLegQuoter.cpp;orderman/orders/spreader_orders/spreader/SpreaderBookkeepingData.cpp;orderman/orders/spreader_orders/spreader/SpreaderChildOrderState.cpp;orderman/orders/spreader_orders/spreader/SpreaderLegData.cpp;orderman/orders/spreader_orders/spreader/SpreaderUtils.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderOrderBuilder.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderOrderServices.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderPreActivationOrderServices.cpp;orderman/orders/spreader_orders/spreader/hedger/HedgerManager.cpp;orderman/orders/spreader_orders/spreader/hedger/UnhedgedDelta.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckCancelledStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteDriverSet.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteDriverSetHistory.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteLegDriver.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckCancelledWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForIOCWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForSizeStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderEndStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderStartStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWaitingForCancelAllStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWaitingForInitialDataStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWorkingStateWorker.cpp;orderman/orders/spreader_orders/tests/spreader_tests.cpp;orderman/server/OrderServiceServer.cpp;orderman/tests/fat_wrapper_tests.cpp;orderman2/orders/NativeOrder.cpp;orderman2/orders/Order.cpp;os/os.cpp;os/tests/os_tests.cpp;persistence/IStore.cpp;persistence/PersistenceServiceServer.cpp;persistence/SqliteStore.cpp;persistence/persistence_utils.cpp;persistence/tests/PersistenceServiceTests.cpp;plugin/SparkServices.cpp;plugin/plugin.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;tracing/PerfLog.cpp;tracing/bts_trace.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/stats.cpp;utils/tests/AuthTokenTests.cpp;utils/thread_manager.cpp) \ No newline at end of file +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/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.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/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.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/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/quickbus_cfg.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/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/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/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/md2_tests.cpp;md/test/synthetic_book_merge_tests.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/ExecutionGateway.cpp;orderman/actors/FillStore.cpp;orderman/actors/MDSupplementarySource.cpp;orderman/actors/OrderStore.cpp;orderman/actors/SODPosition.cpp;orderman/actors/SecuritySrc.cpp;orderman/actors/ServiceBridge.cpp;orderman/actors/order_manager/OrderBuilder.cpp;orderman/actors/order_manager/OrderManager.cpp;orderman/actors/order_manager/OrderServicesData.cpp;orderman/events/CancelRejectEvent.cpp;orderman/events/NewExecutionReportEvent.cpp;orderman/limiter/LimitStore.cpp;orderman/limiter/Limiter.cpp;orderman/limiter/ProductLimitNode.cpp;orderman/limiter/ProductLimitTree.cpp;orderman/limiter/SecurityLimitNode.cpp;orderman/limiter/SecurityLimitTree.cpp;orderman/limiter/tests/limit_tests.cpp;orderman/order_factory/DynamicOrderRegistry.cpp;orderman/order_factory/OrderFactory.cpp;orderman/order_router/OrderRouter.cpp;orderman/orderman_utils/fix_order_codec.cpp;orderman/orders/DynamicOrder.cpp;orderman/orders/IcebergOrder.cpp;orderman/orders/NativeOrder.cpp;orderman/orders/Order.cpp;orderman/orders/TimeBoxOrder.cpp;orderman/orders/TriggerOrder.cpp;orderman/orders/book_algos/BookAlgo.cpp;orderman/orders/book_algos/CoverOrder.cpp;orderman/orders/book_algos/JoinOrder.cpp;orderman/orders/book_algos/LeanOrder.cpp;orderman/orders/book_algos/OCOOrder.cpp;orderman/orders/book_algos/OffsetOrder.cpp;orderman/orders/book_algos/PricerOrder.cpp;orderman/orders/book_algos/TopOrder.cpp;orderman/orders/spreader_orders/SpreaderOrder.cpp;orderman/orders/spreader_orders/spreader/LegFillState.cpp;orderman/orders/spreader_orders/spreader/LegPropertyData.cpp;orderman/orders/spreader_orders/spreader/QuoteLegPriceQuantityState.cpp;orderman/orders/spreader_orders/spreader/SingleFillHedger.cpp;orderman/orders/spreader_orders/spreader/SingleLegQuoter.cpp;orderman/orders/spreader_orders/spreader/SpreaderBookkeepingData.cpp;orderman/orders/spreader_orders/spreader/SpreaderChildOrderState.cpp;orderman/orders/spreader_orders/spreader/SpreaderLegData.cpp;orderman/orders/spreader_orders/spreader/SpreaderUtils.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderOrderBuilder.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderOrderServices.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderPreActivationOrderServices.cpp;orderman/orders/spreader_orders/spreader/hedger/HedgerManager.cpp;orderman/orders/spreader_orders/spreader/hedger/UnhedgedDelta.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckCancelledStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteDriverSet.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteDriverSetHistory.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteLegDriver.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckCancelledWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForIOCWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForSizeStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderEndStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderStartStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWaitingForCancelAllStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWaitingForInitialDataStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWorkingStateWorker.cpp;orderman/orders/spreader_orders/tests/spreader_tests.cpp;orderman/server/OrderServiceServer.cpp;orderman/tests/fat_wrapper_tests.cpp;orderman2/orders/NativeOrder.cpp;orderman2/orders/Order.cpp;os/os.cpp;os/tests/os_tests.cpp;persistence/IStore.cpp;persistence/PersistenceServiceServer.cpp;persistence/SqliteStore.cpp;persistence/persistence_utils.cpp;persistence/tests/PersistenceServiceTests.cpp;plugin/SparkServices.cpp;plugin/plugin.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;tracing/PerfLog.cpp;tracing/bts_trace.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/stats.cpp;utils/tests/AuthTokenTests.cpp;utils/thread_manager.cpp) \ No newline at end of file diff --git a/src/server/sparkd/CMakeDeps.cmake b/src/server/sparkd/CMakeDeps.cmake index ff557cbbe..a4aceb09a 100644 --- a/src/server/sparkd/CMakeDeps.cmake +++ b/src/server/sparkd/CMakeDeps.cmake @@ -1 +1 @@ -set(sources algo/AlgoDefinitionServiceServer.cpp;algo/AlgoServiceServer.cpp;cmds/AdminReport.cpp;cmds/AutoCert.cpp;cmds/Benchmark.cpp;cmds/CmdRegistry.cpp;cmds/ConfigCheck.cpp;cmds/Help.cpp;cmds/Md.cpp;cmds/PrintHedgeOrders.cpp;cmds/QuickTest.cpp;cmds/Run.cpp;cmds/RunSim.cpp;cmds/Span.cpp;cmds/Test.cpp;cmds/TestCeloxica.cpp;cmds/Web.cpp;dspark/mirage/quick_queue/quick_queue.cpp;exchange_sim/ExchangeSim.cpp;exchange_sim/ExchangeSimApplication.cpp;exchange_sim/book/Book.cpp;exchange_sim/book/ExchangeSim.proto;exchange_sim/book/Order.cpp;exchange_sim/book/OrderMatcher.cpp;exchange_sim/book/book_transform.cpp;exchange_sim/tests/test_book_transform.cpp;http/ApiGateway.cpp;http/WebServer.cpp;main.cpp;md/ChannelVolume.cpp;md/MarketDataAuxiliaryServiceServer.cpp;md/VolumeAtPriceState.cpp;md/platforms/celoxica/CXListener.cpp;md/platforms/celoxica/CXMain.cpp;md/platforms/celoxica/tests/cx_tests.cpp;md/platforms/mdp3_onixs/MDP3Listener.cpp;md/platforms/mdp3_onixs/MDP3Main.cpp;md/platforms/mdp3_onixs/tests/mdp3_tests.cpp;md/run_md.cpp;position/IMarginObserver.cpp;position/IPositionObserver.cpp;position/MarginServiceCore.cpp;position/PositionServiceCore.cpp;position/PositionServiceServer.cpp;position/tests/PositionTests.cpp;support/ErrorReportService.cpp;support/ShellLatencyServer.cpp;user/AdminServiceServer.cpp;user/AuthServiceServer.cpp;user/tests/admin_service_tests.cpp) \ No newline at end of file +set(sources algo/AlgoDefinitionServiceServer.cpp;algo/AlgoServiceServer.cpp;cmds/AdminReport.cpp;cmds/AutoCert.cpp;cmds/Benchmark.cpp;cmds/CmdRegistry.cpp;cmds/ConfigCheck.cpp;cmds/Help.cpp;cmds/Md.cpp;cmds/PrintHedgeOrders.cpp;cmds/QuickTest.cpp;cmds/Run.cpp;cmds/RunSim.cpp;cmds/Span.cpp;cmds/Test.cpp;cmds/TestCeloxica.cpp;cmds/Web.cpp;dspark/mirage/quick_queue/quick_queue.cpp;exchange_sim/ExchangeSim.cpp;exchange_sim/ExchangeSimApplication.cpp;exchange_sim/book/Book.cpp;exchange_sim/book/ExchangeSim.proto;exchange_sim/book/Order.cpp;exchange_sim/book/OrderMatcher.cpp;exchange_sim/book/book_transform.cpp;exchange_sim/tests/test_book_transform.cpp;http/ApiGateway.cpp;http/WebServer.cpp;main.cpp;md/ChannelVolume.cpp;md/MarketDataAuxiliaryServiceServer.cpp;md/VolumeAtPriceState.cpp;md/platforms/IMDPlatform.cpp;md/platforms/celoxica/CXListener.cpp;md/platforms/celoxica/CXMain.cpp;md/platforms/celoxica/tests/cx_tests.cpp;md/platforms/ice_onixs/ICEListener.cpp;md/platforms/ice_onixs/ICEMain.cpp;md/platforms/ice_onixs/tests/ice_tests.cpp;md/platforms/mdp3_onixs/MDP3Listener.cpp;md/platforms/mdp3_onixs/MDP3Main.cpp;md/platforms/mdp3_onixs/tests/mdp3_tests.cpp;md/run_md.cpp;position/IMarginObserver.cpp;position/IPositionObserver.cpp;position/MarginServiceCore.cpp;position/PositionServiceCore.cpp;position/PositionServiceServer.cpp;position/tests/PositionTests.cpp;support/ErrorReportService.cpp;support/ShellLatencyServer.cpp;user/AdminServiceServer.cpp;user/AuthServiceServer.cpp;user/tests/admin_service_tests.cpp) \ No newline at end of file From 3af7e561b9b50342b314d81d2c8f27d521b035e9 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 2 Apr 2019 09:01:53 -0500 Subject: [PATCH 72/72] fix crash in miniob --- src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs index 392b4c47a..552d080aa 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs @@ -253,8 +253,8 @@ namespace mbts.spark { (gen, anims) => new OrderBookGridSettings(gen, anims.Select(a => new OrderRecordTuplePredicateAnimations(a.predicate_data, a.cell_animations, a.row_animations, a.sound_notifications))), p => p.create_predicate(notification_service.data_cache), p => p.create_notification_predicate(notification_service.data_cache), - notification_service.link_to_order, - notification_service.link_to_order, + notification_service == null ? new Func, SoundNotification, IDisposable>((p, sn) => Disposable.empty) : notification_service.link_to_order, + notification_service == null ? new Func, IDisposable>(t => Disposable.empty) : notification_service.link_to_order, col_settings_flags); }