QuantLib is also available in other languages. Documentation Documentation is available in several formats from a number of sources. You can also read our installation instructions to get QuantLib working on your computer. Need Help? If you need to ask a question, subscribe to our mailing list and post it there. Before doing that, though, you might want to look at the FAQ and check if it was already answered.
|Published (Last):||11 January 2017|
|PDF File Size:||19.30 Mb|
|ePub File Size:||13.93 Mb|
|Price:||Free* [*Free Regsitration Required]|
Date: December 11, Author: benjaminwhiteside 0 Comments In the previous post we attempted to price a vanilla European option using the QuantLib and Boost libraries. However when we went to price the option the code fell over because the Instrument object was expecting a Pricing Engine and we had given it none. Pricing Engine QuantLib provides many kinds of pricing engines. Stochastic Process The engine class constructor requires us to provide it a type, not just any type, but a Boost Shared Pointer type which is a template for a type and the passed-in type will then become the underlying stochastic process upon which the pricing engine will run.
Let us make the decision to use a 1-dimensional Geometric Brownian Motion to price our European option — this is the standard stochastic process assumption to make not always the best choice, but for a vanilla European option it is probably the best. If we are going to use the BlackScholesMertonProcess we need to give it several inputs! Peeking once again we get a clue as to what data types they will be. Where are they defined then, you may ask? This means that while we have to define spotPrice as a Quote type, in order to get values in to that object, we need to also instantiate one of the inherited, non-abstract class objects.
OK, so what inherits Quote? SimpleQuote does: Looking for a way to get initial parameter values in to the abstract Quote class leads us to utilise the inherited class SimpleQuote. As you can see, SimpleQuote inherits from the abstract base class Quote. The Other Term Structure Objects Using the Peek function can we quickly declare the remaining three variables we need? Erm… How do we do that? I had to cheat here because I had no idea. Either I would have to declare each and every argument required for the constructor, or hopefully, QuantLib had yet another object that could handle all of these.
Some Googling and it turns out that the QuantLib object called FlatForward handles these objects for a Flat Term Structure assumption if we had not wanted a flat term structure, this would be much more difficult to describe. Not as easy as I thought. Turns out that the FlatForward object also requires input arguments upon construction.
Seems we have to declare five inputs, and two of those have defaults gotta love defaults. It works. Look how easy it is to create the same flat term structure objects except one is of the dividend yield and one is of the risk free interest rate: Once you know which objects go where, it becomes very easy to create multiple flat term structure objects.
Well, not because we wanted to be a bit more tricky with the vol surface, but the class constructor demands a new type of input. Upon peeking the class header we see that it is very similar to the FlatForward object except that we also need to provide a calendar. Where did BlackConstantVol come from? The Internet. I googled QuantLib for the required object…. See here for an example. We discovered that there are several pricing engines and stochastic processes to choose from.
Further, we discovered that the term structure of interest rates YieldTermStructure is a crucial ingredient in setting up these instruments.
We encountered our first example of having to instantiate an inherited class SimpleQuote because the type required by a constructor was an abstract class Quote. Share this:.
Oh no! Some styles failed to load. 😵
My books Implementing QuantLib Implementing QuantLib is available as an ebook from Leanpub in a variety of formats suitable for reading on all kinds of computers and tablets. Any feedback, corrections, and criticisms are welcome; my contact information is available in the About page of this blog. The book material was also featured as blog posts, collected on this page. If you are, or want to be, a QuantLib user, you will find here useful information on the design of the library that might not be readily apparent when reading the code. You will find that it covers issues that you might also face, as well as some possible solutions and their rationale.
Official QuantLib Documentation