Solving Financial Problems with Derivatives, Bonds, and Annuities Workshop

Michael Kelly

Wolfram Research Technology Consultant
mkelly@wolfram.com

GraphicsRow[{TradingChart[{"GOOG",DatePlus[-360]},{"Volume","SimpleMovingAverage","HighestHigh","RelativeStrengthIndex"},PlotLabel->"Google prices"],DateListLogPlot[FinancialData["^DJI",DatePlus[-360]],Joined->True,Filling->Bottom,PlotLabel->"Dow Jones Index"],DateListLogPlot[FinancialData["SP500",DatePlus[-360]],Joined->True,Filling->Bottom,PlotLabel->"S&P 500 Index"]},ImageSize->{870,370}]

The notebook for this workshop is available for download from http : // download.wolfram.com/?key=WHRS4G

Outline

Mathematica now has a new range of high level financial functions. These can be accessed in the help documentation at: guide/Finance

These functions can be accessed by all the other functions in Mathematica, especially the general solution functions like Solve, FindRoot, Simplify and Full Simplify. Financial Data functions, Financial Bonds and Derivatives can also be plotted using ListPlot, ListLogPlot, ListPlot3D, DateListPlot and DateListLogPlot. 

In the diagrams below we represent these functional relationships in LayeredGraphPlots using the directed edges to indicate that some functions can be used as inputs to other functions. Not all possible relations are illustrated, just the most relevant.

TimeValue computations

Annuities, AnnuitiesDue

Cashflow

EffectiveInterest

TimeValue

Labeled[Framed[LayeredGraphPlot[{EffectiveInterest->Annuity,EffectiveInterest->AnnuityDue,EffectiveInterest->Cashflow,Annuity->Cashflow,AnnuityDue->Cashflow,EffectiveInterest->TimeValue,Cashflow->TimeValue,Annuity->TimeValue,AnnuityDue->TimeValue,EffectiveInterest->Solve,Cashflow->Solve,Annuity->Solve,AnnuityDue->Solve,TimeValue->Solve,EffectiveInterest->FindRoot,Cashflow->FindRoot,Annuity->FindRoot,AnnuityDue->FindRoot,TimeValue->FindRoot,EffectiveInterest->Simplify,Cashflow->Simplify,Annuity->Simplify,AnnuityDue->Simplify,TimeValue->Simplify},VertexLabeling->True,DirectedEdges->True,ImageSize->{870,270}]],Style["Time Value Computations",Magenta,Large],Top]

Financial Instruments

FinancialBond

FinancialDerivative

CUDAFinancialDerivative

Labeled[Framed[LayeredGraphPlot[{FinancialBond->ListPlot,FinancialDerivative->ListPlot,CUDAFinancialDerivative->ListPlot,FinancialBond->ListLogPlot,FinancialDerivative->ListLogPlot,CUDAFinancialDerivative->ListLogPlot,FinancialBond->DateListPlot,FinancialDerivative->DateListPlot,CUDAFinancialDerivative->DateListPlot,FinancialBond->DateListLogPlot,FinancialDerivative->DateListLogPlot,CUDAFinancialDerivative->DateListLogPlot,FinancialBond->ListPlot3D,FinancialDerivative->ListPlot3D,CUDAFinancialDerivative->ListPlot3D},VertexLabeling->True,DirectedEdges->True,ImageSize->{850,215}]],Style["Financial Instruments",Magenta,Large],Top]

Time Value Instruments

Before one can evaluate Annuities it is necessary to understand that their values are time dependent and that it is necessary to be able to calculate the present discounted and future values of Annuities.
This involves the introduction of the TimeValue function. Furthermore Annuities are a special case of the more general system of cashflows. So we will also look at the Cashflow function and consider the relationship between it and the Annuity function.

TimeValue Function

Symbolic time value computations:

TimeValue[amount,rate,periods]

Time value computation using a rate schedule:

TimeValue[am, {r1,r2,r3,r4,r5},5]

Time value based on a force of interest function:

