SyntheticEditor2 - fix LegSizeRowModel
This commit is contained in:
1 parent
a8b6338411
commit
e7a3dbad5c
4 files changed
+29
-8
No files matched your search
@@ -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<T>(this, leg_tup); }
|
||||
}
|
||||
|
||||
internal class SizeRowModel : ParameterBase<uint> {
|
||||
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<int> {
|
||||
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 };
|
||||
}
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
<TextBlock Text="{Binding value}"/>
|
||||
</DataTemplate>
|
||||
</usp:DataGridParameterCellTemplateSelector.DoubleTemplate>
|
||||
<usp:DataGridParameterCellTemplateSelector.IntTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding value}"/>
|
||||
</DataTemplate>
|
||||
</usp:DataGridParameterCellTemplateSelector.IntTemplate>
|
||||
<usp:DataGridParameterCellTemplateSelector.UIntTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding value}"/>
|
||||
@@ -33,6 +38,11 @@
|
||||
<c:TickUpDownDouble Value="{Binding value}"/>
|
||||
</DataTemplate>
|
||||
</usp:DataGridParameterCellTemplateSelector.DoubleTemplate>
|
||||
<usp:DataGridParameterCellTemplateSelector.IntTemplate>
|
||||
<DataTemplate>
|
||||
<c:TickUpDownInt Value="{Binding value}"/>
|
||||
</DataTemplate>
|
||||
</usp:DataGridParameterCellTemplateSelector.IntTemplate>
|
||||
<usp:DataGridParameterCellTemplateSelector.UIntTemplate>
|
||||
<DataTemplate>
|
||||
<c:TickUpDownUInt Value="{Binding value}"/>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,14 +8,17 @@ using System.Windows.Input;
|
||||
|
||||
namespace mbts.spark
|
||||
{
|
||||
/// <summary>
|
||||
/// The view model designed to serve as the DataContext for the SyntheticEditor2 control
|
||||
/// </summary>
|
||||
internal partial class SyntheticEditorVM2
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="bus"></param>
|
||||
/// <param name="synthetic">the synthetic security to create, or existing strategy modify, on commit</param>
|
||||
/// <param name="strategy">the new or existing strategy to modify</param>
|
||||
/// <param name="bus">The application bus</param>
|
||||
/// <param name="synthetic">The new synthetic security to create, or existing synthetic security who's strategy to modify, on commit</param>
|
||||
/// <param name="strategy">The new strategy to create, or existing strategy to modify, on commit</param>
|
||||
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; }
|
||||
|
||||
Reference in new issue
Block a user