GUIDELINES
Columbia University
MATH GR5260 Spring 2022 Programming for Quant and Computational Finance Ng
Mar 11th 2022 (Fri) 8:15pm – 9:45pm
Copyright By PowCoder代写 加微信 powcoder
This is an open book exam. You may use any notes, reference materials, internet, Jupyter Notebook or any Python IDEs during the exam period. However, you only have limited time to complete the exam, so you must use your time wisely.
All answers must be written legibly.
In the Python code, add comments to your code where you think will help grader understand your logic.
Solution submission
Answer the theory questions on the exam paper provided.
Submit your python code (and output results) as a Jupyter notebook or HTML or pdf files onto Courseworks
under ‘Exam 1’ section,
in the same way you uploaded your homework previously.
If you have technical
issues in submitting your solution, please notify your TAs or Prof Ng and email your solution directly to your
TAs to get
a proper timestamp of submission.
You may name these files whichever way you like.
Make sure that in each of these files, you have your name and UNI on it.
you suspect of any typos or have questions, notify your TAs or Prof Ng.
Question 1 2 3 Total Points 40 15 10 65
During the exam, if
HONOR CODE AFFIRMATION
I affirm that I will not plagiarize, use unauthorized materials, or give or receive illegitimate help on assignments, papers, or examinations. I will also uphold equity and honesty in the evaluation of my work and the work of others. I do so to sustain a community built around this Code of Honor. (https://www.college.columbia.edu/honorcode#:~:text=)
First name Last name UNI Signature
QUESTION 1 (40 POINTS)
This question is about applying Monte Carlo simulation to the valuation of a call option on the spread of two commodity prices (Brent crude vs WTI crude). Spread options were discussed in class and were covered in homework assignment 2.
Suppose that the two commodity prices 𝑆!(𝑡) and 𝑆”(𝑡) follow a 2-dimensional correlated Geometric Brownian Motion (GBM). That is, 𝑑𝑆 (𝑡) = 𝑆 (𝑡)(𝜇 𝑑𝑡 + 𝜎 𝑑𝑊 ) and 𝑑𝑆 (𝑡) = 𝑆 (𝑡)(𝜇 𝑑𝑡 + 𝜎 𝑑𝑊 ) where 𝑊 (𝑡) and
!!!!!”””””!
𝑊 (𝑡) are correlated standard Brownian Motions with constant correlation 𝜌. ”
The present value of the option can be written as follows:
𝑉 = 𝐸[𝑒#$%max (𝑆!(𝑇) − 𝑆”(𝑇) − 𝐾, 0)]
Here 𝑇 is the time to option expiry, 𝐾 is the strike of the option and 𝑟 is the zero coupon rate for the time to
option expiry.
Let’s assume that the drift and volatility parameters in the GBM and the zero rate 𝑟 are known constants.
a) Write down the expression for 𝑆!(𝑡) and 𝑆”(𝑡) in terms of their initial prices, drift, volatility parameters and the bivariate standard normal random variable (𝑍, 𝑊) with correlation 𝜌.
Suppose (𝑧!, 𝑤!), (𝑧”, 𝑤”), … , (𝑧&, 𝑤&) are independent random samples of (𝑍, 𝑊).
b) Write down an expression for the simulated price 𝑉 of the option in terms of (𝑧 ,𝑤 ),(𝑧 ,𝑤 ),…,(𝑧 ,𝑤 ) & !!””&&
of (𝑍, 𝑊). Explain why the estimator is unbiased. Answer
3 c) As 𝑁 goes to infinity, the theoretical value 𝑉 of the option will fall into an interval (𝑉 − 𝜀 , 𝑉 + 𝜀 ) with
95% confidence where 𝜀& is expressed in terms of (𝑧!, 𝑤!), (𝑧”, 𝑤”), … , (𝑧&, 𝑤&). Write down the expression
for 𝜀&. Answer
d) Write a Python function to compute the simulated price 𝑉 of a spread call option. The input parameters &
shall include: the option strike, time to option expiry and any market data required. The number of simulations 𝑁 shall be made as an input. The function shall return both the simulated price and the 95% confidence interval. (You may use the input parameters without validating them within the function)
e) Write a Python function that uses antithetical sampling technique to compute and return the simulated price 𝑉A of the spread call option. Again you may use the function inputs without validating them within the
function. (It’s not required to return the 95% confidence interval, but feel free to do so if you want.)
Trader Joe explains:
“In antithetical sampling, if a random sample (𝑧, 𝑤) is drawn, we compute the simulated payoff as the average of two payoffs, one for (𝑧, 𝑤) and one for (−𝑧, −𝑤). I think we will achieve even better results if we also use (−𝑧, 𝑤) and (𝑧, −𝑤). That is, for each random sample, we compute the simulated payoff as the average of four payoffs, one for (𝑧, 𝑤), one for (−𝑧, 𝑤), one for (𝑧, −𝑤) and one for (−𝑧, −𝑤). And the estimate 𝑉B for the
option price becomes the average of the 𝑁 simulated discounted payoffs.”
f) Write a Python function that uses Joe’s method to compute and return the simulated price 𝑉B of the spread
call option. The function shall have the same inputs as in part d) or e). Considerthisspreadcalloptionexample:𝑆 (0)=98,𝑆 (0)=92,𝜇 =2%,𝜇 =1.5%,K=7,𝜎 =𝜎 =
20%,𝑟=0.05%, 𝜌=70%, 𝑇=1/12
g) Use your functions to compute the estimates 𝑉 , 𝑉A , 𝑉B for the option using n=200000 simulations. ”&
h) Do you think that Joe’s method will give a better convergence than the antithetical method? Explain why you think so.
QUESTION 2 (15 POINTS)
This question is about using Pandas to handle P&L calculations for the equity transactions in a file.
Download the .csv files from Courseworks under the Assignment section, ‘Exam 1’.
The file eq_trans.csv consists of a list of equity transactions for 2 customers.
Header descriptions:
TradeDate: date on which the transaction is traded
Ticker: ticker symbol for the company
Sector: the sector which the company belongs to.
Shares: number of shares purchased or sold. Positive number refers to a long position and negative number refers to a short position
TradePrice: price at which the shares are purchased or sold Customer: alias name for the customer
The file eq_prices.csv keeps the adjusted closing prices of the stocks in February.
a) Write a Python program that reads the given input files and displays a DataFrame that keeps the End-of-day value, daily PnL and total PnL as of Feb 28, 2022 for all transactions.
The EOD value of an equity transaction on a date T is defined as:
(number of shares) x (adjusted closing price on date T)
The daily PnL of an equity transaction on a date T is defined as:
(EOD value on date T) – (EOD value on date T-1)
The total PnL of an equity transaction on a date T is defined as:
(number of shares) x (adjusted closing price on date T – TradePrice)
Here we assume zero transaction cost and date T-1 means the previous business day. The format of the DataFrame should look something like this.
b) Provide an aggregated view of the EOD value, daily PnL and total PnL by customer by ticker. The view should look something like this.
QUESTION 3 (10 POINTS)
The duration formula for a bond that has 𝑛 remaining coupon payments is given as follows: ‘ 𝐶𝐹 𝑒#)*!
Where: 𝐵 is the bond price
𝑦 is the yield to maturity (continuously compounded)
𝐶𝐹 is the bond cashflow for the ith remaining coupon period (
𝑡( is the time in years from value date to the ith coupon date (assuming 365 days in a year) Below is a class that provides bond calculations.
Two class methods are already defined and available in this class.
A function to compute the number of calendar days between two dates is also defined and available.
Use the above defined class methods and function to write a class method (called duration) for the Bond class to compute and return the duration of a bond given an input price quoted in percents. The inputs for the method are: value_date and price.
Note: you don’t need to run this piece of code as the Bond class is not explicitly provided to you.
–end of exam– –Happy spring break–
𝐷=O𝑡(P ( T (+! 𝐵
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com