public void REPORT_FAILURE(string greekName, Average.Type averageType, double runningAccumulator, int pastFixings, List<Date> fixingDates, StrikedTypePayoff payoff, Exercise exercise, double s, double q, double r, Date today, double v, double expected, double calculated, double tolerance) { Assert.Fail(exercise + " " + exercise + " Asian option with " + averageType + " and " + payoff + " payoff:\n" + " running variable: " + runningAccumulator + "\n" + " past fixings: " + pastFixings + "\n" + " future fixings: " + fixingDates.Count() + "\n" + " underlying value: " + s + "\n" + " strike: " + payoff.strike() + "\n" + " dividend yield: " + q + "\n" + " risk-free rate: " + r + "\n" + " reference date: " + today + "\n" + " maturity: " + exercise.lastDate() + "\n" + " volatility: " + v + "\n\n" + " expected " + greekName + ": " + expected + "\n" + " calculated " + greekName + ": " + calculated + "\n" + " error: " + Math.Abs(expected - calculated) + "\n" + " tolerance: " + tolerance); }
protected ConvertibleBond( Exercise exercise, double conversionRatio, DividendSchedule dividends, CallabilitySchedule callability, Handle<Quote> creditSpread, Date issueDate, int settlementDays, Schedule schedule, double redemption) : base(settlementDays, schedule.calendar(), issueDate) { conversionRatio_ = conversionRatio; callability_ = callability; dividends_ = dividends; creditSpread_ = creditSpread; maturityDate_ = schedule.endDate(); if (!callability.empty()) { Utils.QL_REQUIRE( callability.Last().date() <= maturityDate_, () => "last callability date (" + callability.Last().date() + ") later than maturity (" + maturityDate_.ToShortDateString() + ")"); } creditSpread.registerWith(update); }
public DiscretizedOption(DiscretizedAsset underlying, Exercise.Type exerciseType, List<double> exerciseTimes) { underlying_ = underlying; exerciseType_ = exerciseType; exerciseTimes_ =exerciseTimes; }
void REPORT_FAILURE(string greekName, StrikedTypePayoff payoff, Exercise exercise, double s, double q, double r, Date today, double v, double expected, double calculated, double error, double tolerance) { Assert.Fail(exercise + " " + payoff.optionType() + " option with " + payoff + " payoff:\n" + " spot value: " + s + "\n" + " strike: " + payoff.strike() + "\n" + " dividend yield: " + q + "\n" + " risk-free rate: " + r + "\n" + " reference date: " + today + "\n" + " maturity: " + exercise.lastDate() + "\n" + " volatility: " + v + "\n\n" + " expected " + greekName + ": " + expected + "\n" + " calculated " + greekName + ": " + calculated + "\n" + " error: " + error + "\n" + " tolerance: " + tolerance); }
VanillaOption makeOption(StrikedTypePayoff payoff, Exercise exercise, Quote u, YieldTermStructure q, YieldTermStructure r, BlackVolTermStructure vol, EngineType engineType, int binomialSteps, int samples) { GeneralizedBlackScholesProcess stochProcess = makeProcess(u, q, r, vol); IPricingEngine engine; switch (engineType) { case EngineType.Analytic: engine = new AnalyticEuropeanEngine(stochProcess); break; case EngineType.JR: engine = new BinomialVanillaEngine<JarrowRudd>(stochProcess, binomialSteps); break; case EngineType.CRR: engine = new BinomialVanillaEngine<CoxRossRubinstein>(stochProcess, binomialSteps); break; case EngineType.EQP: engine = new BinomialVanillaEngine<AdditiveEQPBinomialTree>(stochProcess, binomialSteps); break; case EngineType.TGEO: engine = new BinomialVanillaEngine<Trigeorgis>(stochProcess, binomialSteps); break; case EngineType.TIAN: engine = new BinomialVanillaEngine<Tian>(stochProcess, binomialSteps); break; case EngineType.LR: engine = new BinomialVanillaEngine<LeisenReimer>(stochProcess, binomialSteps); break; case EngineType.JOSHI: engine = new BinomialVanillaEngine<Joshi4>(stochProcess, binomialSteps); break; case EngineType.FiniteDifferences: engine = new FDEuropeanEngine(stochProcess, binomialSteps, samples); break; case EngineType.Integral: engine = new IntegralEngine(stochProcess); break; //case EngineType.PseudoMonteCarlo: // engine = MakeMCEuropeanEngine<PseudoRandom>(stochProcess) // .withSteps(1) // .withSamples(samples) // .withSeed(42); // break; //case EngineType.QuasiMonteCarlo: // engine = MakeMCEuropeanEngine<LowDiscrepancy>(stochProcess) // .withSteps(1) // .withSamples(samples); // break; default: throw new ArgumentException("unknown engine type"); } VanillaOption option = new EuropeanOption(payoff, exercise); option.setPricingEngine(engine); return option; }
public DividendVanillaOption(StrikedTypePayoff payoff, Exercise exercise, List <Date> dividendDates, List <double> dividends) : base(payoff, exercise) { cashFlow_ = Utils.DividendVector(dividendDates, dividends); }
public ConvertibleFixedCouponBond( Exercise exercise, double conversionRatio, DividendSchedule dividends, CallabilitySchedule callability, Handle<Quote> creditSpread, Date issueDate, int settlementDays, List<double> coupons, DayCounter dayCounter, Schedule schedule, double redemption = 100) : base(exercise, conversionRatio, dividends, callability, creditSpread, issueDate, settlementDays, schedule, redemption) { // !!! notional forcibly set to 100 cashflows_ = new FixedRateLeg(schedule) .withCouponRates(coupons, dayCounter) .withNotionals(100.0) .withPaymentAdjustment(schedule.businessDayConvention()); addRedemptionsToCashflows(new List<double>(){redemption}); Utils.QL_REQUIRE(redemptions_.Count == 1, "multiple redemptions created"); option_ = new option(this, exercise, conversionRatio, dividends, callability, creditSpread, cashflows_, dayCounter, schedule, issueDate, settlementDays, redemption); }
public VanillaOption(StrikedTypePayoff payoff, Exercise exercise) : base(payoff, exercise) {}
public ConvertibleZeroCouponBond(Exercise exercise, double conversionRatio, DividendSchedule dividends, CallabilitySchedule callability, Handle<Quote> creditSpread, Date issueDate, int settlementDays, DayCounter dayCounter, Schedule schedule, double redemption = 100) : base(exercise, conversionRatio, dividends, callability, creditSpread, issueDate, settlementDays,schedule, redemption) { cashflows_ = new List<CashFlow>(); // !!! notional forcibly set to 100 setSingleRedemption(100.0, redemption, maturityDate_); option_ = new option(this, exercise, conversionRatio, dividends, callability, creditSpread, cashflows_, dayCounter, schedule, issueDate, settlementDays, redemption); }
public VanillaOption(StrikedTypePayoff payoff, Exercise exercise) : base(payoff, exercise) { }
public MultiAssetOption(Payoff payoff, Exercise exercise) : base(payoff, exercise) { }
public BarrierOption(Barrier.Type barrierType, double barrier, double rebate, StrikedTypePayoff payoff, Exercise exercise) : base(payoff, exercise) { barrierType_ = barrierType; barrier_ = barrier; rebate_ = rebate; }
public EuropeanOption(StrikedTypePayoff payoff, Exercise exercise) : base(payoff, exercise) { }
public BasketOption(BasketPayoff payoff, Exercise exercise) : base(payoff, exercise) { }
public Option(Payoff payoff, Exercise exercise) { payoff_ = payoff; exercise_ = exercise; }
public Swaption value() { Date evaluationDate = Settings.evaluationDate(); Calendar fixingCalendar = swapIndex_.fixingCalendar(); fixingDate_ = fixingCalendar.advance(evaluationDate, optionTenor_, optionConvention_); if (exerciseDate_ == null) { exercise_ =new EuropeanExercise(fixingDate_); } else { if(exerciseDate_ <= fixingDate_) throw new ArgumentException( "exercise date (" + exerciseDate_ + ") must be less "+ "than or equal to fixing date (" + fixingDate_ + ")"); exercise_ = new EuropeanExercise(exerciseDate_); } double usedStrike = strike_; if (strike_ == null) { // ATM on the forecasting curve if (!swapIndex_.forwardingTermStructure().empty()) throw new ArgumentException( "no forecasting term structure set to "+swapIndex_.name()); VanillaSwap temp = swapIndex_.underlyingSwap(fixingDate_); temp.setPricingEngine(new DiscountingSwapEngine( swapIndex_.forwardingTermStructure())); usedStrike = temp.fairRate(); } BusinessDayConvention bdc = swapIndex_.fixedLegConvention(); underlyingSwap_ =new MakeVanillaSwap( swapIndex_.tenor(), swapIndex_.iborIndex(), usedStrike) .withEffectiveDate(swapIndex_.valueDate(fixingDate_)) .withFixedLegCalendar(swapIndex_.fixingCalendar()) .withFixedLegDayCount(swapIndex_.dayCounter()) .withFixedLegConvention(bdc) .withFixedLegTerminationDateConvention(bdc); Swaption swaption=new Swaption(underlyingSwap_, exercise_, delivery_); swaption.setPricingEngine(engine_); return swaption; }
public ConvertibleFloatingRateBond( Exercise exercise, double conversionRatio, DividendSchedule dividends, CallabilitySchedule callability, Handle<Quote> creditSpread, Date issueDate, int settlementDays, IborIndex index, int fixingDays, List<double> spreads, DayCounter dayCounter, Schedule schedule, double redemption = 100) : base(exercise, conversionRatio, dividends, callability, creditSpread, issueDate, settlementDays, schedule, redemption) { // !!! notional forcibly set to 100 cashflows_ = new IborLeg(schedule, index) .withPaymentDayCounter(dayCounter) .withFixingDays(fixingDays) .withSpreads(spreads) .withNotionals(100.0) .withPaymentAdjustment(schedule.businessDayConvention()); addRedemptionsToCashflows(new List<double>{redemption}); Utils.QL_REQUIRE( redemptions_.Count == 1, () => "multiple redemptions created" ); option_ = new option(this, exercise, conversionRatio, dividends, callability, creditSpread, cashflows_, dayCounter, schedule, issueDate, settlementDays, redemption); }
//public class engine; public option( ConvertibleBond bond, Exercise exercise, double conversionRatio, DividendSchedule dividends, CallabilitySchedule callability, Handle<Quote> creditSpread, List<CashFlow> cashflows, DayCounter dayCounter, Schedule schedule, Date issueDate, int settlementDays, double redemption) :base(new PlainVanillaPayoff(Option.Type.Call, (bond.notionals()[0])/100.0 *redemption/conversionRatio), exercise) { bond_ = bond; conversionRatio_ = conversionRatio; callability_ = callability; dividends_ = dividends; creditSpread_ = creditSpread; cashflows_ = cashflows; dayCounter_ = dayCounter; issueDate_ = issueDate; schedule_ = schedule; settlementDays_ = settlementDays; redemption_ = redemption; }