Update of /cvsroot/quantlibaddin/QuantLibAddin/qlo
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv18689/qlo
Added Files:
marketmodels.cpp marketmodels.hpp
Log Message:
exporting MarketModels classes
--- NEW FILE: marketmodels.hpp ---
/*
Copyright (C) 2006 Ferdinando Ametrano
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 qua...@li...
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.
*/
#ifndef qla_market_models_hpp
#define qla_market_models_hpp
#include <oh/objhandler.hpp>
#include <ql/MarketModels/pseudoroot.hpp>
#include <ql/MarketModels/evolutiondescription.hpp>
#include <ql/MarketModels/curvestate.hpp>
#include <ql/MarketModels/driftcalculator.hpp>
#include <ql/MarketModels/browniangenerator.hpp>
#include <ql/MarketModels/marketmodelevolver.hpp>
namespace QuantLibAddin {
class PseudoRoot : public ObjHandler::LibraryObject<QuantLib::PseudoRoot> {
};
class ExponentialCorrelation : public PseudoRoot {
public:
ExponentialCorrelation(
double longTermCorr,
double beta,
const std::vector<double>& volatilities,
const QuantLib::Array& rateTimes,
const QuantLib::Array& evolutionTimes,
const QuantLib::Size numberOfFactors,
const QuantLib::Array& initialRates,
const QuantLib::Array& displacements);
};
class EvolutionDescription : public ObjHandler::LibraryObject<QuantLib::EvolutionDescription> {
public:
EvolutionDescription(
const QuantLib::Array& rateTimes,
const QuantLib::Array& evolutionTimes,
const std::vector<QuantLib::Size>& numeraires);
};
class CurveState : public ObjHandler::LibraryObject<QuantLib::CurveState> {
public:
CurveState(const QuantLib::Array& rateTimes);
};
class DriftCalculator : public ObjHandler::LibraryObject<QuantLib::DriftCalculator> {
public:
DriftCalculator(const QuantLib::Matrix& pseudo,
const QuantLib::Array& displacements,
const QuantLib::Array& taus,
QuantLib::Size numeraire,
QuantLib::Size alive);
QuantLib::Array compute(const QuantLib::Array& forwards) const;
private:
QuantLib::Size size_;
};
class BrownianGeneratorFactory : public ObjHandler::LibraryObject<QuantLib::BrownianGeneratorFactory> {
};
class MTBrownianGeneratorFactory : public BrownianGeneratorFactory {
public:
MTBrownianGeneratorFactory(unsigned long seed);
};
class MarketModelEvolver : public ObjHandler::LibraryObject<QuantLib::MarketModelEvolver> {
};
class ForwardRateEvolver : public MarketModelEvolver {
public:
ForwardRateEvolver(const boost::shared_ptr<QuantLib::PseudoRoot>&,
const QuantLib::EvolutionDescription&,
const QuantLib::BrownianGeneratorFactory&);
};
}
#endif
--- NEW FILE: marketmodels.cpp ---
/*
Copyright (C) 2006 Ferdinando Ametrano
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 qua...@li...
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.
*/
#if defined(HAVE_CONFIG_H) // Dynamically created by configure
#include <qlo/config.hpp>
#endif
#include <qlo/marketmodels.hpp>
#include <ql/MarketModels/exponentialcorrelation.hpp>
#include <ql/MarketModels/mtbrowniangenerator.hpp>
#include <ql/MarketModels/forwardrateevolver.hpp>
namespace QuantLibAddin {
ExponentialCorrelation::ExponentialCorrelation(
double longTermCorr,
double beta,
const std::vector<double>& volatilities,
const QuantLib::Array& rateTimes,
const QuantLib::Array& evolutionTimes,
const QuantLib::Size numberOfFactors,
const QuantLib::Array& initialRates,
const QuantLib::Array& displacements)
{
libraryObject_ = boost::shared_ptr<QuantLib::PseudoRoot>(
new QuantLib::ExponentialCorrelation(longTermCorr,
beta,
volatilities,
rateTimes,
evolutionTimes,
numberOfFactors,
initialRates,
displacements));
}
EvolutionDescription::EvolutionDescription(
const QuantLib::Array& rateTimes,
const QuantLib::Array& evolutionTimes,
const std::vector<QuantLib::Size>& numeraires = std::vector<QuantLib::Size>())
{
libraryObject_ = boost::shared_ptr<QuantLib::EvolutionDescription>(
new QuantLib::EvolutionDescription(rateTimes,
evolutionTimes,
numeraires));
}
CurveState::CurveState(const QuantLib::Array& rateTimes)
{
libraryObject_ = boost::shared_ptr<QuantLib::CurveState>(
new QuantLib::CurveState(rateTimes));
}
DriftCalculator::DriftCalculator(const QuantLib::Matrix& pseudo,
const QuantLib::Array& displacements,
const QuantLib::Array& taus,
QuantLib::Size numeraire,
QuantLib::Size alive)
: size_(taus.size())
{
libraryObject_ = boost::shared_ptr<QuantLib::DriftCalculator>(
new QuantLib::DriftCalculator(pseudo, displacements,
taus, numeraire, alive));
}
QuantLib::Array DriftCalculator::compute(const QuantLib::Array& forwards) const
{
QuantLib::Array results(size_);
libraryObject_->compute(forwards, results);
return results;
}
MTBrownianGeneratorFactory::MTBrownianGeneratorFactory(unsigned long seed)
{
libraryObject_ = boost::shared_ptr<QuantLib::BrownianGeneratorFactory>(
new QuantLib::MTBrownianGeneratorFactory(seed));
}
ForwardRateEvolver::ForwardRateEvolver(
const boost::shared_ptr<QuantLib::PseudoRoot>& pseudoRoot,
const QuantLib::EvolutionDescription& evolutionDescription,
const QuantLib::BrownianGeneratorFactory& brownianGeneratorfactory)
{
libraryObject_ = boost::shared_ptr<QuantLib::MarketModelEvolver>(
new QuantLib::ForwardRateEvolver(pseudoRoot,
evolutionDescription,
brownianGeneratorfactory));
}
}
|