public override void update() { if (!timeGrid_.empty()) { lattice_ = this.model_.link.tree(timeGrid_); } notifyObservers(); }
/*public override void update() * { * if (!timeGrid_.empty()) * lattice_ = this.model_.tree(timeGrid_); * this.notifyObservers(); * }*/ #region PricingEngine /* protected OneAssetOption.Arguments arguments_ = new OneAssetOption.Arguments(); * protected OneAssetOption.Results results_ = new OneAssetOption.Results(); * * public IPricingEngineArguments getArguments() { return arguments_; } * public IPricingEngineResults getResults() { return results_; } * public void reset() { results_.reset(); } */ #region Observer & Observable public override void update() { if (!timeGrid_.empty()) { lattice_ = this.model_.tree(timeGrid_); } base.update(); }
public DiscretizedVanillaOption(VanillaOption.Arguments args, StochasticProcess process, TimeGrid grid) { arguments_ = args; stoppingTimes_ = new InitializedList<double>(args.exercise.dates().Count); for (int i=0; i<stoppingTimes_.Count; ++i) { stoppingTimes_[i] = process.time(args.exercise.date(i)); if (!grid.empty()) { // adjust to the given grid stoppingTimes_[i] = grid.closestTime(stoppingTimes_[i]); } } }
public DiscretizedVanillaOption(VanillaOption.Arguments args, StochasticProcess process, TimeGrid grid) { arguments_ = args; stoppingTimes_ = new InitializedList <double>(args.exercise.dates().Count); for (int i = 0; i < stoppingTimes_.Count; ++i) { stoppingTimes_[i] = process.time(args.exercise.date(i)); if (!grid.empty()) { // adjust to the given grid stoppingTimes_[i] = grid.closestTime(stoppingTimes_[i]); } } }
public DiscretizedBarrierOption(BarrierOption.Arguments args, StochasticProcess process, TimeGrid grid = null) { arguments_ = args; vanilla_ = new DiscretizedVanillaOption(arguments_, process, grid); Utils.QL_REQUIRE(args.exercise.dates().Count > 0, () => "specify at least one stopping date"); stoppingTimes_ = new InitializedList <double>(args.exercise.dates().Count); for (int i = 0; i < stoppingTimes_.Count; ++i) { stoppingTimes_[i] = process.time(args.exercise.date(i)); if (grid != null && !grid.empty()) { // adjust to the given grid stoppingTimes_[i] = grid.closestTime(stoppingTimes_[i]); } } }
//! \name inspectors public bool empty() { return(timeGrid_.empty()); }
public DiscretizedConvertible(ConvertibleBond.option.Arguments args, GeneralizedBlackScholesProcess process, TimeGrid grid) { arguments_ = args; process_ = process; dividendValues_ = new Vector(arguments_.dividends.Count, 0.0); Date settlementDate = process.riskFreeRate().link.referenceDate(); for (int i = 0; i < arguments_.dividends.Count; i++) { if (arguments_.dividends[i].date() >= settlementDate) { dividendValues_[i] = arguments_.dividends[i].amount() * process.riskFreeRate().link.discount(arguments_.dividends[i].date()); } } DayCounter dayCounter = process.riskFreeRate().currentLink().dayCounter(); Date bondSettlement = arguments_.settlementDate; stoppingTimes_ = new InitializedList <double>(arguments_.exercise.dates().Count, 0.0); for (var i = 0; i < stoppingTimes_.Count; i++) { stoppingTimes_[i] = dayCounter.yearFraction(bondSettlement, arguments_.exercise.date(i)); } callabilityTimes_ = new InitializedList <double>(arguments_.callabilityDates.Count, 0.0); for (var i = 0; i < callabilityTimes_.Count; i++) { callabilityTimes_[i] = dayCounter.yearFraction(bondSettlement, arguments_.callabilityDates[i]); } couponTimes_ = new InitializedList <double>(arguments_.couponDates.Count, 0.0); for (var i = 0; i < couponTimes_.Count; i++) { couponTimes_[i] = dayCounter.yearFraction(bondSettlement, arguments_.couponDates[i]); } dividendTimes_ = new InitializedList <double>(arguments_.dividendDates.Count, 0.0); for (var i = 0; i < dividendTimes_.Count; i++) { dividendTimes_[i] = dayCounter.yearFraction(bondSettlement, arguments_.dividendDates[i]); } if (!grid.empty()) { // adjust times to grid for (var i = 0; i < stoppingTimes_.Count; i++) { stoppingTimes_[i] = grid.closestTime(stoppingTimes_[i]); } for (var i = 0; i < couponTimes_.Count; i++) { couponTimes_[i] = grid.closestTime(couponTimes_[i]); } for (var i = 0; i < dividendTimes_.Count; i++) { dividendTimes_[i] = grid.closestTime(dividendTimes_[i]); } for (var i = 0; i < callabilityTimes_.Count; i++) { callabilityTimes_[i] = grid.closestTime(callabilityTimes_[i]); } } }