diff --git a/src/client/spark/mspark/Shell/Securities/Synthetic2/ParameterRow.cs b/src/client/spark/mspark/Shell/Securities/Synthetic2/ParameterRow.cs index ec25b1f02..3ee577e89 100644 --- a/src/client/spark/mspark/Shell/Securities/Synthetic2/ParameterRow.cs +++ b/src/client/spark/mspark/Shell/Securities/Synthetic2/ParameterRow.cs @@ -1,4 +1,6 @@ -using mbts.ui.spark; +using bts.api; +using mbts.ui.spark; +using System; using System.Collections.Generic; namespace mbts.spark @@ -23,9 +25,12 @@ namespace mbts.spark public object create_cell(LegSpreaderParamsTuple leg_tup) { return new ParameterRowCell(this, leg_tup); } } - internal class SizeRowModel : ParameterBase { - public override uint get_value(LegSpreaderParamsTuple leg_tup) { return leg_tup.leg.Quantity; } - public override void set_value(LegSpreaderParamsTuple leg_tup, uint value) { leg_tup.leg.Quantity = value; } + internal class SizeRowModel : ParameterBase { + public override int get_value(LegSpreaderParamsTuple leg_tup) { return leg_tup.leg.Side == BuySell.Buy ? (int)leg_tup.leg.Quantity : -(int)leg_tup.leg.Quantity; } + public override void set_value(LegSpreaderParamsTuple leg_tup, int value) { + leg_tup.leg.Side = value > 0 ? BuySell.Buy : BuySell.Sell; + leg_tup.leg.Quantity = (uint)Math.Abs(value); + } public override string display_name { get; } = "Size"; public override string[] section_path { get; } = new[] { SectionNames.LegDef }; } diff --git a/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditor2.xaml b/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditor2.xaml index 991e81e84..447931971 100644 --- a/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditor2.xaml +++ b/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditor2.xaml @@ -16,6 +16,11 @@ + + + + + @@ -33,6 +38,11 @@ + + + + + diff --git a/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditor2.xaml.cs b/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditor2.xaml.cs index c6d22fb80..0fcad7baa 100644 --- a/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditor2.xaml.cs +++ b/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditor2.xaml.cs @@ -148,6 +148,7 @@ namespace mbts.ui.spark { public DataTemplate DoubleTemplate { get; set; } public DataTemplate BooleanTemplate { get; set; } + public DataTemplate IntTemplate { get; set; } public DataTemplate UIntTemplate { get; set; } public override DataTemplate SelectTemplate(object item, DependencyObject container) { @@ -157,6 +158,7 @@ namespace mbts.ui.spark Type gt = t.GenericTypeArguments[0]; if (gt == typeof(bool)) return BooleanTemplate; if (gt == typeof(double)) return DoubleTemplate; + if (gt == typeof(int)) return IntTemplate; if (gt == typeof(uint)) return UIntTemplate; } } diff --git a/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditorVM2.cs b/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditorVM2.cs index 0b2c4bdfd..9a855645d 100644 --- a/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditorVM2.cs +++ b/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditorVM2.cs @@ -8,14 +8,17 @@ using System.Windows.Input; namespace mbts.spark { + /// + /// The view model designed to serve as the DataContext for the SyntheticEditor2 control + /// internal partial class SyntheticEditorVM2 { /// /// Initializes a new instance of SyntheticEditorVM2 class. The commit command will create a new Synthetic if synthetic's Id is 0, otherwise it will modify the existing synthetic's strategy. /// - /// - /// the synthetic security to create, or existing strategy modify, on commit - /// the new or existing strategy to modify + /// The application bus + /// The new synthetic security to create, or existing synthetic security who's strategy to modify, on commit + /// The new strategy to create, or existing strategy to modify, on commit public SyntheticEditorVM2(IBus bus, Security synthetic, ExecutionStrategy strategy) { _synthetic = synthetic; leg_tuples = _synthetic.Synthetic.Legs.Select(l => new LegSpreaderParamsTuple(l, strategy.LegParamsMap[l.Security.Id])).ToList(); @@ -32,10 +35,11 @@ namespace mbts.spark new PayupRowModel(), new PaylessRowModel(), new LeanRatioRowModel(), - new MaxTicksInsideMarket() + new MaxTicksInsideMarket(), }; commit = new DelegateCommand(() => new SyntheticEditorModel(bus).save(_synthetic, strategy)); } + private readonly Security _synthetic; public string name { get => _synthetic.Synthetic.Name; set => _synthetic.Synthetic.Name = value; }