Skip to content

Commit

Permalink
Release 0.34
Browse files Browse the repository at this point in the history
  • Loading branch information
domokane committed Dec 9, 2023
1 parent 11861e5 commit 7ca5216
Show file tree
Hide file tree
Showing 40 changed files with 889 additions and 872 deletions.
Binary file modified FinancePyManual.pdf
Binary file not shown.
Binary file removed docs/FinancePyManual.pdf
Binary file not shown.
12 changes: 6 additions & 6 deletions docs/make_user_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ def parse_module(module_name):
start_function_lines = []

# Module level classes and functions
numRows = len(lines)
num_rows = len(lines)

for row_num in range(0, numRows):
for row_num in range(0, num_rows):

line = lines[row_num]

Expand All @@ -324,9 +324,9 @@ def parse_module(module_name):
num_functions += 1
start_function_lines.append(row_num)

start_enum_lines.append(numRows)
start_class_lines.append(numRows)
start_function_lines.append(numRows)
start_enum_lines.append(num_rows)
start_class_lines.append(num_rows)
start_function_lines.append(num_rows)

# print("start_class_lines", start_class_lines)

Expand Down Expand Up @@ -870,7 +870,7 @@ def parse_type(p_type):
os.remove(file_name + ".toc")
os.remove(file_name + ".aux")
# os.remove(file_name + ".fls")
os.remove(file_name + ".fdb_latexmk")
# os.remove(file_name + ".fdb_latexmk")
os.remove(file_name + ".log")
os.remove(new_head_file)
os.remove(new_head_file + ".bak")
Expand Down
2 changes: 1 addition & 1 deletion financepy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cr = "\n"

s = "####################################################################" + cr
s += "# FINANCEPY BETA Version " + str('0.33') + " - This build: 03 Dec 2023 at 17:52 #" + cr
s += "# FINANCEPY BETA Version " + str('0.34') + " - This build: 09 Dec 2023 at 18:51 #" + cr
s += "# This software is distributed FREE AND WITHOUT ANY WARRANTY #" + cr
s += "# Report bugs as issues at https://github.com/domokane/FinancePy #" + cr
s += "####################################################################"
Expand Down
26 changes: 13 additions & 13 deletions financepy/market/curves/discount_curve_ns.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ class DiscountCurveNS(DiscountCurve):

def __init__(self,
value_dt: Date,
beta0: float,
beta1: float,
beta2: float,
beta_0: float,
beta_1: float,
beta_2: float,
tau: float,
freq_type: FrequencyTypes = FrequencyTypes.CONTINUOUS,
dc_type: DayCountTypes = DayCountTypes.ACT_ACT_ISDA):
""" Creation of a FinDiscountCurveNS object. Parameters are provided
individually for beta0, beta1, beta2 and tau. The zero rates produced
individually for beta_0, beta_1, beta_2 and tau. The zero rates produced
by this parametrisation have an implicit compounding convention that
defaults to continuous but which can be overridden. """

Expand All @@ -44,9 +44,9 @@ def __init__(self,
raise FinError("Tau must be positive")

self._value_dt = value_dt
self._beta0 = beta0
self._beta1 = beta1
self._beta2 = beta2
self._beta_0 = beta_0
self._beta_1 = beta_1
self._beta_2 = beta_2
self._tau = tau
self._freq_type = freq_type
self._dc_type = dc_type
Expand Down Expand Up @@ -105,9 +105,9 @@ def _zero_rate(self,

theta = t / self._tau
e = np.exp(-theta)
zero_rate = self._beta0
zero_rate += self._beta1 * (1.0 - e) / theta
zero_rate += self._beta2 * ((1.0 - e) / theta - e)
zero_rate = self._beta_0
zero_rate += self._beta_1 * (1.0 - e) / theta
zero_rate += self._beta_2 * ((1.0 - e) / theta - e)
return zero_rate

###########################################################################
Expand Down Expand Up @@ -144,9 +144,9 @@ def __repr__(self):

s = label_to_string("OBJECT TYPE", type(self).__name__)
s += label_to_string("PARAMETER", "VALUE")
s += label_to_string("BETA0", self._beta0)
s += label_to_string("BETA1", self._beta1)
s += label_to_string("BETA2", self._beta2)
s += label_to_string("beta_0", self._beta_0)
s += label_to_string("beta_1", self._beta_1)
s += label_to_string("beta_2", self._beta_2)
s += label_to_string("TAU", self._tau)
s += label_to_string("FREQUENCY", (self._freq_type))
s += label_to_string("DAY_COUNT", (self._dc_type))
Expand Down
4 changes: 2 additions & 2 deletions financepy/market/curves/interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ def _vinterpolate(xValues,
class Interpolator():

def __init__(self,
interpolatorType: InterpTypes):
interpolator_type: InterpTypes):

self._interp_type = interpolatorType
self._interp_type = interpolator_type
self._interp_fn = None
self._times = None
self._dfs = None
Expand Down
26 changes: 13 additions & 13 deletions financepy/market/volatility/equity_vol_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,16 @@ def __init__(self,
self._discount_curve = discount_curve
self._dividend_curve = dividend_curve

nExpiryDates = len(expiry_dts)
nStrikes = len(strikes)
num_expiry_dates = len(expiry_dts)
num_strikes = len(strikes)
n = len(volatility_grid)
m = len(volatility_grid[0])

if n != nExpiryDates:
raise FinError("1st dimension of vol grid is not nExpiryDates")
if n != num_expiry_dates:
raise FinError("1st dim of vol grid is not num_expiry_dates")

if m != nStrikes:
raise FinError("2nd dimension of the vol matrix is not nStrikes")
if m != num_strikes:
raise FinError("2nd dim of the vol matrix is not num_strikes")

self._strikes = strikes
self._num_strikes = len(strikes)
Expand Down Expand Up @@ -681,7 +681,7 @@ def check_calibration(self, verbose: bool, tol: float = 1e-6):
strike = self._strikes[j]

fitted_vol = self.vol_from_strike_dt(strike,
expiry_dt)
expiry_dt)

mkt_vol = self._volatility_grid[i][j]

Expand All @@ -695,7 +695,7 @@ def check_calibration(self, verbose: bool, tol: float = 1e-6):

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

def implied_dbns(self, lowS, highS, numIntervals):
def implied_dbns(self, lowS, highS, num_intervals):
""" Calculate the pdf for each tenor horizon. Returns a list of
FinDistribution objects, one for each tenor horizon. """

Expand All @@ -706,7 +706,7 @@ def implied_dbns(self, lowS, highS, numIntervals):
f = self._F_0T[iTenor]
t = self._t_exp[iTenor]

dS = (highS - lowS) / numIntervals
dS = (highS - lowS) / num_intervals

disDF = self._discount_curve._df(t)
div_df = self._dividend_curve._df(t)
Expand All @@ -717,7 +717,7 @@ def implied_dbns(self, lowS, highS, numIntervals):
Ks = []
vols = []

for iK in range(0, numIntervals):
for iK in range(0, num_intervals):

k = lowS + iK*dS

Expand Down Expand Up @@ -755,11 +755,11 @@ def plot_vol_curves(self):
ks = []
fitted_vols = []

numIntervals = 30
num_intervals = 30
K = lowK
dK = (highK - lowK)/numIntervals
dK = (highK - lowK)/num_intervals

for i in range(0, numIntervals):
for i in range(0, num_intervals):

ks.append(K)
fitted_vol = self.vol_from_strike_dt(K, expiry_dt) * 100.
Expand Down
Loading

0 comments on commit 7ca5216

Please sign in to comment.