/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* Copyright (C) 2003 Ferdinando Ametrano Copyright (C) 2007 StatPro Italia srl This file is part of QuantLib, a free-software/open-source library for financial quantitative analysts and developers - http://quantlib.org/ QuantLib is free software: you can redistribute it and/or modify it under the terms of the QuantLib license. You should have received a copy of the license along with this program; if not, please email . The license is also available online at . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ #include namespace QuantLib { QuantoForwardVanillaOption::QuantoForwardVanillaOption( const Handle& foreignRiskFreeTS, const Handle& exchRateVolTS, const Handle& correlation, Real moneyness, Date resetDate, const boost::shared_ptr& process, const boost::shared_ptr& payoff, const boost::shared_ptr& exercise, const boost::shared_ptr& engine) : QuantoVanillaOption(foreignRiskFreeTS, exchRateVolTS, correlation, process, payoff, exercise, engine), moneyness_(moneyness), resetDate_(resetDate) { QL_REQUIRE(engine, "null engine or wrong engine type"); } void QuantoForwardVanillaOption::setupArguments( PricingEngine::arguments* args) const { VanillaOption::setupArguments(args); QuantoForwardVanillaOption::arguments* arguments = dynamic_cast(args); QL_REQUIRE(arguments != 0, "pricing engine does not supply needed arguments"); arguments->foreignRiskFreeTS = foreignRiskFreeTS_; arguments->exchRateVolTS = exchRateVolTS_; QL_REQUIRE(!correlation_.empty(), "null correlation given"); arguments->correlation = correlation_->value(); arguments->moneyness = moneyness_; arguments->resetDate = resetDate_; } void QuantoForwardVanillaOption::performCalculations() const { /* we must set the arguments of the underlying engine (which cannot be done by QuantoEngine.) */ typedef QuantoEngine engine_type; boost::shared_ptr qengine = boost::dynamic_pointer_cast(engine_); QL_REQUIRE(qengine, "wrong engine given"); ForwardVanillaOption::arguments* args = qengine->underlyingArgs(); VanillaOption::setupArguments(args); args->moneyness = moneyness_; args->resetDate = resetDate_; // now go on with the show as originally scheduled QuantoVanillaOption::performCalculations(); } }