代写 algorithm math Comp 7405 Assignment 2 (10 marks)

Comp 7405 Assignment 2 (10 marks)
Due time: 7pm, 15-03-2019
1. (2 marks) Implement the Black-Scholes formulas for C(S,t) and P(S,t), and cal- culate the values of both call and put options with following parameters:
(3.1) S = 100, K = 100, t = 0, T = 0.5, σ = 20%, and r = 1%. (3.2) S = 100, K = 120, t = 0, T = 0.5, σ = 20%, and r = 1%. (3.3) S = 100, K = 100, t = 0, T = 1.0, σ = 20%, and r = 1%. (3.4) S = 100, K = 100, t = 0, T = 0.5, σ = 30%, and r = 1%. (3.5) S = 100, K = 100, t = 0, T = 0.5, σ = 20%, and r = 2%.
Based on the results, please comment on how each parameter, namely, strike, maturity, volatility, and the risk free rate affects the call and put values.
Remarks: Please submit your source code along with the numerical results. You are free to choose any programming language. Please treat the implementation of this problem seriously as your next assignment will need it.
2. (Correlated normal random variables, 2 marks) Recall the covariance of two random variables X and Y is defined by
􏰆􏰄 􏰅􏰄 􏰅􏰇
Cov(X,Y)=E X−E(X) Y −E(Y) =E(XY)−E(X)E(Y). Another related definition is correlation coefficient
Cov(X,Y) ρ(X,Y)= 􏰈Var(X)Var(Y).
It can be proved that the correlation coefficient ρ(X, Y ) always lies between −1 and +1. In this problem, you need to finish the following tasks:
(2.1) X and Y are two independent standard normal random variables. We now define another random variable Z by Z = ρX +􏰈1 − ρ2Y , where ρ ∈ [−1, 1]. Prove that
ρ(X,Z) = ρ.
(2.2) Write a short program to numerically verify ρ(X, Z) = ρ. Specifically, you need to
1

(a) write a standard normal random variable generator.
(b) generate 200 samples of X and Y .
(c) generate the samples of Z using the formula and the samples of X and Y . Please use 0.5 as the correlation ρ.
(d) calculatethesamplecorrelationcoefficientρ(X,Z)basedonthesamples of X and Z, and compare it with the theoretical value 0.5.
Please put your source code and numerical test results in text files and submit them. You don’t have to write your own normal random variable generator, and you can use third party code or built-in functions from your chosen programming language.
Remarks: In mathematical finance, we very often need to generate correlated random variables. From this problem you should learn how to do this. Here we consider generating only two correlated random variables. It can be easily ex- tended to generate N correlated random variables. To do that, we need Cholesky decomposition http://en.wikipedia.org/wiki/Cholesky_decomposition.
In case you are wondering how to prove −1 ≤ ρ(X,Y) ≤ 1, here is a simple
proof. Let μX, σX be the mean and standard deviation of X, and μY and σY be
the mean and standard deviation of Y . It can be easily proved that ρ(V, W ) =
Cov(V,W) = ρ(X,Y) where V = X−μX and W = Y−μY . Also we notice that σX σY
Var(V ± W) = Var(V) ± 2Cov(V,W) + Var(W) ≥ 0. Since Var(V) = 1 and Var(W) = 1, we have −1 ≤ Cov(V,W) ≤ 1.
3. (Implied Volatility Calculation, 6 marks) In this problem, you will gain some experience of dealing with real option trading data. First we need to extend the Black-Scholes formulas slightly. So far, we have assumed that the underlying asset doesn’t pay dividends during the life of an option, and that there is no borrowing cost when short-selling the underlying asset. In practice, in most cases these two assumptions are not true; therefore, the Black-Scholes formulas have to be extended slightly. These materials will be covered in the coming lectures. For this problem, let’s just use the formulas directly. We will denote the dividend information and borrowing cost (and other related terms) by a single parameter, repo rate q, and now the Black-Scholes formulas become:
C(S,t) = Se−q(T−t)N(d1) − Ke−r(T−t)N(d2), (1) P(S,t) = Ke−r(T−t)N(−d2) − Se−q(T−t)N(−d1). (2)
where N(x) is the cumulative density function of N(0,1), and
ln(S/K)+(r−q)(T −t) d1 = σ√T−t
ln(S/K)+(r−q)(T −t) d2 = σ√T−t
1 √
+2σ T−t,
1 √
−2σ T−t.
2

At the same time, the call-put parity formula becomes: C(S,t)−P(S,t)=Se−q(T−t) −Ke−r(T−t). (3)
You are given a “marketdata.csv ” file containing some real trading data of options on A50 ETF listed in Shanghai Stock Exchange. You can get the specifications of all instruments in the file “instruments.csv”. You are asked to finish the following tasks:
(3.1) Implement the algorithm presented in Lecture 4 to calculate implied volatil-
ities with the extended Black-Scholes formulas (1)-(2). Note that the formu-
las for ∂C(σ) and ∂P(σ) also need to change to: ∂σ ∂σ
∂C(σ) = ∂P(σ) = Se−q(T−t)√T − tN′(d1) ∂σ ∂σ
The initial guess σˆ changes to:
􏰃 􏰂􏰂lnS0/K+(r−q)(T−t)􏰂􏰂
σˆ= 2􏰂􏰂 T−t 􏰂􏰂
(3.2) Apply your algorithm to calculate the implied volatilities for both the bid
prices and the ask prices. Specifically, you need:
(3.2.1) calculatethebid/askimpliedvolatilitiesofallinstrumentsat09:31:00, 09:32:00, 09:33:00. Specifically, you take snapshots of the given market data at 09:31:00, 09:32:00, 09:33:00, respectively. Then for each snap- shot, you calculate the bid implied volatility and ask implied volatility of each instrument. Put your results in three separate csv files using the names “31.csv”, “32.csv”, and “33.csv” (this is to make our tutor’s life easier, thank you). The csv files should have the following format:
Strike, BidVolP, AskVolP, BidVolC, AskVolC 1.9, ···, ···, ···, ··· ···, ···, ···, ···, ···
If you notice that the implied volatility for some instrument is not achiev- able, put “NaN”.
(3.2.2) Put the results into three different plots one for each time point. For each plot, the x-axis should be the strike levels, and the y-axis should be implied volatilities.
When calculating the implied volatilities, for the asset A50’s spot price , you can use the average of the bid/ask prices. In the instrument.csv file, the symbol for A50 ETF is ’510050’. You can assume the risk free interest rate is 4% and the repo rate is 20%.
3

(3.3) The trading unit for buying/selling an option is 10000, and the transaction cost is about 3.3 RMBs per unit. Using the non-arbitrage conditions you have learned so far, check whether you see any arbitrage opportunities in the data. You can consider two cases: one without any transaction cost, and the other one with the real transaction cost. Write down your findings and submit them.
Please submit your source code, results, plots, and your analysis for (3.3).
Remarks: Here is how you take a snapshot of the market at a specific time. Let’s say you want to do that at 09:31:00. Essentially you just need to observe the latest bid and ask prices of each instrument up to 09:31:00. Note that some bid/ask prices might be last updated before 09:31:00, e.g.,09:30:25.
4