13

I've been using QuantLib for quite a while. Let me share some experience: QuantLib is a highly sophisticated quantitative framework. It can do much and much more than a simple pricing of European option. For example, in your example, you could have changed the payoff to binary payoff or giving a monte-carlo pricing engine (rather than AnalyticEuropeanEngine)...


12

Day-count conventions. You can't live with them, you can't live without them. The reason the prices differ is that the pricing engine can't calculate correctly the time over which the first coupon is discounted, and thus it gets slightly different discount factors to apply to the coupon amounts. Please sit down, it'll take some explaining. Ultimately, both ...


11

At this time, there's no specific documentation for QuantLib-Python, except for a series of screencasts that I started a while ago (you can find them on YouTube at https://www.youtube.com/playlist?list=PLu_PrO8j6XAvOAlZND9WUPwTHY_GYhJVr) but which is far from exhaustive; there's just a few of them for now, and there's no definite learning path. However, the ...


10

To begin with, as Student T suggested, you can check that the cashflows are those you expect: for c in fixed_rate_bond.cashflows(): print '%20s %12f' % (c.date(), c.amount()) July 1st, 2017 2.500000 January 1st, 2018 2.500000 July 1st, 2018 2.500000 January 1st, 2019 2.500000 July 1st, 2019 2.500000 ...


9

I'm familiar with the library, but not with the way it is exported to R. Anyway: gearings are optional multipliers of the LIBOR fixing (some bonds might pay, for instance, 0.8 times the LIBOR) and spreads are the added spreads. In your case, the gearing is 1 and the spread is 0.0140 (that is, 140 bps; rates and spread must be expressed in decimal form). ...


9

