protected double getDividendAmount(int i)
        {
            Dividend dividend = events_[i] as Dividend;

            if (dividend != null)
            {
                return(dividend.amount());
            }
            else
            {
                return(0.0);
            }
        }
        protected override void setGridLimits()
        {
            double underlying = process_.stateVariable().link.value();

            for (int i = 0; i < events_.Count; i++)
            {
                Dividend dividend = events_[i] as Dividend;
                if (dividend == null)
                {
                    continue;
                }
                if (getDividendTime(i) < 0.0)
                {
                    continue;
                }
                underlying -= dividend.amount(underlying);
            }

            base.setGridLimits(underlying, getResidualTime());
            ensureStrikeInGrid();
        }
        public Vector adjustedGrid()
        {
            double t    = time();
            Vector grid = method().grid(t);

            // add back all dividend amounts in the future
            for (var i = 0; i < arguments_.dividends.Count; i++)
            {
                double dividendTime = dividendTimes_[i];
                if (dividendTime >= t || Utils.close(dividendTime, t))
                {
                    Dividend d = arguments_.dividends[i];
                    double   dividendDiscount = process_.riskFreeRate().currentLink().discount(dividendTime) /
                                                process_.riskFreeRate().currentLink().discount(t);
                    for (var j = 0; j < grid.size(); j++)
                    {
                        grid[j] += d.amount(grid[j]) * dividendDiscount;
                    }
                }
            }

            return(grid);
        }
        protected override void executeIntermediateStep(int step)
        {
            Dividend dividend = events_[step] as Dividend;

            if (dividend == null)
            {
                return;
            }
            DividendAdder adder = new DividendAdder(dividend);

            sMin_   = adder.value(sMin_);
            sMax_   = adder.value(sMax_);
            center_ = adder.value(center_);
            intrinsicValues_.transformGrid(adder.value);

            intrinsicValues_.sample(payoff_.value);
            prices_.transformGrid(adder.value);

            initializeOperator();
            initializeModel();

            initializeStepCondition();
            stepCondition_.applyTo(prices_.values(), getDividendTime(step));
        }
 public DividendAdder(Dividend d)
 {
     dividend = d;
 }