private void generate() { var args = new RecentMovesGenerationArgs { CMTCurvePoints = new[] { 3d, 5d, 7d, 10d, 13d, 15d, 18d, 20d, 25d, 30d }, PeriodLenghts = new[] { 1, 5, 10, 21, 42, 63 } }; var task = new Task<IList<Tuple<string, IList<Tuple<string, double>>>>>( () => RecentMovesHelper.GetGraphData( args)); task.GetAwaiter().OnCompleted(() => { var data = task.Result; columnChartMultiArea1.Create( rows_: args.Markets.Length, columns_: args.CMTCurvePoints.Length, data_: data, xAxisLabelFormatString_: null, yAxisLabelFormatString_: "##0.0#"); columnChartMultiArea1.SetColumnColors( x => Singleton<SI.Controls.SpectrumColoursPositiveNegative>.Instance.GetColor(x, 3d)); var maxValue = data.Aggregate(0d, (current, item) => item.Item2.Select(innerItem => Math.Abs(innerItem.Item2)).Concat(new[] {current}).Max()); columnChartMultiArea1.StandardizeYAxisLimits(maxValue); LookFeel.ProcessControl(this); }); task.Start(); }
public static IList<Tuple<string, IList<Tuple<string, double>>>> GetGraphData(RecentMovesGenerationArgs arg_) { var ret = new List<Tuple<string, IList<Tuple<string, double>>>>(); foreach (var market in arg_.Markets) { var hist = HistoricalCMT.GetInstance(BondAnalysisLineHelper.GetDefaultCurveForMarket(market), market, arg_.Focus, false); foreach (var curvePoint in arg_.CMTCurvePoints) { var item = new Tuple<string, IList<Tuple<string, double>>>( item1: string.Format("{0}.{1}Y", EnumDescriptionAttribute.GetDescription(market), curvePoint), item2: new List<Tuple<string, double>>()); ret.Add(item); var pointIndex = CMTLine.IndexOfPoint(curvePoint); var historicalCMTPoint = hist.CMTs.GetColumnValuesAsDDC(pointIndex); var dailyVol = Statistics.Stdev(historicalCMTPoint.GetEndValues(arg_.DailyVolCalcWindow).Data); Array.ForEach(arg_.PeriodLenghts, x => { var move = historicalCMTPoint.Length >= x ? historicalCMTPoint.LastDataValue - historicalCMTPoint.Data[historicalCMTPoint.Length - x - 1] : 0; item.Item2.Add(new Tuple<string, double>(x.ToString(), move / (dailyVol * Math.Sqrt(Convert.ToDouble(x))))); }); } } return ret; }