29#include <ql/patterns/lazyobject.hpp>
30#include <ql/settings.hpp>
31#include <ql/time/daycounters/actualactual.hpp>
33#include <boost/any.hpp>
36class ComputationGraph;
44using QuantLib::Integer;
45using QuantLib::Natural;
48class ModelCG :
public QuantLib::LazyObject {
52 explicit ModelCG(
const QuantLib::Size n);
62 virtual QuantLib::Size
size()
const {
return n_; }
75 virtual const std::string&
baseCcy()
const = 0;
78 virtual std::size_t
dt(
const Date& d1,
const Date& d2)
const;
81 virtual std::size_t
pay(
const std::size_t amount,
const Date& obsdate,
const Date& paydate,
82 const std::string& currency)
const = 0;
85 virtual std::size_t
discount(
const Date& obsdate,
const Date& paydate,
const std::string& currency)
const = 0;
88 virtual std::size_t
npv(
const std::size_t amount,
const Date& obsdate,
const std::size_t
filter,
89 const boost::optional<long>& memSlot,
const std::size_t addRegressor1,
90 const std::size_t addRegressor2)
const = 0;
102 virtual std::size_t
eval(
const std::string& index,
const Date& obsdate,
const Date& fwddate,
103 const bool returnMissingFixingAsNull =
false,
104 const bool ignoreTodaysFixing =
false)
const = 0;
107 virtual std::size_t
fwdCompAvg(
const bool isAvg,
const std::string& index,
const Date& obsdate,
const Date& start,
108 const Date& end,
const Real spread,
const Real gearing,
const Integer lookback,
109 const Natural rateCutoff,
const Natural fixingDays,
const bool includeSpread,
110 const Real cap,
const Real floor,
const bool nakedOption,
111 const bool localCapFloor)
const = 0;
114 virtual std::size_t
barrierProbability(
const std::string& index,
const Date& obsdate1,
const Date& obsdate2,
115 const std::size_t barrier,
const bool above)
const = 0;
118 virtual std::size_t
fxSpotT0(
const std::string& forCcy,
const std::string& domCcy)
const = 0;
142 void calculate()
const override { LazyObject::calculate(); }
149 QuantLib::ext::shared_ptr<QuantExt::ComputationGraph>
g_;
155 const QuantLib::Size
n_;
virtual const Date & referenceDate() const =0
void performCalculations() const override
virtual void resetNPVMem()
virtual Type type() const =0
virtual std::size_t discount(const Date &obsdate, const Date &paydate, const std::string ¤cy) const =0
std::map< std::string, boost::any > additionalResults_
virtual std::size_t eval(const std::string &index, const Date &obsdate, const Date &fwddate, const bool returnMissingFixingAsNull=false, const bool ignoreTodaysFixing=false) const =0
virtual Real getDirectDiscountT0(const Date &paydate, const std::string ¤cy) const =0
virtual std::size_t cgVersion() const =0
QuantLib::ext::shared_ptr< QuantExt::ComputationGraph > computationGraph()
virtual Real getDirectFxSpotT0(const std::string &forCcy, const std::string &domCcy) const =0
QuantLib::ext::shared_ptr< QuantExt::ComputationGraph > g_
void calculate() const override
virtual void toggleTrainingPaths() const
virtual std::size_t pay(const std::size_t amount, const Date &obsdate, const Date &paydate, const std::string ¤cy) const =0
virtual std::size_t barrierProbability(const std::string &index, const Date &obsdate1, const Date &obsdate2, const std::size_t barrier, const bool above) const =0
virtual Size trainingSamples() const
virtual std::vector< std::pair< std::size_t, std::function< double(void)> > > & modelParameterFunctors() const =0
virtual const std::string & baseCcy() const =0
virtual Real extractT0Result(const QuantExt::RandomVariable &value) const =0
virtual std::size_t dt(const Date &d1, const Date &d2) const
virtual std::vector< std::pair< std::size_t, double > > modelParameters() const =0
virtual std::size_t fxSpotT0(const std::string &forCcy, const std::string &domCcy) const =0
const std::map< std::string, boost::any > & additionalResults() const
virtual std::size_t fwdCompAvg(const bool isAvg, const std::string &index, const Date &obsdate, const Date &start, const Date &end, const Real spread, const Real gearing, const Integer lookback, const Natural rateCutoff, const Natural fixingDays, const bool includeSpread, const Real cap, const Real floor, const bool nakedOption, const bool localCapFloor) const =0
virtual const std::vector< std::vector< std::size_t > > & randomVariates() const =0
virtual std::size_t npv(const std::size_t amount, const Date &obsdate, const std::size_t filter, const boost::optional< long > &memSlot, const std::size_t addRegressor1, const std::size_t addRegressor2) const =0
virtual QuantLib::Size size() const
SafeStack< ValueType > value
SafeStack< Filter > filter
Serializable Credit Default Swap.