public DateValuePair Finish()
        {
            if (Current.Date == CurrentStep)
            {
                return(null);
            }

            DateValuePair dvp = new DateValuePair()
            {
                Date = CurrentStep.Add(Step), Value = Current.Value
            };
            var ret = Push(dvp);

            return(ret[0]);
        }
        public List <DateValuePair> Push(DateValuePair dvp)
        {
            List <DateValuePair> lDVPs = new List <DateValuePair>();

            if (fFirst)
            {
                Start(dvp);

                // Add itself as first event
                lDVPs.Add(dvp);

                return(lDVPs);
            }

            DateTime NextStep = CurrentStep.Add(Step);

            while (dvp.Date >= NextStep)
            {
                double dUsedMS = Math.Min((NextStep - CurrentTime).TotalMilliseconds, 1000);
                AccumulatedValue += (dUsedMS * Current.Value) / 1000.0D;
                lDVPs.Add(new DateValuePair(-1)
                {
                    Date = NextStep, Value = AccumulatedValue
                });
                AccumulatedValue = 0;

                CurrentStep = NextStep;
                CurrentTime = NextStep;
                NextStep    = NextStep.Add(Step);
            }

            double dRemainining = Math.Min((dvp.Date - CurrentTime).TotalMilliseconds, 1000);

            AccumulatedValue += (dRemainining * Current.Value) / 1000.0D;
            CurrentTime       = dvp.Date;

            Current = dvp;

            return(lDVPs);
        }