/* Copyright (C) 2003 Niels Elken Sønderby This file is part of QuantLib for Mathematica, a Mathematica extension for QuantLib, a free-software/open-source financial C++ library http://www.nielses.dk/quantlib/mma http://quantlib.org/ QuantLib for Mathematica 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 ferdinando@ametrano.net The license is also available online at http://quantlib.org/html/license.html 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. */ #define NESQUANT #ifdef NESQUANT #include #else #include #endif #ifndef qlmma_h #define qlmma_h #include "mathlink.h" using QuantLib::Date; #define QLML_HANDLE_EXCEPTIONS catch (std::exception& e) { QLMLSignalError(e, true); } catch (...) { QLMLSignalError("unknown error in C++ part of QuantLibMma", true); } void QLMLSignalError(const char* errorMsg, bool returnFailed = false); void QLMLSignalError(const std::exception& e, bool returnFailed = false); void QLMLPutBoolean(MLINK mlp, bool val); void QLMLPutDate(MLINK mlp, Date date); void QLMLPutRule(MLINK mlp, const char* symbol, double value); using namespace QuantLib::RandomNumbers; using namespace QuantLib::VolTermStructures; using namespace QuantLib::TermStructures; using namespace QuantLib::Calendars; using namespace QuantLib::DayCounters; class ConstantTS : public virtual DiscountStructure { public: ConstantTS::ConstantTS(Rate r) : r_(r) { } Date todaysDate() const { return Date::todaysDate(); } Date referenceDate() const { return Date::todaysDate(); } Date maxDate() const { return Date::todaysDate(); } DayCounter dayCounter() const { return DayCounters::Actual365(); } protected: DiscountFactor discountImpl(Time t, bool extrapolate = false) const { return QL_EXP(- r_ * t); } DiscountFactor zeroYieldImpl(Time t, bool extrapolate = false) const { return r_; } private: Rate r_; }; Handle makeFlatCurve(double forward); Handle makeFlatVolatility(double volatility); #endif