private double GetOriginalOrSmoothBondSpread(HistSeriesInputPanelViewModel vm, BondSpreadResult bondSpreadResult)
 {
     return IsSmooth ? SmoothLiveBondSpread(vm, bondSpreadResult) : bondSpreadResult.BondSpread;
 }
        public void LiveChartUpdate(BondSpreadResult bondSpreadResult)
        {
            Logger.Info("live chart update", typeof(HistSeriesChartViewModel));
            
            var vm = subscriptions[bondSpreadResult.Guid];
            var hasLiveData = !(vm.SeriesData.LastDate < DateTime.Today);

            var dataWithRange = vm.SeriesData;
            if (!double.IsNaN(bondSpreadResult.BondSpread))
            {

                dataWithRange.SetValueOnDate(DateTime.Today, GetOriginalOrSmoothBondSpread(vm, bondSpreadResult));                

                //View.UpdateSeries(dataWithRange, vm.KnownStructure.ToString());

                //if (!hasLiveData)
                    View.AddLivePoints(DateTime.Today, GetOriginalOrSmoothBondSpread(vm, bondSpreadResult), vm.KnownStructure.ToString());
                //else
                //    View.RefreshLiveSeries(new DatedDataCollectionGen<double>(new[] { DateTime.Today }, new[] { GetOriginalOrSmoothBondSpread(vm, bondSpreadResult) }), "Live: " + vm.KnownStructure.ToString());

                vm.SeriesData = dataWithRange;
            }
            
        }
        private double SmoothLiveBondSpread(HistSeriesInputPanelViewModel vm, BondSpreadResult bondSpreadResult)
        {
            // firstly we compare if the contract has change

            // if not change
            double smooth;
            if(vm.SeriesData.Dates.Last() == DateTime.Today)
                smooth = vm.SeriesData.Data.SkipLast().Last() + (bondSpreadResult.BondSpread - vm.OriginalLastPoint);
            else
                smooth = vm.SeriesData.Data.Last() + (bondSpreadResult.BondSpread - vm.OriginalLastPoint);

            // if change
            // todo! to implement because we have no way to find out the live ctd yet
            //var smooth = vm.SeriesData.Data.Last() + (bondSpreadResult.oBondSpread - vm.OriginalLastPoint);

            return smooth;
        }
 protected bool Equals(BondSpreadResult other)
 {
     return string.Equals(Guid, other.Guid) && Equals(Components, other.Components) && Curve == other.Curve && Country == other.Country && BondSpread.Equals(other.BondSpread);
 }