/usr/share/quantlib-python/basketoptions.i is in quantlib-python 1.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | /*
Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 StatPro Italia srl
Copyright (C) 2005 Dominic Thuillier
Copyright (C) 2007 Joseph Wang
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
<quantlib-dev@lists.sf.net>. The license is also available online at
<http://quantlib.org/license.shtml>.
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 quantlib_basket_options_i
#define quantlib_basket_options_i
%include date.i
%include options.i
%include payoffs.i
%{
using QuantLib::BasketOption;
using QuantLib::BasketPayoff;
using QuantLib::MinBasketPayoff;
using QuantLib::MaxBasketPayoff;
using QuantLib::AverageBasketPayoff;
typedef boost::shared_ptr<Instrument> BasketOptionPtr;
typedef boost::shared_ptr<Payoff> BasketPayoffPtr;
typedef boost::shared_ptr<Payoff> MinBasketPayoffPtr;
typedef boost::shared_ptr<Payoff> MaxBasketPayoffPtr;
typedef boost::shared_ptr<Payoff> AverageBasketPayoffPtr;
%}
%rename(BasketPayoff) BasketPayoffPtr;
class BasketPayoffPtr : public boost::shared_ptr<Payoff> {};
%rename(MinBasketPayoff) MinBasketPayoffPtr;
class MinBasketPayoffPtr : public BasketPayoffPtr {
public:
%extend {
MinBasketPayoffPtr(const boost::shared_ptr<Payoff> p) {
return new MinBasketPayoffPtr(new MinBasketPayoff(p));
}
}
};
%rename(MaxBasketPayoff) MaxBasketPayoffPtr;
class MaxBasketPayoffPtr : public BasketPayoffPtr {
public:
%extend {
MaxBasketPayoffPtr(const boost::shared_ptr<Payoff> p) {
return new MaxBasketPayoffPtr(new MaxBasketPayoff(p));
}
}
};
%rename(AverageBasketPayoff) AverageBasketPayoffPtr;
class AverageBasketPayoffPtr :
public BasketPayoffPtr {
public:
%extend {
AverageBasketPayoffPtr(const boost::shared_ptr<Payoff> p,
const Array &a) {
return new AverageBasketPayoffPtr(new AverageBasketPayoff(p, a));
}
AverageBasketPayoffPtr(const boost::shared_ptr<Payoff> p,
Size n) {
return new AverageBasketPayoffPtr(new AverageBasketPayoff(p, n));
}
}
};
%rename(BasketOption) BasketOptionPtr;
class BasketOptionPtr : public MultiAssetOptionPtr {
public:
%extend {
BasketOptionPtr(
const boost::shared_ptr<Payoff>& payoff,
const boost::shared_ptr<Exercise>& exercise) {
boost::shared_ptr<BasketPayoff> stPayoff =
boost::dynamic_pointer_cast<BasketPayoff>(payoff);
QL_REQUIRE(stPayoff, "wrong payoff given");
return new BasketOptionPtr(new BasketOption(stPayoff,exercise));
}
}
};
%{
using QuantLib::MCEuropeanBasketEngine;
typedef boost::shared_ptr<PricingEngine> MCEuropeanBasketEnginePtr;
%}
%rename(MCEuropeanBasketEngine) MCEuropeanBasketEnginePtr;
class MCEuropeanBasketEnginePtr : public boost::shared_ptr<PricingEngine> {
%feature("kwargs") MCEuropeanBasketEnginePtr;
public:
%extend {
MCEuropeanBasketEnginePtr(const StochasticProcessArrayPtr& process,
const std::string& traits,
Size timeSteps = Null<Size>(),
Size timeStepsPerYear = Null<Size>(),
bool brownianBridge = false,
bool antitheticVariate = false,
intOrNull requiredSamples = Null<Size>(),
doubleOrNull requiredTolerance = Null<Real>(),
intOrNull maxSamples = Null<Size>(),
BigInteger seed = 0) {
boost::shared_ptr<StochasticProcessArray> processes =
boost::dynamic_pointer_cast<StochasticProcessArray>(process);
QL_REQUIRE(processes, "stochastic-process array required");
std::string s = boost::algorithm::to_lower_copy(traits);
if (s == "pseudorandom" || s == "pr")
return new MCEuropeanBasketEnginePtr(
new MCEuropeanBasketEngine<PseudoRandom>(processes,
timeSteps,
timeStepsPerYear,
brownianBridge,
antitheticVariate,
requiredSamples,
requiredTolerance,
maxSamples,
seed));
else if (s == "lowdiscrepancy" || s == "ld")
return new MCEuropeanBasketEnginePtr(
new MCEuropeanBasketEngine<LowDiscrepancy>(processes,
timeSteps,
timeStepsPerYear,
brownianBridge,
antitheticVariate,
requiredSamples,
requiredTolerance,
maxSamples,
seed));
else
QL_FAIL("unknown Monte Carlo engine type: "+s);
}
}
};
%{
using QuantLib::MCAmericanBasketEngine;
typedef boost::shared_ptr<PricingEngine> MCAmericanBasketEnginePtr;
%}
%rename(MCAmericanBasketEngine) MCAmericanBasketEnginePtr;
class MCAmericanBasketEnginePtr : public boost::shared_ptr<PricingEngine> {
%feature("kwargs") MCAmericanBasketEnginePtr;
public:
%extend {
MCAmericanBasketEnginePtr(const StochasticProcessArrayPtr& process,
const std::string& traits,
Size timeSteps = Null<Size>(),
Size timeStepsPerYear = Null<Size>(),
bool brownianBridge = false,
bool antitheticVariate = false,
intOrNull requiredSamples = Null<Size>(),
doubleOrNull requiredTolerance = Null<Real>(),
intOrNull maxSamples = Null<Size>(),
BigInteger seed = 0) {
boost::shared_ptr<StochasticProcessArray> processes =
boost::dynamic_pointer_cast<StochasticProcessArray>(process);
QL_REQUIRE(processes, "stochastic-process array required");
std::string s = boost::algorithm::to_lower_copy(traits);
if (s == "pseudorandom" || s == "pr")
return new MCAmericanBasketEnginePtr(
new MCAmericanBasketEngine<PseudoRandom>(processes,
timeSteps,
timeStepsPerYear,
brownianBridge,
antitheticVariate,
requiredSamples,
requiredTolerance,
maxSamples,
seed));
else if (s == "lowdiscrepancy" || s == "ld")
return new MCAmericanBasketEnginePtr(
new MCAmericanBasketEngine<LowDiscrepancy>(processes,
timeSteps,
timeStepsPerYear,
brownianBridge,
antitheticVariate,
requiredSamples,
requiredTolerance,
maxSamples,
seed));
else
QL_FAIL("unknown Monte Carlo engine type: "+s);
}
}
};
%{
using QuantLib::StulzEngine;
typedef boost::shared_ptr<PricingEngine> StulzEnginePtr;
%}
%rename(StulzEngine) StulzEnginePtr;
class StulzEnginePtr
: public boost::shared_ptr<PricingEngine> {
public:
%extend {
StulzEnginePtr(const GeneralizedBlackScholesProcessPtr& process1,
const GeneralizedBlackScholesProcessPtr& process2,
Real correlation) {
boost::shared_ptr<GeneralizedBlackScholesProcess> bsProcess1 =
boost::dynamic_pointer_cast<GeneralizedBlackScholesProcess>(
process1);
QL_REQUIRE(bsProcess1, "Black-Scholes process required");
boost::shared_ptr<GeneralizedBlackScholesProcess> bsProcess2 =
boost::dynamic_pointer_cast<GeneralizedBlackScholesProcess>(
process2);
QL_REQUIRE(bsProcess2, "Black-Scholes process required");
return new StulzEnginePtr(
new StulzEngine(bsProcess1,bsProcess2,correlation));
}
}
};
%{
using QuantLib::EverestOption;
typedef boost::shared_ptr<Instrument> EverestOptionPtr;
using QuantLib::MCEverestEngine;
typedef boost::shared_ptr<PricingEngine> MCEverestEnginePtr;
%}
%rename(EverestOption) EverestOptionPtr;
class EverestOptionPtr : public MultiAssetOptionPtr {
public:
%extend {
EverestOptionPtr(Real notional,
Rate guarantee,
const boost::shared_ptr<Exercise>& exercise) {
return new EverestOptionPtr(new EverestOption(notional,guarantee,
exercise));
}
}
};
%rename(MCEverestEngine) MCEverestEnginePtr;
class MCEverestEnginePtr : public boost::shared_ptr<PricingEngine> {
%feature("kwargs") MCEverestEnginePtr;
public:
%extend {
MCEverestEnginePtr(const StochasticProcessArrayPtr& process,
const std::string& traits,
Size timeSteps = Null<Size>(),
Size timeStepsPerYear = Null<Size>(),
bool brownianBridge = false,
bool antitheticVariate = false,
intOrNull requiredSamples = Null<Size>(),
doubleOrNull requiredTolerance = Null<Real>(),
intOrNull maxSamples = Null<Size>(),
BigInteger seed = 0) {
boost::shared_ptr<StochasticProcessArray> processes =
boost::dynamic_pointer_cast<StochasticProcessArray>(process);
QL_REQUIRE(processes, "stochastic-process array required");
std::string s = boost::algorithm::to_lower_copy(traits);
if (s == "pseudorandom" || s == "pr")
return new MCEverestEnginePtr(
new MCEverestEngine<PseudoRandom>(processes,
timeSteps,
timeStepsPerYear,
brownianBridge,
antitheticVariate,
requiredSamples,
requiredTolerance,
maxSamples,
seed));
else if (s == "lowdiscrepancy" || s == "ld")
return new MCEverestEnginePtr(
new MCEverestEngine<LowDiscrepancy>(processes,
timeSteps,
timeStepsPerYear,
brownianBridge,
antitheticVariate,
requiredSamples,
requiredTolerance,
maxSamples,
seed));
else
QL_FAIL("unknown Monte Carlo engine type: "+s);
}
}
};
%{
using QuantLib::HimalayaOption;
typedef boost::shared_ptr<Instrument> HimalayaOptionPtr;
using QuantLib::MCHimalayaEngine;
typedef boost::shared_ptr<PricingEngine> MCHimalayaEnginePtr;
%}
%rename(HimalayaOption) HimalayaOptionPtr;
class HimalayaOptionPtr : public MultiAssetOptionPtr {
public:
%extend {
HimalayaOptionPtr(const std::vector<Date>& fixingDates,
Real strike) {
return new HimalayaOptionPtr(new HimalayaOption(fixingDates,
strike));
}
}
};
%rename(MCHimalayaEngine) MCHimalayaEnginePtr;
class MCHimalayaEnginePtr : public boost::shared_ptr<PricingEngine> {
%feature("kwargs") MCHimalayaEnginePtr;
public:
%extend {
MCHimalayaEnginePtr(const StochasticProcessArrayPtr& process,
const std::string& traits,
bool brownianBridge = false,
bool antitheticVariate = false,
intOrNull requiredSamples = Null<Size>(),
doubleOrNull requiredTolerance = Null<Real>(),
intOrNull maxSamples = Null<Size>(),
BigInteger seed = 0) {
boost::shared_ptr<StochasticProcessArray> processes =
boost::dynamic_pointer_cast<StochasticProcessArray>(process);
QL_REQUIRE(processes, "stochastic-process array required");
std::string s = boost::algorithm::to_lower_copy(traits);
if (s == "pseudorandom" || s == "pr")
return new MCHimalayaEnginePtr(
new MCHimalayaEngine<PseudoRandom>(processes,
brownianBridge,
antitheticVariate,
requiredSamples,
requiredTolerance,
maxSamples,
seed));
else if (s == "lowdiscrepancy" || s == "ld")
return new MCHimalayaEnginePtr(
new MCHimalayaEngine<LowDiscrepancy>(processes,
brownianBridge,
antitheticVariate,
requiredSamples,
requiredTolerance,
maxSamples,
seed));
else
QL_FAIL("unknown Monte Carlo engine type: "+s);
}
}
};
#endif
|