diff --git a/src/client/spark/Orders/OrderPropertiesEditorVM.cs b/src/client/spark/Orders/OrderPropertiesEditorVM.cs index b43aa147f..6e594cd07 100644 --- a/src/client/spark/Orders/OrderPropertiesEditorVM.cs +++ b/src/client/spark/Orders/OrderPropertiesEditorVM.cs @@ -158,11 +158,11 @@ namespace mbts.spark { foreach (AlgoDefinitionVM d in e.NewItems) { switch (d.vm_key.mode) { case AlgoVMKey.Mode.Persisted: - if (_model.algo_model.ui_configuration.include_custom_templates) + if (_model.algo_model.ui_configuration.include_custom_templates && _model.algo_model.templates_enabled()) d.prepend_custom_template(); break; case AlgoVMKey.Mode.LegacyFlex: - if (_model.algo_model.ui_configuration.include_legacy_custom_templates) + if (_model.algo_model.ui_configuration.include_legacy_custom_templates && _model.algo_model.templates_enabled()) d.prepend_custom_template(); break; } @@ -209,7 +209,7 @@ namespace mbts.spark { if (reason == SelectionReason.UserSelectedNewValue && new_value?.algo_root is IOrderTypeVM ar && ar.has_editable_properties) ar.editable_properties_open = true; } - if (selected_algo_template == null) { + if (selected_algo_template == null && _model.algo_model.templates_enabled()) { if (new_value != null) selected_algo_template = new_value.templates.FirstOrDefault(tvm => tvm.is_default, tvm => _favorite_templates.ContainsKey(tvm.vm_key), tvm => true) ?? new_value.templates_with_custom.FirstOrDefault(); } else { @@ -319,7 +319,11 @@ namespace mbts.spark { var order = _model.factory.order(security, selected_account); order.TimeInForce = selected_time_in_force; order.Side = side; - selected_algo_definition.selected_template.algo_root.assign_to(order.CustomDef); + if (_model.algo_model.templates_enabled()) { + selected_algo_template.algo_root.assign_to(order.CustomDef); + } else { + selected_algo_definition.algo_root.assign_to(order.CustomDef); + } return order; }