86
const boost::shared_ptr<StochasticProcess>& process,
87
86
const boost::shared_ptr<Payoff>& payoff,
88
const boost::shared_ptr<Exercise>& exercise,
89
const boost::shared_ptr<PricingEngine>& engine
90
= boost::shared_ptr<PricingEngine>()) {
87
const boost::shared_ptr<Exercise>& exercise) {
91
88
boost::shared_ptr<BasketPayoff> stPayoff =
92
89
boost::dynamic_pointer_cast<BasketPayoff>(payoff);
93
90
QL_REQUIRE(stPayoff, "wrong payoff given");
94
return new BasketOptionPtr(
95
new BasketOption(process,stPayoff,exercise,engine));
91
return new BasketOptionPtr(new BasketOption(stPayoff,exercise));
108
104
%feature("kwargs") MCBasketEnginePtr;
111
MCBasketEnginePtr(const std::string& traits,
112
Size timeStepsPerYear = Null<Size>(),
113
bool brownianBridge = false,
114
bool antitheticVariate = false,
115
bool controlVariate = false,
116
intOrNull requiredSamples = Null<Size>(),
117
doubleOrNull requiredTolerance = Null<Real>(),
118
intOrNull maxSamples = Null<Size>(),
119
BigInteger seed = 0) {
120
// std::string s = QuantLib::lowercase(traits);
121
std::string s = traits;
107
MCBasketEnginePtr(const StochasticProcessArrayPtr& process,
108
const std::string& traits,
109
Size timeStepsPerYear = Null<Size>(),
110
bool brownianBridge = false,
111
bool antitheticVariate = false,
112
bool controlVariate = false,
113
intOrNull requiredSamples = Null<Size>(),
114
doubleOrNull requiredTolerance = Null<Real>(),
115
intOrNull maxSamples = Null<Size>(),
116
BigInteger seed = 0) {
117
boost::shared_ptr<StochasticProcessArray> processes =
118
boost::dynamic_pointer_cast<StochasticProcessArray>(process);
119
QL_REQUIRE(processes, "stochastic-process array required");
120
std::string s = boost::algorithm::to_lower_copy(traits);
122
121
if (s == "pseudorandom" || s == "pr")
123
122
return new MCBasketEnginePtr(
124
new MCBasketEngine<PseudoRandom>(timeStepsPerYear,
123
new MCBasketEngine<PseudoRandom>(processes,
132
132
else if (s == "lowdiscrepancy" || s == "ld")
133
133
return new MCBasketEnginePtr(
134
new MCBasketEngine<LowDiscrepancy>(timeStepsPerYear,
134
new MCBasketEngine<LowDiscrepancy>(processes,
143
144
QL_FAIL("unknown Monte Carlo engine type: "+s);
155
156
%feature("kwargs") MCAmericanBasketEnginePtr;
158
MCAmericanBasketEnginePtr(const std::string& traits,
159
Size timeSteps = Null<Size>(),
160
Size timeStepsPerYear = Null<Size>(),
161
bool brownianBridge = false,
162
bool antitheticVariate = false,
163
bool controlVariate = false,
164
intOrNull requiredSamples = Null<Size>(),
165
doubleOrNull requiredTolerance = Null<Real>(),
166
intOrNull maxSamples = Null<Size>(),
167
BigInteger seed = 0) {
168
// std::string s = QuantLib::lowercase(traits);
169
std::string s = traits;
159
MCAmericanBasketEnginePtr(const StochasticProcessArrayPtr& process,
160
const std::string& traits,
161
Size timeSteps = Null<Size>(),
162
Size timeStepsPerYear = Null<Size>(),
163
bool brownianBridge = false,
164
bool antitheticVariate = false,
165
bool controlVariate = false,
166
intOrNull requiredSamples = Null<Size>(),
167
doubleOrNull requiredTolerance = Null<Real>(),
168
intOrNull maxSamples = Null<Size>(),
169
BigInteger seed = 0) {
170
boost::shared_ptr<StochasticProcessArray> processes =
171
boost::dynamic_pointer_cast<StochasticProcessArray>(process);
172
QL_REQUIRE(processes, "stochastic-process array required");
173
std::string s = boost::algorithm::to_lower_copy(traits);
170
174
if (s == "pseudorandom" || s == "pr")
171
175
return new MCAmericanBasketEnginePtr(
172
new MCAmericanBasketEngine<PseudoRandom>(timeSteps,
176
new MCAmericanBasketEngine<PseudoRandom>(processes,
173
178
timeStepsPerYear,
175
180
antitheticVariate,
181
186
else if (s == "lowdiscrepancy" || s == "ld")
182
187
return new MCAmericanBasketEnginePtr(
183
new MCAmericanBasketEngine<LowDiscrepancy>(timeSteps,
188
new MCAmericanBasketEngine<LowDiscrepancy>(processes,
184
190
timeStepsPerYear,
186
192
antitheticVariate,
206
212
: public boost::shared_ptr<PricingEngine> {
210
return new StulzEnginePtr(new StulzEngine);
215
StulzEnginePtr(const GeneralizedBlackScholesProcessPtr& process1,
216
const GeneralizedBlackScholesProcessPtr& process2,
218
boost::shared_ptr<GeneralizedBlackScholesProcess> bsProcess1 =
219
boost::dynamic_pointer_cast<GeneralizedBlackScholesProcess>(
221
QL_REQUIRE(bsProcess1, "Black-Scholes process required");
222
boost::shared_ptr<GeneralizedBlackScholesProcess> bsProcess2 =
223
boost::dynamic_pointer_cast<GeneralizedBlackScholesProcess>(
225
QL_REQUIRE(bsProcess2, "Black-Scholes process required");
226
return new StulzEnginePtr(
227
new StulzEngine(bsProcess1,bsProcess2,correlation));