TimeValue[am,(1/(((a+b#))^2))&,n]

A symbolic cash-flow computation:

TimeValue[Cashflow[{c1,c2,c3,c4}],r,t]

A symbolic annuity calculation:

TimeValue[Annuity[pmt,n,1/f],r,t]

Future value of $1000 using a nominal rate of 5% with quarterly compounding:

TimeValue[1000,EffectiveInterest[.05,1/4],10]

Present value at 6% of a 12-period annuity with payments of $100:

TimeValue[Annuity[100,12],.06,0]

Future value in three years' time of $1000 invested on January 1, 2010 at 7.5%:

TimeValue[1000,.075,{{2013,1,1},{2010,1,1}}]

Number of periods required to grow $1000 to $3000 at a 6% interest rate:

Solve[TimeValue[1000,.06,n]==3000,n]

EffectiveInterest[r, q] returns the effective interest rate corresponding to interest specification r,compounded at time intervals q  which is an expression suitable for use in TimeValue.

Compound annual growth rate (CAGR) corresponding to a schedule of rates:

EffectiveInterest[{.05,.065,.04,.07,.085}]

Convert a term-structure of interest rates (yield curve) to a list of implied forward rates and the corresponding intervals over which they are valid:

EffectiveInterest[{1/12->.01,3/12->.015,6/12->.02,1->.025,2->.03,3->.032,5->.035,7->.04,10->.045}]

Time Value Instruments: Cashflows

Cashflow Function

Compute the present value at 7% of a stream of cash flows occurring at regular time intervals:

TimeValue[Cashflow[{0,100,250,300,200,500}],.07,0]

Specify an interval at which cash flows occur:

TimeValue[Cashflow[{50,100,250,300},1/2],r,0]

Find the net present value of a $1000 initial investment producing future incoming cash flows:

TimeValue[Cashflow[{-1000,100,200,300,400,500}],.07,0]

Internal rate of return (IRR) of an investment with regular cash flows:

FindRoot[ TimeValue[Cashflow[{-1000,100,200,300,400,500}],r,0]==0,{r,.05}]

Cashflow works with symbolic parameters:

TimeValue[Cashflow[{c1,c2,c3,c4}],r,t]

TimeValue[Cashflow[{c1,c2,c3,c4},1/f],r,t]

TimeValue[Cashflow[{{p1,c1},{p2,c2},{p3,c3}}],r,t]

Cashflow[Annuity[pmt +g (#-1)&,10]]

Solutions to equations involving Cashflow can be found in terms of symbolic parameters:

Solve[TimeValue[Cashflow[{c0,c1,c2,c3}],r,n]==val,c3]

Use Manipulate to explore the various dependencies a series of cash flows has on a set of variables:

Manipulate[
Plot[
Evaluate[
TimeValue[Cashflow[Table[pmt+k,{k,0,900,100}]],EffectiveInterest[r,1/c],n]
],
{n,5,30},AxesLabel->{"time","value"}
],
{{pmt,150,"payment"},100,300},{{r,.05,"interest"},.01,.15},{{c,2,"compounding"},1,10},FrameLabel->"future value of an annuity"
]

Time Value Instruments:Annuities

Annuity objects specify a class of financial instruments involving a series of payments. They can be used to represent loans or mortgages, loan amortizations, and bonds. For instance
The present value of a common mortgage is given byTimeValue[Annuity[p,t,q],r,0].
The value of a typical bond is given byTimeValue[Annuity[{p,{0,(Subscript[p, final])}},t,q],r,0]

Annuity Function

Present value of an annuity of 10 payments of $1000 at 6% effective interest:

TimeValue[Annuity[1000,10],.06,0]

Future value of an annuity of 5 payments of $1000 at 8% nominal interest compounded quarterly:

TimeValue[Annuity[1000,5],EffectiveInterest[.08,1/4],5]

Future value of a 10-period annuity with payments occurring twice per period:

TimeValue[Annuity[1000,10,1/2],.06,10]

Present value of an annuity of 10 payments of $1000 at 6% effective interest:

TimeValue[Annuity[1000,10],.06,0]

Future value of an annuity of 5 payments of $1000 at 8% nominal interest compounded quarterly:

TimeValue[Annuity[1000,5],EffectiveInterest[.08,1/4],5]

Future value of a 10-period annuity with payments occurring twice per period:

TimeValue[Annuity[1000,10,1/2],.06,10]

Annuity works with symbolic parameters. TimeValue[Annuity[…],…] can find closed-form expressions:

TimeValue[Annuity[pmt(((1+g))^(f#-1))&,n,1/f],r,t]

TimeValue[Annuity[p Log[#]&,n],r,0]

Apart can be used to expose the discount factor coefficients on individual payments:

Apart[TimeValue[Annuity[pmt,5],r,0]]

Solutions to equations involving Annuity can be found in terms of symbolic parameters:

Solve[TimeValue[Annuity[pmt,n,1/f],r,n]==val,pmt]

An annuity with a continuous payment flow can be coupled with a force-of-interest specification:

TimeValue[Annuity[(Sqrt[#])&,n,0],(1/(1+#))&,n]

Use Manipulate to explore the various dependencies the annuity has on a set of variables:

Manipulate[
Plot[
Evaluate[
TimeValue[Annuity[pmt,n],EffectiveInterest[r,1/c],n]
],
{n,5,30},AxesLabel->{"time","value"}
],
{{pmt,150,"payment"},100,300},{{r,.05,"interest"},.01,.15},{{c,2,"compounding"},1,10},FrameLabel->"future value of an annuity"
]

Problems for Time Valued Functions

Problems/Solutions

Find the amount that must be invested at a rate of 9% per year in order to accumulate $1000 at the end of 3 years:

Solve[TimeValue[amount,.09,3]==1000,amount]

Find how much time it will take $1000 to accumulate to $1500 if invested at 6%, compounded semiannually:

Solve[TimeValue[1000,EffectiveInterest[.06,1/2],t]==1500,t]

Find the future value of 1 at the end of n years if the force of interest is (1/((1+t))), where t is time:

TimeValue[1,(1/(1+#))&,n]

Find the rate, compounded quarterly, at which $16000 is the present value of a $1000 payment paid at the end of every quarter for 5 years:

FindRoot[TimeValue[Annuity[1000,5,1/4],EffectiveInterest[r,1/4],0]==16000 ,{r,.05}]

What payment at time 2 will make the net present value of a series of cash flows zero:

Solve[TimeValue[Cashflow[{-1000,300,pmt,250,500}],.08,0]==0,pmt]

Solve for the point in time, t where an initial investment of $1000 followed by payments of $300, $400 and $600 at years 2, t and 5 respectively will make the net present value at an interest rate of 8% equal to 0:

Solve[TimeValue[Cashflow[{{0,-1000},{2,300},{t,400},{5,600}}],.08,0]==0,t]

Payments of $100, $200, and $500 are due at the end of years 2, 3, and 8, respectively. Find the point in time where a payment of $800 would be equivalent at 5% interest:

Solve[TimeValue[Cashflow[{{2,100},{3,200},{8,500}}],.05,t]==800,t]

At what effective rate of interest will the present value of $2000 at the end of 2 years and $3000 at the end of 4 years be equal to $4000:

FindRoot[TimeValue[Cashflow[{{2,2000},{4,3000}}],r,0]==4000 ,{r,.05}]

Find the rate, compounded quarterly, at which $16000 is the present value of $1000 paid at the end of every quarter for 5 years:

FindRoot[TimeValue[Annuity[1000,5,1/4],EffectiveInterest[r,1/4],0]==16000 ,{r,.05}]

A loan of $3000 is to be repaid with quarterly installments at the end of each quarter for 5 years. If the interest rate is 10% compounded semiannually, find the amount of each quarterly payment:

Solve[TimeValue[Annuity[p,5,1/4],EffectiveInterest[.1,1/2],0]==3000,p]

Find the present value of a perpetuity whose successive payments are 1, 2, 3, ... at an effective rate of 5% interest:

TimeValue[Annuity[#&,Infinity,1],.05,0]

Find the present value, 2 years before the first payment, of a 20-period annuity at 7% whose payments start at $1000 and grow by 4% thereafter:

TimeValue[Annuity[1000 (1.04^(#-1))&,20],.07,-2]

Find an expression for the present value of a continuously increasing annuity with a term of n years if the (constant) force of interest is δ and the rate of payment is (t^2) per year at time t:

TimeValue[Annuity[((#)^2)&,n,0],δ&,0]

Find the (constant) force of interest at which the future value of a 20-period continuous payment annuity, such that the amount paid over one period is equal to 1, equals 3 times that of a 10-period annuity:

FindRoot[TimeValue[Annuity[1&,20,0],d&,20]==3TimeValue[Annuity[1&,10,0],d&,10] ,{d,.05}]

Financial Bond

Annuities include bonds as a special case, which can be described by TimeValue[Annuity[{p,{0,(Subscript[p, final])}},t,q],r,0]. 
In this way a bond is the instance of an annuity where the final payment equals the principal payment and the coupon.
However the annuity structure doesn’t allow us to study the effects of different interest rate and dividend yield specifications. However the FinancialBond function caters for these additional subtleties.
FinancialBond represents a class of financial instruments involving a series of coupon payments together with a principal payment made at maturity.

Basics

All of the features for a Financial Bond can be displayed in one Tab View:

Panel[Column[{HoldForm@FinancialBond[
{"FaceValue"->par,"Coupon"->c,"Maturity"->{2020,1,1},"CouponInterval"->1/2},{"InterestRate"->r,"Settlement"->{2010,3,8},"DayCountBasis"->"Actual/365"},
Style["property",Italic]
],
"     ",
TabView[#->Column[{
FinancialBond[
{"FaceValue"->par,"Coupon"->c,"Maturity"->{2020,1,1},"CouponInterval"->1/2},{"InterestRate"->r,"Settlement"->{2010,3,8},"DayCountBasis"->"Actual/365"},
#
]}]&/@{"Value","AccruedInterest","Duration","Convexity","SettlementToCouponDays","NextCouponDate","RemainingCoupons"},1, Alignment->{Center,Center},ControlPlacement->Left]

},BaseStyle->{FontFamily-> "Georgia", 16}, Background-> Lighter@Lighter@ LightGray],  Background->Lighter@ LightGray]

Price of a 10-year semiannual coupon bond with a 5% yield 9 months after the issue date:

FinancialBond[{"FaceValue"->1000,"Coupon"->0.0575,"Maturity"->10,"CouponInterval"->(1/2)},{"InterestRate"->.05,"Settlement"->(9/12)}]

FinancialBond works with symbolic parameters and can find closed-form expressions:

FinancialBond[{"FaceValue"->p,"Coupon"->c,"Maturity"->n,"CouponInterval"->(1/f)},{"InterestRate"->r,"Settlement"->0}]

FinancialBond[{"FaceValue"->p,"Coupon"->c,"Maturity"->{2003,12,31},"CouponInterval"->(1/2)},{"InterestRate"->y,"Settlement"->{2001,7,12},"DayCountBasis"->"Actual/365"}]

FinancialBond[{"FaceValue"->p,"Coupon"->c,"Maturity"->n,"CouponInterval"->(1/f)},{"InterestRate"->r,"Settlement"->0},"Duration"]//Simplify

Symbolic solutions to equations involving FinancialBond can be found:

Solve[FinancialBond[{"FaceValue"->F,"Coupon"->c,"Maturity"->{2003,12,31},"CouponInterval"->(1/2)},{"InterestRate"->y,"Settlement"->{2001,7,12},"DayCountBasis"->"Actual/365"}]==price,c]

FinancialBond can be given a term structure of interest rates or a list of future spot rates:

FinancialBond[{"FaceValue"->1000,"Coupon"->.035,"Maturity"->10,"CouponInterval"->1/2},{"InterestRate"->{1->.02,2->.03,3->.04,5->.045,10->.06},"Settlement"->2/12,"DayCountBasis"->"ActualISDA"}]

FinancialBond can take a functional (growing) coupon together with a force of interest:

FinancialBond[{"FaceValue"->par,"Coupon"->(c (((1+g))^(2#-1))&),"Maturity"->{2003,12,31},"CouponInterval"->(1/2)},{"InterestRate"->((1/(1+#))&),"Settlement"->{2001,7,12},"DayCountBasis"->"Actual/365"}]

A console bond can be valued using Infinity as the maturity date:

FinancialBond[{"FaceValue"->1000,"Coupon"->c,"Maturity"->Infinity},{"InterestRate"->y,"Settlement"->0}]

FinancialBond takes a nominal yield and assumes a compounding equal to the coupon frequency. However, it may be desirable to use a different compounding frequency. EffectiveInterest can be used to find a nominal rate that gives the correct effective discounting after being compounded at the coupon frequency:

Solve[EffectiveInterest[r,1/2]==EffectiveInterest[.05,0],r]

FinancialBond[{"FaceValue"->1000,"Coupon"->.05,"Maturity"->10,"CouponInterval"->1/2},{"InterestRate"->0.0506302,"Settlement"->.2}]

A constant force of interest can be used to create the same continuous compounding:

FinancialBond[{"FaceValue"->1000,"Coupon"->.05,"Maturity"->10,"CouponInterval"->1/2},{"InterestRate"->(.05&),"Settlement"->.2}]

Financial Bond Problems

Problems/Solutions

A console bond can be valued using Infinity as the maturity date:

FinancialBond[{"FaceValue"->1000,"Coupon"->c,"Maturity"->Infinity},{"InterestRate"->y,"Settlement"->0}]

Find the price of a 10-year, inflation-adjusted bond with a par value of $1000, interest rate of 9%, inflation rate of 5% and with annual coupons. The initial coupon rate is 7%, and each coupon is 3% greater than the preceding one. The bond's redemption value is $1200:

Table[0.07 (1.03^(t-1)) 1.09,{t,1,10}]

FinancialBond[{"FaceValue"->1000,"RedemptionValue"->1200,"Coupon"->(0.07 1.05 ((1.03`)^(#1-1))&),"Maturity"->10},{"InterestRate"->0.09,"Settlement"->0}]

Find the accrued interest for the bond above, assuming it is purchased three months into its life.

FinancialBond[{"FaceValue"->1000,"RedemptionValue"->1200,"Coupon"->(0.07 1.05 ((1.03`)^(#1-1))&),"Maturity"->10},{"InterestRate"->0.09,"Settlement"->3/12},"AccruedInterest"]

Price of a $1000 par value, 6% yield, semiannual callable bond with a redemption value of $1200, a call date on December 31, 2020, and a settlement date of July 12, 2010:

FinancialBond[{"FaceValue"->1000,"RedemptionValue"->1200,"Coupon"->0.07,"Maturity"->{2020,12,31},"CouponInterval"->(1/2)},{"InterestRate"->.06,"Settlement"->{2010,7,12},"DayCountBasis"->"Actual/360"}]

Days until the next coupon date for a 6% yield, 4% quarterly coupon bond maturing December 31, 2030 and settling September 5, 2013, using the "30/360" day count convention:

FinancialBond[{"FaceValue"->1000,"Coupon"->0.04,"Maturity"->{2030,12,31},"CouponInterval"->(1/4)},{"InterestRate"->.06,"Settlement"->{2013,9,5},"DayCountBasis"->"30/360"},{"SettlementToCouponDays","NextCouponDate"}]

A semiannual coupon bond has a nominal rate of 8% and a price of $1722.25. The bond can be called at par on any coupon date starting at the end of year 15. Find the par value that will guarantee at least a 6% yield:

Solve[FinancialBond[{"FaceValue"->par,"Coupon"->0.08,"Maturity"->15,"CouponInterval"->(1/2)},{"InterestRate"->0.06,"Settlement"->0}]==1722.25,par]

Find the call price that will guarantee at least a 7% yield if this same bond had a par value of 1000 and a price of $1300:

Solve[FinancialBond[{"FaceValue"->1000,"RedemptionValue"->red,"Coupon"->0.08,"Maturity"->15,"CouponInterval"->(1/2)},{"InterestRate"->.06,"Settlement"->0}]==1300,red]

Find the maximum yield an investor can hope to achieve if this bond had a call of 1100 and a price of $900:

FindRoot[FinancialBond[{"FaceValue"->1000,"RedemptionValue"->1100,"Coupon"->0.08,"Maturity"->15,"CouponInterval"->(1/2)},{"InterestRate"->y,"Settlement"->0}]==900,{y,.1}]

Duration and convexity for a semiannual bond maturing on December 31, 2030 and settling on November 12, 2010, using the "Actual/360" day count convention:

FinancialBond[{"FaceValue"->1000,"Coupon"->0.08,"Maturity"->{2030,12,31},"CouponInterval"->(1/2)},{"InterestRate"->0.06,"Settlement"->{2010,11,12},"DayCountBasis"->"Actual/360"},{"Duration","Convexity"}]

Financial Derivatives

Derivatives or options as they are sometimes called are higher order financial instruments or functions of underlying assets. As such they derive their value from the distribution of future values of those assets. In this way derivatives depend upon the assumptions of the future behaviour of their underlying instruments and use probability distributions, especially the lognormal distribution to describe the range of future underlying values at maturity.

Overview

ticks[min_,max_]:=Table[{j,Round[j 50],{.04,0}},{j,min,max, 0.2}];
s4=Framed[Panel[Manipulate[Text/@FinancialDerivative[]//TableForm, ContentSize->{400,200}], BaseStyle->{FontFamily-> "Georgia", Large}, Background-> LightGray], RoundingRadius-> 8, Background-> LightGray];
s1=Framed[Panel[Column[{pmsft=FinancialData["MSFT"];Spacer[20],Manipulate[ListPlot[{#,  FinancialDerivative[{"American","Put"}, {"StrikePrice"-> 40.00, "Expiration"->3},  {"InterestRate"-> EffectiveInterest[.05,0], "Volatility" -> 0.26, "CurrentPrice"-> pmsft, "Dividend"->0.07,"ReferenceTime"->#}, "CriticalValue", "GridSize"->{xgrid,50}]}&/@Range[0,3, 0.05], Joined->True,InterpolationOrder->0, Filling->Bottom,FillingStyle->Directive[Opacity[0.7], ColorData[1,2], Specularity[White,10]],Axes->False, Frame->True, PlotRange->All, ImageSize->350, PlotLabel->"Critical Value of a put option as a function of years to expiration"], {{xgrid, 500, "size of the numerical grid"}, 100, 1000, 100}]}], BaseStyle->{FontFamily-> "Georgia", 15}, Background-> LightGray], RoundingRadius-> 8, Background-> LightGray];
s2=Framed[Panel[Column[{Spacer[20],Manipulate[ListPlot[{#,FinancialDerivative[contspec,{"Expiration"->1,"MaxSoFar"->50},{"CurrentPrice"->45,"Dividend"->0.04,"Volatility"->#,"InterestRate"->0.05},"CriticalValue"]}&/@Range[0.1, 0.5, 0.02], Filling->Axis, FillingStyle->ColorData[1,3],ImageSize->350, PlotLabel->"Critical Values of Exotics as a function of volatility"], {{contspec,"Russian", "Contract specification"} ,{"Russian"->"Russian", {"PerpetualLookback","Put"}->"Perpetual put"}}]}], BaseStyle->{FontFamily-> "Georgia", 15}, Background-> LightGray], RoundingRadius-> 8, Background-> LightGray];
s3=Framed[Column[{Style[Text["Greeks for an American call option"], Bold, 20],Spacer[20],Panel[Grid[{Take[#, 3], Take[#, -2]}&@(ListPlot[#, Ticks->{ticks, Automatic}, Epilog->Inset[Rotate[Text[Style[#2,Bold,16,Directive[Opacity[0.5]],FontFamily->"Courier"]],0]]]&@@@Transpose[{Transpose[Table[{i,#}&/@FinancialDerivative[{"American", "Call"}, {"StrikePrice"->40,"Expiration"->3},  {"InterestRate"-> 0.01,"Volatility" -> 0.2, "CurrentPrice"-> 50 i,"Dividend"->0.05,"ReferenceTime"->0.4}, "Greeks"][[All, 2]], {i,0.5,1,0.05}]], {"Delta", "Gamma", "Rho", "Theta", "Vega"}}])], BaseStyle->{FontFamily-> "Georgia", Large}, Background-> LightGray]}, Alignment->Center], RoundingRadius-> 8, Background-> LightGray];
s5=Framed[Panel[Column[{Spacer[20],Manipulate[ListLinePlot[Table[{i,FinancialDerivative[{"American","Call"}, {"StrikePrice"->40.00, "Expiration"->1, "Value"->i},  {"InterestRate"-> int,"CurrentPrice"-> 50, "Dividend"->0.05}, "ImpliedVolatility"]}, {i, 15, 25, 0.5}], PlotStyle->ColorData[1,5],Frame->True, Axes->False, FrameLabel->{"Price", "Volatility"}] , {{int,0.02, "Interest rate"}, 0.01, 0.1}]}], BaseStyle->{FontFamily-> "Georgia", 15}, Background-> LightGray], RoundingRadius-> 8, Background-> LightGray];
TabView[{"Solvers for vanillas\nand exotics"-> s4, "Control over\nnumerical evaluation"-> s1,"Computation\nof Greeks"->s3, "Compute IV"->s5, "Exotic Contracts"->  s2}, Alignment-> {Center, Center}, Appearance-> {"Limited", 6}]

A Unified, Interactive Interface

FinancialDerivative[{"American","Call"},{"StrikePrice"->40,"Expiration"->1},{"CurrentPrice"->30,"Dividend"->0.05,"Volatility"->0.3,"InterestRate"->0.05}, {"Value", "CriticalValue"}]

{“American”,”Call”} contract specification

{“StrikePrice”->40,”Expiration”->1} contract parameter specification

{“CurrentPrice”->30,”Dividend”->0.05,”Volatility”->0.3,”InterestRate”->0.05} ambient parameter specification

{“Value”, “CriticalValue”} return values

Determine the output

Grid[({Style[#, 14, Bold], Style[#2, 14, Italic, Background->LightYellow]}&@@@{{"Value","value on the reference date"},{"CriticalValue","critical value for American options"},{"Delta","derivative of the value with respect to the price"},{"Gamma","second derivative of the value with respect to the price"},{"Rho","derivative of the value with respect to the interest rate"},{"Theta","derivative of the value with respect to the time until expiration"},{"Vega","derivative of the value with respect to the volatility"},{"ImpliedVolatility","volatility implied by the contract price"}}), Frame->All, Alignment->{Left}]

Financial Derivative Examples

Examples

List all available contract types:

FinancialDerivative[]

Value of a European call option:

FinancialDerivative[{"European","Call"}, {"StrikePrice"-> 50.00, "Expiration"->1},  {"InterestRate"-> 0.1, "Volatility" -> 0.5, "CurrentPrice"-> 50, "Dividend"->0.05}]

Value and all Greeks of a European call option:

FinancialDerivative[{"European","Call"}, {"StrikePrice"-> 50.00, "Expiration"->1},  {"InterestRate"-> 0.1, "Volatility" -> 0.5, "CurrentPrice"-> 50, "Dividend"->0.05}, {"Value", "Greeks"}]

Compute the value given an expiration date of the contract:

FinancialDerivative[{"European","Call"}, {"StrikePrice"-> 50.00, "Expiration"->DatePlus[DateList[], 365]},  {"InterestRate"-> 0.1, "Volatility" -> 0.5, "CurrentPrice"-> 50, "Dividend"->0.05}]

Determine the parameters for a vanilla contract:

FinancialDerivative[{"American","Call"}]

Value of a American vanilla contract:

FinancialDerivative[{"American","Call"}, {"StrikePrice"->30.00, "Expiration"->1},  {"InterestRate"-> 0.01, "Volatility" -> 0.1, "CurrentPrice"-> 50, "Dividend"->0.05}]

Compute the difference in values of an American and a European vanilla contract:

Subtract@@(FinancialDerivative[{#,"Call"}, {"StrikePrice"->40.00, "Expiration"->1},  {"InterestRate"-> 0.01, "Volatility" -> 0.2, "CurrentPrice"-> 50, "Dividend"->0.05}]&/@{"American", "European"})

Compute the implied volatility of the contract:

FinancialDerivative[{"American","Call"}, {"StrikePrice"->40.00, "Expiration"->1, "Value"->13},  {"InterestRate"-> 0.01,"CurrentPrice"-> 50, "Dividend"->0.05}, "ImpliedVolatility"]

Compute the value of a barrier option:

FinancialDerivative[{"BarrierUpOut","American","Call"},{"StrikePrice"->35,"Expiration"->1,"Barrier"->40},{"CurrentPrice"->30,"Dividend"->0.05,"Volatility"->0.2,"InterestRate"->0.05}]

Barriers restrict positive outcomes for the option holder, compared to a vanilla contract:

FinancialDerivative[{"American","Call"},{"StrikePrice"->35,"Expiration"->1},{"CurrentPrice"->30,"Dividend"->0.05,"Volatility"->0.2,"InterestRate"->0.05}]

Compute the value of a European exercise call on a call option:

FinancialDerivative[{"CompoundCall","European","Call"},{"StrikePriceUnderlying"->50,"StrikePrice"->3,"ExpirationUnderlying"->2,"Expiration"->1},{"CurrentPrice"->50,"Dividend"->0.05,"Volatility"->0.3,"InterestRate"->0.05}]

An extendible contract for the same parameters is at least as valuable as a compound option:

FinancialDerivative[{"ExtendibleHolder","European","Call"}, {"StrikePriceAdjusted"->50,"StrikePrice"->50,"ExtensionPeriod"->1,"ExtensionFee"->3,"Expiration"->1}, {"CurrentPrice"->50,"Dividend"->0.05,"Volatility"->0.3,"InterestRate"->0.05}]

A chooser option for the same parameters will be more expensive than either:

FinancialDerivative[{"Chooser","European"},{"Expiration"->1,"ExpirationCall"->2,"ExpirationPut"->2,"StrikePricePut"->50,"StrikePriceCall"->50},{"CurrentPrice"->50,"Dividend"->0.05,"Volatility"->0.3,"InterestRate"->0.0}]

A rainbow money option is a hedge against poor performance by all basket components:

Positive[FinancialDerivative[{"RainbowMoney","American"},{"Money"->100,"Expiration"->1},{"CurrentPrice"->{100, 100},"Dividend"->0,"Volatility"->0.30,"CorrelationMatrix"->{0.5},"InterestRate"->0.05}]-
FinancialDerivative[{"RainbowBest","American"},{"Expiration"->1},{"CurrentPrice"->{100, 100},"Dividend"->0,"Volatility"->0.30,"CorrelationMatrix"->{0.5},"InterestRate"->0.05}]]

Range contract values are computed using a simulation, and are subject to a small uncertainty:

StandardDeviation[Table[FinancialDerivative["Atlas",{"Expiration"->1,"NominalAmount"->100,"StrikePrice"->1.},{"CurrentPrice"->ConstantArray[100,4],"Dividend"->0.0,"Volatility"->0.2,"CorrelationMatrix"->{0.06,0.5,0.4,0.24,0,0.3},"InterestRate"->0.01}], {i,10}]]

Dynamic evaluation of American options:

Manipulate[Plot[FinancialDerivative[{"American",type}, {"StrikePrice"-> K, "Expiration"->T},  {"InterestRate"-> r, "Volatility" ->σ, "CurrentPrice"-> S, "Dividend"->δ}], {S, 70., 140.}, AxesLabel->{"stock", "option price"},ImageSize->400,ImagePadding->{{40,50},{25,25}}], {{type,"Call","American option"}, {"Call","Put"}}, {{K, 100.,"strike price"},50.,150.}, {{r,.05,"interest rate"},.02,.1},{{δ,.004,"dividend yield"}, .002, .05},{{σ,.3, "volatility"}, .2, .5}, {{T,.1,"time to maturity"}, .001,1.}]

Dynamic evaluation of American option Greeks:

Manipulate[Plot[FinancialDerivative[{"American",type}, {"StrikePrice"-> K, "Expiration"->T},  {"InterestRate"-> r, "Volatility" ->σ, "CurrentPrice"-> S, "Dividend"->δ},greek], {S, 70., 140.}, AxesLabel->{"stock", "option Greek"},ImageSize->400,ImagePadding->{{40,50},{25,25}}], {{type,"Call","American option"}, {"Call","Put"}},{{greek,"Delta","Greeks"}, {"Delta","Gamma","Rho","Theta","Vega"}}, {{K, 100.,"strike price"},50.,150.}, {{r,.05,"interest rate"},.02,.1},{{δ,.004,"dividend yield"}, .002, .05},{{σ,.3, "volatility"}, .2, .5}, {{T,.1,"time to maturity"}, .001,1.}]

Dynamic evaluation of double-barrier knock-out options:

Manipulate[Plot[FinancialDerivative[{"DoubleBarrierKnockOut",exercise,type}, {"StrikePrice"-> K, "Expiration"->T,"Barriers"->{lb,ub}},  {"InterestRate"-> r, "Volatility" ->σ, "CurrentPrice"-> S, "Dividend"->δ}], {S, lb,ub}, AxesLabel->{"stock", "option price"},ImageSize->400,ImagePadding->{{40,50},{25,25}}], {{type,"Call","Dble Barrier KnockOut"}, {"Call","Put"}},{{exercise,"European","Exercise"}, {"European","American"}}, {{K, 70.,"strike price"},50.,150.}, {{r,.05,"interest rate"},.02,.1},{{δ,.004,"dividend yield"}, .002, .05},{{σ,.3, "volatility"}, .2, .5}, {{T,.1,"time to maturity"}, .001,1.},{{ub,lb+20,"Upper Barrier"},lb+5,150},{{lb,80,"Lower Barrier"},50,120}]

Financial Derivative Problems

Problems/Solutions

Plot the values of Greeks of an American Put option with parameters {“StrikePrice”->45.00,”Expiration”->1} and {“InterestRate”-> 0.1,”Volatility” -> 0.5, “CurrentPrice”-> 50,”Dividend”->0.05} as a function of time left until expiration:

TabView[Rule@@@Transpose[{{"Delta", "Gamma", "Rho", "Theta", "Vega"},ListPlot[#,Joined->True]&/@Transpose[Table[{i,#}&/@FinancialDerivative[{"American", "Put"}, {"StrikePrice"->45.00,"Expiration"->1},  {"InterestRate"-> 0.1,"Volatility" -> 0.5, "CurrentPrice"-> 50,"Dividend"->0.05,"ReferenceTime"->i}, "Greeks"][[All, 2]], {i,0.95,0,-0.05}]]}]]

Plot the effect of volatility on the critical values of perpetual Lookback puts with parameters {“Expiration”->1,”MaxSoFar”->50} and {“CurrentPrice”->45,”Dividend”->0.04,”InterestRate”->0.05}

ListPlot[{#,FinancialDerivative[{"PerpetualLookback","Put"},{"Expiration"->1,"MaxSoFar"->50},{"CurrentPrice"->45,"Dividend"->0.04,"Volatility"->#,"InterestRate"->0.05},"CriticalValue"]}&/@Range[0.1, 0.5, 0.02], Filling->Axis]

Plot the critical value surface of an American put contract with parameters {“StrikePrice”-> 40.00, “Expiration”->3} and {“InterestRate”-> 0.09, “Volatility” -> 0.26, “CurrentPrice”-> 36, “Dividend”->0.07}

ListPlot[{#,  FinancialDerivative[{"American","Put"}, {"StrikePrice"-> 40.00, "Expiration"->3},  {"InterestRate"-> 0.09, "Volatility" -> 0.26, "CurrentPrice"-> 36, "Dividend"->0.07, "ReferenceTime"->#}, "CriticalValue"]}&/@Range[0,3, 0.05], Joined->True,InterpolationOrder->0, Filling->Bottom,Axes->False, Frame->True, PlotRange->All]

Plot the return surface of a call spread with parameters  {“Expiration”->1} and {“InterestRate”-> 0.1, “Volatility” -> 0.5, “CurrentPrice”-> #, “Dividend”->0.05} but with different Strikes of 45.0 and 55.0

ListPlot3D[{#, 1-#2,FinancialDerivative[{"American","Call"}, {"StrikePrice"-> 45.00, "Expiration"->1},  {"InterestRate"-> 0.1, "Volatility" -> 0.5, "CurrentPrice"-> #, "Dividend"->0.05, "ReferenceTime"->#2}]-FinancialDerivative[{"American", "Call"}, {"StrikePrice"->55.00, "Expiration"->1},  {"InterestRate"-> 0.1, "Volatility" -> 0.5, "CurrentPrice"-> #, "Dividend"->0.05, "ReferenceTime"->#2}]}&@@@Flatten[Table[{price, referencetime}, {referencetime, 0, 1, 0.05}, {price, 35, 65, 1}], 1]]

Follow up Contact and Financial Consulting

If further questions, explanations or financial examples are required then please contact me at:

Dr Michael Kelly
Wolfram Technology (Finance) Consultant 
mkelly@wolfram.com
217-398-0700 ext. 5545