Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CS 335 - Fall 2023: Assignment 1

Due: Friday, Oct 6, 2023, 23:59pm

Submit all components of your solutions (written/analytical work, code/scripts/notebooks, figures, plots, etc.) to Crowdmark in PDF form in the section for each question.

You must also separately submit a single zip file containing any and all code/notebooks/scripts you write to the A1 DropBox on LEARN, in runnable format (that is, .ipynb).

For full marks, you must show your work and adequately explain your logic!

1. (6 marks) No-arbitrage option pricing.

Suppose the current price of a stock is $18. Consider a two state tree model defined such that after 3 months, the stock price may increase to $19 with a 40% probability or decrease to $16 with a 60% probability. Consider a European call option, based on this stock, with strike price

K=$17 and expiry time T = 3 months. Assume the risk-free interest rate is 9%.

(a) (3 marks) Construct a risk-free portfolio and use it to determine the present no-arbitrage value (fair value) of the option (i.e., at time t = 0).

(b) (3 marks) Suppose such an option is priced on the market at V ∗ = 2.0 (i.e., higher than the no-arbitrage price). Describe the details for a strategy that will result in a guaranteed profit (in present value, i.e., at t = 0) and determine the value of that profit (per option), somewhat similar to what we did in class. (As usual in this course, we will assume shortselling is allowed and the no-arbitrage principle holds.)

2. (10 marks) Coding: Convergence of a walk on a discrete lattice.

Consider a random walk on an N step lattice on t ∈ [0, T] with the parameters

which converges to the solution of the SDE
dX = α dt + σ dZ ,
as ∆t → 0. The exact solution to this SDE is such that the exact density (probability distribu tion) of X (T) is a normal density with mean Xinit +αT and standard deviation σ √ T, assuming the initial value of X is Xinit.

Verify this experimentally via numerical simulation of many lattice walks, by preparing a Jupyter/Python notebook to carry out the following. Perform a lattice walk simulation, using the parameters given in Table 1. Starting at X0 = Xinit, the value of X is then moved up with probability p or down with probability (1 − p). A uniformly distributed random number 1on [0, 1] should be generated and used to determine the actual move taken. At the next lattice node (i.e., time step), this process is repeated, until we obtain the final position of X after N steps, XN , at t = T. This is a single simulation outcome; we perform many such simulations to produce many (possibly) different outcomes. Because each step moves up or down a fixed amount, the set of all possible outcomes for this discrete lattice walk is


As indicated in Table 1, you should perform the above process first for 1000 simulations, then separately for 10,000 simulations, and finally for 100,000 simulations. In each case, print out the number of simulations and the corresponding mean and standard deviation of the computed values of XN from the simulations in that set. Also, print out the anticipated exact mean and standard deviation for comparison.

Next, for each set of simulations, we would like to generate a histogram of the observed probability density versus X(T) as described below. Care must be taken in scaling this histogram to get the correct probability density. Let p(x) be the probability density, and let bin[a,b] be the bin on an interval [a, b] of the x axis. Then


so that

Use N +1 bins, with the bin boundaries falling half-way between the lattice nodes at timestep N. Use matplotlib’s bar function to display your probability density plot constructed as described above. (Alternatively, if you prefer, Matplotlib’s hist or Numpy’s histogram functionality can automate some of this process, if you give it appropriately chosen values for the range, bin width, and density parameters.) Be sure to include appropriate labeling on your plots (axis labels, title,

legend if necessary).

Then, for comparison, over top of each of your histograms, generate a standard (line) plot of the true normal distribution with mean Xinit + αT and standard deviation σ √ T, over the same range (in a different color). The Scipy function stats.norm.pdf can be used to evaluate a true normal distribution function. Thus each of your three plots will look something roughly along the lines of Figure 1 (albeit generated with different data).

Your code must be vectorized for efficiency, i.e., prefer vector operations instead of scalar oper ations. As a very simple example of vectorization, if I have a Numpy vector V and I want to add 1 to every entry of the vector, I can simply write the vector operation V = V + 1, instead of using a slower for loop over index i and separately computing V [i] = V [i] + 1 for each entry.Similarly, many Numpy functions work on vectors rather than single numbers.

Specifically, your code for the lattice walk should only explicitly loop over the timesteps, not over the individual simulations - for each time step, the updates for all the simulations (within a set) should be computed together using vector operations. Also, you should not store the entire

Figure 1: A histogram of an approximate probability density function, with a normal distribution plotted on top.


Table 1: Data to be used in your simulations of discrete walks on a lattice.

lattice at once, but rather only one or two columns of it, to save on memory. The example lattice walk code in the course notes is likely to be very helpful, since it illustrates both vectorization and lattice walk implementation! (Course notes, page 17).

In addition to the NumPy functions mentioned previously above, you may also find the mean, std, and random.uniform functions useful.

In a markdown cell in your Jupyter notebook, describe what you observe about your results (plots and statistics) as the number of simulations increases from 1000 to 100,000.

3. (6 marks) Coding: Brownian motion and Ito calculus.


and

Write a Jupyter/Python notebook to evaluate I(T, ∆t). For T = 2, for fixed ∆t, compute the value of I(T, ∆t). Use 70000 paths, and compute the mean and variance of the result, for N = 100, 200, 400, 800, 1600, 3200, 6400 timesteps. Vectorize your code so that there is only one explicit for loop over the timesteps, for a given value of N.

Write code to generate a simple text-based table of mean and variance of I(T, ∆t) for the different values of ∆t. (No fancy formatting is required! You can just use Python’s print function to generate each row, with appropriate arguments.)

Plot a graph of var(I(T, ∆t)) versus ∆t, with appropriate labels. In a markdown cell of your Jupyter notebook, explain mathematically what you observe.

4. (7 marks) Ito calculus.



5. (6 marks) Ito calculus and Ito’s Lemma.



Suppose dZ is the increment of a Wiener process and




dX = µ(X(t), t)dt + σ(X(t), t)dZ.