Skip to content

Commit 910e729

Browse files
authored
ENH: make settlement and forward more consistent for Periods (#163) (#1086)
1 parent 78ef6b8 commit 910e729

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

python/rateslib/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
)
9393

9494
FW_FIXINGS_AS_SERIES = (
95-
"Setting any `fixings` argument as a Series directly is currently supported, but not"
95+
"Setting any `fixings` argument as a Series directly is currently supported, but not "
9696
"recommended and may be removed in future versions.\n"
9797
"Best practice is to add the fixings object to the default _BaseFixingsLoader and then "
9898
"reference that object by Series name.\n"

python/rateslib/periods/components/protocols/analytic_delta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
)
1818

1919
if TYPE_CHECKING:
20-
from rateslib.typing import (
20+
from rateslib.typing import ( # pragma: no cover
2121
CurveOption_,
2222
DualTypes,
2323
FXForwards_,

python/rateslib/periods/components/protocols/analytic_fixings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from rateslib.periods.components.protocols.npv import _screen_ex_div_and_forward
1414

1515
if TYPE_CHECKING:
16-
from rateslib.typing import (
16+
from rateslib.typing import ( # pragma: no cover
1717
CurveOption_,
1818
FXForwards_,
1919
FXVolOption_,

python/rateslib/periods/components/protocols/analytic_greeks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from rateslib.splines import evaluate
1616

1717
if TYPE_CHECKING:
18-
from rateslib.typing import (
18+
from rateslib.typing import ( # pragma: no cover
1919
Any,
2020
DualTypes,
2121
DualTypes_,

python/rateslib/periods/components/protocols/cashflows.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
)
2525

2626
if TYPE_CHECKING:
27-
# from rateslib.periods.components import Period
28-
from rateslib.typing import (
27+
from rateslib.typing import ( # pragma: no cover
2928
Any,
3029
CurveOption_,
3130
DualTypes,

python/rateslib/periods/components/protocols/npv.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
)
1919

2020
if TYPE_CHECKING:
21-
from rateslib.typing import (
21+
from rateslib.typing import ( # pragma: no cover
2222
FX_,
2323
CurveOption_,
2424
DualTypes,
@@ -88,8 +88,9 @@ def _screen_ex_div_and_forward(
8888
# in the case of Dualtypes this would be faster to just return 0.0
8989
# but the multiplication is used to handle DataFrame (FixingsSensitivity)
9090
if not is_forward:
91-
# forward is assumed to be equal to settlement
92-
return Ok(local_value.unwrap() / disc_curve_[settlement]) # type: ignore[index]
91+
# forward is assumed to be immediate value if not given.
92+
# # forward is assumed to be equal to settlement
93+
return local_value # / disc_curve_[settlement]) # type: ignore[index]
9394
else:
9495
return Ok(local_value.unwrap() / disc_curve_[forward]) # type: ignore[index]
9596

python/tests/legs/test_legs_legacy.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -439,12 +439,12 @@ def test_is_linear(self, method, spread_method, expected) -> None:
439439
("method", "settlement", "forward", "expected"),
440440
[
441441
("ISDA_compounding", NoInput(0), NoInput(0), 357.7019143401966),
442-
("ISDA_compounding", dt(2022, 4, 6), NoInput(0), 580.3895480501503),
442+
("ISDA_compounding", dt(2022, 4, 6), dt(2022, 4, 6), 580.3895480501503),
443443
("ISDA_flat_compounding", NoInput(0), NoInput(0), 360.65913016465225),
444-
("ISDA_flat_compounding", dt(2022, 4, 6), NoInput(0), 587.64160672647),
444+
("ISDA_flat_compounding", dt(2022, 4, 6), dt(2022, 4, 6), 587.64160672647),
445445
("NONE_Simple", NoInput(0), NoInput(0), 362.2342162),
446446
("NONE_Simple", NoInput(0), dt(2022, 2, 1), 360.98240826375957),
447-
("NONE_Simple", dt(2022, 4, 6), NoInput(0), 590.6350781908598),
447+
("NONE_Simple", dt(2022, 4, 6), dt(2022, 4, 6), 590.6350781908598),
448448
],
449449
)
450450
def test_float_leg_spread_calculation(
@@ -956,7 +956,7 @@ def test_zero_float_leg_analytic_delta(self, curve) -> None:
956956
[
957957
(NoInput(0), NoInput(0), 0.71008),
958958
(NoInput(0), dt(2023, 1, 1), -0.11739),
959-
(dt(2026, 1, 1), NoInput(0), -2.40765),
959+
(dt(2026, 1, 1), dt(2026, 1, 1), -2.40765),
960960
],
961961
)
962962
def test_zero_float_spread_calc(self, settlement, forward, exp, curve) -> None:
@@ -1651,8 +1651,8 @@ def test_non_deliverable(self, curve):
16511651
("settlement", "forward", "exp"),
16521652
[
16531653
(NoInput(0), NoInput(0), 403.9491881327746),
1654-
(dt(2022, 3, 30), NoInput(0), 399.9990223763462),
1655-
(dt(2022, 4, 6), NoInput(0), 799.0147512470912),
1654+
(dt(2022, 3, 30), dt(2022, 3, 30), 399.9990223763462),
1655+
(dt(2022, 4, 6), dt(2022, 4, 6), 799.0147512470912),
16561656
],
16571657
)
16581658
def test_fixed_leg_spread(self, settlement, forward, exp, curve) -> None:
@@ -2071,8 +2071,8 @@ def test_exchanges_raises(self, final):
20712071
("settlement", "forward", "exp"),
20722072
[
20732073
(NoInput(0), NoInput(0), 408.02994815795125),
2074-
(dt(2022, 3, 30), NoInput(0), 404.03987718823055),
2075-
(dt(2022, 4, 6), NoInput(0), 811.1815703665554),
2074+
(dt(2022, 3, 30), dt(2022, 3, 30), 404.03987718823055),
2075+
(dt(2022, 4, 6), dt(2022, 4, 6), 811.1815703665554),
20762076
],
20772077
)
20782078
def test_fixed_leg_spread(self, settlement, forward, exp, curve) -> None:

0 commit comments

Comments
 (0)