32 std::vector<DiscountFactor> discounts,
33 ext::shared_ptr<StochasticProcess1D> diffProcess,
35 : barrierType_(barrierType), barrier_(barrier), rebate_(rebate),
36 diffProcess_(
std::move(diffProcess)), sequenceGen_(
std::move(sequenceGen)),
37 payoff_(type, strike), discounts_(
std::move(discounts)) {
39 "strike less than zero not allowed");
41 "barrier less/equal zero not allowed");
50 bool isOptionActive =
false;
51 Size knockNode = null;
63 isOptionActive =
false;
64 for (i = 0; i <
n-1; i++) {
65 new_asset_price = path[i+1];
70 x = std::log(new_asset_price / asset_price);
71 y = 0.5*(x - std::sqrt (x*x - 2*vol*vol*dt*std::log(u[i])));
72 y = asset_price * std::exp(
y);
74 isOptionActive =
true;
75 if (knockNode == null)
78 asset_price = new_asset_price;
82 isOptionActive =
false;
83 for (i = 0; i <
n-1; i++) {
84 new_asset_price = path[i+1];
89 x = std::log(new_asset_price / asset_price);
90 y = 0.5*(x + std::sqrt(x*x - 2*vol*vol*dt*std::log((1-u[i]))));
91 y = asset_price * std::exp(
y);
93 isOptionActive =
true;
94 if (knockNode == null)
97 asset_price = new_asset_price;
101 isOptionActive =
true;
102 for (i = 0; i <
n-1; i++) {
103 new_asset_price = path[i+1];
108 x = std::log(new_asset_price / asset_price);
109 y = 0.5*(x - std::sqrt(x*x - 2*vol*vol*dt*std::log(u[i])));
110 y = asset_price * std::exp(
y);
112 isOptionActive =
false;
113 if (knockNode == null)
116 asset_price = new_asset_price;
120 isOptionActive =
true;
121 for (i = 0; i <
n-1; i++) {
122 new_asset_price = path[i+1];
127 x = std::log(new_asset_price / asset_price);
128 y = 0.5*(x + std::sqrt(x*x - 2*vol*vol*dt*std::log((1-u[i]))));
129 y = asset_price * std::exp(
y);
131 isOptionActive =
false;
132 if (knockNode == null)
135 asset_price = new_asset_price;
139 QL_FAIL(
"unknown barrier type");
142 if (isOptionActive) {
153 QL_FAIL(
"unknown barrier type");
164 std::vector<DiscountFactor> discounts)
165 : barrierType_(barrierType), barrier_(barrier), rebate_(rebate),
payoff_(type, strike),
166 discounts_(
std::move(discounts)) {
168 "strike less than zero not allowed");
170 "barrier less/equal zero not allowed");
179 bool isOptionActive =
false;
180 Size knockNode = null;
186 isOptionActive =
false;
187 for (i = 1; i <
n; i++) {
188 asset_price = path[i];
190 isOptionActive =
true;
191 if (knockNode == null)
197 isOptionActive =
false;
198 for (i = 1; i <
n; i++) {
199 asset_price = path[i];
201 isOptionActive =
true;
202 if (knockNode == null)
208 isOptionActive =
true;
209 for (i = 1; i <
n; i++) {
210 asset_price = path[i];
212 isOptionActive =
false;
213 if (knockNode == null)
219 isOptionActive =
true;
220 for (i = 1; i <
n; i++) {
221 asset_price = path[i];
223 isOptionActive =
false;
224 if (knockNode == null)
230 QL_FAIL(
"unknown barrier type");
233 if (isOptionActive) {
244 QL_FAIL(
"unknown barrier type");
Barrier::Type barrierType_
PlainVanillaPayoff payoff_
std::vector< DiscountFactor > discounts_
PseudoRandom::ursg_type sequenceGen_
BarrierPathPricer(Barrier::Type barrierType, Real barrier, Real rebate, Option::Type type, Real strike, std::vector< DiscountFactor > discounts, ext::shared_ptr< StochasticProcess1D > diffProcess, PseudoRandom::ursg_type sequenceGen)
Real operator()(const Path &path) const override
ext::shared_ptr< StochasticProcess1D > diffProcess_
BiasedBarrierPathPricer(Barrier::Type barrierType, Real barrier, Real rebate, Option::Type type, Real strike, std::vector< DiscountFactor > discounts)
Barrier::Type barrierType_
PlainVanillaPayoff payoff_
std::vector< DiscountFactor > discounts_
Real operator()(const Path &path) const override
template class providing a null value for a given type.
single-factor random walk
const TimeGrid & timeGrid() const
time grid
Real front() const
initial asset value
Random sequence generator based on a pseudo-random number generator.
const sample_type & nextSequence() const
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
const ext::shared_ptr< Payoff > payoff_
Real Time
continuous quantity with 1-year units
Real Volatility
volatility
std::size_t Size
size of a container
Monte Carlo barrier option engines.