# Help With MATH60082,Help With Java，Python Programming

MATH60082 (Computational Finance) Finite Difference Methods Assignment

1 Background Theory

1.1 Coupon Bonds with Stochastic Interest Rate

Consider a set of coupon bonds B are trading on the financial markets, and the term structure of interest rates is stochastic. Let us denote B(r,t;T) as the value of a bond at time t that matures at time T, given the current stochatic interest rate is r. Later on in this project, you will be asked to price the option to buy (or sell) a coupon bond at some time T1 before the bond matures T1 < T. To price this contract, we need to first calculate the value of the bond B(r,t;T) at all time t < T.

The risk-neutral process followed by interest rate is given by

dr = κ ?θeμt ? r? dt + σrβ dW. (1)

Here κ, θ, μ, σ and β are all constant model parameters that can be determined from market prices of zero coupon bonds.

It is relatively straightforward to show that the market value of the coupon bond B(r,t;T) satisfies the following PDE

?B+1σ2r2β?2B+κ?θeμt?r??B?rB+Ce?αt =0, (2) ?t 2 ?r2 ?r

if the bond pays out a continuous coupon at the rate of

C e?αt for constants C and α defined in the bond contract.

(3)

The domain of this problem is r ∈ [0, ∞) and t < T . The boundary conditions are:

B(r,t = T;T) = F; (4)

and

1.2 Options on a Bond

?B + κθeμt ?B + Ce?αt = 0, at r = 0; (5) ?t ?r

B(r,t;T) → 0 as r → ∞. (6)

Now consider an option V to buy the bond at time T1. Let V(r,t;T1,T) be the value of a call (or put) option to buy (or sell) at time T1 the coupon bond B(r, t; T ) maturing at time T . On the domain r ∈ [0, ∞), t < T1, it can be shown that function V satisfies the following PDE:

European Call Option

For a European call option, the boundary conditions are given by:

V (r, t = T1; T1, T ) = max(B(r, T1; T ) ? X, 0); (8)

and

European Put Option

?V +κθeμt?V =0, atr=0; (9) ?t ?r

V (r, t; T1 , T ) → 0 as r → ∞. (10)

For a European put option, the boundary conditions are given by:

V (r, t = T1; T1, T ) = max(X ? B(r, T1; T ), 0); (11)

and

American Call Option

?V +κθeμt?V =0, atr=0; (12) ?t ?r

V (r, t; T1 , T ) → 0 as r → ∞. (13)

For an American call option, the boundary conditions are given by:

V (r, t; T1, T ) ≥ max(B(r, t; T ) ? X, 0) for t ≤ T1; (14)

and

American Put Option

V (r, t; T1, T ) = B(r, t; T ) ? X at r = 0; (15) V (r, t; T1 , T ) → 0 as r → ∞. (16)

For an American put option, the boundary conditions are given by:

V (r, t; T1, T ) ≥ max(X ? B(r, t; T ), 0) for t ≤ T1; (17)

and

V (r, t; T1, T ) → X ? B(r, t; T )

atr=0; (18) as r → ∞. (19)
Write out the correct numerical scheme (i.e. aj =, bj =, cj = and dj =) matching the PDE for a bond (2), including the boundary conditions (5) and (6) at j = 0 and j = jMax. Be careful to make your notation clear and understandable.

(understanding 5 marks)

Unless otherwise instructed, you should assume that the following standard values for the parameters apply: T = 2, F = 140, θ = 0.035, r0 = 0.0271, κ = 0.1172, μ = ?0.0075, C = 7, α = 0.01, β = 0.317 and σ = 0.104.

Write code to calculate the value of the bond B(r,0;T) using rmax = 1, iMax = 100 and jMax = 100. You must use the finite-difference method with a Crank-Nicolson scheme, along with an appropriate method to solve the algebraic system. State the value of the bond B(r0, 0; T ) using these parameters.

An alternative boundary condition is

Plot out the value of the option B(r, 0; T ) against the interest rate r for r ∈ [0, rmax] and compare the

results with different boundary conditions.

Comment on the results in each case, can you explain which boundary condition works best and why?

(understanding 5 marks)

Include in your report an accurate estimate for the bond price B(r0,t = 0;T) using the parameters outlined above. Explain how you obtained your result, how efficient it is, and also how accurate it is, by exploring the effect that each of the different numerical parameters (iMax, jMax, rmax) have on your solution.

2.2 Options on Bonds

You are tasked to solve for a European and an American put option.

