Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TYP: refactor directories #617

Merged
merged 11 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ exclude = [
"/instruments/bonds/securities.py",
"/instruments/fx_volatility.py",
"/instruments/generics.py",
"/instruments/rates_derivatives.py",
"/instruments/rates_multi_ccy.py",
"/instruments/rates/inflation.py",
"/instruments/rates/multi_currency.py",
"/instruments/rates/single_currency.py",
"solver.py",
]
strict = true
Expand Down
8 changes: 3 additions & 5 deletions python/rateslib/instruments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,17 @@
FXStrangle,
)
from rateslib.instruments.generics import Fly, Portfolio, Spread, Value, VolValue
from rateslib.instruments.rates_derivatives import (
from rateslib.instruments.rates import (
FRA,
IIRS,
IRS,
SBS,
XCS,
ZCIS,
ZCS,
STIRFuture,
)
from rateslib.instruments.rates_multi_ccy import (
XCS,
FXExchange,
FXSwap,
STIRFuture,
)
from rateslib.instruments.sensitivities import Sensitivities

Expand Down
4 changes: 2 additions & 2 deletions python/rateslib/instruments/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ def npv(
base,
self.leg1.currency,
)
leg1_npv: NPV = self.leg1.npv(curves_[0], curves_[1], fx_, base_, local) # type: ignore[arg-type]
leg2_npv: NPV = self.leg2.npv(curves_[2], curves_[3], fx_, base_, local) # type: ignore[arg-type]
leg1_npv: NPV = self.leg1.npv(curves_[0], curves_[1], fx_, base_, local)
leg2_npv: NPV = self.leg2.npv(curves_[2], curves_[3], fx_, base_, local)
if local:
return {
k: leg1_npv.get(k, 0) + leg2_npv.get(k, 0) # type: ignore[union-attr]
Expand Down
2 changes: 1 addition & 1 deletion python/rateslib/instruments/bonds/futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ def rate(
else: # metric == "ytm":
return self.basket[ctd_index].ytm(future_price * self.cfs[ctd_index], f_settlement)

def npv( # type: ignore[override]
def npv(
self,
curves: Curves = NoInput(0),
solver: Solver | NoInput = NoInput(0),
Expand Down
4 changes: 2 additions & 2 deletions python/rateslib/instruments/credit/derivatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def analytic_rec_risk(self, *args: Any, **kwargs: Any) -> DualTypes:
"""
return self.leg2.analytic_rec_risk(*args, **kwargs)

def npv( # type: ignore[override]
def npv(
self,
curves: Curves = NoInput(0),
solver: Solver | NoInput = NoInput(0),
Expand Down Expand Up @@ -174,7 +174,7 @@ def rate(
leg2_npv: DualTypes = self.leg2.npv(curves_[2], curves_[3], local=False) # type: ignore[assignment]
return self.leg1._spread(-leg2_npv, curves_[0], curves_[1]) * 0.01

def cashflows( # type: ignore[override]
def cashflows(
self,
curves: Curves = NoInput(0),
solver: Solver | NoInput = NoInput(0),
Expand Down
5 changes: 5 additions & 0 deletions python/rateslib/instruments/rates/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from rateslib.instruments.rates.inflation import IIRS, ZCIS
from rateslib.instruments.rates.multi_currency import XCS, FXExchange, FXSwap
from rateslib.instruments.rates.single_currency import FRA, IRS, SBS, ZCS, STIRFuture

__all__ = ["ZCIS", "IIRS", "SBS", "FRA", "IRS", "ZCS", "STIRFuture", "XCS", "FXExchange", "FXSwap"]
Loading
Loading