Add aggregator to MGSHPositionSumFunctionRisk.
Add RMultipleValueConverter so that we can represent RMultiple as numeric in the grid while at the same time preserving the "R" which is appended to it.
This commit is contained in:
@@ -290,6 +290,22 @@ namespace TradeBlotter.UIUtils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class MGSHPositionSumFunctionRisk:AggregateFunction<MGSHPositionModel,String>
|
||||||
|
{
|
||||||
|
public MGSHPositionSumFunctionRisk()
|
||||||
|
{
|
||||||
|
this.AggregationExpression=items => Sum(items);
|
||||||
|
}
|
||||||
|
private String Sum(IEnumerable<MGSHPositionModel> source)
|
||||||
|
{
|
||||||
|
StringBuilder sb=new StringBuilder();
|
||||||
|
List<MGSHPositionModel> activePositions=source.Where(x => x.IsActivePosition).ToList();
|
||||||
|
double sum=activePositions.Sum(x => x.TotalRiskExposure);
|
||||||
|
return Utility.FormatCurrency(sum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// **********************************************************************************************************************************
|
// **********************************************************************************************************************************
|
||||||
// ********************************************************* C M M O M E N T U M ******************************************************
|
// ********************************************************* C M M O M E N T U M ******************************************************
|
||||||
// **********************************************************************************************************************************
|
// **********************************************************************************************************************************
|
||||||
|
|||||||
@@ -10,6 +10,20 @@ using MarketData.Utils;
|
|||||||
|
|
||||||
namespace TradeBlotter.UIUtils
|
namespace TradeBlotter.UIUtils
|
||||||
{
|
{
|
||||||
|
public class RMultipleValueConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||||
|
{
|
||||||
|
double doubleValue = (double)value;
|
||||||
|
if (double.IsNaN(doubleValue)) return Constants.CONST_DASHES;
|
||||||
|
return Utility.FormatNumber(doubleValue,2)+"R";
|
||||||
|
}
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class DoubleValueConverter : IValueConverter
|
public class DoubleValueConverter : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||||
|
|||||||
Reference in New Issue
Block a user