I reproduce the Ametrano-Bianchetti paper on dual-curve bootstrapping in Python with QuantLib in a chapter of the QuantLib Python Cookbook. (Note: I'm not sure what the etiquette is about plugging one's own for-sale book. Moderators, please let me know if that's out of line.) That includes both OIS and LIBOR bootstrapping with different tenors, and it's ...


8

It's because of the settlement days you passed when you initialized the flat volatility curve. You're creating the spot, forward and flat volatilities as: boost::shared_ptr<BlackVarianceSurface> volatilitySurface( new BlackVarianceSurface(todaysDate, calendar, maturityArray, strikeArray, ...


8

You will find a tutorial of QuantLib using python with simple examples here: http://gouthamanbalaraman.com/blog/quantlib-python-tutorials-with-examples.html I have been writing these as a means to be instructive to others going through the process of learning and working with QuantLib. If you have suggestions on what topics you would like to read, please ...


8

In the call to Bisection.solve, the question mark must be the Python function whose zero you want to find. In your case, it should be something reproducing the logic of IRRSolver::operator() in Mick Hittesdorf's code, i.e., something like this (which I haven't tested): cashflows = fixedRateBond.cashflows() npv = fixedRateBond.NPV() def ...


8

No, I'm afraid you're comparing apples with oranges. Your calculation of the DV01 of the swap is correct (with a caveat, see below), but the figure returned from swap.fixedLegBPS is not comparable. The DV01 tells you what happens to the NPV if the interest-rate curve change; in the case of the fixed leg, this affects the discount factors used to discount ...


8

Yes, it can work. However, keep in mind that: you'll be safer if you don't share any objects between threads; see my answer here, in particular the last point; even if you use different seeds, there's no guarantee that the generated sequences won't overlap. If you're willing to change the engine code so that you can pass the relevant parameters, a safer ...


7

The QuantLib you installed is just a C++ library. If you were on a Windows machine, you'd need the QuantLibXL addin to use it in Excel (http://quantlib.org/quantlibxl/). But on a Mac, you've no such luck. As far as I know, Excel for Mac only allows addins written in VBA, so QuantLibXL can't be built for it.


7

There is experimental code available under https://sourceforge.net/tracker/?func=detail&atid=312740&aid=3413982&group_id=12740 Basically I tried to answer the question if you should do the riskfactor shifts on the level of the pricing engine or on the level of the market data. For me the answer is that one has to do it on the level of the ...


7

I'm guessing you're simulating rate curves etc. inside your system, and you want to reprice your instruments over the simulated curves using QuantLib. In this case, most of the logic is in your system already, and you have to plug pricing functionality in. If so, I don't think there's many steps involved besides, well, pricing the instrument on the ...


7

It is always better to use some closed form approximation first to get initial guess. Corrado and Miller (1996) produced a solution that is quite accurate across a range of moneyness ( though it can be applied to BS model only and can’t be used for plain vanilla options or exotic options). The formula for implied volatility $\sigma$ is : $\sigma = \frac{1}{...


6

There are two different issues at play here. One is that, of course, you want only the future cash flows to enter the calculation. This is taken care when you set the evaluation date to 6 months from today. In C++, you would say Settings::instance().evaluationDate() = today + 6*Months; I don't remember the corresponding function in QuantLibXL, but you can ...


6

Ok, I've done some digging in the code. It's an issue with the LogLinear interpolation; while trying to find the correct rate for the 1-week node, the bootstrapper wanders unchecked into a region of negative rates and the logarithms blow up. At this time, I'm afraid the workaround is just to use some other interpolation. Or recompile the library and the ...


6

A free to use Excel wizard-based Add-In providing QuantLib-backed derivatives pricing analytics directly in Excel is available at https://www.deriscope.com Since August 18, 2017 Deriscope has moved from beta to production. Disclosure: answerer is author of the package. Update as of 24 Oct 17: Deriscope already covers the whole QuantLib


6

There's no class at this time to add two curves as you want, but it won't be much difficult to write it. The closest you'll get in the library is the ZeroSpreadedTermStructure class, that shows the general idea: it inherits from YieldTermStructure (by way of ZeroYieldStructure) takes a YieldTermStructure and a spread (constant, in this case) and override ...


6

The Strata project is the new pure Java market risk quant library from OpenGamma. For more information, see the documentation and GitHub. It is Apache v2 licensed. Strata takes the experience of the OG-Platform codebase referenced in the question and turns it into a library - no need for databases, servers or similar. Ease of use is a big focus and there ...


6

The time to expiry is required, but it's included in the inputs: the two discounts $e^{-rT}$ and $e^{-qT}$ and the standard deviation $\sigma\sqrt{T}$. You might argue it could be documented more clearly, and I might agree with you.


6

fixedLegBPS is the basis-point sensitivity of the fixed leg, that is, how much its NPV changes when the fixed rate changes by one basis point: it's calculated as the NPV corresponding to a fixed rate of 1 bps. Since the NPV of the fixed leg is linearly proportional to the fixed rate, you can write the equation targetNPV : fixedRate = BPS : 1 basis point ...


6

And don't forget that there are wrappers as eq RQuantLib which I use on the command-line here: edd@max:~$ r -l RQuantLib -e 'print(EuropeanOption("call", 47, 40, 0.05, 0.0, 4/12, 0.2))' Concise summary of valuation for EuropeanOption value delta gamma vega theta rho divRho 6.4728 0.8899 0.0307 4.5139 0.7372 11....


6

It is a simple root finder, and if you give it impossible starting values... well then it fails. Here, you can play with the values and it seems bounded at USD 5 whereas you start from USD 2.7: R> AmericanOption(type="put", underlying = 55, strike = 60, + dividendYield = 0.02, riskFreeRate = 0.03, + maturity = 0.02, ...


6

Do you really need to do this yourself? The absolute state of the art is Peter Jaeckel's work, where he makes an implied vol function as good as exp, cos, and log special functions. And he pulished source code and algorithm details with careful numerical analysis of errors and convergence. This is a wheel you don't have to reinvent, any more than you ...


6

1: Follow the calculations in The Complete Guide to Option Pricing Formulas. The book has many formulas, sample values and outputs. Highly recommended for validating your results. Apparently, this is one of most popular books used by real-world quants (simple and fast). 2: You can still use QuantLib to price with year fractions. I have an example: ...


6

the model is described in Andersen, Piterbarg: Interest Rate Modeling. The formulas that are acutally implemented are derived here https://ssrn.com/abstract=2246013 Best Peter


6

I use Xcode for QuantLib. It works great. To compile the project, just put all the source files into the Xcode project like: That's the C++ compiler I use: That's how I configure my header files. You will only need boost in my screenshot. You will also need to tell Xcode where to find the QuantLib header files. The other paths are for my own code. I then ...


6

You're not setting the global evaluation date. If you don't, you're in December 2017 and your option has expired a good while ago. Adding ql.Settings.instance().evaluationDate = valuation_date before the calculations will give you the expected results.


6

The problem is that you are not pricing the same thing, and for two reasons: The vanilla instruments you are pricing should start on spot date and have a maturity with that start as reference The frequency of the fixed leg on the OIS swap should be annual. If you change you code to: print('TENOR \t PV \t fairrate% \t fairrate% + fairspread%') calendar = ql....


Only top voted, non community-wiki answers of a minimum length are eligible