Skip to content

Commit 0ef8f4c

Browse files
committed
Fixed spd rename issue
1 parent 9832e81 commit 0ef8f4c

File tree

5 files changed

+40
-40
lines changed

5 files changed

+40
-40
lines changed

.pylintrc

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ disable=
1212
C0114, # missing-module-docstring
1313
C0115, # missing-class-docstring
1414
C0116, # missing-function-docstring
15+
C0411, # wrong-import-order (instead of old E0411)
16+
C0413, # wrong-import-position (instead of old E0413)
1517
R0902, # too-many-instance-attributes (common in product models)
1618
R0913, # too-many-arguments (pricers/calibrators often need them)
1719
R0914, # too-many-locals (numerical routines)
@@ -20,10 +22,7 @@ disable=
2022
W0511, # fixme (we allow TODO notes, use pre-commit to gate later)
2123
W1203, # logging-fstring-interpolation (we prefer f-strings)
2224
E1136, # unsubscriptable-object (often false-positive with numpy)
23-
# E1101, # no-member (NumPy/Numba dynamic attrs)
2425
E0401, # unable to import
25-
E0411, # unable to import in some order
26-
E0413, # unable to import in some order
2726

2827
enable=
2928
unused-import,
@@ -43,15 +42,27 @@ max-module-lines=4000
4342
indent-string=' '
4443

4544
[BASIC]
46-
good-names=i,j,k,m,n,t,x,y,z,dt,df,pv,dv01,ir,fx,np,va,vc,mu,sigma,qr
45+
good-names =
46+
i, j, k, n, m, t, x, y, z, r, q, p,
47+
df, pv, fv, fx, npv, irr,
48+
dt, dr, dv, dx,
49+
mu, sigma, lam, va, vc, dv01
50+
X, Y, Z,
51+
s, S, K,
52+
u, v, w,
53+
__version__
54+
4755
bad-names=foo,bar,baz
48-
variable-rgx=^[a-z_][a-z0-9_]*$
49-
argument-rgx=^[a-z_][a-z0-9_]*$
50-
attr-rgx=^[a-z_][a-z0-9_]*$
51-
method-rgx=^(test_.+|[a-z_][a-z0-9_]*)$
52-
function-rgx=^(test_.+|[a-z_][a-z0-9_]*)$
53-
class-rgx=^[A-Z][a-zA-Z0-9]+$
54-
const-rgx=^(_?[A-Z][A-Z0-9_]*|k[A-Z][A-Za-z0-9]+)$
56+
57+
# Regexes for naming style checks (keep defaults except constants)
58+
argument-rgx=[a-z_][a-z0-9_]{0,30}$
59+
attr-rgx=[a-z_][a-z0-9_]{0,30}$
60+
class-rgx=[A-Z_][a-zA-Z0-9]+$
61+
const-rgx=^(_?[A-Z][A-Z0-9_]*|__version__)$
62+
function-rgx=[a-z_][a-z0-9_]{2,30}$
63+
method-rgx=[a-z_][a-z0-9_]{2,30}$
64+
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
65+
variable-rgx=[a-z_][a-z0-9_]{0,30}$
5566

5667
[TYPECHECK]
5768
generated-members=numpy.*,np.*,pandas.*,pd.*

