Getting Started

Setting up the link to QuantLib

The first step is to load the QuantLib package.

In[2]:=

index_1.gif

The current version of Quantlib can be retrieved

In[3]:=

index_2.gif

Out[3]=

index_3.gif

Also the QuantLibAddin version might be of interest

In[4]:=

index_4.gif

Out[4]=

index_5.gif

Getting around

A list of available QuantLib categories is set up during installation and can be retrieved as

In[5]:=

index_6.gif

Out[5]=

index_7.gif

There is same basic information available on each category

In[6]:=

index_8.gif

index_9.gif

The functions available in each category can be retrieved with the Category command

In[7]:=

index_10.gif

Out[7]=

index_11.gif

In[8]:=

index_12.gif

Out[8]=

index_13.gif

To each function the type is attached. This allows to select the constructors and member functions

In[9]:=

index_14.gif

Out[9]=

index_15.gif

In[10]:=

index_16.gif

Out[10]=

index_17.gif

Also for each function usage information is available

In[12]:=

index_18.gif

index_19.gif

In most cases there are additional options set up for a function

In[13]:=

index_20.gif

Out[13]=

index_21.gif

A simple option pricing example as a starter

This simple example demonstrates the valuation of  a plain vanilla option using the different object available in QuantLib. Alternatively you also can use the well known formula which is also available in QuantLib.

Just using a formula

In[14]:=

index_22.gif

index_23.gif


With most functions there are options associated. This simplifies the calling of functions.

In[15]:=

index_24.gif

Out[15]=

index_25.gif

In[16]:=

index_26.gif

Out[22]=

index_27.gif

Working with objects

Defining an instrument

The exericise function is one part of the instrument description

In[23]:=

index_28.gif

Out[24]=

index_29.gif

Global`Ex1

BaseClass[Ex1]^=
Category[Ex1]^=Exercise
ClassName[Ex1]^=qlEuropeanExercise
ExpiryDate[Ex1]^=36297
ObjectId[Ex1]^=Ex1
Overwrite[Ex1]^=False
Permanent[Ex1]^=False
Properties[Ex1]^=4
ValueObject[Ex1]^=qlEuropeanExercise

When looking at the ExpiryDate properity it is noticable that internally dates a represnted as julian numbers. The transformation from date to julian number is most of the times done automatically. But there is also a function available to do it manually.

In[26]:=

index_30.gif

index_31.gif

In[27]:=

index_32.gif

index_33.gif

In[28]:=

index_34.gif

Out[28]=

index_35.gif

In[29]:=

index_36.gif

Out[29]=

index_37.gif

In[30]:=

index_38.gif

Global`MyVanilla

BaseClass[MyVanilla]^=
Category[MyVanilla]^=Options
ClassName[MyVanilla]^=qlVanillaOption
Exercise[MyVanilla]^=Ex1
Instrument[MyVanilla]^=True
ObjectId[MyVanilla]^=MyVanilla
OneAssetOption[MyVanilla]^=True
Overwrite[MyVanilla]^=False
Payoff[MyVanilla]^=MyStrike1
Permanent[MyVanilla]^=False
Properties[MyVanilla]^=5
ValueObject[MyVanilla]^=qlVanillaOption

So far we have generated three objects.

In[31]:=

index_39.gif

Out[31]=

index_40.gif

Defining the driving process

Here a Black-Scholes process is assumed which is driven by a scalar volatility parameter

In[32]:=

index_41.gif

index_42.gif

In[33]:=

index_43.gif

Out[34]=

index_44.gif

In[35]:=

index_45.gif

Out[35]=

index_46.gif

Now an symbol/object vol1 exists with a number of attributes. To see the details use

In[36]:=

index_47.gif

Global`vol1

BaseClass[vol1]^=
Calendar[vol1]^=Target
Category[vol1]^=Volatilities
ClassName[vol1]^=qlBlackConstantVol
DayCounter[vol1]^=Actual/365 (Fixed)
ObjectId[vol1]^=vol1
Overwrite[vol1]^=False
Permanent[vol1]^=False
Properties[vol1]^=7
SettlementDate[vol1]^=35932
ValueObject[vol1]^=qlBlackConstantVol
Volatility[vol1]^=0.2

In[37]:=

index_48.gif

index_49.gif

Out[38]=

index_50.gif

In[39]:=

index_51.gif

Out[40]=

index_52.gif

In[41]:=

index_53.gif

Global`GBSP

BaseClass[GBSP]^=
BlackVolID[GBSP]^=vol1
Category[GBSP]^=Processes
ClassName[GBSP]^=qlGeneralizedBlackScholesProcess
DayCounter[GBSP]^=Actual/Actual
DividendYield[GBSP]^=0.
ObjectId[GBSP]^=GBSP
Overwrite[GBSP]^=False
Permanent[GBSP]^=False
Properties[GBSP]^=9
RiskFreeRate[GBSP]^=0.06
SettlementDate[GBSP]^=35932
Underlying[GBSP]^=36.
ValueObject[GBSP]^=qlGeneralizedBlackScholesProcess

Defining the valuation method

In[42]:=

index_54.gif

index_55.gif

In[43]:=

index_56.gif

Out[43]=

index_57.gif

In[44]:=

index_58.gif

Global`MyEngine

BaseClass[MyEngine]^=
Category[MyEngine]^=Pricing Engines
ClassName[MyEngine]^=qlPricingEngine1
EngineID[MyEngine]^=AE
ObjectId[MyEngine]^=MyEngine
Overwrite[MyEngine]^=False
Permanent[MyEngine]^=False
ProcessID[MyEngine]^=GBSP
Properties[MyEngine]^=5
ValueObject[MyEngine]^=qlPricingEngine1

Doing the valuation

In[45]:=

index_59.gif

Out[46]=

index_60.gif

Out[47]=

index_61.gif

Spikey Created with Wolfram Mathematica 7.0