GithubHelp home page GithubHelp logo

py4fi's People

Contributors

yhilpisch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

py4fi's Issues

【chapter6】data['Mov_Vol'] = data['Return'].rolling(window=252).std() * math.sqrt(252)

Rolling.std(ddof=1, *args, **kwargs) calculates rolling standard deviation, normalized by N-1 by default. It means, by default, it uses the sample standard deviation function, in which the denominator is a N-1. The denominator can be set to 1 in this case, if std(ddof=251), then N-251=1. I guess the multiplying of math.sqrt(252) here may be a mistake of confusing rolling.std with numpy.std. The default ddof in numpy.std is 0, which means its denominator is a N. In that case, multiplying of math.sqrt(252) can offset the denominator of 252 exactly.

mcs_full_vector_numpy.py has a drift a S[0]

Hi @yhilpisch, the fixed for #4 by setting the first time slice (t=0) to 0 does not correctly fixed the issue. On first look, it appears that it has solved the issue. However, on closer inspection of the equation, I notice that even though setting the first time slice (t=0) to 0, a drift will still be included at time slice resulting in an over-estimation.

mcs_full_vector_numpy.py does not converge to the true price.

Hi @yhilpisch,

Thank you for the great work as an undergraduate student I have learn a lot from your book!

Example 3-4 code which estimates the theoretical value of a European call option via Monte Carlo simulation appears to yield different results from that of bsm_call_value() function in Chapter 3.

Using the analytical formula for the valuation of European call option in BSM model for S0 = 100, K = 105, T = 1.0, r = 0.05 and sigma = 0.2, we arrive at a European call price of 8.02135.

Using the code from example 3-4 which estimates the theoretical value of a European call option via Monte Carlo simulation using the same parameter should yield the same result as that of the analytical formula. However, the results yield by mcs_full_vector_numpy.py appears to be significantly different from that of bsm_call_value().

My suspect is that random.standard_normal((M + 1, I)) should be changed to random.standard_normal((M, I)) such that the calculation converge to the true price.

screen shot 2018-07-08 at 2 17 27 pm

screen shot 2018-07-08 at 2 18 09 pm

Conda environment creation fails

The creation of the conda enviornment as shown in the readme fails on windows with the last version of conda (conda 4.5.11).

conda env create -f py4fi_conda.yml
Solving environment: failed

