全部版块 我的主页
论坛 金融投资论坛 六区 金融学(理论版)
4342 0
2006-10-22

Introd

Financial Numerical Recipes in C ++.

Bernt Arne Ødegaard



uction

We have shown binomial calculations given an up and down movement in chapter 5. However, binomial option pricing can also be viewed as an approximation to a continuous time distribution by judicious choice of the constants and . To do so one has to ask: Is it possible to find a parametrization (choice of and ) of a binomial process which has the same time series properties as a (continous time) process with the same mean and volatility? There is actually any number of ways of constructing this, hence one uses one degree of freedom on imposing that the nodes reconnect, by imposing .

To value an option using this approach, we specify the number of periods to split the time to maturity into, and then calculate the option using a binomial tree with that number of steps.

Given and the number of periods , calculate






We also redefine the ``risk neutral probabilities''




To find the option price, will ``roll backwards:'' At node , calculate the call price as a function of the two possible outcomes at time . For example, if there is one step, find the call price at time 0 as


With more periods one will ``roll backwards'' as discussed in chapter 5

Pricing of options in the Black Scholes setting

Consider options on underlying securities not paying dividend.

European Options

For European options, binomial trees are not that much used, since the Black Scholes model will give the correct answer, but it is useful to see the construction of the binomial tree without the checks for early exercise, which is the American case.

The computer algorithm for a binomial in the following merits some comments. There is only one vector of call prices, and one may think one needs two, one at time and another at time . (Try to write down the way you would solve it before looking at the algorithm below.) But by using the fact that the branches reconnect, it is possible to get away with the algorithm below, using one less array. You may want to check how this works. It is also a useful way to make sure one understands binomial option pricing.



American Options

An American option differs from an European option by the exercise possibility. An American option can be exercised at any time up to the maturity date, unlike the European option, which can only be exercised at maturity. In general, there is unfortunately no analytical solution to the American option problem, but in some cases it can be found. For example, for an American call option on non-dividend paying stock, the American price is the same as the European call.

It is in the case of American options, allowing for the possibility of early exercise, that binomial approximations are useful. At each node we calculate the value of the option as a function of the next periods prices, and then check for the value exercising of exercising the option now

Code 9.2 illustrates the calculation of the price of an American call.

Actually, for this particular case, the american price will equal the european.


Estimating partials.

It is always necessary to calculate the partial derivatives as well as the option price.

The binomial methods gives us ways to approximate these as well. How to find them in the binomial case are described in Hull (2003). The code below is for the non-dividend case.

Delta

, the derivative of the option price with respect to the underlying.



Other hedge parameters.



Adjusting for payouts for the underlying

The simplest case of a payout is the similar one to the one we saw in the Black Scholes case, a continous payout of .

Pricing options on stocks paying dividends using a binomial approximation

Checking for early exercise in the binomial model.

If the underlying asset is a stock paying dividends during the maturity of the option, the terms of the option is not adjusted to reflect this cash payment, which means that the option value will reflect the dividend payments.

In the binomial model, the adjustment for dividends depend on whether the dividends are discrete or proportional.

Proportional dividends.

For proportional dividends, we simply multiply with an adjustment factor the stock prices at the ex-dividend date, the nodes in the binomial tree will ``link up'' again, and we can use the same ``rolling back'' procedure.



Discrete dividends

The problem is when the dividends are constant dollar amounts.

In that case the nodes of the binomial tree do not ``link up,'' and the number of branches increases dramatically, which means that the time to do the calculation is increased.

The algorithm presented here implements this case, with no linkup, by constructing a binomial tree up to the ex-dividend date, and then, at the terminal nodes of that tree, call itself with one less dividend payment, and time to maturity the time remaining at the ex-dividend date. Doing that calculates the value of the option at the ex-dividend date, which is then compared to the value of exercising just before the ex-dividend date. It is a cute example of using recursion in simplifying calculations, but as with most recursive solutions, it has a cost in computing time. For large binomial trees and several dividends this procedure will take a long time. In that case it will be a good deal faster to avoid the recursive calls. Look in (Hull, 1993, pg 347) for ways to achieve this by making some small assumptions.



Option on futures

For American options, because of the feasibility of early exercise, the binomial model is used to approximate the option value.




Foreign Currency options

For American options, the usual method is approximation using binomial trees, checking for early exercise due to the interest rate differential.



References

The original source for binomial option pricing was the paper by Cox et al. (1979). Good textbook discussions are in Cox and Rubinstein (1985), Bossaerts and Ødegaard (2001) and Hull (2003).



2003-10-22
Finite Differences

The method of choice for any engineer given a differential equation to solve is to numerically approximate it using a finite difference scheme, which is to approximate the continous differential equation with a discrete difference equation, and solve this difference equation.

In the following we implement the two schemes described in chapter 14.7 of Hull (1993), the implicit finite differences and the the explicit finite differences.

Brennan and Schwartz (1978) is one of the first finance applications of finite differences. Section 14.7 of Hull (1993) has a short introduction to finite differences. Wilmott et al. (1994) is an exhaustive source on option pricing from the perspective of

