32#include <ql/indexes/interestrateindex.hpp>
33#include <ql/instruments/swaption.hpp>
34#include <ql/methods/montecarlo/lsmbasissystem.hpp>
75 const Handle<CrossAssetModel>& model,
const SequenceType calibrationPathGenerator,
76 const SequenceType pricingPathGenerator,
const Size calibrationSamples,
const Size pricingSamples,
77 const Size calibrationSeed,
const Size pricingSeed,
const Size polynomOrder,
78 const LsmBasisSystem::PolynomialType polynomType,
const SobolBrownianGenerator::Ordering ordering,
79 const SobolRsg::DirectionIntegers directionIntegers,
80 const std::vector<Handle<YieldTermStructure>>& discountCurves = std::vector<Handle<YieldTermStructure>>(),
81 const std::vector<Date>& simulationDates = std::vector<Date>(),
82 const std::vector<Size>& externalModelIndices = std::vector<Size>(),
const bool minimalObsDate =
true,
84 const Real regressionVarianceCutoff = Null<Real>());
90 QuantLib::ext::shared_ptr<AmcCalculator>
amcCalculator()
const;
93 mutable std::vector<Leg>
leg_;
96 mutable QuantLib::ext::shared_ptr<Exercise>
exercise_;
133 std::function<
RandomVariable(
const Size n,
const std::vector<std::vector<const RandomVariable*>>&)>
141 RegressionModel(
const Real observationTime,
const std::vector<CashflowInfo>& cashflowInfo,
142 const std::function<
bool(std::size_t)>& cashflowRelevant,
const CrossAssetModel& model,
143 const RegressorModel regressorModel,
const Real regressionVarianceCutoff = Null<Real>());
145 void train(
const Size polynomOrder,
const LsmBasisSystem::PolynomialType polynomType,
146 const RandomVariable& regressand,
const std::vector<std::vector<const RandomVariable*>>& paths,
147 const std::set<Real>& pathTimes,
const Filter& filter =
Filter());
149 RandomVariable apply(
const Array& initialState,
const std::vector<std::vector<const RandomVariable*>>& paths,
150 const std::set<Real>& pathTimes)
const;
166 const std::set<Real>& exerciseXvaTimes,
const std::set<Real>& exerciseTimes,
167 const std::set<Real>& xvaTimes,
168 const std::vector<McMultiLegBaseEngine::RegressionModel>& regModelUndDirty,
169 const std::vector<McMultiLegBaseEngine::RegressionModel>& regModelUndExInto,
170 const std::vector<McMultiLegBaseEngine::RegressionModel>& regModelContinuationValue,
171 const std::vector<McMultiLegBaseEngine::RegressionModel>& regModelOption,
172 const Real resultValue,
const Array& initialState,
const Currency& baseCurrency);
175 std::vector<QuantExt::RandomVariable>
simulatePath(
const std::vector<QuantLib::Real>& pathTimes,
176 std::vector<std::vector<QuantExt::RandomVariable>>& paths,
177 const std::vector<size_t>& relevantPathIndex,
178 const std::vector<size_t>& relevantTimeIndex)
override;
198 Real
time(
const Date& d)
const;
205 Size
timeIndex(
const Time t,
const std::set<Real>& simulationTimes)
const;
209 const std::set<Real>& simulationTimes)
const;
interface for amc calculator
std::vector< McMultiLegBaseEngine::RegressionModel > regModelUndExInto_
std::set< Real > exerciseTimes_
std::set< Real > exerciseXvaTimes_
std::vector< McMultiLegBaseEngine::RegressionModel > regModelOption_
std::vector< QuantExt::RandomVariable > simulatePath(const std::vector< QuantLib::Real > &pathTimes, std::vector< std::vector< QuantExt::RandomVariable > > &paths, const std::vector< size_t > &relevantPathIndex, const std::vector< size_t > &relevantTimeIndex) override
Settlement::Type settlement_
Currency npvCurrency() override
std::vector< Filter > exercised_
std::vector< McMultiLegBaseEngine::RegressionModel > regModelContinuationValue_
std::vector< McMultiLegBaseEngine::RegressionModel > regModelUndDirty_
std::set< Real > xvaTimes_
std::vector< Size > externalModelIndices_
RegressionModel()=default
std::set< std::pair< Real, Size > > regressorTimesModelIndices_
Real regressionVarianceCutoff_
std::vector< std::function< RandomVariable(const std::vector< const RandomVariable * > &)> > basisFns_
Matrix coordinateTransform_
void train(const Size polynomOrder, const LsmBasisSystem::PolynomialType polynomType, const RandomVariable ®ressand, const std::vector< std::vector< const RandomVariable * > > &paths, const std::set< Real > &pathTimes, const Filter &filter=Filter())
RandomVariable apply(const Array &initialState, const std::vector< std::vector< const RandomVariable * > > &paths, const std::set< Real > &pathTimes) const
RegressorModel regressorModel_
std::vector< LgmVectorised > lgmVectorised_
SequenceType calibrationPathGenerator_
Settlement::Type optionSettlement_
Real regressionVarianceCutoff_
std::vector< Currency > currency_
QuantLib::ext::shared_ptr< Exercise > exercise_
RandomVariable cashflowPathValue(const CashflowInfo &cf, const std::vector< std::vector< RandomVariable > > &pathValues, const std::set< Real > &simulationTimes) const
SobolBrownianGenerator::Ordering ordering_
SobolRsg::DirectionIntegers directionIntegers_
Real resultUnderlyingNpv_
LsmBasisSystem::PolynomialType polynomType_
std::vector< Date > simulationDates_
static constexpr Real tinyTime
QuantLib::ext::shared_ptr< AmcCalculator > amcCalculator_
CashflowInfo createCashflowInfo(QuantLib::ext::shared_ptr< CashFlow > flow, const Currency &payCcy, bool payer, Size legNo, Size cfNo) const
Size timeIndex(const Time t, const std::set< Real > &simulationTimes) const
Real time(const Date &d) const
std::vector< Handle< YieldTermStructure > > discountCurves_
Handle< CrossAssetModel > model_
QuantLib::ext::shared_ptr< AmcCalculator > amcCalculator() const
std::vector< bool > payer_
bool includeSettlementDateFlows_
SequenceType pricingPathGenerator_
std::vector< Size > externalModelIndices_
vectorised lgm model calculations
multi leg option instrument
base class for multi path generators
boost::timer::cpu_timer calc_timer
boost::timer::cpu_timer path_timer
boost::timer::cpu_timer other_timer
std::vector< Real > simulationTimes
std::vector< std::vector< Size > > modelIndices
std::function< RandomVariable(const Size n, const std::vector< std::vector< const RandomVariable * > > &)> amountCalculator