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

            if (dividend != null)
            {
                return(dividend.amount());
            }
            else
            {
                return(0.0);
            }
        }
Example #2
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();
        }
Example #3
0
        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);
        }
Example #4
0
        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));
        }
Example #5
0
 public DividendAdder(Dividend d)
 {
     dividend = d;
 }
Example #6
0
 public DividendAdder(Dividend d)
 {
     dividend = d;
 }