Quantlib-Python Module Reference David Duarte Created on : December, 2018 Last Updated : September, 2021
Total Page:16
File Type:pdf, Size:1020Kb
QuantLib-Python Module Reference David Duarte Created on : December, 2018 Last updated : September, 2021 More documents are freely available at PythonDSP Table of contents Table of contents i List of figures vii List of tables ix 1 Basics 3 1.1 Settings...................................................3 1.2 Array....................................................3 1.3 Matrix....................................................4 1.4 Observable.................................................4 1.5 Quotes....................................................5 1.5.1 SimpleQuote............................................5 1.5.2 DerivedQuote............................................5 1.5.3 CompositeQuote..........................................5 1.5.4 DeltaVolQuote...........................................5 2 CashFlows, Legs and Interest Rates7 2.1 Interest Rates................................................7 2.2 CashFlows..................................................8 2.2.1 SimpleCashFlow..........................................8 2.2.2 Redemption.............................................8 2.2.3 AmortizingPayment........................................8 2.3 Coupons...................................................8 2.3.1 FixedRateCoupon.........................................8 2.3.2 IborCoupon.............................................9 2.3.3 OvernightIndexedCoupon.....................................9 2.3.4 CappedFlooredCoupon......................................9 2.3.5 CappedFlooredIborCoupon....................................9 2.3.6 CmsCoupon.............................................9 2.3.7 CappedFlooredCmsCoupon.................................... 10 2.3.8 CmsSpreadCoupon......................................... 10 2.3.9 CappedFlooredCmsSpreadCoupon................................ 10 2.4 Legs..................................................... 11 2.4.1 Leg................................................. 11 2.4.2 FixedRateLeg............................................ 11 2.4.3 IborLeg............................................... 11 2.4.4 OvernightLeg............................................ 12 2.5 Pricers.................................................... 12 2.5.1 BlackIborCouponPricer...................................... 12 2.5.2 LinearTsrPricer........................................... 12 2.5.3 LognormalCmsSpreadPricer.................................... 13 2.5.4 NumericHaganPricer........................................ 13 i 2.5.5 AnalyticHaganPricer........................................ 13 2.6 Cashflow Analysis Functions........................................ 13 2.6.1 Date Inspectors........................................... 13 2.6.2 Cashflow Inspectors........................................ 13 2.6.3 YieldTermstructure........................................ 13 2.6.4 Yield (a.k.a. Internal Rate of Return, i.e. IRR)......................... 14 2.6.5 Z-spread............................................... 15 3 Currencies 17 3.1 Currency.................................................. 17 3.2 Money.................................................... 17 3.3 ExhangeRate................................................ 18 3.4 ExchangeRateManager........................................... 18 4 Dates and Conventions 19 4.1 Conventions................................................. 19 4.1.1 Compounding............................................ 19 4.1.2 Frequencies............................................. 19 4.1.3 Weekday correction........................................ 19 4.1.4 DateGeneration........................................... 20 4.2 Date..................................................... 20 4.3 Period.................................................... 21 4.4 Calendar................................................... 22 4.5 DayCounter................................................. 24 4.6 Schedule................................................... 25 4.7 MakeSchedule................................................ 26 4.8 TimeGrid.................................................. 26 5 Indexes 27 5.1 Interest Rate................................................ 27 5.1.1 IborIndex.............................................. 27 5.1.2 OvernightIndex........................................... 27 5.1.3 SwapIndex............................................. 28 5.1.4 SwapSpreadIndex.......................................... 28 5.2 Inflation................................................... 28 5.2.1 Zero Inflation............................................ 28 5.2.2 YoY inflation............................................ 28 5.3 Fixings.................................................... 29 5.4 IndexManager................................................ 29 6 Instruments 31 6.1 Fixed Income................................................ 31 6.1.1 Forwards.............................................. 31 6.1.2 Bonds................................................ 32 6.1.3 Swaps................................................ 35 6.1.4 Swaptions.............................................. 39 6.1.5 Caps & Floors........................................... 39 6.2 Inflation................................................... 40 6.2.1 CPI Bond.............................................. 40 6.2.2 CPISwap.............................................. 41 6.2.3 ZeroCouponInflationSwap..................................... 41 6.2.4 YearOnYearInflationSwap..................................... 42 6.2.5 YoYInflationCap.......................................... 42 6.2.6 YoYInflationFloor......................................... 42 6.2.7 YoYInflationCollar......................................... 42 6.3 Credit.................................................... 42 6.3.1 CreditDefaultSwap......................................... 42 6.3.2 CdsOption............................................. 42 6.4 Options................................................... 43 6.4.1 Vanilla Options........................................... 43 6.4.2 Asian Options........................................... 43 6.4.3 Barrier Options........................................... 44 6.4.4 Basket Options........................................... 45 6.4.5 Cliquet Options........................................... 45 6.4.6 Forward Options.......................................... 45 6.4.7 Quanto Options.......................................... 46 7 Math Tools 47 7.1 Solvers.................................................... 47 7.2 Integration................................................. 48 7.2.1 Gaussian Quadrature....................................... 48 7.3 Interpolation................................................ 49 7.3.1 1D interpolation method...................................... 49 7.3.2 2D Interpolation Methods..................................... 50 7.4 Optimization................................................ 50 7.5 Random Number Generators....................................... 50 7.5.1 HaltonRsg.............................................. 52 7.5.2 SobolRsg.............................................. 52 7.6 Path Generators.............................................. 52 7.6.1 GaussianMultiPathGenerator................................... 52 7.6.2 GaussianSobolMultiPathGenerator................................ 53 7.7 Statistics.................................................. 54 7.8 Convention Calculators.......................................... 54 7.8.1 BlackDeltaCalculator....................................... 54 8 Pricing Engines 55 8.1 Bond Pricing Engines........................................... 55 8.1.1 DiscountingBondEngine...................................... 55 8.1.2 BlackCallableFixedRateBondEngine............................... 55 8.1.3 TreeCallableFixedRateEngine................................... 55 8.2 Cap Pricing Engines............................................ 56 8.2.1 BlackCapFloorEngine....................................... 56 8.2.2 BachelierCapFloorEngine..................................... 56 8.2.3 AnalyticCapFloorEngine...................................... 56 8.2.4 TreeCapFloorEngine........................................ 57 8.3 Swap Pricing Engines........................................... 57 8.3.1 DiscountingSwapEngine...................................... 57 8.4 Swaption Pricing Engines......................................... 58 8.4.1 BlackSwaptionEngine....................................... 58 8.4.2 BachelierSwaptionEngine..................................... 58 8.4.3 FdHullWhiteSwaptionEngine................................... 58 8.4.4 FdG2SwaptionEngine....................................... 58 8.4.5 G2SwaptionEngine......................................... 58 8.4.6 JamshidianSwaptionEngine.................................... 59 8.4.7 TreeSwaptionEngine........................................ 59 8.5 Credit Pricing Engines........................................... 59 8.5.1 IsdaCdsEngine........................................... 59 8.5.2 MidPointCdsEngine........................................ 59 8.5.3 IntegralCdsEngine......................................... 60 8.5.4 BlackCdsOptionEngine...................................... 60 8.6 Option Pricing Engines.......................................... 60 8.6.1 Vanilla Options........................................... 60 8.6.2 Asian Options........................................... 64 8.6.3 Barrier Options........................................... 67 8.6.4 Basket Options..........................................