financepy/products/credit/cds_index_portfolio.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def intrinsic_prot_leg_pv(self, value_dt, step_in_dt, maturity_dt, issuer_curves
8989

9090
####################################################################################
9191

92-
def intrinsic_spd(self, value_dt, step_in_dt, maturity_dt, issuer_curves):
92+
def intrinsic_spread(self, value_dt, step_in_dt, maturity_dt, issuer_curves):
9393
"""Calculation of the intrinsic spd of the CDS portfolio as the one
9494
which would make the value of the protection legs equal to the value of
9595
the premium legs if all premium legs paid the same spd."""
@@ -108,7 +108,7 @@ def intrinsic_spd(self, value_dt, step_in_dt, maturity_dt, issuer_curves):
108108

109109
####################################################################################
110110

111-
def average_spd(self, value_dt, step_in_dt, maturity_dt, issuer_curves):
111+
def average_spread(self, value_dt, step_in_dt, maturity_dt, issuer_curves):
112112
"""Calculates the average par CDS spd of the CDS portfolio."""
113113

114114
num_credits = len(issuer_curves)
@@ -126,7 +126,7 @@ def average_spd(self, value_dt, step_in_dt, maturity_dt, issuer_curves):
126126

127127
####################################################################################
128128

129-
def total_spd(self, value_dt, step_in_dt, maturity_dt, issuer_curves):
129+
def total_spread(self, value_dt, step_in_dt, maturity_dt, issuer_curves):
130130
"""Calculates the total CDS spd of the CDS portfolio by summing
131131
over all of the issuers and adding the spd with no weights."""
132132

@@ -144,7 +144,7 @@ def total_spd(self, value_dt, step_in_dt, maturity_dt, issuer_curves):
144144

145145
####################################################################################
146146

147-
def min_spd(self, value_dt, step_in_dt, maturity_dt, issuer_curves):
147+
def min_spread(self, value_dt, step_in_dt, maturity_dt, issuer_curves):
148148
"""Calculates the minimum par CDS spd across all of the issuers in
149149
the CDS portfolio."""
150150

@@ -168,7 +168,7 @@ def min_spd(self, value_dt, step_in_dt, maturity_dt, issuer_curves):
168168

169169
####################################################################################
170170

171-
def max_spd(self, value_dt, step_in_dt, maturity_dt, issuer_curves):
171+
def max_spread(self, value_dt, step_in_dt, maturity_dt, issuer_curves):
172172
"""Calculates the maximum par CDS spd across all of the issuers in
173173
the CDS portfolio."""
174174

financepy/utils/date_format.py

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,37 +25,23 @@ class DateFormatTypes(Enum):
2525
########################################################################################
2626

2727
# Private module-level variable to hold current global date format
28-
_date_format: DateFormatTypes = DateFormatTypes.UK_LONG
28+
G_DATE_TYPE_FORMAT: DateFormatTypes = DateFormatTypes.UK_LONG
2929

3030
########################################################################################
3131

3232

33-
def set_date_format(format_type: DateFormatTypes):
34-
"""
35-
Set the current global date format type.
36-
37-
Parameters
38-
----------
39-
format_type : DateFormatTypes
40-
The new date format to set globally.
41-
"""
42-
global _date_format
43-
_date_format = format_type
33+
def set_date_format(fmt: str) -> None:
34+
"""Set the global date format."""
35+
global G_DATE_TYPE_FORMAT
36+
G_DATE_TYPE_FORMAT = fmt
4437

4538

4639
########################################################################################
4740

4841

49-
def get_date_format() -> DateFormatTypes:
50-
"""
51-
Get the current global date format type.
52-
53-
Returns
54-
-------
55-
DateFormatTypes
56-
The currently set global date format.
57-
"""
58-
return _date_format
42+
def get_date_format() -> str:
43+
"""Return the current global date format."""
44+
return G_DATE_TYPE_FORMAT
5945

6046

6147
########################################################################################
@@ -64,3 +50,6 @@ def get_date_format() -> DateFormatTypes:
6450
def print_date_format():
6551
global G_DATE_TYPE_FORMAT
6652
print("TEST TYPE", G_DATE_TYPE_FORMAT)
53+
54+
55+
########################################################################################

golden_tests/TestFinCDSIndexAdjustSpreads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def test_cds_index_adjust_spreads():
200200
start = time.time()
201201

202202
index_portfolio = CDSIndexPortfolio()
203-
adjusted_issuer_curves = index_portfolio.spread_adjust_intrinsic(
203+
adjusted_issuer_curves = index_portfolio.spd_adjust_intrinsic(
204204
value_dt,
205205
issuer_curves,
206206
index_cpns,

golden_tests/TestFinCDSIndexOption.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def test_dirty_price_cds_index_option():
234234

235235
test_cases.print(
236236
elapsed,
237-
strike,
237+
strike_bps,
238238
index,
239239
v_pay_1,
240240
v_rec_1,

0 commit comments

Comments
 (0)