예제 #1
0
        // static method to get data directly by passing the Args to parser: i.e. input string, Focus, and bond curve.
        public static Tuple<string, DatedDataCollectionGen<double>> getData(DateTime earliestDate_, Args args, bool insertNan_ = true, bool displayAnyError_ = true)
        {
            if (args.Curve == Data.BondCurves.NONE && args.Focus != BondSpreadAnalysis.Enums.Focus.Yield)
            {
                if (displayAnyError_)
                    throw new Exception(
                      string.Format("No curve selected: You need to select a curve over which {0} is calculated", args.Focus));
                
            }

            var processed = InputStringParser.ParseToCombination(args.Curve, args.Focus, args.Text.Trim());

            if (processed == null)
            {
                if (displayAnyError_)
                    throw new Exception(
                      string.Format("Unrecognised input :Unable to parse given input string '{0}'.  Please look at examples", args.Text));
                
            }

            if (processed.Item1 != null)
            {
                if (displayAnyError_)
                    throw new Exception("Error processing given input string");
                
            }

            return new Tuple<string, DatedDataCollectionGen<double>>(null, processed.Item2);
        }
 private void PlotCMT(DateTime endDate)
 {
     for (int i = 0; i < CMTInputVM.Count; i++)
     {
         var args = new Args {Curve = CMTInputVM[i].Curve, Focus = CMTInputVM[i].Focus, Text = CMTInputVM[i].Text};
         var data = DailyDataRetriever.getData(new DateTime(StartYear, 01, 01), args);
         var dataWithRange = data.Item2.GetValuesBetweenDates(new DateTime(StartYear, 1, 1), endDate);
         CMTInputVM[i].SeriesData = dataWithRange;
         if (HasTechnicals)
             View.AddChartSeriesWithIndicator(dataWithRange, CMTInputVM[i].Text);
         else
             View.AddChartSeries(dataWithRange, CMTInputVM[i].Text);
         View.CreateChartLegend(CMTInputVM[i].Text, CMTInputVM.Count);
         SetupTechnicalsMark(dataWithRange);
     }
 }