MAPLE in Finance
Igor Hlivka - MUFG Securities International
Introduction
Many aspects of Financial Economics are technical in nature and require mathematical formulation to solve them.Extensive use of mathematical methods in Finance has led to the development of Mathematical Finance - a distinct subgroup of mathematical and statistical rules and theorems that deal with particular problems arising in financial analysis.
In pure mathematical terms, problems of Financial Economics are typically reduced to (i) equations solving, (ii) optimization routines, (iii) simulations, (iv) parameters estimation or (v) process modeling which are all well-suited for computer algebra packages using symbolic manipulation and highly efficient numerical solvers.
The purpose of this document is to demonstrate how Maple - with its powerful analytical engine and robust numerical routines - can be used to tackle various topics in Financial Economics / Mathematics, and lead to elegant solutions through its symbolic and numerical interfaces.
Interest base conversion, compounding and discounting
Rates compounding
There are many many different rates in the economy - they differ by:
Here we examine how one can easily obtain conversion formulas for interest rates under various compounding regimes:
Assume we are given a rate with discrete compounding frequency . We may want to express this rate [now denoted ]with different discrete compounding frequency . Further assume that the rate has duration of years.
Continuously compounded rates will always be lower than rates with discrete compounding due to the compounding effect'
Discounting
Discounting future cash flows:
The present value of the a single CF received in the future:
A) Discrete case: = B) Continuously compounded case:
However, what is the present value of a stream of CF for a given period of time (n-years?) - i.e. the PV of Annuity?
This quantity depends on the compounding frequency:
A): Discrete compounding: B): Continuous compounding:
PV of ?1 received over the period of 5Y semi-annually:
PV of ?1 received over the period of 5Y continuously:
The annuity factor for continuously compounded case is higher, again due to higher compounding frequency
Fixed Income Mathematics
Bonds
Fixed Coupon
Let's define fixed-coupon bond as with coupon , yield-to-maturity , annual payment frequency and maturity years. The value of the bond can be expressed as a present value of future cash flows:
Floating rate note [FRN]
CMT
Constant-maturity Treasury is a bond with variable coupon where the coupon value is linked to a longer-dated yield on other (typically) government securities.
The problem in evaluation of CMTs is reduced to the determination of future coupons: (i) forward par rates and (ii) convexity correction.
CMT floater is then defined as FRN with coupons being equal to
Maple's powerful symbolic engine returns the desired formula and is capable of finding any desired comparative static of this instrument. We can differentiate the CMT formula to obtain the first and second derivative of the CMT price w.r.t to yield:
Asset Swap Package on CMT
CMTs are frequently compared or swapped into a standard FRN. Investors may want to swap a longer-dated CMT par yield for a short-term money-market yield when they expect the shorter rates to outperform the longer-dated yields.
In CMT Asset Swap package, one needs to determine the value of a spread over money-market rate (say: 3M Libor) that makes the both legs of transaction equal:
The asset swap on CMT is then expressed as as Asset Swap Spread (AS)
Floating leg definition: L[i] = i-th Libor rate, s = spread, N = notional principal, DF[i] = i-th Discount factor, δ = year fraction
CMT Leg definition: CMT[i] = i-th CMT coupon, ξ = CMT spread, DP = "dirty price of a bond", Par = Par bond
Derivative Products
Standard Financial Options
Define the Standard Normal Density
Determine the critical value for which the stock's terminal value is equal to the strike price K: S[T] = K
Specify the option's payoff:
Price an option:
Option's sensitivities
Non-Standard Options
Black-Scholes option pricing formula is a standard option with piecewise linear payoff.
However, we can use Maple's symbolic engine to derive various non-standard option formulas where the terminal payoff is not any longer piecewise linear.
Power Option
The option payoff is now the square of the stock price:
Powered Option
The payoff is the difference between the stock price and the strike price squared:
Digital
Option will pay a pre-determined amount PA if S[T] ≥ K
Range
Option that pays a fixed amount A if the stock price at option maturity is within the range of [LP,HP]:
Performance Option
Alternative Process Dynamics
PDEs in Finance
Finding probability density function [PDF] for B/S process
PDF in higher dimension
PDF for Jump-Diffusion
Numerical Computation
Monte Carlo method for standard option
Here we demonstrate how Maple's Statistics package can be efficiently used to value European-type financial options numerically
Monte Carlo method with stochastic volatility
Normal option with stochastic volatility - numerical integration
Here we show how Maple's numerical integration can be efficiently applied to solve the option pricing when the volatility itself is stochastic
Numerical PDE method
Standard Black-Scholes approach
Define the drift and diffusion parameters of BS PDE:
Specify the numerical values and Initial / Boundary conditions
Solve the PDE numerically
Visualize the result:
Alternative PDE process
Data Analysis
We use Maple's Statistics package to test various regression models on the given set of data
Selection of regression models is arbitrary and many other model combinations are feasible.
Risk Application
In this section we examine the calculation of Value-At-Risk statistics for a small portfolio of financial instruments.
Value-at-Risk [Value@Risk] determines how much an institution may loose over a given time (typically number of days), at pre-determined confidence level.
Practical Approach
We see that the quantile of Gumbel density at 99% confidence level is almost double of that of standard normal density:
Example: Market exposure = 100 million, t= 10 Days
The difference in the risk measure is significant:
Theoretical Approach
Having determined the theoretical portfolio's volatility, we can obtain comparative static for the VaR behavior:
Conclusion
Legal Notice: The copyright for this application is owned by the author. Neither Maplesoft nor the author are responsible for any errors contained within and are not liable for any damages resulting from the use of this material. This application is intended to demonstrate the use of Maple to solve particular set of problems.It has been made available for product evaluation purposes only and may not be used in any other context without the express permission of Maplesoft and/or author.