3
3
Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
4
Copyright (C) 2003 StatPro Italia srl
5
Copyright (c) 2005 Dominic Thuillier
4
Copyright (C) 2003, 2007 StatPro Italia srl
5
Copyright (C) 2005 Dominic Thuillier
6
Copyright (C) 2007 Luis Cota
7
8
This file is part of QuantLib, a free-software/open-source library
8
9
for financial quantitative analysts and developers - http://quantlib.org/
161
162
%template(ShortRateModel) boost::shared_ptr<ShortRateModel>;
162
163
IsObservable(boost::shared_ptr<ShortRateModel>);
165
%template(ShortRateModelHandle) Handle<ShortRateModel>;
166
IsObservable(Handle<ShortRateModel>);
167
%template(RelinkableShortRateModelHandle)
168
RelinkableHandle<ShortRateModel>;
167
using QuantLib::HullWhite;
168
using QuantLib::BlackKarasinski;
170
typedef boost::shared_ptr<ShortRateModel> HullWhitePtr;
171
typedef boost::shared_ptr<ShortRateModel> BlackKarasinskiPtr;
172
typedef boost::shared_ptr<ShortRateModel> G2Ptr;
173
using QuantLib::Vasicek;
174
using QuantLib::HullWhite;
175
using QuantLib::BlackKarasinski;
177
typedef boost::shared_ptr<ShortRateModel> VasicekPtr;
178
typedef boost::shared_ptr<ShortRateModel> HullWhitePtr;
179
typedef boost::shared_ptr<ShortRateModel> BlackKarasinskiPtr;
180
typedef boost::shared_ptr<ShortRateModel> G2Ptr;
183
%rename(Vasicek) VasicekPtr;
184
class VasicekPtr : public boost::shared_ptr<ShortRateModel> {
187
VasicekPtr(Rate r0 = 0.05,
192
return new VasicekPtr(new Vasicek(r0, a, b, sigma, lambda));
194
DiscountFactor discount(Time t) const {
195
return boost::dynamic_pointer_cast<Vasicek>(*self)->discount(t);
175
201
%rename(HullWhite) HullWhitePtr;
176
202
class HullWhitePtr : public boost::shared_ptr<ShortRateModel> {
205
234
Real eta = 0.01, Real rho = -0.75) {
206
235
return new G2Ptr(new G2(termStructure, a, sigma, b, eta, rho));
237
DiscountFactor discount(Time t) const {
238
return boost::dynamic_pointer_cast<G2>(*self)->discount(t);
230
262
JamshidianSwaptionEnginePtr(
231
const boost::shared_ptr<ShortRateModel>& model) {
263
const boost::shared_ptr<ShortRateModel>& model,
264
const Handle<YieldTermStructure>& termStructure =
265
Handle<YieldTermStructure>()) {
232
266
using QuantLib::OneFactorAffineModel;
233
267
boost::shared_ptr<OneFactorAffineModel> m =
234
268
boost::dynamic_pointer_cast<OneFactorAffineModel>(model);
235
269
QL_REQUIRE(model, "affine model required");
236
270
return new JamshidianSwaptionEnginePtr(
237
new JamshidianSwaptionEngine(m));
271
new JamshidianSwaptionEngine(m,termStructure));
243
277
class TreeSwaptionEnginePtr : public boost::shared_ptr<PricingEngine> {
246
TreeSwaptionEnginePtr(const boost::shared_ptr<ShortRateModel>& model,
280
TreeSwaptionEnginePtr(
281
const boost::shared_ptr<ShortRateModel>& model,
283
const Handle<YieldTermStructure>& termStructure =
284
Handle<YieldTermStructure>()) {
248
285
return new TreeSwaptionEnginePtr(
249
new TreeSwaptionEngine(model,timeSteps));
286
new TreeSwaptionEngine(model,timeSteps,termStructure));
251
TreeSwaptionEnginePtr(const boost::shared_ptr<ShortRateModel>& model,
252
const TimeGrid& grid) {
288
TreeSwaptionEnginePtr(
289
const boost::shared_ptr<ShortRateModel>& model,
290
const TimeGrid& grid,
291
const Handle<YieldTermStructure>& termStructure =
292
Handle<YieldTermStructure>()) {
253
293
return new TreeSwaptionEnginePtr(
254
new TreeSwaptionEngine(model,grid));
294
new TreeSwaptionEngine(model,grid,termStructure));
263
303
AnalyticCapFloorEnginePtr(
264
const boost::shared_ptr<ShortRateModel>& model) {
304
const boost::shared_ptr<ShortRateModel>& model,
305
const Handle<YieldTermStructure>& termStructure =
306
Handle<YieldTermStructure>()) {
265
307
using QuantLib::OneFactorAffineModel;
266
308
boost::shared_ptr<OneFactorAffineModel> m =
267
309
boost::dynamic_pointer_cast<OneFactorAffineModel>(model);
268
310
QL_REQUIRE(model, "affine model required");
269
311
return new AnalyticCapFloorEnginePtr(
270
new AnalyticCapFloorEngine(m));
312
new AnalyticCapFloorEngine(m,termStructure));
276
318
class TreeCapFloorEnginePtr : public boost::shared_ptr<PricingEngine> {
279
TreeCapFloorEnginePtr(const boost::shared_ptr<ShortRateModel>& model,
321
TreeCapFloorEnginePtr(
322
const boost::shared_ptr<ShortRateModel>& model,
324
const Handle<YieldTermStructure>& termStructure =
325
Handle<YieldTermStructure>()) {
281
326
return new TreeCapFloorEnginePtr(
282
new TreeCapFloorEngine(model,timeSteps));
327
new TreeCapFloorEngine(model,timeSteps,termStructure));
284
TreeCapFloorEnginePtr(const boost::shared_ptr<ShortRateModel>& model,
285
const TimeGrid& grid) {
329
TreeCapFloorEnginePtr(
330
const boost::shared_ptr<ShortRateModel>& model,
331
const TimeGrid& grid,
332
const Handle<YieldTermStructure>& termStructure =
333
Handle<YieldTermStructure>()) {
286
334
return new TreeCapFloorEnginePtr(
287
new TreeCapFloorEngine(model,grid));
335
new TreeCapFloorEngine(model,grid,termStructure));