ResolvePackageNotFound:
  - ncurses==6.0=hd04f020_2
  - requests==2.18.4=py36h4516966_1
  - xlsxwriter==1.0.2=py36h3736301_0
  - tornado==4.5.2=py36h468dda9_0
  - itsdangerous==0.24=py36h49fbb8d_1
  - cycler==0.10.0=py36hfc81398_0
  - jinja2==2.9.6=py36hde4beb4_1
  - gmp==6.1.2=hb37e062_1
  - tk==8.6.7=h35a86e2_3
  - lzo==2.10=hb6b8854_1
  - testpath==0.3.1=py36h625a49b_0
  - appnope==0.1.0=py36hf537a9a_0
  - setuptools==36.5.0=py36h2134326_0
  - cffi==1.10.0=py36h880867e_1
  - jupyter==1.0.0=py36h598a6cc_0
  - numba==0.35.0=np113py36_6
  - pandocfilters==1.4.2=py36h3b0b094_1
  - pyqt==5.6.0=py36he5c6137_6
  - jupyter_core==4.3.0=py36h93810fe_0
  - cryptography==2.0.3=py36h22d4226_1
  - expat==2.2.5=hb8e80ba_0
  - chardet==3.0.4=py36h96c241c_1
  - patsy==0.4.1=py36ha1b3fa5_0
  - zeromq==4.2.2=ha360ad0_2
  - jedi==0.10.2=py36h6325097_0
  - zlib==1.2.11=hf3cbc9b_2
  - sqlite==3.20.1=h7e4c145_2
  - traitlets==4.3.2=py36h65bd3ce_0
  - python==3.6.3=h5ce8c04_4
  - mpc==1.0.3=hc455b36_4
  - werkzeug==0.12.2=py36h168efa1_0
  - matplotlib==2.1.0=py36h5068139_0
  - pexpect==4.2.1=py36h3eac828_0
  - wheel==0.29.0=py36h3597b6d_1
  - html5lib==0.999999999=py36h79312fd_0
  - pysocks==1.6.7=py36hfa33cec_1
  - libedit==3.1=hb4e282d_0
  - jpeg==9b=he5867d9_2
  - mpmath==0.19=py36h9185fea_2
  - nbconvert==5.3.1=py36h810822e_0
  - xlwt==1.2.0=py36h5ad1178_0
  - pyzmq==16.0.2=py36h087ffad_2
  - fastcache==1.0.2=py36h8606a76_0
  - pytz==2017.2=py36h2e7dfbc_1
  - pyopenssl==17.2.0=py36h5d7bf08_0
  - nbformat==4.4.0=py36h827af21_0
  - pcre==8.41=hfb6ab37_1
  - gettext==0.19.8.1=h15daf44_3
  - libiconv==1.15=hdd342a3_7
  - urllib3==1.22=py36h68b9469_0
  - certifi==2017.7.27.1=py36hd973bb6_0
  - bleach==2.0.0=py36h8fcea71_0
  - ipython_genutils==0.2.0=py36h241746c_0
  - numexpr==2.6.2=py36h8fc668d_2
  - prompt_toolkit==1.0.15=py36haeda067_0
  - widgetsnbextension==3.0.2=py36h91f43ea_1
  - hdf5==1.10.1=ha036c08_1
  - sympy==1.1.1=py36h7f3cf04_0
  - qt==5.6.2=h9975529_14
  - flask==0.12.2=py36h5658096_0
  - ipykernel==4.6.1=py36h3208c25_0
  - libffi==3.2.1=h475c297_4
  - gmpy2==2.0.8=py36h7ef02cb_1
  - freetype==2.8=h12048fb_1
  - asn1crypto==0.22.0=py36hb705621_1
  - xlrd==1.1.0=py36h336f4a2_1
  - intel-openmp==2018.0.0=h68bdfb3_7
  - pymc3==3.2=py36h1e7238b_0
  - openpyxl==2.4.8=py36he899640_1
  - readline==7.0=hc1231fa_4
  - pip==9.0.1=py36h1555ced_4
  - libgfortran==3.0.1=h93005f0_2
  - pycparser==2.18=py36h724b2fc_1
  - libgpuarray==0.6.9=0
  - python-dateutil==2.6.1=py36h86d2abb_1
  - six==1.11.0=py36h0e22d5e_1
  - libsodium==1.0.13=hba5e272_2
  - numpy==1.13.3=py36h2cdce51_0
  - simplegeneric==0.8.1=py36he5b5b09_0
  - ptyprocess==0.5.2=py36he6521c3_0
  - wcwidth==0.1.7=py36h8c6ec74_0
  - ipython==6.1.0=py36hf612aae_1
  - bzip2==1.0.6=h649919c_2
  - icu==58.2=h4b95b61_1
  - qtconsole==4.3.1=py36hd96c0ff_0
  - click==6.7=py36hec950be_0
  - jupyter_client==5.1.0=py36hf6c435f_0
  - libcxx==4.0.1=h579ed51_0
  - libpng==1.6.32=h6184301_3
  - dbus==1.10.22=h50d9ad6_0
  - terminado==0.6=py36h656782e_0
  - mako==1.0.7=py36h55379d4_0
  - pyparsing==2.2.0=py36hb281f35_0
  - pytables==3.4.2=py36hfbd7ab0_2
  - et_xmlfile==1.0.1=py36h1315bdc_0
  - nose==1.3.7=py36h73fae2b_2
  - markupsafe==1.0=py36h3a1e703_1
  - tqdm==4.19.4=py36he502594_0
  - entrypoints==0.2.3=py36hd81d71f_2
  - h5py==2.7.0=py36h6400cee_1
  - pandoc==1.19.2.1=ha5e8f32_1
  - scikit-learn==0.19.1=py36hffbff8c_0
  - decorator==4.1.2=py36h69a1b52_0
  - notebook==5.2.1=py36h640abe8_0
  - mkl==2018.0.0=h5ef208c_6
  - cython==0.26.1=py36hd51f8eb_0
  - jupyter_console==5.2.0=py36hccf5b1c_1
  - pandas==0.21.0=py36hfed917e_1
  - jsonschema==2.6.0=py36hb385e00_0
  - mkl-service==1.1.2=py36h7ea6df4_4
  - jdcal==1.3=py36h1986823_0
  - ipywidgets==7.0.0=py36h24d3910_0
  - glib==2.53.6=h33f6a65_2
  - ca-certificates==2017.08.26=ha1e5d58_0
  - pygments==2.2.0=py36h240cd3f_0
  - sip==4.18.1=py36h2824476_2
  - xz==5.2.3=h0278029_2
  - mpfr==3.1.5=h7fa3772_1
  - openssl==1.0.2m=h86d3e6a_1
  - webencodings==0.5.1=py36h3b9701d_1
  - mistune==0.8.1=py36h638d0ca_0
  - pickleshare==0.7.4=py36hf512f8e_0
  - scipy==1.0.0=py36h1de22e9_0
  - libcxxabi==4.0.1=hebd6815_0
  - idna==2.6=py36h8628d0a_1

i'm pretty sure it's a version mismatch - but couldn't figure out a way to fix it

according to an issuei found (ContinuumIO/anaconda-issues#9480 (comment)) exporting via conda env export --no-builds > environment.yml should help fix the issue.

Q about bsm_vega?

If I understand it right, the Vega of an option, the derivative of the norm cdf is needed. The notation you used in your book is N'(d_1), with a prime. The calculation in bsm_vega has used:

 stats.norm.cdf( ) 

which doesn't appear to be correct. Shouldn't this be just the norm pdf? ie. exp(-x^2) normalized?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.