Unless otherwise instructed, you should assume that the following standard values for the parameters apply: T = 2, T1 = 0.73737, X = 142, F = 140, θ = 0.035, r0 = 0.0271, κ = 0.1172, μ = ?0.0075, C = 7, α = 0.01, β = 0.317 and σ = 0.104.

Write out the correct numerical scheme (i.e. aj =, bj =, cj = and dj =) matching the PDE for the European or American put option (7), and also appropriate boundary conditions such as (12), (13), (18) and (19) at j = 0 and j = jMax. Describe how you create a grid to account for any discontinuities that may arise.

(understanding 5 marks )

WritecodetocalculatethevalueofboththeoptionV(r,t;T1,T)(fort≤T1)andthebondB(r,t;T) (for t ≤ T). Plot out the value of the European option V against the interest rate r at time t = T1 and time t = 0. What is the minimum value of r at time t = T1 at which the option is exercised?

(coding 2 marks, understanding 5 marks)

StateanaccuratevalueforboththeEuropeanandAmericanstyleversionsoftheoptionV(r0,0;T1,T) using the parameters as given above. Explain how you obtained your result, how efficient it is, and also how accurate it is, by exploring the effect that each of the different numerical parameters (iMax, jMax, rmax) and different boundary conditions have on your solution.

(understanding 5 marks, originality 10 marks)

3

(coding 3 marks)

(originality 5 marks )

3 Instructions

The deadline for this assignment is 11am on Tuesday 9th May, and as part of a 15 credit course unit you should expect this may take up to 25 hours to complete. Unless you have an agreed extension on coursework deadlines with DASS reports handed in AFTER 11am Tuesday 9th May will be docked 5 marks plus an additional 5 marks each day thereafter until a mark of zero is reached. Reports handed in after 5pm Friday 19th May will be awarded a mark of zero and will not be marked.

In order that your report conforms to the standards for a technical report, you should use the following structure:

MS Word, LaTeX, or similar, and must be submitted without your name, but with your univer- sity ID number online through the TurnItIn system.

approximately 8 - 10 pages long (excluding appendices)
be written in continuous prose

give a brief introduction stating the problem you are solving and the parameters you are using (from the model or method),

present your results in the form of figures and tables, using the order of items in the bullet points as a guide as to the order of your document

absolutely NO screenshots of running code need to be included,

do not include overly long tables – a table should never cross over a page,

present the results for any methods you have implemented, there is no credit for a discussion of a method that has not been shown to be implemented by you (through results) for your problem

refer to and discuss each of your results in the text, part of the marks available in each bullet point are for interpreting the results

try to keep to the page limit, removing any unnecessary results from the main text

number and caption your figures and tables and refer to them by their number (not their position in

the text),

number any equations to which you refer,

use consistent internal (and external) referencing.

4 RUBRIC

This assignment is the last assignment, and it will account for 50% of your final assessment for this module. Marks will be awarded as follows:

(i) 5% for working codes; Grade Description

0-50% Little or no attempt, codes not working

50%-70% One or two bugs in the code are affecting the results

70%-100%

Results in 2.1 and 2.2 from the codes appear correct

0-50% Poorly presented work. Significant amount of text unreferenced. Graphs and tables poorly labelled making it difficult to interpret them.

50%-70% Good presentation. Text is readable. Graphs are ok, maybe miss- ing labels and not always referenced correctly. Report is overly long and unnecessarily repeats the same (or similar) results. Excellent presentation, well written and well referenced. Graphs are clear, tables used when appropriate. Report keeps within the page limit.

(iii) 25% for the understanding of the problems involved; Grade Description

0-50% Results are poorly presented or they are without supporting text. The methods are described but are not shown to be implemented through results. The student is unable to demonstrate they can correctly interpret results.

50%-70% Demonstrates a good understanding of the standard methods. Is able to generate standard results and discuss them. Results are well presented.

Student is able to correctly interpret standard results and evaluate the efficiency of the standard methods.

(iv) 15% for originality/initiative. Grade Description

0-50% Little or no attempt at adapting the methods for this particular problem. Those adaptations that have been implemented have poorly presented results or the student is unable to demonstrate they can correctly interpret results.

50%-70% Is able to efficiently adapt the method for this problem, or make improvements to the standard implementation. Is able to present results and discuss them. Results are well presented.

Is able to implement new or combine existing algorithms together to produce a highly efficient numerical method. Presentation of the results is excellent. Student is able to correctly interpret re- sults and compare methods in a coherent way.

Please see bullet points for a more detailed breakdown of marks.

70%-100%

70%-100%

70%-100%