Impvol Documentation Release 0.1

Impvol Documentation Release 0.1

ImpVol Documentation Release 0.1 Stanislav Khrapov May 01, 2018 Contents 1 Introduction 1 2 Examples 3 3 Functions 5 Python Module Index 7 i ii CHAPTER 1 Introduction The original Black-Scholes formula is given by −rT BS (S; K; 휎; r; T ) = SΦ(d1) − e KΦ(d2) ; log (S=K) + rT 1 p d1 = p + 휎 T; 휎 T 2 p d2 = d1 − 휎 T: After normalization by the current asset price S it can be written as X BS~ (X; 휎; T ) = Φ (d1) − e Φ(d2) ; X 1 p d1 = − p + 휎 T; 휎 T 2 p d2 = d1 − 휎 T; where X = log (K=F ) is log-forward moneyness, and forward price is given by F = SerT . 1 ImpVol Documentation, Release 0.1 2 Chapter 1. Introduction CHAPTER 2 Examples >>> from impvol import imp_vol, lfmoneyness >>> strike=[1,.95] >>> premium=[.024,.057] >>> price=1 >>> riskfree=.02 >>> maturity= 30/365 >>> call= True >>> moneyness= lfmoneyness(price, strike, riskfree, maturity) >>> vol= imp_vol(moneyness, maturity, premium, call) >>> print(vol) [ 0.20277309 0.20093061] >>> vol= impvol_bisection(moneyness, maturity, premium, call) >>> print(vol) [ 0.20270996 0.20095215] 3 ImpVol Documentation, Release 0.1 4 Chapter 2. Examples CHAPTER 3 Functions impvol.impvol.imp_vol(moneyness, maturity, premium, call) Compute implied volatility given vector of option premium. Parameters moneyness [array_like] Log-forward moneyness maturity [array_like] Fraction of the year premium [array_like] Option premium normalized by current asset price call [bool array_like] Call/put flag. True for call, False for put Returns array_like Implied volatilities. Shape of the array is according to broadcasting rules. Notes This code relies on SciPy root method. Although vectorized, it is still very slow. Bisection method in this impvol library is substantially faster. impvol.impvol.impvol_bisection(moneyness, maturity, premium, call, tol=1e-05, fcount=1000) Function to find BS Implied Vol using Bisection Method. Parameters moneyness [array_like] Log-forward moneyness maturity [array_like] Fraction of the year premium [array_like] Option premium normalized by current asset price call [array_like bool] Call/put flag. True for call, False for put Returns array_like Implied volatilities Shape of the array is according to broadcasting rules. 5 ImpVol Documentation, Release 0.1 impvol.impvol.impvol_table(data) Implied volatility for structured data. Parameters data [pandas DataFrame, record array, or dictionary of arrays] Mandatory labels: moneyness, maturity, premium, call Returns array Implied volatilities Notes ‘premium’ should be normalized by the current asset price. impvol.impvol.lfmoneyness(price, strike, riskfree, maturity) Compute log-forward moneyness. Parameters price [array_like] Underlying prices strike [array_like] Option strikes riskfree [array_like] Annualized risk-free rate maturity [array_like] Time horizons, in shares of the calendar year Returns array_like Log-forward moneyness impvol.impvol.blackscholes_norm(moneyness, maturity, vol, call) Standardized Black-Scholes Function. Parameters moneyness [array_like] Log-forward moneyness maturity [array_like] Fraction of the year, i.e. = 30/365 vol [array_like] Annualized volatility (sqrt of variance), i.e. = .15 call [bool array_like] Call/put flag. True for call, False for put Returns array_like Option premium standardized by current asset price 6 Chapter 3. Functions Python Module Index i impvol.impvol,1 7 ImpVol Documentation, Release 0.1 8 Python Module Index Index B blackscholes_norm() (in module impvol.impvol),6 I imp_vol() (in module impvol.impvol),5 impvol.impvol (module),1 impvol_bisection() (in module impvol.impvol),5 impvol_table() (in module impvol.impvol),5 L lfmoneyness() (in module impvol.impvol),6 9.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    13 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us