16

This is off-topic and maybe belongs to StackOverflow, but here goes. 1. Compile QuantLib The best way is to open the Visual Studio Command Prompt using a shortcut under Programs→Microsoft Visual Studio→Visual Studio Tools. Now, you need to navigate to the QuantLib folder inside the folder where you have QuantLib (there are other folders such as ...


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 ...


12

Well, actually it's designed to use whatever discretization you throw at it---but for the time being only Euler discretization is implemented, mostly for lack of time or interest on the part of contributors. If you want to use exact numerics with a process, you can just code the corresponding discretization class (you'll have to inherit from ...


10

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 ...


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). ...


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

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

How at ease are you with programming, dynamic linking, Makefiles and the rest? In essence, there is no magic here. QL has a very liberal license, and you "merely" have to set up your project such that it finds the quantlib headers (and hence Boost headers) during compilation the quantlib library during linking and both of those can be automated by ...


7

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 ...


7

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 ...


7

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 ...


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

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 ...


6

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 ...


6

Numerical methods are only approximations. So binomial trees, Monte Carlo simulations, and finite difference methods should all produce different numbers. As for whether you should install it for your customers, that can only be answered by what you think your customers want. Do retail customers really want the potential confusion? Are they going to ...


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 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.


6

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 ...


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

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 ...


5

I believe it's correct. However, consider that it would be easy enough, and more clear, to create a new class (at least in C++; the task is more difficult if you also want to export it to Excel). The new instrument should only inherit from Bond and implement a constructor that builds the desired cash flows via a call to FixedLeg and another to IborLeg; you ...


5

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 ...


5

It's hard to be sure without seeing the inputs, but I'm guessing that the implied curve changes shape because the original curve does (which you can see from your output: except for the 1-year and 5-years points, the actual discounts are different). The reason the original curve changes is probably the different position of weekends or holidays (so that, ...


5

While @Baruch Youssin answers correctly in the general sense, the first part of his answer isn't what happened in the example code. While QLNet is a port of QuantLib, it's not a direct port. Your quoted example doesn't show up in QLNet. The example in QuantLib was written in a very complicated way, in fact it's a simple example. discountingTermStructure is ...


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