Extending the Black Scholes formula

Adjusting for payouts of the underlying.

For options on other financial instruments than stocks, we have to allow for the fact that the underlying may have payouts during the life of the option. For example, in working with commodity options, there is often some storage costs if one wanted to hedge the option by buying the underlying.

Continous Payouts from underlying.

The simplest case is when the payouts are done continuously. To value an European option, a simple adjustment to the Black Scholes formula is all that is needed. Let be the continuous payout of the underlying commodity.

Call and put prices for European options are then given by formula 8.1, which are implemented in code 8.1.





Dividends.

A special case of payouts for the underlying is dividends. When the underlying pays dividends, the pricing formula is adjusted, because the dividend changes the value of the underlying.

The case of continuous dividends is easiest to deal with. It corresponds to the continuous payouts we have looked at previously. The problem is the fact that most dividends are paid at discrete dates.

European Options on dividend-paying stock.

To adjust the price of an European option for known dividends, we merely subtract the present value of the dividends from the current price of the underlying asset in calculating the Black Scholes value.



American options.

American options are much harder to deal with than European ones. The problem is that it may be optimal to use (exercise) the option before the final expiry date. This optimal exercise policy will affect the value of the option, and the exercise policy needs to be known when solving the pde. There is therefore no general analytical solutions for American call and put options. There is some special cases. For American call options on assets that do not have any payouts, the American call price is the same as the European one, since the optimal exercise policy is to not exercise. For American Put is this not the case, it may pay to exercise them early. When the underlying asset has payouts, it may also pay to exercise the option early. There is one known known analytical price for American call options, which is the case of a call on a stock that pays a known dividend, which is discussed next. In all other cases the American price has to be approximated using one of the techniques discussed in later chapters: Binomial approximation, numerical solution of the partial differential equation, or another numerical approximation.

Exact american call formula when stock is paying one dividend.

When a stock pays dividend, a call option on the stock may be optimally exercised just before the stock goes ex-dividend. While the general dividend problem is usually approximated somehow, for the special case of one dividend payment during the life of an option an analytical solution is available, due to Roll-Geske-Whaley.

If we let be the stock price, the exercise price, the amount of dividend paid, the time of dividend payment, the maturity date of option, we find

The time to dividend payment and the time to maturity .

A first check of early exercise is:


If this inequality is fulfilled, early exercise is not optimal, and the value of the option is


where is the regular Black Scholes formula.

If the inequality is not fulfilled, one performs the calculation shown in formula 8.2 and implemented in code 8.3




Options on futures


Black's model

For an European option written on a futures contract, we use an adjustment of the Black Scholes solution, which was developed in Black (1976). Essentially we replace with in the Black Scholes formula, and get the formula shown in 8.3 and implemented in code 8.4.






Foreign Currency Options

Another relatively simple adjustment of the Black Scholes formula occurs when the underlying security is a currency exchange rate (spot rate). In this case one adjusts the Black-Scholes equation for the interest-rate differential.

Let be the spot exchange rate, and now let be the domestic interest rate and the foreign interest rate. is then the volatility of changes in the exchange rate. The calculation of the price of an European call option is then shown in formula 8.4 and implented in code 8.5.



Perpetual puts and calls

A perpetal option is one with no maturity date, it is inifinitely lived. Of course, only American perpetual options make any sense, European perpetual options would probably be hard to sell.8.1 For both puts and calls analytical formulas has been developed. We consider the price of an American call, and discuss the put in an exercise. Formula 8.5 gives the analytical solution.



Readings

Hull (2003) and McDonald (2002) are general references.

A first formulation of an analytical call price with dividends was in Roll (1977). This had some errors, that were partially corrected in Geske (1979), before Whaley (1981) gave a final, correct formula. See Hull (2003) for a textbook summary.

Black (1976) is the original development of the futures option.

The original formulations of European foreign currency option prices are in Garman and Kohlhagen (1983) and Grabbe (1983).

The price of a perpetual put was first shown in Merton (1973). For a perpetual call see McDonald and Siegel (1986). The notation here follows the summary in (McDonald, 2002, pg. 393).

Problems











solving partial differential equations.

European Options.

For European options we do not need to use the finite difference scheme, but we show how one would find the european price for comparison purposes. We show the case of an explitit finite difference scheme. This is an alternative to the implicit finite difference scheme The explicit version is faster, but a problem with the explicit version is that it may not converge. The following follows the discussion of finite differences starting on page 356 of Hull (1993).



American Options.

We now compare the American versions of the same algoritms, the only difference being the check for exercise at each point.



2003-10-22
The term structure of interest rates and an object lesson

In this chapter we look at various algorithms that has been used to estimate a ``term structure,'' i e a relation between length of period for investment and interest rate.

The term structure is the current price for a future (time ) payment of one dollar (discount factor). It can also be viewed as the yield on a zero coupon bond paying one dollar at time . Alternatively one can think about forward interest rates, the yield on borrowing at some future date and repaying it at a later date . Knowing one of these one also knows the others, since there are one-to-one transforms moving one into the other.

Term structure calculations

