I need help to write this program
Project 2, 4CMP Spring Term 2018/19 PROJECT 2 4CMP, SPRING TERM, PART 2: PROGRAMMING IN C++ Lecturer: Dr Fabian Spill (
[email protected]) Due Date: Sunday 31th March 2019 at 11.59 pm Weighting: This project counts 40% to your final mark for the spring part of 4CMP. INSTRUCTIONS FOR THE SUBMISSION: Submit your code as a single zip file as well as single source files by the deadline on Canvas. The program contains a main.cpp. Additional files should be logically named. Also submit one pdf document as described below, and csv, excel or other files used to output or plot data. The source files should compile without errors or warnings on Visual Studio 2015 as installed on the clusters in the learning centre, and the executable should run without problems. Plagiarism: Note that obviously group work or copying solutions from other students or sources constitutes plagiarism and is not allowed. Please, each one of you, implement your own code! Marking: The most important criteria for marking is the correctness of the code. It needs to compile and run correctly, and do what you were asked to do. However, style, efficiency, readability and formatting are also part of the evaluation criteria. In particular, if the code is so unreadable that one cannot evaluate if it is working correctly, then you risk losing many marks for that. PROJECT 2: IMPLIED VOLATILITY AND DELTA HEDGING Write a program with the following capabilities: The program should be able to price European put and call options with different models. One model is the standard Black Scholes model (for which you just need to implement the analytic formula). However, the code should be written in such was that one can quickly price the same options with other models (see below). Furthermore, write functionality that can read in csv files that contain time series data for option and stock markets. Write further functionality that can determine the implied volatility of an option from the Black-Scholes formula, given the price of the option and share as well as the other parameters. Then, write functionality that can perform delta hedging. This simply means that for each time you calculate the delta for each option, and buy (sell) as many underlyings to be delta-neutral. Note that during each time step, the price of the option, and therefore also its implied volatility, in general change. INSTRUCTIONS: Download the data on Canvas for a number of European call options on the DAX30 index of 30 largest German companies, as well as the data for the DAX themselves. The data contains a Date in the first column, given by the same integer that Excel stores for these dates. You can convert these to dates in Excel through changing the format of the first column from general to Date, and you will see that e.g. integer 43535 corresponds to the 11/3/2019. You do not need opening, low, high and volume for this project, but can only work with closing prices. mailto:
[email protected] Note that all options have a subscription, or cover ratio of 100. This simply means that the payoff is 0.01 of the normal payoff of an option that pays max(S-K,0). So in your code, you can simply multiply all the option prices you read in from the csv files by the factor of 100. (Note that we are using real data here, so I simply give you the data in the form as it is!). Note also that all of these options expire on the 18/9/2020. Each option price file has the form “18092020_DAX_9500.csv”. Here, the strike is given by K=9500. Now, calculate the implied volatility for each option, each strike and each date. Assume a constant interest rate of r = 0.004 = 0.4%, assuming that the standard Black Scholes model is valid for the DAX index. Output this implied volatility as a function of strike and time to expiry into a csv file, and plot the data in a program of your choice. You can plot this in in 3D, but sometimes it is actually easier to see what is happening if you plot volatility as a function of strike for several given times to expiry. Likewise, plot volatilities as a function of time to expiry for different given strikes. Add the plots into a document and describe what you see. Also, calculate historical volatilities (you may use the longer time series for DAX as given), and compare to the implied volatilities you see. Describe the outcome of the delta hedging experiment. You may describe the outcome as follows: Say for a given option C(t1), with given strike, on the first day, t1, you purchase the following portfolio: C(t1) – Delta(t1)S(t1) Then, on day two, the portfolio value has changed by (C(t2) -C(t1)) – Delta(t1)(S(t2)- S(t1)) In the next time step you again delta hedge by adjusting your position (dynamic hedging). You may normalise your portfolio to be a fixed amount of Euros for better comparison (e.g. show profits and losses relative to portfolio value). Describe in the document what you see. How good does this delta hedging work? Finally, implement a model of your choice that can describe well the fact that volatility is varying in both time and with strike. Price and delta hedge with this model. Describe your finding in the document. Clarification: In a previous version of this file I called the implied volatility plotted as a function of strike and time to expiry the volatility surface. This is, in principle, correct, but maybe a bit misleading in the following sense: Usually, one plots the volatility surface at a given date t for options with different strike K and expiry T. So the current date t is fixed and T varies. But the option data you were given always has the same T, but t varies. If all other quantities are constant, then obviously there is no difference between the two possibilities. However, in practice, these two surfaces (i.e. sigma(K,T-t) once plotted for fixed T, once for fixed t) can be quite different. Obviously, when the actual time t changes then the share price changes, and also the volatility can dynamically change. For the results for this project, it does not matter. It would matter if you would try to find the best model to describe both the strike and time-to-expiry dependence of the volatility. However, as mentioned during the lecture on Monday, you can implement any additional model that can somehow capture this strike and time-to-expiry dependence of the volatility. You will be evaluated on the correct implementation of this model, the description and motivation of why this model (in the pdf) and your findings regarding pricing and delta hedging. If the model is not so good, there is no need to further improve it – simply explain your observations.