This file is indexed.

/usr/share/quantlib-python/defaultprobability.i is in quantlib-python 1.3-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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
/*
 Copyright (C) 2008, 2009 StatPro Italia srl

 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_default_probability_structures_i
#define quantlib_default_probability_structures_i

%include common.i
%include types.i
%include date.i
%include calendars.i
%include daycounters.i
%include scheduler.i
%include observer.i
%include marketelements.i
%include interpolation.i

%{
using QuantLib::DefaultProbabilityTermStructure;
%}

%ignore DefaultProbabilityTermStructure;
class DefaultProbabilityTermStructure : public Extrapolator {
    #if defined(SWIGMZSCHEME) || defined(SWIGGUILE)
    %rename("day-counter")     dayCounter;
    %rename("reference-date")  referenceDate;
    %rename("max-date")        maxDate;
    %rename("max-time")        maxTime;
    %rename("default-probability")  defaultProbability;
    %rename("survival-probability") survivalProbability;
    %rename("hazard-rate")          hazardRate;
    %rename("default-density")      defaultDensity;
    #endif
  public:
    DayCounter dayCounter() const;
    Calendar calendar() const;
    Date referenceDate() const;
    Date maxDate() const;
    Time maxTime() const;

    Probability defaultProbability(const Date&, bool extrapolate = false);
    Probability defaultProbability(Time, bool extrapolate = false);
    Probability defaultProbability(const Date&, const Date&,
                                   bool extrapolate = false);
    Probability defaultProbability(Time, Time, bool extrapolate = false);

    Probability survivalProbability(const Date&, bool extrapolate = false);
    Probability survivalProbability(Time, bool extrapolate = false);

    Real defaultDensity(const Date&, bool extrapolate = false);
    Real defaultDensity(Time, bool extrapolate = false);

    Real hazardRate(const Date&, bool extrapolate = false);
    Real hazardRate(Time, bool extrapolate = false);
};

%template(DefaultProbabilityTermStructure)
boost::shared_ptr<DefaultProbabilityTermStructure>;
IsObservable(boost::shared_ptr<DefaultProbabilityTermStructure>);

%template(DefaultProbabilityTermStructureHandle)
Handle<DefaultProbabilityTermStructure>;
IsObservable(Handle<DefaultProbabilityTermStructure>);
%template(RelinkableDefaultProbabilityTermStructureHandle)
RelinkableHandle<DefaultProbabilityTermStructure>;


// concrete curves


// flat forward curve

%{
using QuantLib::FlatHazardRate;
typedef boost::shared_ptr<DefaultProbabilityTermStructure> FlatHazardRatePtr;
%}

%rename(FlatHazardRate) FlatHazardRatePtr;
class FlatHazardRatePtr
    : public boost::shared_ptr<DefaultProbabilityTermStructure> {
  public:
    %extend {
        FlatHazardRatePtr(Integer settlementDays,
                          const Calendar& calendar,
                          const Handle<Quote>& hazardRate,
                          const DayCounter& dayCounter) {
            return new FlatHazardRatePtr(
                           new FlatHazardRate(settlementDays,calendar,
                                              hazardRate,dayCounter));
        }
        FlatHazardRatePtr(const Date& todaysDate,
                          const Handle<Quote>& hazardRate,
                          const DayCounter& dayCounter) {
            return new FlatHazardRatePtr(
                        new FlatHazardRate(todaysDate,hazardRate,dayCounter));
        }
    }
};



%{
using QuantLib::InterpolatedHazardRateCurve;
%}

%define export_hazard_curve(Name,Interpolator)

%{
typedef boost::shared_ptr<DefaultProbabilityTermStructure> Name##Ptr;
%}

%rename(Name) Name##Ptr;
class Name##Ptr : public boost::shared_ptr<DefaultProbabilityTermStructure> {
  public:
    %extend {
        Name##Ptr(const std::vector<Date>& dates,
                  const std::vector<Real>& hazardRates,
                  const DayCounter& dayCounter,
                  const Calendar& calendar = Calendar(),
                  const Interpolator& i = Interpolator()) {
            return new Name##Ptr(
                new InterpolatedHazardRateCurve<Interpolator>(dates,hazardRates,
                                                              dayCounter,
                                                              calendar,i));
        }
        const std::vector<Date>& dates() {
            typedef InterpolatedHazardRateCurve<Interpolator> Name;
            return boost::dynamic_pointer_cast<Name>(*self)->dates();
        }
        const std::vector<Real>& hazardRates() {
            typedef InterpolatedHazardRateCurve<Interpolator> Name;
            return boost::dynamic_pointer_cast<Name>(*self)->hazardRates();
        }
        #if !defined(SWIGR) && !defined(SWIGGUILE) && !defined(SWIGMZSCHEME)
        std::vector<std::pair<Date,Real> > nodes() {
            typedef InterpolatedHazardRateCurve<Interpolator> Name;
            return boost::dynamic_pointer_cast<Name>(*self)->nodes();
        }
        #endif
    }
};

%enddef

export_hazard_curve(HazardRateCurve,BackwardFlat);

// add interpolations as you wish, e.g.,
// export_hazard_curve(LinearHazardRateCurve,Linear);



%{
using QuantLib::InterpolatedDefaultDensityCurve;
%}

%define export_default_density_curve(Name,Interpolator)

%{
typedef boost::shared_ptr<DefaultProbabilityTermStructure> Name##Ptr;
%}

%rename(Name) Name##Ptr;
class Name##Ptr : public boost::shared_ptr<DefaultProbabilityTermStructure> {
  public:
    %extend {
        Name##Ptr(const std::vector<Date>& dates,
                  const std::vector<Real>& densities,
                  const DayCounter& dayCounter,
                  const Calendar& calendar = Calendar(),
                  const Interpolator& i = Interpolator()) {
            return new Name##Ptr(
                new InterpolatedDefaultDensityCurve<Interpolator>(dates,
                                                                  densities,
                                                                  dayCounter,
                                                                  calendar,i));
        }
        const std::vector<Date>& dates() {
            typedef InterpolatedDefaultDensityCurve<Interpolator> Name;
            return boost::dynamic_pointer_cast<Name>(*self)->dates();
        }
        const std::vector<Real>& defaultDensities() {
            typedef InterpolatedDefaultDensityCurve<Interpolator> Name;
            return boost::dynamic_pointer_cast<Name>(*self)->defaultDensities();
        }
        #if !defined(SWIGR) && !defined(SWIGGUILE) && !defined(SWIGMZSCHEME)
        std::vector<std::pair<Date,Real> > nodes() {
            typedef InterpolatedDefaultDensityCurve<Interpolator> Name;
            return boost::dynamic_pointer_cast<Name>(*self)->nodes();
        }
        #endif
    }
};

%enddef

export_default_density_curve(DefaultDensityCurve,Linear);

// add interpolations as you wish, e.g.,
// export_default_density_curve(CubicDefaultDensityCurve,Cubic);



%{
using QuantLib::DefaultProbabilityHelper;
using QuantLib::SpreadCdsHelper;
typedef boost::shared_ptr<DefaultProbabilityHelper> SpreadCdsHelperPtr;
using QuantLib::UpfrontCdsHelper;
typedef boost::shared_ptr<DefaultProbabilityHelper> UpfrontCdsHelperPtr;
%}

// rate helpers for curve bootstrapping
%template(DefaultProbabilityHelper) boost::shared_ptr<DefaultProbabilityHelper>;

#if defined(SWIGCSHARP)
SWIG_STD_VECTOR_ENHANCED( boost::shared_ptr<DefaultProbabilityHelper> )
#endif
namespace std {
    %template(DefaultProbabilityHelperVector)
    vector<boost::shared_ptr<DefaultProbabilityHelper> >;
}


%rename(SpreadCdsHelper) SpreadCdsHelperPtr;
class SpreadCdsHelperPtr : public boost::shared_ptr<DefaultProbabilityHelper> {
  public:
    %extend {
        SpreadCdsHelperPtr(
                const Handle<Quote>& spread,
                const Period& tenor,
                Integer settlementDays,
                const Calendar& calendar,
                Frequency frequency,
                BusinessDayConvention convention,
                DateGeneration::Rule rule,
                const DayCounter& dayCounter,
                Real recoveryRate,
                const Handle<YieldTermStructure>& discountCurve,
                bool settlesAccrual = true,
                bool paysAtDefaultTime = true) {
            return new SpreadCdsHelperPtr(
                new SpreadCdsHelper(spread,tenor,settlementDays,calendar,
                                    frequency,convention,rule,dayCounter,
                                    recoveryRate,discountCurve,
                                    settlesAccrual,paysAtDefaultTime));
        }
        SpreadCdsHelperPtr(
                Rate spread,
                const Period& tenor,
                Integer settlementDays,
                const Calendar& calendar,
                Frequency frequency,
                BusinessDayConvention convention,
                DateGeneration::Rule rule,
                const DayCounter& dayCounter,
                Real recoveryRate,
                const Handle<YieldTermStructure>& discountCurve,
                bool settlesAccrual = true,
                bool paysAtDefaultTime = true) {
            return new SpreadCdsHelperPtr(
                new SpreadCdsHelper(spread,tenor,settlementDays,calendar,
                                    frequency,convention,rule,dayCounter,
                                    recoveryRate,discountCurve,
                                    settlesAccrual,paysAtDefaultTime));
        }
    }
};


%rename(UpfrontCdsHelper) UpfrontCdsHelperPtr;
class UpfrontCdsHelperPtr : public boost::shared_ptr<DefaultProbabilityHelper> {
  public:
    %extend {
        UpfrontCdsHelperPtr(
                const Handle<Quote>& upfront,
                Rate spread,
                const Period& tenor,
                Integer settlementDays,
                const Calendar& calendar,
                Frequency frequency,
                BusinessDayConvention convention,
                DateGeneration::Rule rule,
                const DayCounter& dayCounter,
                Real recoveryRate,
                const Handle<YieldTermStructure>& discountCurve,
                bool settlesAccrual = true,
                bool paysAtDefaultTime = true) {
            return new UpfrontCdsHelperPtr(
                new UpfrontCdsHelper(upfront,spread,tenor,
                                     settlementDays,calendar,
                                     frequency,convention,rule,dayCounter,
                                     recoveryRate,discountCurve,
                                     settlesAccrual,paysAtDefaultTime));
        }
        UpfrontCdsHelperPtr(
                Rate upfront,
                Rate spread,
                const Period& tenor,
                Integer settlementDays,
                const Calendar& calendar,
                Frequency frequency,
                BusinessDayConvention convention,
                DateGeneration::Rule rule,
                const DayCounter& dayCounter,
                Real recoveryRate,
                const Handle<YieldTermStructure>& discountCurve,
                bool settlesAccrual = true,
                bool paysAtDefaultTime = true) {
            return new UpfrontCdsHelperPtr(
                new UpfrontCdsHelper(upfront,spread,tenor,
                                     settlementDays,calendar,
                                     frequency,convention,rule,dayCounter,
                                     recoveryRate,discountCurve,
                                     settlesAccrual,paysAtDefaultTime));
        }
    }
};



// bootstrap traits

%{
using QuantLib::HazardRate;
using QuantLib::DefaultDensity;
%}

struct HazardRate {};
struct DefaultDensity {};

// curve

%{
using QuantLib::PiecewiseDefaultCurve;
%}

%define export_piecewise_default_curve(Name,Base,Interpolator)

%{
typedef boost::shared_ptr<DefaultProbabilityTermStructure> Name##Ptr;
%}

%rename(Name) Name##Ptr;
class Name##Ptr : public boost::shared_ptr<DefaultProbabilityTermStructure> {
  public:
    %extend {
        Name##Ptr(
              const Date& referenceDate,
              const std::vector<boost::shared_ptr<DefaultProbabilityHelper> >&
                                                                  instruments,
              const DayCounter& dayCounter,
              Real accuracy = 1.0e-12,
              const Interpolator& i = Interpolator()) {
            return new Name##Ptr(
                new PiecewiseDefaultCurve<Base,Interpolator>(
                                                 referenceDate,instruments,
                                                 dayCounter, accuracy, i));
        }
        Name##Ptr(
              Integer settlementDays, const Calendar& calendar,
              const std::vector<boost::shared_ptr<DefaultProbabilityHelper> >&
                                                                  instruments,
              const DayCounter& dayCounter,
              Real accuracy = 1.0e-12,
              const Interpolator& i = Interpolator()) {
            return new Name##Ptr(
                new PiecewiseDefaultCurve<Base,Interpolator>(
                                        settlementDays, calendar, instruments,
                                        dayCounter, accuracy, i));
        }
        const std::vector<Date>& dates() {
            typedef PiecewiseDefaultCurve<Base,Interpolator> Name;
            return boost::dynamic_pointer_cast<Name>(*self)->dates();
        }
        const std::vector<Time>& times() {
            typedef PiecewiseDefaultCurve<Base,Interpolator> Name;
            return boost::dynamic_pointer_cast<Name>(*self)->times();
        }
        #if !defined(SWIGR) && !defined(SWIGGUILE) && !defined(SWIGMZSCHEME)
        std::vector<std::pair<Date,Real> > nodes() {
            typedef PiecewiseDefaultCurve<Base,Interpolator> Name;
            return boost::dynamic_pointer_cast<Name>(*self)->nodes();
        }
        #endif
    }
};

%enddef


export_piecewise_default_curve(PiecewiseFlatHazardRate,HazardRate,BackwardFlat);

// combine traits as you wish, e.g.,
// export_piecewise_default_curve(PiecewiseLinearDensity,DefaultDensity,Linear);


#endif