Skip to content

Commit 4011f8f

Browse files
committed
Merge branch 'master' into gh-pages
2 parents 48f7576 + e8843ce commit 4011f8f

11 files changed

Lines changed: 2238 additions & 16 deletions

File tree

doc/Projects/2020/Project5/BlackScholes/html/._BlackScholes-bs000.html

Lines changed: 480 additions & 0 deletions
Large diffs are not rendered by default.

doc/Projects/2020/Project5/BlackScholes/html/BlackScholes-bs.html

Lines changed: 480 additions & 0 deletions
Large diffs are not rendered by default.

doc/Projects/2020/Project5/BlackScholes/html/BlackScholes.html

Lines changed: 422 additions & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

doc/Projects/2020/Project5/BlackScholes/pdf/BlackScholes.p.tex

Lines changed: 412 additions & 0 deletions
Large diffs are not rendered by default.
222 KB
Binary file not shown.
Lines changed: 384 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,384 @@
1+
%%
2+
%% Automatically generated file from DocOnce source
3+
%% (https://github.com/hplgit/doconce/)
4+
%%
5+
%%
6+
7+
8+
%-------------------- begin preamble ----------------------
9+
10+
\documentclass[%
11+
oneside, % oneside: electronic viewing, twoside: printing
12+
final, % draft: marks overfull hboxes, figures with paths
13+
10pt]{article}
14+
15+
\listfiles % print all files needed to compile this document
16+
17+
\usepackage{relsize,makeidx,color,setspace,amsmath,amsfonts,amssymb}
18+
\usepackage[table]{xcolor}
19+
\usepackage{bm,ltablex,microtype}
20+
21+
\usepackage[pdftex]{graphicx}
22+
23+
\usepackage[T1]{fontenc}
24+
%\usepackage[latin1]{inputenc}
25+
\usepackage{ucs}
26+
\usepackage[utf8x]{inputenc}
27+
28+
\usepackage{lmodern} % Latin Modern fonts derived from Computer Modern
29+
30+
% Hyperlinks in PDF:
31+
\definecolor{linkcolor}{rgb}{0,0,0.4}
32+
\usepackage{hyperref}
33+
\hypersetup{
34+
breaklinks=true,
35+
colorlinks=true,
36+
linkcolor=linkcolor,
37+
urlcolor=linkcolor,
38+
citecolor=black,
39+
filecolor=black,
40+
%filecolor=blue,
41+
pdfmenubar=true,
42+
pdftoolbar=true,
43+
bookmarksdepth=3 % Uncomment (and tweak) for PDF bookmarks with more levels than the TOC
44+
}
45+
%\hyperbaseurl{} % hyperlinks are relative to this root
46+
47+
\setcounter{tocdepth}{2} % levels in table of contents
48+
49+
% prevent orhpans and widows
50+
\clubpenalty = 10000
51+
\widowpenalty = 10000
52+
53+
% --- end of standard preamble for documents ---
54+
55+
56+
% insert custom LaTeX commands...
57+
58+
\raggedbottom
59+
\makeindex
60+
\usepackage[totoc]{idxlayout} % for index in the toc
61+
\usepackage[nottoc]{tocbibind} % for references/bibliography in the toc
62+
63+
%-------------------- end preamble ----------------------
64+
65+
\begin{document}
66+
67+
% matching end for #ifdef PREAMBLE
68+
69+
\newcommand{\exercisesection}[1]{\subsection*{#1}}
70+
71+
72+
% ------------------- main content ----------------------
73+
74+
75+
76+
% ----------------- title -------------------------
77+
78+
\thispagestyle{empty}
79+
80+
\begin{center}
81+
{\LARGE\bf
82+
\begin{spacing}{1.25}
83+
Project 5, deadline December 16, 2020
84+
\end{spacing}
85+
}
86+
\end{center}
87+
88+
% ----------------- author(s) -------------------------
89+
90+
\begin{center}
91+
{\bf Black-Scholes equation${}^{}$} \\ [0mm]
92+
\end{center}
93+
94+
\begin{center}
95+
% List of all institutions:
96+
\end{center}
97+
98+
% ----------------- end author(s) -------------------------
99+
100+
% --- begin date ---
101+
\begin{center}
102+
Fall semester 2020
103+
\end{center}
104+
% --- end date ---
105+
106+
\vspace{1cm}
107+
108+
109+
\subsection*{Solving the Black-Scholes Equation Numerically}
110+
111+
WARNING: this is a somewhat experimental problem given for the
112+
first time the Autumn of 2020. Only a very minimal theoretical
113+
background is given in this text. Feel free to write to Sebastian for more information.
114+
115+
\paragraph{The briefest introduction to options.}
116+
A financial derivative is a contract that derives its value from
117+
the performance of an underlying asset. Perhaps the most common
118+
financial derivative is the option. Such contracts are
119+
incredibly old, the first mention of options contracts in
120+
history is by greek philosopher Thales from the sixth century.
121+
122+
An option is a right, but not an obligation, to buy or sell
123+
and underlying asset\footnote{We focus on stocks, but it can be anything.} at a pretermined price $E$ at or before
124+
an expiration time $T$. Having such an option is valuable, but
125+
determining the fair price of an option is a difficult problem.
126+
127+
128+
129+
Options to buy (sell) are commonly referred to as
130+
call (put) options. An option that only allows one to
131+
excercise this right at the maturity date is called a
132+
European option, while an option that can be exercise at any
133+
date prior to the maturity date is called an American option.
134+
There are many other varieties.
135+
136+
In 1997, the (pseudo-)Nobel prize in economics was awarded
137+
to Robert C. Merton and Myron S. Scholes "for a new method
138+
to determine the value of derivatives", the Black-Scholes-Merton
139+
model.
140+
141+
\paragraph{The Black-Scholes equation.}
142+
The Black-Scholes equation is a partial differential equation, which
143+
describes the price of an option over time. The key insight behind the
144+
equation is that one can perfectly hedge the option by
145+
buying and selling the underlying asses and the "bank account
146+
asset" (cash) in just the right way to eliminate risk.
147+
148+
\begin{equation}
149+
\frac{\partial V}{\partial t}
150+
+ \frac{1}{2}S^2\sigma^2\frac{\partial^2 V}{\partial S^2}
151+
+ (r - D)\frac{\partial V}{\partial S} - r V = 0
152+
\end{equation}
153+
154+
Here $V(S, T)$ is the value of the options, $S$ is the price of the
155+
underlying asset, $\sigma$ is the volatility of the underlying asset,
156+
$r$ is the "risk-free" interest rate, and $D$ is the yield
157+
(dividend paying rate) of the underlying stock.
158+
159+
The volatility $\sigma$ stems from an underlying assumption that
160+
the stock moves like a geometric Brownial motion,
161+
\begin{equation}
162+
\frac{dS}{S} = \mu dt + \sigma dW.
163+
\end{equation}
164+
165+
Explicit solutions for the Black-Scholes equation,
166+
called The Black-Scholes formulae, are known only for
167+
European call and put options. For other derivatives, such
168+
a formula doest not have to exist. However, a numberical solution is
169+
always possible.
170+
171+
\paragraph{5a: Transformation to Heat Equation/Diffusion equation.}
172+
Instead of an initial value problem, we have a terminal value
173+
problem at time $T$, i.e.~the expiration date or the
174+
maturity date. We change to an initial value problem
175+
by substitutin $\tau = T - t$. This new variable can
176+
be interpretad as time remaining to expiration.
177+
178+
The transformed spatial variable is $x = \ln(S/E)$, where
179+
$E$ is the exercise price of the option. Now, values of
180+
$x$ close to zero correspond to stock prices that are close to
181+
the exercise price of the option. Negative values of $x$
182+
correspond to stock prices lower than the exercise price and
183+
positive values of $x$ correspond to prices higher than the
184+
exercise price.
185+
186+
Just substituting for the variables above leads to a parabolic
187+
equation, with constant coefficitions. Show that by making a final
188+
substitution;
189+
\begin{equation}
190+
u(x, \tau) = e^{\alpha x + \beta \tau} V(S, t)
191+
\end{equation}
192+
we get the heat (diffusion) equation
193+
\begin{equation}
194+
\frac{\partial u}{\partial \tau}
195+
= \frac{\sigma^2}{2}\frac{\partial^2 u}{\partial x^2}
196+
\end{equation}
197+
198+
What are the correct parameters for $\alpha$ and $\beta$?
199+
200+
% SUPPOSED TO BE COMMENTED. THIS IS THE SOLUTION.
201+
202+
% $$
203+
% \alpha = \frac{r - D}{\sigma^2} - \frac{1}{2},
204+
% $$
205+
206+
% $$
207+
% \beta = \frac{r - D}{2} + \frac{\sigma^2}{8}
208+
% + \frac{(r - D)^2}{2\sigma^2}.
209+
% $$
210+
211+
\paragraph{5b: Create solver(s) for the 1D diffusion equation.}
212+
You can implement a solver for the diffusion equation
213+
inspiration from the project on the diffusion equation.
214+
Another very good resourse is Langtangen and Linge's
215+
book "Finite Difference Computing with PDEs".
216+
217+
It is highly recommended to start with an explicit
218+
scheme, and then move to a more sophisticated
219+
implicit scheme. You should make up your
220+
own mind regarding what scheme is robust enough.
221+
Gauss-Seidel (successive over-relaxation) and
222+
Crank-Nicholson are some suggestions.
223+
224+
After creating a general diffusion equation solver, you
225+
can adapt the program to solve the Black-Scholes equation.
226+
Plot $V$ vs $S$ at different values for $t$ ($\tau$).
227+
228+
\paragraph{Special considerations}
229+
The variable $x$ is unbounded, i,e. $s\in[-\infty, \infty]$. Numerically,
230+
we have to pick a bounded interval $[-L, L]$, wher $L$ is a sufficiently
231+
large number. This interval remain unchanged when considering an option with a
232+
different strike price.
233+
234+
You need to impose special boundary conditions for $x=-L$ and $x=L$, corresponding
235+
to stock prices that are close to zero and very high, approaching infinity.
236+
237+
You need to pick som values for $E$, $r$, $D$ and $\sigma$ some starting
238+
choices can $50$, $0.04$, $0.12$ and $0.4$, respectively. Discuss what
239+
values would be reasonable - in the present market situation the values
240+
suggested are absolutely not!
241+
242+
In order to make reasonable plots, you need to transform the solution of
243+
the diffusion equation into the solution for the Black-Scholes
244+
equation.
245+
246+
You should compare to the analytic solution, i.e.~the Black-Scholes Formula:
247+
248+
\begin{equation}
249+
C(S_t, t) = N(d_1) S_t - N(d_2) PV(K),
250+
\end{equation}
251+
where
252+
\begin{equation}
253+
d_1 = \frac{1}{\sigma \sqrt{T - t}}
254+
\left[
255+
\ln \left(\frac{S_t}{K} \right)
256+
+ \left(r + \frac{\sigma^2}{2} \right) (T - t)
257+
\right]
258+
\end{equation}
259+
and
260+
\begin{equation}
261+
d_2 = d_1 - \sigma \sqrt{t}
262+
\end{equation}
263+
264+
265+
\paragraph{5c: Compute values for first-order Greeks.}
266+
The "Greeks" measure sensitivity of the value of the derivative of
267+
a portfolio to changes in parameter value while holding other
268+
parameters fixed. There are different ways of hedging a portfolio
269+
agains risk by eliminating the movement in one or several of
270+
these parameters.
271+
272+
Delta: $\Delta = \frac{\partial V}{\partial S}$
273+
274+
Gamma: $\gamma = \frac{\partial^2 V}{\partial V}$
275+
276+
Vega\footnote{Notice that this is not really a greek letter.}: $\nu = \frac{\partial V}{\partial \sigma}$
277+
278+
279+
280+
Theta: $\Theta = -\frac{\partial V}{\partial \tau}$
281+
282+
Rho: $\rho = \frac{\partial V}{\partial r}$
283+
284+
Make a representation of how these parameters move over time.
285+
Why are the Greeks interesting? Is your computed results reasonable?
286+
287+
288+
\paragraph{5d: Find data and compute implied volatility.}
289+
There are several market-traded standardised options. On the
290+
Oslo Stock Exchange (OSE) there are standardised options for several
291+
of the larger listed companies such as Equinor, Norsk Hydro,
292+
Telenor, Mowi, Orkla etc. See for instance
293+
\href{{https://www.oslobors.no/markedsaktivitet/#/list/derivatives/quotelist/false}}{\nolinkurl{https://www.oslobors.no/markedsaktivitet/\#/list/derivatives/quotelist/false}}
294+
295+
Since there the marked already prices the options, one can use these options
296+
prices to derive the value of implicit variables. A common practice
297+
is to use the market-given prices of options to derive the
298+
implied volatility of the option.
299+
300+
To do this; pick a large company with a high turnover of stock,
301+
and whose stock has seen several actual option trades on OSE lately.
302+
Find a reasonable estimate for the risk-free interest rate $r$. This would
303+
typically be given by short-term government bonds of the same currency as
304+
the stock. In NOK, you can find "Statskassaveksler" - these are bonds issued
305+
by the Norwegian Government with a shorter maturity than 12 months.
306+
Find the effective, real, annualised interest of these and use that as an
307+
estimate for $r$ (these days it would be very close to zero). Norges
308+
Bank publishes data on this. You can also find quotes on OSE.
309+
The dividend yield $D$ of the stock can be computed by taking the sum
310+
of all dividends paid py the company per stock for the year and dividing
311+
by the stock
312+
price. Then you should be able to tune the volatility in your solver to
313+
fit the call prices given by the market. You can do this by trial and
314+
error, but also use a root-finder like Newton's method or Brent's
315+
method.
316+
317+
318+
\subsection*{Introduction to numerical projects}
319+
320+
Here follows a brief recipe and recommendation on how to write a report for each
321+
project.
322+
323+
\begin{itemize}
324+
\item Give a short description of the nature of the problem and the eventual numerical methods you have used.
325+
326+
\item Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself.
327+
328+
\item Include the source code of your program. Comment your program properly.
329+
330+
\item If possible, try to find analytic solutions, or known limits in order to test your program when developing the code.
331+
332+
\item Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes.
333+
334+
\item Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc.
335+
336+
\item Try to give an interpretation of you results in your answers to the problems.
337+
338+
\item Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it.
339+
340+
\item Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning.
341+
\end{itemize}
342+
343+
\noindent
344+
\subsection*{Format for electronic delivery of report and programs}
345+
346+
The preferred format for the report is a PDF file. You can also use DOC or postscript formats or as an ipython notebook file. As programming language we prefer that you choose between C/C++, Fortran2008 or Python. The following prescription should be followed when preparing the report:
347+
348+
\begin{itemize}
349+
\item Use \textbf{Canvas} to hand in your projects, log in at \href{{https://www.uio.no/english/services/it/education/canvas/}}{\nolinkurl{https://www.uio.no/english/services/it/education/canvas/}} with your normal UiO username and password.
350+
351+
\item Upload \textbf{only} the report file! For the source code file(s) you have developed please provide us with your link to your github domain. The report file should include all of your discussions and a list of the codes you have developed. Do not include library files which are available at the course homepage, unless you have made specific changes to them. Alternatively, you can just upload the address to your GitHub or GitLab repository.
352+
353+
\item In your git repository, please include a folder which contains selected results. These can be in the form of output from your code for a selected set of runs and input parameters.
354+
355+
\item In this and all later projects, you should include tests (for example unit tests) of your code(s).
356+
357+
\item Comments from us on your projects, approval or not, corrections to be made etc can be found under your \textbf{Canvas} domain and are only visible to you and the teachers of the course.
358+
\end{itemize}
359+
360+
\noindent
361+
Finally,
362+
we encourage you to work two and two together. Optimal working groups consist of
363+
2-3 students. You can then hand in a common report.
364+
365+
366+
367+
368+
369+
370+
371+
372+
373+
374+
375+
376+
377+
378+
379+
380+
381+
% ------------------- end of main content ---------------
382+
383+
\end{document}
384+

0 commit comments

Comments
 (0)