[go: up one dir, main page]

Skip to content

Commit

Permalink
Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
domokane committed Sep 3, 2024
1 parent 9c6fb43 commit 09ad349
Show file tree
Hide file tree
Showing 5 changed files with 2,308 additions and 1,398 deletions.
30 changes: 14 additions & 16 deletions financepy/market/volatility/equity_vol_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,17 @@
# TODO: This should be deleted and replaced with equity_vol_surface


class EquityVolCurve():
""" Class to manage a smile or skew in volatility at a single maturity
class EquityVolCurve:
"""Class to manage a smile or skew in volatility at a single maturity
horizon. It fits the volatility using a polynomial. Includes analytics to
extract the implied pdf of the underyling at maturity. THIS NEEDS TO BE
SUBSTITUTED WITH FINEQUITYVOLSURFACE. """
SUBSTITUTED WITH FINEQUITYVOLSURFACE."""

###############################################################################
###########################################################################

def __init__(self,
curve_dt,
expiry_dt,
strikes,
volatilities,
polynomial=3):
def __init__(
self, curve_dt, expiry_dt, strikes, volatilities, polynomial=3
):

if expiry_dt <= curve_dt:
raise FinError("Expiry date before curve date.")
Expand Down Expand Up @@ -52,11 +49,11 @@ def __init__(self,
self._z = np.polyfit(self._strikes, self._volatilities, polynomial)
self._f = np.poly1d(self._z)

###############################################################################
###########################################################################

def volatility(self, strike):
""" Return the volatility for a strike using a given polynomial
interpolation. """
"""Return the volatility for a strike using a given polynomial
interpolation."""

vol = self._f(strike)

Expand All @@ -65,12 +62,13 @@ def volatility(self, strike):

return vol

###############################################################################
###########################################################################

def calculate_pdf(self):
""" calculate the probability density function of the underlying using
"""calculate the probability density function of the underlying using
the volatility smile or skew curve following the approach set out in
Breedon and Litzenberger. """
Breedon and Litzenberger."""
return


###############################################################################
Loading

0 comments on commit 09ad349

Please sign in to comment.