Let us show some useful transformations for moving between these three alternative views of the term structure. . Let be the yield on a -period discount bond, and the discount factor for time (the current price of a bond that pays $1 at time . Then




Also, the forward rate for borrowing at time for delivery at time is calculated as


The forward rate can also be calculated directly from yields as


Note that this assumes continously compounded interest rates.

Code 3.1 shows the implementation of these transformations.



Using the currently observed term structure.

To just use todays term structure, we need to take the observations of yields that is observed in the market and use these to generate a term structure. The simplest possible way of doing this is to linearly interpolate the currently observable zero coupon yields.

Linear Interpolation.

If we are given a set of yields for various maturities, the simplest way to construct a term structure is by straightforward linear interpolation between the observations we have to find an intermediate time. For many purposes this is ``good enough.'' This interpolation can be on either yields, discount factors or forward rates, we illustrate the case of linear interpolation of spot rates.

Computer algorithm, linear interpolation of yields.

Note that the algorithm assumes the yields are ordered in increasing order of time to maturity.



The term structure as an object

To actually use the term structure one has to specify one of these three alternative views of the term stucuture for all possible future dates. This is of course not feasible, so one will need to have a method for specifying the term structure, such as the linear interpolation above. Next this term structure will have to be made available for use in other contexts. This is perfect for specifying a class, so we will use this as the prime example of the uses of a class. One can think of the term structure class as an abstract function that either return a discount_factor or a yield.

Implementing a term structure class

A term structure can thus be abstractly described as a function of time. The user of a term structure will not need to know the underlying model of term structures, all that is needed is an interface that specifies functions for

  • prices of zero coupon bonds (discount factors).
  • yields of zero coupon bonds (spot rates).
  • forward rates.
These will for given parameters and term structure models provide all that a user will want to use for calculations.

Base class



The code for these functions uses algorithms that are described earlier in this chapter for transforming between various views of the term structure. The term structure class merely provide a convenient interface to these algoritms.



Note that the definitions of calculations are circular. Any given specific type of term structure has to over-ride at least one of the functions yield, discount_factor or forward_rate.

We next consider two examples of specific term structures.

Flat term structure.

The flat term structure overrides both the yield member function of the base class.

The only piece of data this type of term structure needs is an interest rate.





Interpolated term structure.

The interpolated term structure implemented here uses a set of observations of yields as a basis, and for observations in between observations will interpolate between the two closest. The following only provides implementations of calculation of the yield, for the other two rely on the base class code.

There is some more book-keeping involved here, need to have code that stores observations of times and yields.





Bond calculations using the term structure class

Codes 3.9 and 3.10 illustrates how one would calculate bond prices and duration if one has a term structure class.





References

Shiller (1990) is a good reference on the term structure.

2003-10-22
Normal Distribution approximations.

We will in general not go into detail about more standard numerical problems not connected to finance, there are a number of well known sources for such, but we show the example of calculations involving the normal distribution.

The normal distribution function

The nurmal distribution function


is calculated as

The cumulative normal distribution

The solution of a large number of option pricing formulas are written in terms of the cumulative normal distribution. For a random variable the cumulative probability is the probability that the outcome is lower than a given value . To calculate the probability that a normally distubuted random variable with mean and unit variance is less than , , one have to evaluate the integral


There is no explicit closed form solution for calculation of this integral, but a large number of well known approximations exists. Abramowiz and Stegun (1964) is a good source for these approximations. The following is probably the most used such approximation, it being pretty accurate and relatively fast. The arguments to the function are assumed normalized to a (0,1 ) distribution.



Multivariate normal

The normal distribution is also defined for several random variables. We then characterise the vector of random variables


A probability statement about this vector is a joint statement about all elements of the vector.

Calculating cumulative bivariate normal probabilities

The most used multivariate normal calculation is the bivariate case, where we let and be bivariate normally distributed, each with mean 0 and variance 1, and assume the two variables have correlation of . By the definition of correlation . The cumulative probability distribution



There are several approximations to this integral. We pick one such, discussed in (Hull, 1993, Ch 10), shown in code A.3



If one has more than two correlated variables, the calculation of cumulative probabilites is a nontrivial problem. One common method involves Monte Carlo estimation of the definite integral. We will consider this, but then it is necessary to first consider simulation of random normal variables.


Simulating random normal numbers

Generation of random numbers is a large topic and is treated at length in such sources as Knuth (1997). The generated numbers can never be truly random, only ``pseudo''-random, they will be generated according to some reproducible algorithm and after a (large) number of random number generations the sequence will start repeating itself. The number of iterations before replication starts is a measure of the quality of a random number generator. For anybody requiring high-quality random number generators the rand() function provided by the standard C ++ library should be avoided, but for not getting into involved discussion of random number generations we use this function as a basis for the generation of uniformly distributed numbers in the interval , as shown in code A.4.



These uniformly distributed distributed random variates are used as a basis for the Polar method for normal densities discussed in Knuth (1997) and inplemented as shown in code A.5



Cumulative probabilities for general multivariate distributions

When moving beyond

References

Tong (1990) discusses the multivariate normal distribution, and is a good reference.

Exercises



2003-10-22
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群