diff --git a/.conan/windows/profiles/debug b/.conan/windows/profiles/debug new file mode 100644 index 000000000..715ec1f26 --- /dev/null +++ b/.conan/windows/profiles/debug @@ -0,0 +1,28 @@ +[settings] +os=Windows +compiler='Visual Studio' +build_type=Debug +arch=x86_64 +compiler.version=17 +compiler.runtime=MTd + +[options] +boost:without_graph=True +boost:without_iostreams=True +boost:without_json=True +boost:without_log=True +boost:without_math=True +boost:without_nowide=True +boost:without_program_options=True +boost:without_python=True +boost:without_random=True +boost:without_serialization=True +boost:without_test=True +boost:without_timer=True +boost:without_wave=True +boost:layout=system +boost:multithreading=True + +[build_requires] + +[env] diff --git a/.conan/windows/profiles/release b/.conan/windows/profiles/release new file mode 100644 index 000000000..3e675a4e3 --- /dev/null +++ b/.conan/windows/profiles/release @@ -0,0 +1,28 @@ +[settings] +os=Windows +compiler='Visual Studio' +build_type=Release +arch=x86_64 +compiler.version=17 +compiler.runtime=MT + +[options] +boost:without_graph=True +boost:without_iostreams=True +boost:without_json=True +boost:without_log=True +boost:without_math=True +boost:without_nowide=True +boost:without_program_options=True +boost:without_python=True +boost:without_random=True +boost:without_serialization=True +boost:without_test=True +boost:without_timer=True +boost:without_wave=True +boost:layout=system +boost:multithreading=True + +[build_requires] + +[env] diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index d8d5a3bc7..81773435b 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -7,6 +7,12 @@ "commands": [ "dotnet-format" ] + }, + "protobuf-net.protogen": { + "version": "3.1.17", + "commands": [ + "protogen" + ] } } } \ No newline at end of file diff --git a/.gitignore b/.gitignore index 775120b97..e6b2b6ebf 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ trace_data/ /.venv*/* .cache/ src/web/api/tsconfig.*.g.json +.conan/windows/install/* diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a50fd465..b4f6bb48b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,10 @@ set(TOOLS "${CMAKE_SOURCE_DIR}/tools") set(BUILD_SDK OFF CACHE BOOL "Build the sdk") set(BUILD_WEB ON CACHE BOOL "Build the web server") +include(${CMAKE_SOURCE_DIR}/.conan/${platform}/install/debug/conanbuildinfo.cmake) +set(CONAN_SYSTEM_INCLUDES ON) +conan_basic_setup() + include_directories(BEFORE SYSTEM ${SPARK_INCLUDE} ${EXTERNALS_ROOT}/include/zlib) link_directories(${SPARK_LIB}) @@ -31,6 +35,7 @@ if(WIN32) COMMAND cp ARGS ${TOOLS}/cpp.build.props ${CMAKE_BINARY_DIR}/Directory.Build.Props DEPENDS ${TOOLS}/cpp.build.props COMMENT "Copy cpp.build.props -> Directory.Build.Props") + add_custom_target(client_layout ALL DEPENDS ${CMAKE_BINARY_DIR}/Directory.Build.Props) else() add_compile_definitions(SPARK_ENABLE_CCAPI) add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA) diff --git a/CMakePresets.json b/CMakePresets.json index 6872d5805..a14032f1d 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -21,6 +21,8 @@ "CMAKE_CXX_FLAGS_DEBUG": "/MTd", "CMAKE_CXX_FLAGS_RELEASE": "/MT", "CMAKE_SHARED_LINKER_FLAGS_RELEASE": "/DEBUG /OPT:REF /OPT:ICF /LTCG", + "CONAN_COMPILER": "Visual Studio", + "CONAN_COMPILER_VERSION": "17", "EXTERNALS_ROOT": "${sourceDir}/externals/windows" } }, diff --git a/cmake/Protobuf.cmake b/cmake/Protobuf.cmake index 2008f9b01..5b33d2556 100644 --- a/cmake/Protobuf.cmake +++ b/cmake/Protobuf.cmake @@ -1,6 +1,4 @@ -set(Protobuf_PROTOC_EXECUTABLE "${SPARK_BIN}/protoc") set(PROTOBUF_INCLUDE_DIRS "${SPARK_INCLUDE}") -set(PROTOBUF_STATIC_LIB "libprotobuf") function(Protobuf_Generate_Cpp SRCS HDRS) set(${SRCS}) diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 000000000..c3c4411d4 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile + + +class SparkCryptoConan(ConanFile): + name = "spark_crypto" + version = "0.1" + author = "Blue Trading Solutions" + topics = ( + "crypto", "trading", "options", "futures", "derivatives", "api", + "risk", "volatility", "finance") + requires = [ + "boost/1.79.0", "catch2/3.0.1", "cmake/3.23.2", "fmt/8.1.1", + "libcurl/7.83.1", "nlohmann_json/3.10.5", "openssl/1.1.1o", + "protobuf/3.21.1", "onetbb/2021.3.0", "zlib/1.2.12" + ] + generators = ("cmake", "virtualenv") diff --git a/requirements.txt b/requirements.txt index 51c22aa07..7d3a4aadb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,17 +1,39 @@ astroid==2.7.3 autopep8==1.5.7 +bottle==0.12.21 +certifi==2022.6.15 cffi==1.14.6 +charset-normalizer==2.1.0 colorama==0.4.4 +conan==1.50.0 +fasteners==0.17.3 +gitdb==4.0.9 +idna==3.3 isort==5.9.3 +Jinja2==3.1.2 lazy-object-proxy==1.6.0 +MarkupSafe==2.1.1 mccabe==0.6.1 +node-semver==0.6.1 +patch-ng==1.17.4 platformdirs==2.3.0 +pluginbase==1.0.1 protobuf==3.19.1 pybars3==0.9.7 pycodestyle==2.7.0 pycparser==2.20 +Pygments==2.12.0 +PyJWT==2.4.0 pylint==2.10.2 PyMeta3==0.5.1 +python-dateutil==2.8.2 +PyYAML==6.0 +requests==2.28.1 +six==1.16.0 +smmap==5.0.0 +termcolor==1.1.0 toml==0.10.2 +tqdm==4.64.0 +urllib3==1.26.9 wrapt==1.12.1 yapf==0.31.0 diff --git a/src/client/Directory.Build.Props b/src/client/Directory.Build.Props index 47b823c6d..cfaf3c083 100644 --- a/src/client/Directory.Build.Props +++ b/src/client/Directory.Build.Props @@ -29,8 +29,8 @@ $(SparkRoot)\src\lib\api\service_compiler - $(Externals)\bin\protoc.exe - $(Externals)\bin\protogen.exe + protoc + dotnet protogen diff --git a/src/client/Directory.Build.Targets b/src/client/Directory.Build.Targets index 19c38157c..629def79b 100644 --- a/src/client/Directory.Build.Targets +++ b/src/client/Directory.Build.Targets @@ -3,7 +3,7 @@ @@ -17,9 +17,6 @@ DestinationFolder="$(WorkingDirectory)" SkipUnchangedFiles="True" UseHardLinksIfPossible="True" /> - @@ -37,7 +34,7 @@ Name="CompileProto3" AfterTargets="GetAssemblyVersion" Condition="'@(Proto3)'!=''" - Inputs="$(protoc); + Inputs=" %(Proto3.Identity);$(ProtocPluginBase)\plugin.py; $(ProtocPluginBase)\templates\c#\client.pb.cs; $(ProtocPluginBase)\templates\c#\server.pb.cs; @@ -52,7 +49,7 @@ (); - Log.Ui.info($"VolSurfaceUsageList vs_usage acount: {vs_usage.vol_surface_usage.Count}"); - foreach (var u in vs_usage.vol_surface_usage) { - string option_name = u.option_name; - string vs_name = u.vs_name; + Log.Ui.info($"VolSurfaceUsageList vs_usage acount: {vs_usage.VolSurfaceUsages.Count}"); + foreach (var u in vs_usage.VolSurfaceUsages) { + string option_name = u.OptionName; + string vs_name = u.VsName; int vs_key; if (name_to_ids.TryGetValue(vs_name, out vs_key)) { ulist.UsageList.Add(new VolSurfaceUsageEntry() { diff --git a/src/client/spark/AlgoProvider/AlgoProviderFactory.cs b/src/client/spark/AlgoProvider/AlgoProviderFactory.cs index 52e8f66fa..0ea20a06c 100644 --- a/src/client/spark/AlgoProvider/AlgoProviderFactory.cs +++ b/src/client/spark/AlgoProvider/AlgoProviderFactory.cs @@ -20,7 +20,7 @@ namespace mbts.spark { [ImportingConstructor] public AlgoProviderFactory(IAlgoStudioModel studio_model, DynamicOrderHelper dynamic_helper, ISecurityAuxiliaryDataModel security_auxiliary_model) { var from_conf = config.Configuration.get(); - if (from_conf.rules.Count == 0) { + if (from_conf.Rules.Count == 0) { // There seems to be a config race bug, where the returned config values are empty, despite having entries in spark.conf. // [John]I've only noticed it happen when attached to the debugger, // but best to have a contingency plan in place anyways, to prevent any chance of regression. @@ -108,7 +108,7 @@ namespace mbts.spark { .Select(t => _get_type_data(t)) .Concat(dynamic_helper.dynamic_types.Select(dt => _get_type_data(AlgoType.Dynamic, dt))) .ToListLazy(); - var conf_sets = from_conf.rules.Select(r => _to_security_algo_set(r, dynamic_helper, algo_type_data)).ToList(); + var conf_sets = from_conf.Rules.Select(r => _to_security_algo_set(r, dynamic_helper, algo_type_data)).ToList(); security_algo_provider = new AlgoProvider(conf_sets.Select(tup => tup.standard).ToList(), studio_model, dynamic_helper, security_auxiliary_model); attachable_algo_provider = new AttachableAlgoProvider(conf_sets.Select(tup => tup.attachable).ToList(), studio_model, dynamic_helper, security_auxiliary_model); } @@ -128,9 +128,9 @@ namespace mbts.spark { context == null ? new SecurityCriteriaClause() : new SecurityCriteriaClause( - exchanges: context.exchanges?.Select(EnumHelper.parse)?.ToArray(), - security_types: context.security_types?.Select(EnumHelper.parse)?.Select(t => t.security_type())?.ToArray(), - symbols: context.symbols?.ToArray()); + exchanges: context.Exchanges?.Select(EnumHelper.parse)?.ToArray(), + security_types: context.SecurityTypes?.Select(EnumHelper.parse)?.Select(t => t.security_type())?.ToArray(), + symbols: context.Symbols?.ToArray()); static (SecurityAlgoTypeSetImmutable standard, SecurityAlgoTypeSetImmutable attachable) _to_security_algo_set( bts.config.AlgoTypeRule rule, @@ -141,24 +141,24 @@ namespace mbts.spark { var dynamic_types = ImmutableHashSet.Empty.ToBuilder(); var attachable_factory_types = ImmutableHashSet.Empty.ToBuilder(); var attachable_dynamic_types = ImmutableHashSet.Empty.ToBuilder(); - foreach (var a in rule.algos) { - if (Enum.TryParse(a.name, out AlgoType sys_algo) && sys_algo != AlgoType.Composite && sys_algo != AlgoType.Dynamic) { - on_sys_match(sys_algo, a.is_attachable); - } else if (dynamic_helper.try_parse(a.name, out var dyn_type)) { - on_dyn_match(dyn_type, a.is_attachable); + foreach (var a in rule.Algos) { + if (Enum.TryParse(a.Name, out AlgoType sys_algo) && sys_algo != AlgoType.Composite && sys_algo != AlgoType.Dynamic) { + on_sys_match(sys_algo, a.IsAttachable); + } else if (dynamic_helper.try_parse(a.Name, out var dyn_type)) { + on_dyn_match(dyn_type, a.IsAttachable); } else { foreach (var (name, factory, dynamic) in algo_type_data) { - if (Regex.Match(name, a.name).Success) { + if (Regex.Match(name, a.Name).Success) { switch (factory) { case AlgoType.None: case AlgoType.Composite: // unexpected, but no need to crash continue; case AlgoType.Dynamic: - on_dyn_match(dynamic, a.is_attachable); + on_dyn_match(dynamic, a.IsAttachable); break; default: - on_sys_match(factory, a.is_attachable); + on_sys_match(factory, a.IsAttachable); break; } } @@ -168,13 +168,13 @@ namespace mbts.spark { return ( // standard new SecurityAlgoTypeSetImmutable( - _to_clause(rule.context), + _to_clause(rule.Context), new AlgoTypeSetImmutable( factory_types.ToImmutable(), dynamic_types.ToImmutable())), // attachable new SecurityAlgoTypeSetImmutable( - _to_clause(rule.context), + _to_clause(rule.Context), new AlgoTypeSetImmutable( attachable_factory_types.ToImmutable(), attachable_dynamic_types.ToImmutable()))); diff --git a/src/client/spark/Daemons/AboutDaemon.cs b/src/client/spark/Daemons/AboutDaemon.cs index 324817708..f9d3b6b29 100644 --- a/src/client/spark/Daemons/AboutDaemon.cs +++ b/src/client/spark/Daemons/AboutDaemon.cs @@ -37,7 +37,7 @@ namespace bts.ui { Window about = Application.LoadComponent(new Uri("/view/Shell/About.xaml", UriKind.Relative)) as Window; enable_crash_on_dblclick(about); if (about != null) { - about.DataContext = new { Version = Configuration.get().version, User = _user }; + about.DataContext = new { Version = Configuration.get().Version, User = _user }; about.Topmost = true; about.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (a, b) => about.Close())); about.CommandBindings.Add(new CommandBinding(ApplicationCommands.Open, (arg, e) => { diff --git a/src/client/spark/Daemons/MDDaemon.cs b/src/client/spark/Daemons/MDDaemon.cs index 4999d5881..1e47dcd9c 100644 --- a/src/client/spark/Daemons/MDDaemon.cs +++ b/src/client/spark/Daemons/MDDaemon.cs @@ -49,7 +49,7 @@ namespace bts { ss, user, security_metadata, - TimeSpan.FromMilliseconds(Configuration.get().naggle_ms), + TimeSpan.FromMilliseconds(Configuration.get().NaggleMs), TimeSpan.FromSeconds(1)) { } public MDDaemon( diff --git a/src/client/spark/Daemons/OrderTicketDaemon.cs b/src/client/spark/Daemons/OrderTicketDaemon.cs index 374869492..e9a53af78 100644 --- a/src/client/spark/Daemons/OrderTicketDaemon.cs +++ b/src/client/spark/Daemons/OrderTicketDaemon.cs @@ -33,7 +33,7 @@ namespace bts.shell { [ImportingConstructor] public OrderTicketDaemon(IBus bus, OrdersModel model, UserSettingsHub settings_hub, ErrorReporter error_reporter) - : this(bus, model, settings_hub, error_reporter, Configuration.get().close_on_send) { } + : this(bus, model, settings_hub, error_reporter, Configuration.get().CloseOnSend) { } public OrderTicketDaemon(IBus bus, OrdersModel model, UserSettingsHub settings_hub, ErrorReporter error_reporter, bool close_on_send) { _bus = bus; diff --git a/src/client/spark/Daemons/RecenterDaemon.cs b/src/client/spark/Daemons/RecenterDaemon.cs index 8c11c92d3..7ddbc3b34 100644 --- a/src/client/spark/Daemons/RecenterDaemon.cs +++ b/src/client/spark/Daemons/RecenterDaemon.cs @@ -21,7 +21,7 @@ namespace mbts.ui { [ImportingConstructor] public RecenterDaemon(IBus bus) { _bus = bus; - _time_to_center = TimeSpan.FromSeconds(config.Configuration.get().seconds_to_recenter); + _time_to_center = TimeSpan.FromSeconds(config.Configuration.get().SecondsToRecenter); _last_recenter = DateTime.UtcNow; _dispose = _bus.subscribe(SparkTags.RequestRecenterLadder).Subscribe(_ => trigger_recenter(SparkTags.RecenterLadderNow)); diff --git a/src/client/spark/Daemons/ShellLatencyDaemon.cs b/src/client/spark/Daemons/ShellLatencyDaemon.cs index c9a910749..b8f2252b1 100644 --- a/src/client/spark/Daemons/ShellLatencyDaemon.cs +++ b/src/client/spark/Daemons/ShellLatencyDaemon.cs @@ -24,7 +24,7 @@ namespace bts.perf { [ImportingConstructor] public ShellLatencyDaemon(ShellLatencyService service, Lazy user) { _service = service; - _version = Configuration.get().version; + _version = Configuration.get().Version; _username = user.Value.name; _hostname = Environment.MachineName; @@ -49,32 +49,32 @@ namespace bts.perf { async void _forever_ping_host(Ping pinger) { var config = Configuration.get(); - string server_ip = Configuration.get().config_ip; - int delay = config.workloop_milliseconds_interval; + string server_ip = Configuration.get().ConfigIp; + int delay = config.WorkloopMillisecondsInterval; int _current_missed_ping_count = 0; - if (config.shell_ping_is_enabled && pinger != null) { + if (config.ShellPingIsEnabled && pinger != null) { while (true) { try { await Task.Delay(delay); - var response = await pinger.SendPingAsync(server_ip, config.timeout_milliseconds_threshold); + var response = await pinger.SendPingAsync(server_ip, config.TimeoutMillisecondsThreshold); if (response.Status == IPStatus.Success) { _current_missed_ping_count = 0; - if (response.RoundtripTime > config.logging_milliseconds_threshold) { + if (response.RoundtripTime > config.LoggingMillisecondsThreshold) { Log.Ui.warn($"Ping response not received in a timely manner:\n" + $"\tAddress:\t{response.Address}\n" + $"\tRoundTrip:\t{response.RoundtripTime} ms"); } // potentially reset delay to initial work period (no-op otherwise) - delay = config.workloop_milliseconds_interval; + delay = config.WorkloopMillisecondsInterval; } else { _current_missed_ping_count++; - delay = _get_exp_delay(_current_missed_ping_count, config.workloop_milliseconds_interval, config.maximum_backoff_milliseconds); + delay = _get_exp_delay(_current_missed_ping_count, config.WorkloopMillisecondsInterval, config.MaximumBackoffMilliseconds); Log.Ui.warn($"Ping was not successful. Ping response: {response.Status}. Missed ping count: {_current_missed_ping_count}. Backing off for {delay} milliseconds."); } } catch (PingException e) { _current_missed_ping_count++; - delay = _get_exp_delay(_current_missed_ping_count, config.workloop_milliseconds_interval, config.maximum_backoff_milliseconds); + delay = _get_exp_delay(_current_missed_ping_count, config.WorkloopMillisecondsInterval, config.MaximumBackoffMilliseconds); Log.Ui.error($"Ping exception. {e}\nBacking off for {delay} milliseconds."); } } // end while diff --git a/src/client/spark/Init/ReleaseNotesParade.cs b/src/client/spark/Init/ReleaseNotesParade.cs index c7c70c0a3..be8a9b172 100644 --- a/src/client/spark/Init/ReleaseNotesParade.cs +++ b/src/client/spark/Init/ReleaseNotesParade.cs @@ -28,7 +28,7 @@ namespace bts.shell { } } bool check_version() { - string current = Configuration.get().version; + string current = Configuration.get().Version; if (!string.IsNullOrWhiteSpace(current) && current != "private") { using (var key = Registry.CurrentUser.CreateSubKey(@"Software\BTS")) { var value = key.GetValue("version"); diff --git a/src/client/spark/Modules/Analytics/VolSurface/VolSurfaceWindow.cs b/src/client/spark/Modules/Analytics/VolSurface/VolSurfaceWindow.cs index 2f80a8140..dee741440 100644 --- a/src/client/spark/Modules/Analytics/VolSurface/VolSurfaceWindow.cs +++ b/src/client/spark/Modules/Analytics/VolSurface/VolSurfaceWindow.cs @@ -31,7 +31,7 @@ public override string window_type => WINDOW_TYPE; string ISharedWindow.thread_id => - config.Configuration.get().vol_surface ? "VolSurface" : null; + config.Configuration.get().VolSurface ? "VolSurface" : null; public int vs_id => _startup_data.id; public string vs_name { get; } diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs b/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs index 8038890b4..93004c464 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs @@ -65,7 +65,7 @@ namespace mbts.spark { _settings_hub = settings_hub; _settings_manager = settings_hub.create_mview_settings_manager(state.grid); Icon.Freeze(); - thread_id = config.Configuration.get().market_view ? "MarketView" : null; + thread_id = config.Configuration.get().MarketView ? "MarketView" : null; _dispose = Disposable.Create(() => { Disposable.dispose(ref _subscriptions); _vm.Dispose(); diff --git a/src/client/spark/Modules/Market/TimeAndSalesWindowFactory.cs b/src/client/spark/Modules/Market/TimeAndSalesWindowFactory.cs index f8373cce2..78232ee01 100644 --- a/src/client/spark/Modules/Market/TimeAndSalesWindowFactory.cs +++ b/src/client/spark/Modules/Market/TimeAndSalesWindowFactory.cs @@ -42,7 +42,7 @@ public override Task load(TimeAndSalesSettings state) { var conf = Configuration.get(); - var thread_id = Configuration.get().time_and_sales ? + var thread_id = Configuration.get().TimeAndSales ? TimeAndSalesWindow.WINDOW_TYPE_NAME : null; var settings_man = new WindowSettingsManager( _settings_hub, state.grid, s => s.time_and_sales_grid, (s, g) => s.with(time_and_sales: g)); @@ -52,7 +52,7 @@ _consumer, state, settings_man, - conf.can_pause_updates, + conf.CanPauseUpdates, _security_auxiliary_model.get_display_quantity_divisor, thread_id); return Task.FromResult(win); diff --git a/src/client/spark/Modules/Settings/SettingsShellModule.cs b/src/client/spark/Modules/Settings/SettingsShellModule.cs index 0a737d859..969a7f2d9 100644 --- a/src/client/spark/Modules/Settings/SettingsShellModule.cs +++ b/src/client/spark/Modules/Settings/SettingsShellModule.cs @@ -32,7 +32,7 @@ namespace bts.ui { SparkCommands.ShowGlobalAlerts, SparkCommands.ShowWorkspaces }; - if (Configuration.get().enabled) { + if (Configuration.get().Enabled) { actions_list.Add(SparkCommands.ShowSettings); } actions = actions_list; diff --git a/src/client/spark/Modules/ShellModuleCollection.cs b/src/client/spark/Modules/ShellModuleCollection.cs index 15c8e6c21..6df74b73b 100644 --- a/src/client/spark/Modules/ShellModuleCollection.cs +++ b/src/client/spark/Modules/ShellModuleCollection.cs @@ -26,9 +26,9 @@ namespace bts { static bool _is_hidden(IShellModule module) { var props = Configuration.get(); string name = module.GetType().Name; - foreach (var p in props.module) { - if (p.name.ToLower() == name.ToLower()) { - return !p.visible; + foreach (var p in props.Modules) { + if (p.Name.ToLower() == name.ToLower()) { + return !p.Visible; } } return false; diff --git a/src/client/spark/Modules/Spreader/SyntheticManagementWindow.cs b/src/client/spark/Modules/Spreader/SyntheticManagementWindow.cs index ec6e6948a..7b0ded691 100644 --- a/src/client/spark/Modules/Spreader/SyntheticManagementWindow.cs +++ b/src/client/spark/Modules/Spreader/SyntheticManagementWindow.cs @@ -42,7 +42,7 @@ namespace mbts.spark { _state = state; _settings_manager = settings_manager; Icon.Freeze(); - thread_id = config.Configuration.get().synthetic_management ? + thread_id = config.Configuration.get().SyntheticManagement ? "SyntheticManagement" : null; _dispose = Disposable.Create(() => { Disposable.dispose(ref _vm); diff --git a/src/client/spark/Modules/Support/Browser/BrowserWindow.cs b/src/client/spark/Modules/Support/Browser/BrowserWindow.cs index 60fbc2732..a2e1622fe 100644 --- a/src/client/spark/Modules/Support/Browser/BrowserWindow.cs +++ b/src/client/spark/Modules/Support/Browser/BrowserWindow.cs @@ -44,8 +44,8 @@ namespace bts.shell { string uristr = uri.ToString(); string http_base = "http://{0}:{1}/".fmt( - Configuration.get().config_host, - Configuration.get().config_port); + Configuration.get().ConfigHost, + Configuration.get().ConfigPort); string temp = uristr; if (uristr.StartsWith("bts://m/")) { temp = uristr.Replace("bts://m/", http_base + "docs/"); @@ -94,7 +94,7 @@ namespace bts.shell { emulation_key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(ke_name); } - var process_name = Configuration.get().process_name; + var process_name = Configuration.get().ProcessName; emulation_key.SetValue(process_name, 11001); // IE11 } #endregion diff --git a/src/client/spark/Modules/Trading/AlgoStudio/AlgoStudioWindow.cs b/src/client/spark/Modules/Trading/AlgoStudio/AlgoStudioWindow.cs index 7bec54999..4c7bc2c72 100644 --- a/src/client/spark/Modules/Trading/AlgoStudio/AlgoStudioWindow.cs +++ b/src/client/spark/Modules/Trading/AlgoStudio/AlgoStudioWindow.cs @@ -43,7 +43,7 @@ namespace mbts.spark { : base(NAME, bus, factory, SparkCommands.ShowAlgoStudio.icon) { _model = model; _state = state; - thread_id = config.Configuration.get().algo_studio ? "AlgoStudio" : null; + thread_id = config.Configuration.get().AlgoStudio ? "AlgoStudio" : null; _dispose = Disposable.Create(_dispose_core); } @@ -74,12 +74,12 @@ namespace mbts.spark { _commands.Add(new SparkCommandCommand("Add Algo", Icons.AddBoxes, _vm.add_definition_cmd)); _commands.Add(new SparkCommandCommand("Clone Algo", Icons.CopyBoxes, _vm.clone_selected_definition_cmd)); _commands.Add(new SparkCommandCommand("Save Algo", Icons.DiskFile, _vm.save_cmd) { - show_in_toolbar = _ui_configuration.can_save_specific + show_in_toolbar = _ui_configuration.CanSaveSpecific }); _commands.Add(new SparkCommandCommand("Save All", Icons.Disk, ObservantAsyncCommand.create(_vm.save_all, out var save_all_observer))); _resources.Add(_vm.subscribe_dirty().OnDispatcher().Subscribe(save_all_observer)); // undo/redo - if (_ui_configuration.can_undo_redo) { + if (_ui_configuration.CanUndoRedo) { // undo var undo_cmd = new ObservantCommand(() => _vm.selected_definition?.try_undo()); var undo_spark_cmd = new SparkCommandCommand("Undo", Icons.UndoCircular, undo_cmd); diff --git a/src/client/spark/Modules/Trading/AlgoStudio/Model/IAlgoStudioModel.cs b/src/client/spark/Modules/Trading/AlgoStudio/Model/IAlgoStudioModel.cs index 7adadaa41..af2fe078f 100644 --- a/src/client/spark/Modules/Trading/AlgoStudio/Model/IAlgoStudioModel.cs +++ b/src/client/spark/Modules/Trading/AlgoStudio/Model/IAlgoStudioModel.cs @@ -17,10 +17,10 @@ namespace mbts.spark { static class AlgoStudioModelUtils { public static IReadOnlyDictionary get_dynamic_resources(bts.config.AlgoStudioOptions ui_configuration) => new Dictionary { - { AlgoStudioWindow.ShowAlgoToolBarRenameDefinitionKey, ui_configuration.can_modify_definition_name && ui_configuration.show_algo_toolbar_rename }, - { AlgoStudioWindow.ShowAlgoToolBarSaveDefinitionKey, ui_configuration.can_modify_definition_values && ui_configuration.show_algo_toolbar_save }, - { AlgoStudioWindow.ShowAlgoToolBarRevertDefinitionKey, ui_configuration.show_algo_toolbar_revert }, - { AlgoStudioWindow.ShowAlgoToolBarUndoRedoDefinitionKey, ui_configuration.show_algo_toolbar_undo_redo } + { AlgoStudioWindow.ShowAlgoToolBarRenameDefinitionKey, ui_configuration.CanModifyDefinitionName && ui_configuration.ShowAlgoToolbarRename }, + { AlgoStudioWindow.ShowAlgoToolBarSaveDefinitionKey, ui_configuration.CanModifyDefinitionValues && ui_configuration.ShowAlgoToolbarSave }, + { AlgoStudioWindow.ShowAlgoToolBarRevertDefinitionKey, ui_configuration.ShowAlgoToolbarRevert }, + { AlgoStudioWindow.ShowAlgoToolBarUndoRedoDefinitionKey, ui_configuration.ShowAlgoToolbarUndoRedo } }; } } diff --git a/src/client/spark/Modules/Trading/AlgoStudio/VM/AlgoDefinitionVM.cs b/src/client/spark/Modules/Trading/AlgoStudio/VM/AlgoDefinitionVM.cs index aeee811db..8f824d3d6 100644 --- a/src/client/spark/Modules/Trading/AlgoStudio/VM/AlgoDefinitionVM.cs +++ b/src/client/spark/Modules/Trading/AlgoStudio/VM/AlgoDefinitionVM.cs @@ -65,9 +65,9 @@ namespace mbts.spark { _permissions_mask.mask = init_permissions; _permissions_mask.raw = init_permissions; var resources = new CompositeDisposable(); - if (!model.algo_model.ui_configuration.can_modify_definition_values) + if (!model.algo_model.ui_configuration.CanModifyDefinitionValues) editing_permissions_mask ^= (AlgoEditingPermissions.AllowEditValues | AlgoEditingPermissions.AllowSaveValues); - if (!model.algo_model.ui_configuration.can_modify_definition_structure) + if (!model.algo_model.ui_configuration.CanModifyDefinitionStructure) editing_permissions_mask ^= (AlgoEditingPermissions.AllowEditStructure | AlgoEditingPermissions.AllowSaveStructure); key = def_data.key; algos_view = ObservableAutoWrapper.create_sorted_wrapper(_algo_roots, AlgoCollectionHelper.algo_vm_comparer); @@ -128,7 +128,7 @@ namespace mbts.spark { case AlgoKey.Mode.Persisted: _metadata = new AlgoDefinitionMetadata(key); resources.Add(model.algo_model.metadata_service.subscribe_metadata(key).OnDispatcher().Subscribe(_on_metadata)); - _edit_pane_vs_model.set_state(VisualStateNames.Name.GroupName, conf.can_modify_definition_name ? VisualStateNames.Name.Active : VisualStateNames.Name.CannotRenameDefinition); + _edit_pane_vs_model.set_state(VisualStateNames.Name.GroupName, conf.CanModifyDefinitionName ? VisualStateNames.Name.Active : VisualStateNames.Name.CannotRenameDefinition); break; case AlgoKey.Mode.Factory: _edit_pane_vs_model.set_state(VisualStateNames.Name.GroupName, VisualStateNames.Name.Inactive); diff --git a/src/client/spark/Modules/Trading/Fills/FillsWindow.cs b/src/client/spark/Modules/Trading/Fills/FillsWindow.cs index 807763ee6..5535195f3 100644 --- a/src/client/spark/Modules/Trading/Fills/FillsWindow.cs +++ b/src/client/spark/Modules/Trading/Fills/FillsWindow.cs @@ -37,7 +37,7 @@ namespace mbts.spark { _orders_model = orders_model; _state = state; _settings_manager = settings_manager; - thread_id = config.Configuration.get().fills ? "Fills" : null; + thread_id = config.Configuration.get().Fills ? "Fills" : null; _dispose = Disposable.Create(() => { Disposable.dispose(ref _vm); if (_commands != null) { diff --git a/src/client/spark/Modules/Trading/Ladder/LadderSettings.cs b/src/client/spark/Modules/Trading/Ladder/LadderSettings.cs index 45c08c91d..92e64fe04 100644 --- a/src/client/spark/Modules/Trading/Ladder/LadderSettings.cs +++ b/src/client/spark/Modules/Trading/Ladder/LadderSettings.cs @@ -515,7 +515,7 @@ namespace mbts.spark { static LadderSettings() { var knobs = config.Configuration.get(); - mimic_tt = knobs.mimic_tt; + mimic_tt = knobs.MimicTt; } // Default proto constructor diff --git a/src/client/spark/Modules/Trading/Ladder/LadderWindowFactory.cs b/src/client/spark/Modules/Trading/Ladder/LadderWindowFactory.cs index 3b053d359..981118c6d 100644 --- a/src/client/spark/Modules/Trading/Ladder/LadderWindowFactory.cs +++ b/src/client/spark/Modules/Trading/Ladder/LadderWindowFactory.cs @@ -58,7 +58,7 @@ _sec_meta_store = sec_meta_store; _ladder_conf = new LadderConfig( Configuration.get(), - Configuration.get().ladder); + Configuration.get().Ladder); _thread_id_provider = ShellWindowThreadIDFactory.create(_window_type, _ladder_conf.ladders_on_threads); _mbo = mbo; _dispose = Disposable.Create( @@ -117,10 +117,10 @@ public readonly TimeSpan security_timeout; public LadderConfig(bts.config.LadderKnobs knobs, bool ladders_on_threads) { - max_open_ladders = knobs.max_open_ladders; - open_algo_popup_on_select = knobs.open_algo_popup_on_select; - use_algo_param_grid = knobs.use_algo_param_grid; - security_timeout = TimeSpan.FromSeconds(Math.Max(15, knobs.security_timeout_secs)); + max_open_ladders = knobs.MaxOpenLadders; + open_algo_popup_on_select = knobs.OpenAlgoPopupOnSelect; + use_algo_param_grid = knobs.UseAlgoParamGrid; + security_timeout = TimeSpan.FromSeconds(Math.Max(15, knobs.SecurityTimeoutSecs)); this.ladders_on_threads = ladders_on_threads; } } diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderGridHost.cs b/src/client/spark/Modules/Trading/Ladder/View/LadderGridHost.cs index e60f2f588..4c256600e 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderGridHost.cs +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderGridHost.cs @@ -101,16 +101,16 @@ namespace mbts.spark { static LadderGridHost() { var knobs = config.Configuration.get(); - _show_scrollbar = knobs.show_scrollbar; - _lighten_market_cells = knobs.lighten_market_cells; - _initial_row_count = (int)knobs.scrollable_tick_window_size; + _show_scrollbar = knobs.ShowScrollbar; + _lighten_market_cells = knobs.LightenMarketCells; + _initial_row_count = (int)knobs.ScrollableTickWindowSize; // For market cell backgrounds, 0 means null. Note that the full // range of colors can still be expressed, as zero is merely one of // 2^24 possible representations of 'transparent.' - if (knobs.bid_market_cell_background != 0) - _bid_market_cell_background = knobs.bid_market_cell_background.argb_color(); - if (knobs.ask_market_cell_background != 0) - _ask_market_cell_background = knobs.ask_market_cell_background.argb_color(); + if (knobs.BidMarketCellBackground != 0) + _bid_market_cell_background = knobs.BidMarketCellBackground.argb_color(); + if (knobs.AskMarketCellBackground != 0) + _ask_market_cell_background = knobs.AskMarketCellBackground.argb_color(); } public LadderGridHost() { diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderView.xaml.cs b/src/client/spark/Modules/Trading/Ladder/View/LadderView.xaml.cs index 2218d242b..6eb726022 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderView.xaml.cs +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderView.xaml.cs @@ -27,7 +27,7 @@ namespace mbts.spark { static LadderView() { var knobs = config.Configuration.get(); - MimicTT = knobs.mimic_tt; + MimicTT = knobs.MimicTt; } public static bool MimicTT { get; } diff --git a/src/client/spark/Modules/Trading/ManualFills/ManualFillsWindowFactory.cs b/src/client/spark/Modules/Trading/ManualFills/ManualFillsWindowFactory.cs index e68440a83..12a0b193f 100644 --- a/src/client/spark/Modules/Trading/ManualFills/ManualFillsWindowFactory.cs +++ b/src/client/spark/Modules/Trading/ManualFills/ManualFillsWindowFactory.cs @@ -130,8 +130,8 @@ namespace bts.shell { } public static ManualFillsConfig read() => new ManualFillsConfig( - mbts.config.Configuration.get().manual_fills ? window_type : null, - mbts.config.Configuration.get().modal_transactions); + mbts.config.Configuration.get().ManualFills ? window_type : null, + mbts.config.Configuration.get().ModalTransactions); } static class CommandGroups { diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookColumns.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookColumns.cs index 30f4247d7..fde65d489 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookColumns.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookColumns.cs @@ -1260,7 +1260,7 @@ namespace mbts.spark { _background_converter = new AnonymousMultiValueConverter( (selected, status) => selected || status != OrderStatus.Working ? Brushes.Transparent : BTSColors.Orders.working_order_background_brush); - static readonly bool _animate_child_order_rows = mbts.config.Configuration.get().animate_child_order_rows; + static readonly bool _animate_child_order_rows = mbts.config.Configuration.get().AnimateChildOrderRows; public static BindingBase _get_background_binding() { var mb = new MultiBinding { Converter = _background_converter }; diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs index ceafe9809..80dab9718 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs @@ -1014,11 +1014,11 @@ namespace mbts.spark { var top = config.Configuration.get(); var offset = config.Configuration.get(); _algo_type_conf = new Dictionary { - { CustomOrderDefinition.CustomOneofCase.Cover, (cover.show_price, cover.show_quantity) }, - { CustomOrderDefinition.CustomOneofCase.Join, (join.show_price, join.show_quantity) }, - { CustomOrderDefinition.CustomOneofCase.Lean, (lean.show_price, lean.show_quantity) }, - { CustomOrderDefinition.CustomOneofCase.Top, (top.show_price, top.show_quantity) }, - { CustomOrderDefinition.CustomOneofCase.Offset, (offset.show_price, offset.show_quantity) } + { CustomOrderDefinition.CustomOneofCase.Cover, (cover.ShowPrice, cover.ShowQuantity) }, + { CustomOrderDefinition.CustomOneofCase.Join, (join.ShowPrice, join.ShowQuantity) }, + { CustomOrderDefinition.CustomOneofCase.Lean, (lean.ShowPrice, lean.ShowQuantity) }, + { CustomOrderDefinition.CustomOneofCase.Top, (top.ShowPrice, top.ShowQuantity) }, + { CustomOrderDefinition.CustomOneofCase.Offset, (offset.ShowPrice, offset.ShowQuantity) } }; } diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs index c9f2facab..d939a16a3 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs @@ -67,7 +67,7 @@ namespace mbts.spark { _state = state; _settings_manager = settings_manager; _can_edit_specific_algo_params = can_edit_specific_algo_params; - thread_id = config.Configuration.get().order_book ? "OrderBook" : null; + thread_id = config.Configuration.get().OrderBook ? "OrderBook" : null; _dispose = Disposable.Create(() => { Disposable.dispose(_thread_init_resources); Disposable.dispose(ref _attachment_exit_sub); diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindowFactory.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindowFactory.cs index 6dbca724c..e8117274a 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindowFactory.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindowFactory.cs @@ -35,7 +35,7 @@ namespace bts.shell { ISecurityMetadataStore sec_meta_store, UserSettingsHub settings_hub) : base(owner, "SparkOrderBookWindow") { var raw_config = Configuration.get(); - _config = new OrderBookConfig(raw_config.can_edit_specific_algo_params); + _config = new OrderBookConfig(raw_config.CanEditSpecificAlgoParams); _bus = bus; _notification_service = notification_service; _notification_service_data_cache = notification_service_data_cache; diff --git a/src/client/spark/Modules/Trading/OrderBook/View/OrderBookGridView.xaml.cs b/src/client/spark/Modules/Trading/OrderBook/View/OrderBookGridView.xaml.cs index 9afde67ef..d02e0ffc5 100644 --- a/src/client/spark/Modules/Trading/OrderBook/View/OrderBookGridView.xaml.cs +++ b/src/client/spark/Modules/Trading/OrderBook/View/OrderBookGridView.xaml.cs @@ -70,7 +70,7 @@ namespace mbts.spark { var bg_binding = new MultiBinding(); bg_binding.Bindings.Add(new Binding(nameof(OrderBookRowVM.status))); bg_binding.Bindings.Add(new Binding(nameof(ListBoxItem.IsSelected)) { RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(ListBoxItem), 1) }); - double overlay_opacity = config.Configuration.get().status_color_opacity_when_selected; + double overlay_opacity = config.Configuration.get().StatusColorOpacityWhenSelected; if (overlay_opacity > 0.1 && overlay_opacity < 0.9) { bg_binding.Converter = ValueConverter.create((status, is_selected) => { var color = _status_color(status); diff --git a/src/client/spark/Modules/Trading/PNL/PNLWindowFactory.cs b/src/client/spark/Modules/Trading/PNL/PNLWindowFactory.cs index 91daef06e..1d0da5ad4 100644 --- a/src/client/spark/Modules/Trading/PNL/PNLWindowFactory.cs +++ b/src/client/spark/Modules/Trading/PNL/PNLWindowFactory.cs @@ -61,7 +61,7 @@ namespace bts.shell { _position_model = position_model; _sec_meta_store = sec_meta_store; _pnl_conf = new PNLConfig(Configuration.get()); - _thread_id_provider = ShellWindowThreadIDFactory.create(_window_type, Configuration.get().pnl); + _thread_id_provider = ShellWindowThreadIDFactory.create(_window_type, Configuration.get().Pnl); _dispose = bus.subscribe(SparkTags.ShowPNLTag).OnDispatcher().Subscribe(_show); } @@ -308,8 +308,8 @@ namespace bts.shell { show_pause_resume; public PNLConfig(bts.config.PNLOptions options) { - enable_animations = options.enable_animations; - show_pause_resume = options.show_pause_resume; + enable_animations = options.EnableAnimations; + show_pause_resume = options.ShowPauseResume; } } diff --git a/src/client/spark/Modules/Trading/ReconcileReport/ReconcileReportWindow.cs b/src/client/spark/Modules/Trading/ReconcileReport/ReconcileReportWindow.cs index f0077cb97..915c18ed1 100644 --- a/src/client/spark/Modules/Trading/ReconcileReport/ReconcileReportWindow.cs +++ b/src/client/spark/Modules/Trading/ReconcileReport/ReconcileReportWindow.cs @@ -51,7 +51,7 @@ namespace Spark.Trading { IWindowSettingsManager settings_manager, UserTuple user) : base("Reconcile Report", bus, save, Icons.Reports) { - thread_id = Configuration.get().reconcile_report ? + thread_id = Configuration.get().ReconcileReport ? WINDOW_TYPE_NAME : null; _position_model = position_model; _security_metadata = security_metadata; diff --git a/src/client/spark/NMSheets/Settings/NMSheetSettingGrid.cs b/src/client/spark/NMSheets/Settings/NMSheetSettingGrid.cs index 98d314a41..9aa3da872 100644 --- a/src/client/spark/NMSheets/Settings/NMSheetSettingGrid.cs +++ b/src/client/spark/NMSheets/Settings/NMSheetSettingGrid.cs @@ -26,7 +26,7 @@ namespace BCG Right } - private readonly bool _is_remoted = mbts.config.Configuration.get().is_remote_app; + private readonly bool _is_remoted = mbts.config.Configuration.get().IsRemoteApp; [Category("Grid Lines")] [DisplayName("Row Seperator Line Color")] diff --git a/src/client/spark/NMSheets/UIComponents/MainSheet/NMSheetTheoGrid.cs b/src/client/spark/NMSheets/UIComponents/MainSheet/NMSheetTheoGrid.cs index 163ae8057..45f02ec2d 100644 --- a/src/client/spark/NMSheets/UIComponents/MainSheet/NMSheetTheoGrid.cs +++ b/src/client/spark/NMSheets/UIComponents/MainSheet/NMSheetTheoGrid.cs @@ -21,7 +21,7 @@ namespace BCG { Down } - private readonly bool _is_remoted = mbts.config.Configuration.get().is_remote_app; + private readonly bool _is_remoted = mbts.config.Configuration.get().IsRemoteApp; private readonly PerfStatsLogger _recorder = new PerfStatsLogger(); private readonly HighPerformanceTimer _timer = new HighPerformanceTimer(); private System.ComponentModel.Container components = null; @@ -350,4 +350,4 @@ namespace BCG { } #endregion } -} \ No newline at end of file +} diff --git a/src/client/spark/Notifications/INotifier.cs b/src/client/spark/Notifications/INotifier.cs index 2561cbea2..915195427 100644 --- a/src/client/spark/Notifications/INotifier.cs +++ b/src/client/spark/Notifications/INotifier.cs @@ -56,8 +56,8 @@ namespace mbts.ui { SoundNotificationPlayer _sound_player; Dispatcher _dispatcher; bool - _sound_notifications_enabled = Configuration.get().enabled, - _toast_notifications_enabled = Configuration.get().enabled; + _sound_notifications_enabled = Configuration.get().Enabled, + _toast_notifications_enabled = Configuration.get().Enabled; [ImportingConstructor] public Notifier(IBus bus, UserSettingsHub settings_hub) { @@ -77,7 +77,7 @@ namespace mbts.ui { if (_disposer.has_dispose_started) return; _sound_player = SoundNotificationPlayer.create(); - if (Configuration.get().enabled) { + if (Configuration.get().Enabled) { _toast_controller = new ToastNotificationController(bus); _settings_sub = settings_hub.subscribe_default_settings().StartWith(settings_hub.current).OnDispatcher().Subscribe(s => { if (s == null || _disposer.has_dispose_started) diff --git a/src/client/spark/Orders/OrdersModel.cs b/src/client/spark/Orders/OrdersModel.cs index 6a09e66b6..15a6a73b4 100644 --- a/src/client/spark/Orders/OrdersModel.cs +++ b/src/client/spark/Orders/OrdersModel.cs @@ -36,7 +36,7 @@ [Export] class OrdersModel : IDisposable { - public static readonly bool piq_enabled = Configuration.get().enabled; + public static readonly bool piq_enabled = Configuration.get().Enabled; public readonly MarketDataAuxiliaryModel md_auxiliary_model; public readonly ISecurityAuxiliaryDataModel security_auxiliary_model; diff --git a/src/client/spark/Predicates/Data/Events/OrderSentEventPredicate.cs b/src/client/spark/Predicates/Data/Events/OrderSentEventPredicate.cs index ea2e2c1fb..8412c9182 100644 --- a/src/client/spark/Predicates/Data/Events/OrderSentEventPredicate.cs +++ b/src/client/spark/Predicates/Data/Events/OrderSentEventPredicate.cs @@ -32,7 +32,7 @@ class OrderSentEventPredicate : IEquatable { static readonly int _type_hash = typeof(OrderSentEventPredicate).GetHashCode(); // arbitrary short time period (can override in config) - static readonly TimeSpan _stale_order_threshold = TimeSpan.FromSeconds(config.Configuration.get().stale_order_threshold_seconds); + static readonly TimeSpan _stale_order_threshold = TimeSpan.FromSeconds(config.Configuration.get().StaleOrderThresholdSeconds); public enum PredicateTypeOneofCase { [Description("(any order)")] diff --git a/src/client/spark/Predicates/IPredicateVM.cs b/src/client/spark/Predicates/IPredicateVM.cs index 8578cc924..39951ff92 100644 --- a/src/client/spark/Predicates/IPredicateVM.cs +++ b/src/client/spark/Predicates/IPredicateVM.cs @@ -30,7 +30,7 @@ namespace mbts.ui.settings { } static class PredicateVMWrapper { - static readonly bool _toast_notifications_enabled_global = Configuration.get().enabled; + static readonly bool _toast_notifications_enabled_global = Configuration.get().Enabled; public static ITemplatedPropertyWrapperVM wrap_child_oneof( Func get, Action set, Func get_child_oneof, Dictionary> oneof_vms) diff --git a/src/client/spark/Risk/Combo/ComboReportWindow.cs b/src/client/spark/Risk/Combo/ComboReportWindow.cs index e43dec2c6..934b876f7 100644 --- a/src/client/spark/Risk/Combo/ComboReportWindow.cs +++ b/src/client/spark/Risk/Combo/ComboReportWindow.cs @@ -29,7 +29,7 @@ namespace mbts.analytics { IBus bus, ISaveWindow save, ComboReportSettings settings) : base(settings.id.ToString(), bus, save, Icons.Reports) { - thread_id = config.Configuration.get().combo_report ? + thread_id = config.Configuration.get().ComboReport ? "Combo" : null; _settings = settings; _dispose = Disposable.Create(() => (_vm, _model)); diff --git a/src/client/spark/Risk/Slide/SlideReportWindow.cs b/src/client/spark/Risk/Slide/SlideReportWindow.cs index 3c2dfbe16..482ac1239 100644 --- a/src/client/spark/Risk/Slide/SlideReportWindow.cs +++ b/src/client/spark/Risk/Slide/SlideReportWindow.cs @@ -34,7 +34,7 @@ namespace mbts.analytics { ISaveWindow save, SlideReportSettings settings) : base(settings.id.ToString(), bus, save, Icons.Reports) { - thread_id = config.Configuration.get().slide_report ? "Slide" : null; + thread_id = config.Configuration.get().SlideReport ? "Slide" : null; _settings = settings; _dispose = Disposable.Create(() => Disposable.dispose(ref _vm)); } diff --git a/src/client/spark/Security/ISecurityAuxiliaryDataModel.cs b/src/client/spark/Security/ISecurityAuxiliaryDataModel.cs index c59ddc197..8fab0eb7a 100644 --- a/src/client/spark/Security/ISecurityAuxiliaryDataModel.cs +++ b/src/client/spark/Security/ISecurityAuxiliaryDataModel.cs @@ -28,9 +28,9 @@ namespace mbts.spark { public SecurityAuxiliaryDataModel() { var sym_config = Configuration.get(); - var sym_config_items = Configuration.get().items; + var sym_config_items = Configuration.get().Items; foreach (var item in sym_config_items) - _auxiliary_data[item.symbol] = new SecurityAuxiliaryData(item.display_quantity_divisor); + _auxiliary_data[item.Symbol] = new SecurityAuxiliaryData(item.DisplayQuantityDivisor); } public SecurityAuxiliaryData? get_auxiliary_data(SecurityImmutable security) => diff --git a/src/client/spark/ShellBootstrapper.cs b/src/client/spark/ShellBootstrapper.cs index e330a775b..87c9f41cc 100644 --- a/src/client/spark/ShellBootstrapper.cs +++ b/src/client/spark/ShellBootstrapper.cs @@ -88,7 +88,7 @@ } public override void CreateShell(ShellModel model) { - if (Configuration.get().software_only) { + if (Configuration.get().SoftwareOnly) { System.Windows.Media.RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly; } diff --git a/src/client/spark/core/NativeMethods/NativeMethods.cs b/src/client/spark/core/NativeMethods/NativeMethods.cs index 3ca81fe25..ade9c1e38 100644 --- a/src/client/spark/core/NativeMethods/NativeMethods.cs +++ b/src/client/spark/core/NativeMethods/NativeMethods.cs @@ -202,7 +202,7 @@ namespace mbts.ui.native { private static extern bool SetWorkArea_SystemParametersInfo(SPI action, uint zero, Win32Rect param, uint winini); public static void SetWorkArea(Rect workarea) { - var dpi_ratio = config.Configuration.get().dpi_ratio; + var dpi_ratio = config.Configuration.get().DpiRatio; workarea = new Rect(workarea.Left * dpi_ratio, workarea.Top * dpi_ratio, (workarea.Right - workarea.Left) * dpi_ratio, (workarea.Bottom - workarea.Top) * dpi_ratio); //const uint SPIF_SENDWININICHANGE = 2; const uint SPIF_UPDATEINIFILE = 1; @@ -220,7 +220,7 @@ namespace mbts.ui.native { // Get the work area for monitor where the specified window is currently. // The work area is the area of the window not covered by the task bar or a docked shell public static Rect GetWorkArea(IntPtr window) { - var dpi_ratio = config.Configuration.get().dpi_ratio; + var dpi_ratio = config.Configuration.get().DpiRatio; IntPtr monitor = MonitorFromWindow(window, MONITOR_DEFAULTONNEAREST); MONITORINFO info = new MONITORINFO(); info.cbSize = Marshal.SizeOf(info); diff --git a/src/client/spark/core/Utility/MarketSchedule.cs b/src/client/spark/core/Utility/MarketSchedule.cs index 3f3c4f748..2036572d9 100644 --- a/src/client/spark/core/Utility/MarketSchedule.cs +++ b/src/client/spark/core/Utility/MarketSchedule.cs @@ -28,13 +28,13 @@ namespace mbts.spark { // i.e. 21:30 UTC corresponds to 16:30 Central (4:30 PM), but only during *CDT* // CDT it UTC -5 // CST is UTC -6 - static readonly int sod_hh = (int)config.Configuration.get().sod_hh; - static readonly int sod_mm = (int)config.Configuration.get().sod_mm; + static readonly int sod_hh = (int)config.Configuration.get().SodHh; + static readonly int sod_mm = (int)config.Configuration.get().SodMm; static readonly TimeZoneInfo central_tzi = TimeZoneInfo.FindSystemTimeZoneById(cst_id); static MarketSchedule() { var cme_schedule = config.Configuration.get(); - _cme_gen_open_hrs = cme_schedule?.gen_open_hour ?? 8.5; + _cme_gen_open_hrs = cme_schedule?.GenOpenHour ?? 8.5; } // for object initializers public MarketSchedule() { } diff --git a/src/client/spark/view/Extensions/HighDpiExtensions.cs b/src/client/spark/view/Extensions/HighDpiExtensions.cs index 09c835ebc..a1992c4b5 100644 --- a/src/client/spark/view/Extensions/HighDpiExtensions.cs +++ b/src/client/spark/view/Extensions/HighDpiExtensions.cs @@ -24,7 +24,7 @@ namespace mbts.ui.dpi { public static readonly float fdpi_ratio; static HighDpiExtensions() { - dpi_ratio = Configuration.get().dpi_ratio; + dpi_ratio = Configuration.get().DpiRatio; pixel_unit = 1.0 / dpi_ratio; fdpi_ratio = (float)dpi_ratio; } diff --git a/src/client/spark/view/Extensions/ScrollViewerCorrector.cs b/src/client/spark/view/Extensions/ScrollViewerCorrector.cs index 15d0adc95..98883566f 100644 --- a/src/client/spark/view/Extensions/ScrollViewerCorrector.cs +++ b/src/client/spark/view/Extensions/ScrollViewerCorrector.cs @@ -8,7 +8,7 @@ using System.Windows.Input; namespace mbts.ui { class ScrollViewerCorrector { - static readonly bool _fix_nested_scrolling_enabled = mbts.config.Configuration.get().enabled; + static readonly bool _fix_nested_scrolling_enabled = mbts.config.Configuration.get().Enabled; static List _reentrancy_list => ThreadStaticActivator.instance; public static readonly DependencyProperty FixNestedScrollingProperty = diff --git a/src/client/spark/view/Extensions/WindowExtensions.cs b/src/client/spark/view/Extensions/WindowExtensions.cs index d848809f6..a396da426 100644 --- a/src/client/spark/view/Extensions/WindowExtensions.cs +++ b/src/client/spark/view/Extensions/WindowExtensions.cs @@ -9,7 +9,7 @@ using System.Windows.Media; namespace mbts.ui { static class WindowExtensions { - static readonly bool _ensure_onscreen_with_work_area_rect = config.Configuration.get().enabled; + static readonly bool _ensure_onscreen_with_work_area_rect = config.Configuration.get().Enabled; public static Rect bounds(this Window window) { return new Rect(window.Left, window.Top, window.ActualWidth, window.ActualHeight); diff --git a/src/client/spark/view/Shell/ShellModel.cs b/src/client/spark/view/Shell/ShellModel.cs index 962cb1c2f..1d9b48ccd 100644 --- a/src/client/spark/view/Shell/ShellModel.cs +++ b/src/client/spark/view/Shell/ShellModel.cs @@ -77,7 +77,7 @@ .WithParts(types) .WithDefaultConventions(rules); - string plugin_path = Configuration.get().data_path + "/plugins/"; + string plugin_path = Configuration.get().DataPath + "/plugins/"; if (Directory.Exists(plugin_path)) { var assemblies = Directory.GetFiles(plugin_path, "*.dll") .Select(AssemblyLoadContext.Default.LoadFromAssemblyPath); diff --git a/src/client/spark/view/Shell/Workspaces/WorkspacesModel.cs b/src/client/spark/view/Shell/Workspaces/WorkspacesModel.cs index 5cee3d04d..d6b1b31c0 100644 --- a/src/client/spark/view/Shell/Workspaces/WorkspacesModel.cs +++ b/src/client/spark/view/Shell/Workspaces/WorkspacesModel.cs @@ -127,7 +127,7 @@ namespace mbts.ui.shell { } public async void save_workspace_periodically() { - TimeSpan interval = TimeSpan.FromSeconds(Configuration.get().save_timer); + TimeSpan interval = TimeSpan.FromSeconds(Configuration.get().SaveTimer); await Task.Delay(interval); while (!_closing) { var workspace = await get_workspace_async(); @@ -153,7 +153,7 @@ namespace mbts.ui.shell { private static string local_workspace_path() { var system = Configuration.get(); - return @"{0}/{1}/{2}".fmt(system.data_path, WORKSPACE_NAMESPACE, "recover_workspace"); + return @"{0}/{1}/{2}".fmt(system.DataPath, WORKSPACE_NAMESPACE, "recover_workspace"); } private static void save_workspace_locally(WorkspaceDefinition workspace) { string path = local_workspace_path(); diff --git a/src/client/spark/view/Spark/Ladder/MBO/MBOPopupModel.cs b/src/client/spark/view/Spark/Ladder/MBO/MBOPopupModel.cs index 1c90cc74d..1004adca6 100644 --- a/src/client/spark/view/Spark/Ladder/MBO/MBOPopupModel.cs +++ b/src/client/spark/view/Spark/Ladder/MBO/MBOPopupModel.cs @@ -129,7 +129,7 @@ namespace mbts.spark { #region static public static readonly MBOSecurityQueryImmutable default_query = (MBOSecurityQueryImmutable) new MBOSecurityQuery { - Limit = Configuration.get().max_mbo_orders + Limit = Configuration.get().MaxMboOrders }; #endregion } diff --git a/src/client/spark/view/Spark/Utilities/WorkLoop.cs b/src/client/spark/view/Spark/Utilities/WorkLoop.cs index d678b3f4f..02b4cda7a 100644 --- a/src/client/spark/view/Spark/Utilities/WorkLoop.cs +++ b/src/client/spark/view/Spark/Utilities/WorkLoop.cs @@ -14,8 +14,8 @@ namespace mbts.spark { static WorkLoop() { var timer_params = config.Configuration.get(); - default_priority = Enum.TryParse(timer_params.priority, true, out DispatcherPriority p) ? p : DispatcherPriority.ApplicationIdle; - default_interval = TimeSpan.FromMilliseconds(timer_params.interval_ms); + default_priority = Enum.TryParse(timer_params.Priority, true, out DispatcherPriority p) ? p : DispatcherPriority.ApplicationIdle; + default_interval = TimeSpan.FromMilliseconds(timer_params.IntervalMs); } /// diff --git a/src/client/spark/view/Utility/ScreenCapture.cs b/src/client/spark/view/Utility/ScreenCapture.cs index e78b784f4..0c3d56e80 100644 --- a/src/client/spark/view/Utility/ScreenCapture.cs +++ b/src/client/spark/view/Utility/ScreenCapture.cs @@ -47,7 +47,7 @@ namespace mbts.ui.utility { static Int32Rect screen_size() { var config = Configuration.get(); - var dpi = config.dpi_ratio; + var dpi = config.DpiRatio; return new Int32Rect( (int)(SystemParameters.VirtualScreenLeft * dpi), (int)(SystemParameters.VirtualScreenTop * dpi), diff --git a/src/client/spark_core/TestRunner/TestRunner.cs b/src/client/spark_core/TestRunner/TestRunner.cs index 4de8733e7..ad38ac40d 100644 --- a/src/client/spark_core/TestRunner/TestRunner.cs +++ b/src/client/spark_core/TestRunner/TestRunner.cs @@ -106,7 +106,7 @@ namespace bts.test { port = (uint)((IPEndPoint)listener.LocalEndpoint).Port; listener.Stop(); } - var cfg = new config.QuickbusNodeCfg() { my_port = port }; + var cfg = new config.QuickbusNodeCfg() { MyPort = port }; var stream = new MemoryStream(); ProtoBuf.Serializer.Serialize(stream, cfg); IntPtr qbus = ApiNativeMethods.api_create_quickbus(stream.ToArray(), stream.Length); @@ -115,4 +115,4 @@ namespace bts.test { #endregion } -} \ No newline at end of file +} diff --git a/src/client/spark_core/logging/LogUtil.cs b/src/client/spark_core/logging/LogUtil.cs index 7c7d569b8..4aee8502f 100644 --- a/src/client/spark_core/logging/LogUtil.cs +++ b/src/client/spark_core/logging/LogUtil.cs @@ -11,7 +11,7 @@ using bts.support; namespace mbts { public static class LogUtil { - private static string log_path = Path.Combine(Configuration.get().data_path, "logging", "log"); + private static string log_path = Path.Combine(Configuration.get().DataPath, "logging", "log"); diff --git a/src/client/spark_test/Utils/TestUtils.cs b/src/client/spark_test/Utils/TestUtils.cs index 8e01b02b9..2c8a1e667 100644 --- a/src/client/spark_test/Utils/TestUtils.cs +++ b/src/client/spark_test/Utils/TestUtils.cs @@ -135,9 +135,9 @@ namespace bts.tests.utils { var prts = mbts.config.Configuration.get(); Console.WriteLine("\n\n\n\n\n\n\n\n\n\n"); - Console.WriteLine("config_port: " + prts.config_port); - Console.WriteLine("qbus_port: " + prts.qbus_port); - Console.WriteLine("glbx_sim_fix_port: " + prts.glbx_sim_fix_port); + Console.WriteLine("config_port: " + prts.ConfigPort); + Console.WriteLine("qbus_port: " + prts.QbusPort); + Console.WriteLine("glbx_sim_fix_port: " + prts.GlbxSimFixPort); Console.WriteLine("\n\n\n\n\n\n\n\n\n\n"); var ctx = new ServiceContext(); @@ -258,4 +258,4 @@ namespace bts.tests.utils { return md_result != null; } } -} \ No newline at end of file +} diff --git a/src/client/sparkcmd/Cmd/OrderStress.cs b/src/client/sparkcmd/Cmd/OrderStress.cs index 1a0bd48a5..aeba18a7d 100644 --- a/src/client/sparkcmd/Cmd/OrderStress.cs +++ b/src/client/sparkcmd/Cmd/OrderStress.cs @@ -124,7 +124,7 @@ namespace bts { ConsoleEx.WriteLine("Invalid Credentials", ConsoleColor.Red); } - if (Configuration.get().type.ToUpper() == "PROD") { + if (Configuration.get().Type.ToUpper() == "PROD") { ConsoleEx.WriteLine("Refusing to run on production system", ConsoleColor.Red); return -1; } @@ -165,4 +165,4 @@ namespace bts { } } -} \ No newline at end of file +} diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index fc37d93ae..a86f4d30f 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -100,11 +100,7 @@ if(WIN32) target_link_libraries( libspark libcurl - debug - fmtd - optimized - fmt - libtbb + debug tbb_debug libboost_system libboost_thread libboost_filesystem @@ -112,11 +108,9 @@ if(WIN32) libboost_chrono libboost_date_time libboost_atomic - libprotobuf - libprotoc - libssl - libcrypto - crypt32) + debug libprotobufd optimized libprotobuf + debug libprotocd optimized libprotoc + ${CONAN_LIBS}) else() add_library(libspark SHARED ${SparkLib_Sources} ${PROTO_SRCS} ${SERVICE_COMPILER_SRCS}) target_link_libraries( diff --git a/src/lib/config/ConfigValueQueue.cpp b/src/lib/config/ConfigValueQueue.cpp index 2ed282504..bd4f070ca 100644 --- a/src/lib/config/ConfigValueQueue.cpp +++ b/src/lib/config/ConfigValueQueue.cpp @@ -95,7 +95,7 @@ bool ConfigValueQueue::can_process(const std::string &source) { for (size_t x = 0; x < len; ++x) { // If there is a destination assignment underneath the source path // Then we cannot copy the value yet - const string &dest = _vals[x].dest_key; + const std::string &dest = _vals[x].dest_key; if (dest.compare(0, source.size(), source) == 0) { if (dest.size() <= source.size() || dest[source.size()] == '.') { return false; @@ -156,7 +156,7 @@ void ConfigValueQueue::assign( } else if (field->type() == proto::FieldDescriptor::Type::TYPE_BOOL) { reflection->SetBool(message, field, value_to_bool(value)); } else { - string error = "Invalid type conversion in assignment to " + + std::string error = "Invalid type conversion in assignment to " + message->GetTypeName() + "." + field->name(); throw ConfigurationException(error.c_str()); } @@ -227,7 +227,7 @@ void ConfigValueQueue::assign_value_to_field( case FieldDescriptor::TYPE_FIXED32: case FieldDescriptor::TYPE_INT32: if (value.which() == ValueType::string) { - lexical_assign(MY_ARGS); + lexical_assign(MY_ARGS); } else { assign(MY_ARGS); } @@ -241,9 +241,9 @@ void ConfigValueQueue::assign_value_to_field( case FieldDescriptor::TYPE_STRING: if (value.which() == ValueType::integer || value.which() == ValueType::real) { - lexical_assign(MY_ARGS); + lexical_assign(MY_ARGS); } else { - assign(MY_ARGS); + assign(MY_ARGS); } break; case FieldDescriptor::TYPE_MESSAGE: @@ -257,7 +257,7 @@ void ConfigValueQueue::assign_value_to_field( int size = reflection->FieldSize(*message, field); const EnumDescriptor *enum_type = field->enum_type(); const EnumValueDescriptor *enum_value = - enum_type->FindValueByName(boost::get(value)); + enum_type->FindValueByName(boost::get(value)); reflection->AddEnum(message, field, enum_value); if (index != size) { for (int i = index; i < size; ++i) { @@ -270,7 +270,7 @@ void ConfigValueQueue::assign_value_to_field( } else { const EnumDescriptor *enum_type = field->enum_type(); const EnumValueDescriptor *enum_value = - enum_type->FindValueByName(boost::get(value)); + enum_type->FindValueByName(boost::get(value)); set_field(message, reflection, field, enum_value, index); if (field->is_repeated()) { bump_indexes(message, field, 1); diff --git a/src/lib/config/text_format/text_format.h b/src/lib/config/text_format/text_format.h index af0fd78d8..36f7f17b7 100644 --- a/src/lib/config/text_format/text_format.h +++ b/src/lib/config/text_format/text_format.h @@ -99,11 +99,11 @@ class TextFormat { const UnknownFieldSet &unknown_fields, io::ZeroCopyOutputStream *output); // Like Print(), but outputs directly to a string. - static bool PrintToString(const Message &message, string *output); + static bool PrintToString(const Message &message, std::string *output); // Like PrintUnknownFields(), but outputs directly to a string. static bool PrintUnknownFieldsToString( - const UnknownFieldSet &unknown_fields, string *output); + const UnknownFieldSet &unknown_fields, std::string *output); // Outputs a textual representation of the value of the field supplied on // the message supplied. For non-repeated fields, an index of -1 must @@ -113,7 +113,7 @@ class TextFormat { const Message &message, const FieldDescriptor *field, int index, - string *output); + std::string *output); // Class for those users which require more fine-grained control over how // a protobuffer message is printed out. @@ -130,16 +130,16 @@ class TextFormat { const UnknownFieldSet &unknown_fields, io::ZeroCopyOutputStream *output) const; // Like TextFormat::PrintToString - bool PrintToString(const Message &message, string *output) const; + bool PrintToString(const Message &message, std::string *output) const; // Like TextFormat::PrintUnknownFieldsToString bool PrintUnknownFieldsToString( - const UnknownFieldSet &unknown_fields, string *output) const; + const UnknownFieldSet &unknown_fields, std::string *output) const; // Like TextFormat::PrintFieldValueToString void PrintFieldValueToString( const Message &message, const FieldDescriptor *field, int index, - string *output) const; + std::string *output) const; // Adjust the initial indent level of all output. Each indent level is // equal to two spaces. @@ -231,19 +231,19 @@ class TextFormat { // by Print(). static bool Parse(io::ZeroCopyInputStream *input, Message *output); // Like Parse(), but reads directly from a string. - static bool ParseFromString(const string &input, Message *output); + static bool ParseFromString(const std::string &input, Message *output); // Like Parse(), but the data is merged into the given message, as if // using Message::MergeFrom(). static bool Merge(io::ZeroCopyInputStream *input, Message *output); // Like Merge(), but reads directly from a string. - static bool MergeFromString(const string &input, Message *output); + static bool MergeFromString(const std::string &input, Message *output); // Parse the given text as a single field value and store it into the // given field of the given message. If the field is a repeated field, // the new value will be added to the end static bool ParseFieldValueFromString( - const string &input, const FieldDescriptor *field, Message *message); + const std::string &input, const FieldDescriptor *field, Message *message); // Interface that TextFormat::Parser can use to find extensions. // This class may be extended in the future to find more information @@ -255,7 +255,7 @@ class TextFormat { // Try to find an extension of *message by fully-qualified field // name. Returns NULL if no extension is known for this name or number. virtual const FieldDescriptor * - FindExtension(Message *message, const string &name) const = 0; + FindExtension(Message *message, const std::string &name) const = 0; }; // For more control over parsing, use this class. @@ -267,11 +267,11 @@ class TextFormat { // Like TextFormat::Parse(). bool Parse(io::ZeroCopyInputStream *input, Message *output); // Like TextFormat::ParseFromString(). - bool ParseFromString(const string &input, Message *output); + bool ParseFromString(const std::string &input, Message *output); // Like TextFormat::Merge(). bool Merge(io::ZeroCopyInputStream *input, Message *output); // Like TextFormat::MergeFromString(). - bool MergeFromString(const string &input, Message *output); + bool MergeFromString(const std::string &input, Message *output); void SetValueLookup(IDeferValueLookup *lookup) { lookup_ = lookup; } @@ -292,7 +292,7 @@ class TextFormat { // Like TextFormat::ParseFieldValueFromString bool ParseFieldValueFromString( - const string &input, const FieldDescriptor *field, Message *output); + const std::string &input, const FieldDescriptor *field, Message *output); private: // Forward declaration of an internal class used to parse text diff --git a/tools/build_protos.cmd b/tools/build_protos.cmd deleted file mode 100644 index c56afdf05..000000000 --- a/tools/build_protos.cmd +++ /dev/null @@ -1,6 +0,0 @@ -@echo off - -@call %~dp0\..\.venv\Scripts\activate.bat -set PYTHONPATH=%~dp0\..\.venv\Scripts\python -@call %~dp0\..\externals\windows\bin\protoc.exe %* - diff --git a/tools/install_conan.py b/tools/install_conan.py new file mode 100644 index 000000000..d19497a35 --- /dev/null +++ b/tools/install_conan.py @@ -0,0 +1,79 @@ +import os +from pathlib import Path +import platform +import subprocess +import argparse +import termcolor + + +def _exit(code=0, msg=None): + if msg is not None: + print(msg) + exit(code) + + +def _get_arg_parser(): + parser = argparse.ArgumentParser(description='Install conan deps') + + parser.add_argument( + '--profile', metavar='debug|release', help='The conan profile') + + parser.set_defaults(profile='debug') + return parser + + +class BuildStep: + def __init__( + self, header, body=None, begin_color='green', end_color='cyan'): + self.header = header + self.body = body + self.begin_color = begin_color + self.end_color = end_color + + def _desc_parts(self): + parts = [self.header] + if self.body is not None: + parts.append(self.body) + return parts + + def __str__(self): + return ': '.join(self._desc_parts()) + + def __enter__(self): + termcolor.cprint( + f'\n* BEGIN {self.header}', color=self.begin_color, flush=True) + if self.body is not None: + print(f'{self.body}', flush=True) + + def __exit__(self, exc_type, exc_val, exc_tb): + termcolor.cprint( + f'* END {self.header}', color=self.end_color, flush=True) + + +def _platform_name(): + return platform.system().lower() + + +def _repo_root(): + return Path(os.path.realpath(__file__)).parent.parent.absolute() + + +def _main(): + parser = _get_arg_parser() + args = parser.parse_args() + + repo_root_path = _repo_root() + os.chdir(repo_root_path) + conan_cfg_path = repo_root_path.joinpath('.conan', _platform_name()) + profile_path = conan_cfg_path.joinpath('profiles', args.profile) + install_path = conan_cfg_path.joinpath('install', args.profile) + conan_install_cmd = f'conan install --profile {profile_path} --install-folder {install_path} --build missing .' + with BuildStep(conan_install_cmd): + subprocess.run(conan_install_cmd, shell=True) + + +if __name__ == '__main__': + try: + _main() + except Exception as e: + _exit(1, str(e))