private BsEqtySimulatorStepDatas StepSimulDatas(DateTime start, DateTime end, BlackScholesModel model, DiscountCurve assetDiscount, DateTime horizon) { DiscreteLocalDividend[] stepDividends = model.Dividends .Where(div => start < div.Date && div.Date <= end) .OrderBy(div => div.Date) .ToArray(); //If step end date is not a div date, we insert a fictious zero dividend if (!(stepDividends.Any() && end.Equals(stepDividends.Last().Date))) { stepDividends = stepDividends.Union(new[] { DiscreteLocalDividend.ZeroDiv(end) }).ToArray(); } var variance = (model.Sigma * model.Sigma).Integral(0.0); var stepVols = new double[stepDividends.Length]; var stepVarDrifts = new double[stepDividends.Length]; for (int i = 0; i < stepDividends.Length; i++) { var subStepStart = i > 0 ? stepDividends[i - 1].Date : start; var subStepEnd = stepDividends[i].Date; var subStep = RealInterval.Compact(model.Time[subStepStart], model.Time[subStepEnd]); var stepVariance = variance.Eval(subStep.Sup) - variance.Eval(subStep.Inf); var stepVarDrift = -0.5 * stepVariance; stepVols[i] = Math.Sqrt(stepVariance / subStep.Length); stepVarDrifts[i] = stepVarDrift; } var horizonDiscount = assetDiscount.Zc(horizon); var discounts = stepDividends.Map(div => horizonDiscount / assetDiscount.Zc(div.Date)); var dates = model.Time[stepDividends.Map(div => div.Date)]; var step = RealInterval.Compact(model.Time[start], model.Time[end]); return(new BsEqtySimulatorStepDatas(step, dates, stepDividends, discounts, stepVols, stepVarDrifts)); }
public static DiscreteLocalDividend DivModel(this DividendQuote divQuote) { return(DiscreteLocalDividend.AffineDividend(divQuote.Date, divQuote.Cash, divQuote.Yield)); }