37 const std::list<std::vector<Time> >& stoppingTimes,
Conditions conditions)
38 : conditions_(
std::move(conditions)) {
40 std::set<Real> allStoppingTimes;
42 allStoppingTimes.insert(stoppingTime.begin(), stoppingTime.end());
45 allStoppingTimes.end());
59 condition->applyTo(a,
t);
63 ext::shared_ptr<FdmStepConditionComposite>
65 const ext::shared_ptr<FdmSnapshotCondition>& c1,
66 const ext::shared_ptr<FdmStepConditionComposite>& c2) {
76 return ext::make_shared<FdmStepConditionComposite>(
80 ext::shared_ptr<FdmStepConditionComposite>
83 const ext::shared_ptr<Exercise>& exercise,
84 const ext::shared_ptr<FdmMesher>& mesher,
85 const ext::shared_ptr<FdmInnerValueCalculator>& calculator,
90 std::list<ext::shared_ptr<StepCondition<Array> > > stepConditions;
92 if (!cashFlow.empty()) {
93 auto dividendCondition =
94 ext::make_shared<FdmDividendHandler>(cashFlow, mesher,
95 refDate, dayCounter, 0);
96 stepConditions.push_back(dividendCondition);
98 std::vector<Time> dividendTimes = dividendCondition->dividendTimes();
99 const Time maturityTime = dayCounter.
yearFraction(refDate, exercise->lastDate());
102 for (
auto&
t: dividendTimes)
103 t = std::min(maturityTime,
t);
107 for (
auto&
t: dividendTimes)
108 t = std::min(maturityTime,
t+1e-5);
115 "exercise type is not supported");
121 ext::shared_ptr<FdmBermudanStepCondition> bermudanCondition(
124 mesher, calculator));
125 stepConditions.push_back(bermudanCondition);
129 return ext::make_shared<FdmStepConditionComposite>(
1-D array used in linear algebra.
Time yearFraction(const Date &, const Date &, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date()) const
Returns the period between two dates as a fraction of year.
const std::vector< Time > & stoppingTimes() const
std::vector< Time > stoppingTimes_
static ext::shared_ptr< FdmStepConditionComposite > joinConditions(const ext::shared_ptr< FdmSnapshotCondition > &c1, const ext::shared_ptr< FdmStepConditionComposite > &c2)
std::list< ext::shared_ptr< StepCondition< Array > > > Conditions
const Conditions & conditions() const
void applyTo(Array &a, Time t) const override
FdmStepConditionComposite(const std::list< std::vector< Time > > &stoppingTimes, Conditions conditions)
const Conditions conditions_
static ext::shared_ptr< FdmStepConditionComposite > vanillaComposite(const DividendSchedule &schedule, const ext::shared_ptr< Exercise > &exercise, const ext::shared_ptr< FdmMesher > &mesher, const ext::shared_ptr< FdmInnerValueCalculator > &calculator, const Date &refDate, const DayCounter &dayCounter)
condition to be applied at every time step
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Option exercise classes and payoff function.
american step condition for multi dimensional problems
bermudan step condition for multi dimensional problems
dividend handler for fdm method for one equity direction
layer of abstraction to calculate the inner value
step condition for value inspection
composite of fdm step conditions
Real Time
continuous quantity with 1-year units
std::vector< ext::shared_ptr< Dividend > > DividendSchedule