Skip to content

Commit

Permalink
Finish p3, p4
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhouzhou committed Oct 4, 2019
1 parent 78ca16d commit 2bd6684
Show file tree
Hide file tree
Showing 12 changed files with 180 additions and 0 deletions.
1 change: 1 addition & 0 deletions .idea/sml_2019.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions HW03_2019_09_30/p1.aux
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\relax
25 changes: 25 additions & 0 deletions HW03_2019_09_30/p1.fdb_latexmk
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Fdb version 3
["pdflatex"] 1570211777 "/Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.tex" "/Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.pdf" "p1" 1570211777
"/Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.aux" 1570211777 8 a94a2480d3289e625eea47cd1b285758 ""
"/Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.tex" 1570211777 247 8071d3c5f16d933e933ba95d6076a45e ""
"/usr/local/texlive/2019/texmf-dist/fonts/map/fontname/texfonts.map" 1511824771 3332 103109f5612ad95229751940c61aada0 ""
"/usr/local/texlive/2019/texmf-dist/fonts/tfm/public/cm/cmbx12.tfm" 1136768653 1324 c910af8c371558dc20f2d7822f66fe64 ""
"/usr/local/texlive/2019/texmf-dist/fonts/tfm/public/cm/cmr12.tfm" 1136768653 1288 655e228510b4c2a1abe905c368440826 ""
"/usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb" 1248133631 32080 340ef9bf63678554ee606688e7b5339d ""
"/usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb" 1248133631 36299 5f9df58c2139e7edcf37c8fca4bd384d ""
"/usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb" 1248133631 35752 024fb6c41858982481f6968b5fc26508 ""
"/usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmr7.pfb" 1248133631 32762 224316ccc9ad3ca0423a14971cfa7fc1 ""
"/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls" 1544567569 19933 3097d1b31d3c45dc957096f554529032 ""
"/usr/local/texlive/2019/texmf-dist/tex/latex/base/size10.clo" 1544567569 8294 6d6e23d5169c0d89d173f6c7e08a005a ""
"/usr/local/texlive/2019/texmf-dist/web2c/texmf.cnf" 1566248362 39543 a0bd1f17d0daea30a3905c0b020d0959 ""
"/usr/local/texlive/2019/texmf-var/fonts/map/pdftex/updmap/pdftex.map" 1566642953 4641080 fe1b79c6ead19573b2061dde83f2c777 ""
"/usr/local/texlive/2019/texmf-var/web2c/pdftex/pdflatex.fmt" 1566643052 4264881 087ad6a495ffe58ae3a112c69127d905 ""
"/usr/local/texlive/2019/texmf.cnf" 1557341546 577 d150fef99ac436ad1156e86b0892f6ef ""
"p1.aux" 1570211777 8 a94a2480d3289e625eea47cd1b285758 "pdflatex"
"p1.tex" 1570211777 247 8071d3c5f16d933e933ba95d6076a45e ""
(generated)
"/Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.pdf"
"p1.aux"
"p1.log"
"/Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.log"
"p1.pdf"
23 changes: 23 additions & 0 deletions HW03_2019_09_30/p1.fls
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PWD /Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30
INPUT /usr/local/texlive/2019/texmf.cnf
INPUT /usr/local/texlive/2019/texmf-dist/web2c/texmf.cnf
INPUT /usr/local/texlive/2019/texmf-var/web2c/pdftex/pdflatex.fmt
INPUT /Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.tex
OUTPUT /Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.log
INPUT /usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
INPUT /usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
INPUT /usr/local/texlive/2019/texmf-dist/tex/latex/base/size10.clo
INPUT /usr/local/texlive/2019/texmf-dist/tex/latex/base/size10.clo
INPUT /Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.aux
INPUT /Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.aux
OUTPUT /Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.aux
INPUT /usr/local/texlive/2019/texmf-dist/fonts/map/fontname/texfonts.map
INPUT /usr/local/texlive/2019/texmf-dist/fonts/tfm/public/cm/cmr12.tfm
INPUT /usr/local/texlive/2019/texmf-dist/fonts/tfm/public/cm/cmbx12.tfm
OUTPUT /Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.pdf
INPUT /usr/local/texlive/2019/texmf-var/fonts/map/pdftex/updmap/pdftex.map
INPUT /Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.aux
INPUT /usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb
INPUT /usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb
INPUT /usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb
INPUT /usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmr7.pfb
62 changes: 62 additions & 0 deletions HW03_2019_09_30/p1.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=pdflatex 2019.8.24) 4 OCT 2019 19:56
entering extended mode
restricted \write18 enabled.
file:line:error style messages enabled.
%&-line parsing enabled.
**"/Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.tex"
(/Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.tex
LaTeX2e <2018-12-01>
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2018/09/03 v1.4i Standard LaTeX file (size option)
)
\c@part=\count80
\c@section=\count81
\c@subsection=\count82
\c@subsubsection=\count83
\c@paragraph=\count84
\c@subparagraph=\count85
\c@figure=\count86
\c@table=\count87
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
) (/Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.aux)
\openout1 = `p1.aux'.

LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 2.
LaTeX Font Info: ... okay on input line 2.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 2.
LaTeX Font Info: ... okay on input line 2.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 2.
LaTeX Font Info: ... okay on input line 2.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 2.
LaTeX Font Info: ... okay on input line 2.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 2.
LaTeX Font Info: ... okay on input line 2.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 2.
LaTeX Font Info: ... okay on input line 2.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <7> on input line 4.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line 4.
[1

{/usr/local/texlive/2019/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (/Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.aux) )
Here is how much of TeX's memory you used:
208 strings out of 492609
2893 string characters out of 6129048
59806 words of memory out of 5000000
4212 multiletter control sequences out of 15000+600000
4245 words of font info for 16 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
23i,4n,17p,206b,109s stack positions out of 5000i,500n,10000p,200000b,80000s
</usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb></usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb></usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmr7.pfb>
Output written on "/Users/YuhouZhou/Desktop/2019 Fall/Stochastic_Method/sml_2019/HW03_2019_09_30/p1.pdf" (1 page, 33603 bytes).
PDF statistics:
24 PDF objects out of 1000 (max. 8388607)
16 compressed objects within 1 object stream
0 named destinations out of 1000 (max. 500000)
1 words of extra memory for PDF output out of 10000 (max. 10000000)

Binary file added HW03_2019_09_30/p1.pdf
Binary file not shown.
Binary file added HW03_2019_09_30/p1.synctex.gz
Binary file not shown.
10 changes: 10 additions & 0 deletions HW03_2019_09_30/p1.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
\documentclass{article}
\begin{document}
\section*{Problem 1 Answer}
\begin{equation}
\omega_{1} + \omega_{2} = 1
\end{equation}
\begin{equation}
\omega_{1}D_{1}+\omega_{2}D_{2} = D
\end{equation}
\end{document}
Binary file modified HW03_2019_09_30/p2.pdf
Binary file not shown.
Binary file added HW03_2019_09_30/p3.pdf
Binary file not shown.
43 changes: 43 additions & 0 deletions HW03_2019_09_30/p3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import numpy as np
import matplotlib.pyplot as plt


def payoff(s, x, type, position):
"""
:param s: float. stock price
:param x: float. strike price
:param type: str. type of options. 'put' or 'call'
:param psotion: str. 'long' position or 'short' position
:return: payoff
"""
zero = np.zeros(len(s))
if type == 'call' and position == 'long':
return np.fmax(zero, s - x)
elif type == 'put' and position == 'long':
return np.fmax(zero, x - s)
elif type == 'call' and position == 'short':
return np.fmin(zero, x - s)
elif type == 'put' and position == 'short':
return np.fmin(zero, s - x)
else:
print('Invalid input!')


if __name__ == '__main__':
s = np.arange(0, 200)
x = 100
types = ['call', 'put']
positions = ['long', 'short']
i = 0
for type in types:
for position in positions:
i += 1
plt.subplot(len(types), len(positions), i)
plt.plot(s, payoff(s=s, x=x, type=type, position=position))
plt.title(position + ' a ' + type)
plt.ylabel('Payoff')
plt.xlabel('Price')
plt.tight_layout()
plt.savefig('p3.pdf')
plt.show()
15 changes: 15 additions & 0 deletions HW03_2019_09_30/p4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from p3 import payoff
import numpy as np
import matplotlib.pyplot as plt

if __name__ == '__main__':
s = np.arange(30, 110)
payoff_butterfly = payoff(s=s, x=50, type='call', position='long') +\
payoff(s=s, x=90, type='call', position='long') + \
payoff(s=s, x=70, type='call', position='short') * 2
plt.plot(s, payoff_butterfly)
plt.xlabel('Stock Price [$]')
plt.ylabel('Payoff [$]')
plt.title('Butterfly Spread')
plt.savefig('p4.pdf')
plt.show()

0 comments on commit 2bd6684

Please sign in to comment.