abaquant.rates¶
Import path: abaquant.rates
Domain: Interest-rate curves, interpolation, discounting, and FRED/manual providers.
Package purpose¶
Rate curves, FRED integration, and pure interest-rate helpers.
How to use this package¶
Defines the package facade and supported import surface. Use this package when a workflow needs tenor-dependent rates or discount factors rather than one scalar risk-free-rate assumption.
Facade objects¶
class:
RatesProviderError— Raised when an applied rate provider cannot supply usable data.class:
RatesValidationError— Raised when a rate-curve request violates a domain constraint.class:
FredObservation— One FRED observation converted to an annual decimal rate.class:
RateCurve— Provider-neutral annual decimal rate curve. *RateCurve.from_rates— Create a curve from manually supplied decimal annual rates. *RateCurve.maturities— Return curve maturities in ascending order. *RateCurve.rates— Return annual decimal rates in ascending maturity order. *RateCurve.as_frame— Return the curve points as a tidy DataFrame. *RateCurve.zero_rate— Interpolate an annual decimal zero-rate proxy for one maturity. *RateCurve.discount_factor— Convert the interpolated annual rate into a discount factor. *RateCurve.visualize— Return a themed figure of the annual decimal rate curve.class:
FredJsonCacheStore— Versioned, checksum-protected disk cache for FRED curve inputs. *FredJsonCacheStore.observation_path— Return the deterministic cache path for one series/date request. *FredJsonCacheStore.load_observation— Load one cached observation when it is present, valid, and fresh. *FredJsonCacheStore.save_observation— Persist one FRED observation through atomic temporary-file replacement. *FredJsonCacheStore.observation_status— Return cache availability metadata for one observation request. *FredJsonCacheStore.clear_observation— Remove one cached observation if it exists.class:
FredRateProvider— FRED Treasury constant-maturity provider with optional disk caching. *FredRateProvider.rate_curve— Return a Treasury-rate curve from FRED observations. *FredRateProvider.cache_status— Return memory and disk cache status for all configured FRED series. *FredRateProvider.clear_cache— Clear memory and disk observations for the configured date label.class:
ManualRateProvider— Provider object that returns a manually supplied curve without network access. *ManualRateProvider.rate_curve— Return the configured manual curve for tests and examples.function:
get_rate_curve— Return a provider-backed risk-free-rate curve.
Package reference¶
Rate curves, FRED integration, and pure interest-rate helpers.
Purpose¶
This module combines AbaQuant’s pure interest-rate conversion functions with an optional applied risk-free-rate curve interface. The applied interface can read U.S. Treasury constant-maturity yields from the Federal Reserve Economic Data (FRED) API, cache downloaded observations, interpolate a decimal annual zero rate, and convert that rate into discount factors for pricing workflows.
Conventions¶
FRED Treasury constant-maturity series are reported as annual percentage yields.
AbaQuant converts them to annual decimal rates, so 4.50 from FRED becomes
0.045. RateCurve.zero_rate uses linear interpolation across maturity in
years by default. RateCurve.discount_factor uses continuous compounding by
default, \(D(T)=\exp(-rT)\).
Scope and limitations¶
Treasury constant-maturity yields are treated as a pragmatic risk-free-rate proxy. They are not bootstrapped zero-coupon curves, do not include collateral or funding adjustments, and should not be interpreted as production-grade curve construction.
References
[1] Federal Reserve Bank of St. Louis, FRED API documentation. [2] Kellison, S. G. (2009), The Theory of Interest.
- class abaquant.rates.DataProvenance(provider, dataset, retrieved_at_utc=None, cache_status=<factory>, source_labels=(), currency=None, reporting_date=None, transformation_steps=(), request=<factory>, notes=())¶
Bases:
objectImmutable metadata describing how a dataset or result was produced.
- Parameters:
provider (str) – Source provider or construction mechanism, such as
"yahoo","sec","fred","manual", or"derived".dataset (str) – Dataset or object category, for example
"option_chain"or"financial_statement_snapshot".retrieved_at_utc (str | None, default=None) – ISO-8601 UTC retrieval/construction timestamp. When omitted, the current UTC time is used.
cache_status (Mapping[str, object], optional) – Provider-specific cache diagnostics.
source_labels (Sequence[str], optional) – Provider-native labels or series identifiers used in the dataset.
currency (str | None, default=None) – Reporting currency where applicable.
reporting_date (str | None, default=None) – Reporting date, observation date, or period label.
transformation_steps (Sequence[str], optional) – Ordered human-readable transformations applied to the source data.
request (Mapping[str, object], optional) – Request metadata such as symbol, period, source, or refresh policy.
notes (Sequence[str], optional) – Additional limitations or interpretation notes.
- as_dict()¶
Return a JSON-serializable provenance dictionary.
- Return type:
dict[str, object]
- with_step(step)¶
Return a copy with one additional transformation step appended.
- Parameters:
step (str)
- Return type:
- classmethod from_dict(payload)¶
Build a provenance object from a saved dictionary payload.
- Parameters:
payload (mapping or None) – Serialized provenance dictionary.
NonereturnsNone.- Returns:
Reconstructed provenance record or
Nonewhen unavailable.- Return type:
DataProvenance | None
- class abaquant.rates.FredJsonCacheStore(directory=None)¶
Bases:
objectVersioned, checksum-protected disk cache for FRED curve inputs.
Configure the root directory used for FRED JSON cache files.
- Parameters:
directory (str | Path | None)
- observation_path(series_id, date_label)¶
Return the deterministic cache path for one series/date request.
- Parameters:
series_id (str)
date_label (str)
- Return type:
Path
- load_observation(series_id, date_label, *, max_age_days=None)¶
Load one cached observation when it is present, valid, and fresh.
- Parameters:
series_id (str)
date_label (str)
max_age_days (float | None)
- Return type:
FredObservation | None
- save_observation(date_label, observation)¶
Persist one FRED observation through atomic temporary-file replacement.
- Parameters:
date_label (str)
observation (FredObservation)
- Return type:
None
- observation_status(series_id, date_label, *, max_age_days=None)¶
Return cache availability metadata for one observation request.
- Parameters:
series_id (str)
date_label (str)
max_age_days (float | None)
- Return type:
dict[str, object]
- clear_observation(series_id, date_label)¶
Remove one cached observation if it exists.
- Parameters:
series_id (str)
date_label (str)
- Return type:
None
- class abaquant.rates.FredObservation(series_id, maturity_years, observation_date, annual_rate, raw_value_percent)¶
Bases:
objectOne FRED observation converted to an annual decimal rate.
- Parameters:
series_id (str)
maturity_years (float)
observation_date (date)
annual_rate (float)
raw_value_percent (float)
- series_id¶
FRED series identifier, such as
"DGS10".- Type:
str
- maturity_years¶
Maturity represented by the series, expressed in years.
- Type:
float
- observation_date¶
Date of the FRED observation used for the curve point.
- Type:
date
- annual_rate¶
Annual rate in decimal units. For example,
0.045denotes 4.5%.- Type:
float
- raw_value_percent¶
Raw FRED observation in percentage-point units.
- Type:
float
- class abaquant.rates.FredRateProvider(*, api_key=None, series_by_maturity=None, cache_mode='memory', cache_directory=None, timeout_seconds=10.0, user_agent=_DEFAULT_FRED_USER_AGENT)¶
Bases:
objectFRED Treasury constant-maturity provider with optional disk caching.
- Parameters:
api_key (str | None, default=None) – FRED API key. When omitted,
FRED_API_KEYis read from the environment. Cache-only calls can work without an API key when the required observation files already exist.series_by_maturity (mapping of float to str, optional) – Mapping from maturity in years to FRED series IDs. The default uses U.S. Treasury constant-maturity series such as
DGS1andDGS10.cache_mode ({"none", "memory", "disk"}, default="memory") – Cache layer used for observations.
cache_directory (str | pathlib.Path | None, default=None) – Directory used by
cache_mode='disk'.timeout_seconds (float)
user_agent (str)
Configure provider credentials, curve series, cache, and timeout.
- rate_curve(*, date='latest', refresh_policy='if_stale', max_age_days=1.0)¶
Return a Treasury-rate curve from FRED observations.
- Parameters:
date (str | date, default="latest") –
"latest"requests each series’ latest valid observation. A date uses the most recent valid observation on or before that date.refresh_policy ({"cache_only", "if_missing", "if_stale", "refresh"}, default="if_stale") – Cache policy applied independently to each FRED series.
max_age_days (float | None, default=1.0) – Freshness threshold for cached observation files.
Nonedisables staleness checks.
- Returns:
Provider-neutral curve with annual decimal rates.
- Return type:
- cache_status(*, date='latest', max_age_days=1.0)¶
Return memory and disk cache status for all configured FRED series.
- Parameters:
date (str | date)
max_age_days (float | None)
- Return type:
dict[str, object]
- clear_cache(*, date='latest')¶
Clear memory and disk observations for the configured date label.
- Parameters:
date (str | date)
- Return type:
None
- class abaquant.rates.ManualRateProvider(rates_by_maturity)¶
Bases:
objectProvider object that returns a manually supplied curve without network access.
Store manual annual decimal rates keyed by maturity in years.
- Parameters:
rates_by_maturity (Mapping[float, float])
- class abaquant.rates.RateCurve(observations, provider_name='manual', curve_date=None, retrieved_at_utc=None, provenance=None)¶
Bases:
objectProvider-neutral annual decimal rate curve.
- Parameters:
observations (sequence of FredObservation) – Curve points sorted internally by maturity. Rates are annual decimal rates; maturities are measured in years.
provider_name (str, default="manual") – Source label recorded for provenance.
curve_date (date | None, default=None) – Requested curve date.
Noneis allowed for synthetic or latest curves whose observations can have slightly different dates.retrieved_at_utc (datetime | None, default=None) – Retrieval or construction timestamp in UTC.
provenance (DataProvenance | None)
Notes
The class intentionally does not bootstrap a zero-coupon curve. It interpolates the supplied annual yields directly.
- classmethod from_rates(rates_by_maturity, *, curve_date=None, provider_name='manual')¶
Create a curve from manually supplied decimal annual rates.
- Parameters:
rates_by_maturity (mapping of float to float) – Mapping from maturity in years to annual decimal rate.
curve_date (date | str | None, default=None) – Optional observation date recorded for all synthetic points.
provider_name (str, default="manual") – Provenance label stored on the returned curve.
- Returns:
Curve constructed without making any provider request.
- Return type:
- property maturities: tuple[float, ...]¶
Return curve maturities in ascending order.
- property rates: tuple[float, ...]¶
Return annual decimal rates in ascending maturity order.
- as_frame()¶
Return the curve points as a tidy DataFrame.
- Returns:
Columns are
maturity_years,annual_rate,observation_date,series_id,provider_name, andraw_value_percent.- Return type:
pandas.DataFrame
- zero_rate(maturity, *, interpolation='linear', extrapolation='flat')¶
Interpolate an annual decimal zero-rate proxy for one maturity.
- Parameters:
maturity (float) – Requested maturity in years. Must be positive.
interpolation ({"linear"}, default="linear") – Interpolation method across the supplied curve points.
extrapolation ({"flat", "error"}, default="flat") – Out-of-range behavior.
"flat"returns the nearest endpoint rate;"error"raises when maturity is outside the curve range.
- Returns:
Annual decimal rate for the requested maturity.
- Return type:
float
- discount_factor(maturity, *, compounding='continuous')¶
Convert the interpolated annual rate into a discount factor.
- Parameters:
maturity (float) – Maturity in years.
compounding ({"continuous", "annual", "simple"}, default="continuous") – Discounting convention applied to the interpolated annual rate.
- Returns:
Present-value factor for one currency unit paid at
maturity.- Return type:
float
- visualize(*, backend=None, theme=None, save_path=None, filename=None)¶
Return a themed figure of the annual decimal rate curve.
The method follows AbaQuant’s visualization convention: it returns a backend-native figure and never calls
showautomatically.- Parameters:
backend (str | None)
filename (str | None)
- exception abaquant.rates.RatesProviderError¶
Bases:
RuntimeErrorRaised when an applied rate provider cannot supply usable data.
- exception abaquant.rates.RatesValidationError¶
Bases:
ValueErrorRaised when a rate-curve request violates a domain constraint.
- abaquant.rates.amortization_schedule(principal, period_rate, periods)¶
Construct the deterministic payment, interest, principal, and balance schedule of a level-payment loan.
- Parameters:
principal (float) – Initial invested amount or loan principal in currency units.
period_rate (float) – Effective interest rate per payment period in decimal units.
periods (int) – Number of discrete compounding or payment periods.
- Returns:
Tabular result with the index, column schema, units, and missing-value treatment defined by the module convention.
- Return type:
pandas.DataFrame
- abaquant.rates.annualized_covariance_from_returns(returns, periods=TRADING_DAYS)¶
Annualize the sample covariance matrix of periodic returns.
- Parameters:
returns (pd.DataFrame) – Periodic simple return observations; rows are observation dates and columns are assets when two-dimensional.
periods (int, default=TRADING_DAYS) – Number of discrete compounding or payment periods.
- Returns:
Tabular result with schema defined by the module-level convention.
- Return type:
pd.DataFrame
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.annualized_mean_returns_from_returns(returns, periods=TRADING_DAYS)¶
Annualize arithmetic mean returns from periodic observations.
- Parameters:
returns (pd.DataFrame) – Periodic simple return observations; rows are observation dates and columns are assets when two-dimensional.
periods (int, default=TRADING_DAYS) – Number of discrete compounding or payment periods.
- Returns:
One-dimensional labeled result aligned to the documented input order.
- Return type:
pd.Series
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.arithmetic_gradient_future_value(R1, G, i_m, n_m)¶
Compute accumulated value of an arithmetic-gradient payment stream.
- Parameters:
R1 (float) – First payment in a gradient cash-flow stream, in currency units.
G (float) – Arithmetic increment added to each successive payment, in currency units per period.
i_m (float) – Effective interest rate per gradient-payment period in decimal units.
n_m (float) – Number of gradient-payment periods.
- Returns:
Computed arithmetic gradient future value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.arithmetic_gradient_present_value(R1, G, i_m, n_m)¶
Compute present value of an arithmetic-gradient payment stream.
- Parameters:
R1 (float) – First payment in a gradient cash-flow stream, in currency units.
G (float) – Arithmetic increment added to each successive payment, in currency units per period.
i_m (float) – Effective interest rate per gradient-payment period in decimal units.
n_m (float) – Number of gradient-payment periods.
- Returns:
Computed arithmetic gradient present value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.beta_alpha_from_returns(asset_returns, market_returns, risk_free_rate, trading_days=252)¶
Estimate beta and alpha from paired asset and market return series.
- Parameters:
asset_returns (pd.Series) – Periodic return series for the asset.
market_returns (pd.Series) – Periodic return series for the market benchmark.
risk_free_rate (float) – Annual risk-free rate in decimal units.
trading_days (int, default=252) – Observations per year used to annualize regression statistics.
- Returns:
Named outputs of the beta alpha from returns calculation.
- Return type:
dict[str, float | pd.DataFrame]
- abaquant.rates.bond_price(face_value, coupon_rate_per_period, redemption_value, yield_per_period, periods)¶
Value a coupon bond from deterministic promised cash flows.
- Parameters:
face_value (float) – Bond face or par value in currency units.
coupon_rate_per_period (float) – Coupon rate per payment period in decimal units.
redemption_value (float) – Bond redemption value paid at maturity in currency units.
yield_per_period (float) – Yield rate per coupon period in decimal units.
periods (int) – Number of discrete compounding or payment periods.
- Returns:
(price, coupon_per_period, coupon_present_value, redemption_present_value)in positional order.- Return type:
tuple[float, float, float, float]
- abaquant.rates.bond_risk(face_value, coupon_rate_per_period, redemption_value, yield_per_period, periods, payments_per_year)¶
Compute price, duration, and convexity measures for a coupon bond.
- Parameters:
face_value (float) – Bond face or par value in currency units.
coupon_rate_per_period (float) – Coupon rate per payment period in decimal units.
redemption_value (float) – Bond redemption value paid at maturity in currency units.
yield_per_period (float) – Yield rate per coupon period in decimal units.
periods (int) – Number of discrete compounding or payment periods.
payments_per_year (int | float) – Coupon or payment frequency per year.
- Returns:
(price, Macaulay_duration_years, convexity_years_squared)under the implemented coupon-bond convention.- Return type:
tuple[float, float, float]
- abaquant.rates.bond_yield(price, face_value, coupon_rate_per_period, redemption_value, periods)¶
Solve the yield per coupon period consistent with an observed bond price.
- Parameters:
price (float) – Price or option premium in currency units.
face_value (float) – Bond face or par value in currency units.
coupon_rate_per_period (float) – Coupon rate per payment period in decimal units.
redemption_value (float) – Bond redemption value paid at maturity in currency units.
periods (int) – Number of discrete compounding or payment periods.
- Returns:
Computed bond yield as a dimensionless decimal quantity.
- Return type:
float
- abaquant.rates.capm_cost_of_equity(risk_free_rate, beta, market_return)¶
Compute the CAPM required return on equity.
- Parameters:
risk_free_rate (float) – Annual risk-free rate in decimal units.
beta (float) – Model-specific beta parameter; consult the module convention.
market_return (float) – Expected market return in decimal annual units.
- Returns:
Computed capm cost of equity as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.continuous_annuity_future_value(annual_flow, delta, years)¶
Compute accumulated value of a continuous cash-flow annuity.
- Parameters:
annual_flow (float) – Continuous cash-flow rate in currency units per year.
delta (float) – Constant force of interest in decimal annual units.
years (float) – Time horizon in years.
- Returns:
Computed continuous annuity future value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.continuous_annuity_present_value(annual_flow, delta, years)¶
Compute present value of a continuous cash-flow annuity.
- Parameters:
annual_flow (float) – Continuous cash-flow rate in currency units per year.
delta (float) – Constant force of interest in decimal annual units.
years (float) – Time horizon in years.
- Returns:
Computed continuous annuity present value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.continuous_future_value(principal, delta, periods)¶
Compute accumulated value under a constant force of interest.
- Parameters:
principal (float) – Initial invested amount or loan principal in currency units.
delta (float) – Constant force of interest in decimal annual units.
periods (float) – Number of discrete compounding or payment periods.
- Returns:
Computed continuous future value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.continuous_present_value(future_amount, delta, periods)¶
Compute discounted value under a constant force of interest.
- Parameters:
future_amount (float) – Target future amount in currency units.
delta (float) – Constant force of interest in decimal annual units.
periods (float) – Number of discrete compounding or payment periods.
- Returns:
Computed continuous present value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.continuous_to_effective_rate(delta)¶
Convert a constant force of interest to an effective annual rate.
- Parameters:
delta (float) – Constant force of interest in decimal annual units.
- Returns:
Computed continuous to effective rate as a dimensionless decimal quantity.
- Return type:
float
- abaquant.rates.continuous_to_nominal_rate(delta, compounds_per_year)¶
Convert a constant force of interest to a nominal annual rate.
- Parameters:
delta (float) – Constant force of interest in decimal annual units.
compounds_per_year (int | float) – Positive number of nominal compounding periods per year.
- Returns:
Computed continuous to nominal rate as a dimensionless decimal quantity.
- Return type:
float
- abaquant.rates.convert_nominal_frequency(nominal_rate, from_frequency, to_frequency)¶
Convert a nominal annual rate between compounding frequencies.
- Parameters:
nominal_rate (float) – Nominal annual interest rate in decimal units.
from_frequency (int | float) – Original nominal compounding frequency per year.
to_frequency (int | float) – Target nominal compounding frequency per year.
- Returns:
Computed convert nominal frequency as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.dcf_sensitivity_matrix(fcfs, terminal_growth_values, discount_rate_values, net_debt, shares_outstanding)¶
Evaluate DCF output across terminal-growth and discount-rate scenarios.
- Parameters:
fcfs (list[float] | np.ndarray) – Free-cash-flow sequence in currency units for DCF sensitivity analysis.
terminal_growth_values (list[float] | np.ndarray) – Terminal-growth-rate grid in decimal annual units for DCF sensitivity analysis.
discount_rate_values (list[float] | np.ndarray) – Discount-rate grid in decimal annual units for DCF sensitivity analysis.
net_debt (float) – Net debt deducted from enterprise value, in currency units.
shares_outstanding (float) – Number of shares outstanding used to convert equity value to value per share.
- Returns:
Tabular result with the index, column schema, units, and missing-value treatment defined by the module convention.
- Return type:
pandas.DataFrame
- abaquant.rates.dcf_valuation(fcf_base, projection_growth, terminal_growth, discount_rate, projection_years, net_debt, shares_outstanding)¶
Estimate enterprise and equity value from a deterministic discounted-cash-flow model.
- Parameters:
fcf_base (float) – Base-period free cash flow in currency units.
projection_growth (float) – Forecast free-cash-flow growth rate in decimal annual units.
terminal_growth (float) – Perpetual terminal-growth rate in decimal annual units.
discount_rate (float) – Annual discount rate in decimal units.
projection_years (int) – Number of explicit free-cash-flow forecast years.
net_debt (float) – Net debt deducted from enterprise value, in currency units.
shares_outstanding (float) – Number of shares outstanding used to convert equity value to value per share.
- Returns:
Named outputs of the dcf valuation calculation.
- Return type:
dict[str, float | list[float] | pd.DataFrame]
- abaquant.rates.decompose_periods(periods)¶
Decompose a real-valued period count into its implemented representation.
- Parameters:
periods (float) – Number of discrete compounding or payment periods.
- Returns:
Tabular result with schema defined by the module-level convention.
- Return type:
pd.DataFrame
- abaquant.rates.effective_annuity_future_value(payment, period_rate, periods, due=False)¶
Compute accumulated value of a level annuity under an effective period rate.
- Parameters:
payment (float) – Level payment amount in currency units per payment period.
period_rate (float) – Effective interest rate per payment period in decimal units.
periods (float) – Number of discrete compounding or payment periods.
due (bool, default=False) – Whether annuity payments occur at the beginning rather than end of each period.
- Returns:
Computed effective annuity future value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.effective_annuity_present_value(payment, period_rate, periods, due=False)¶
Compute present value of a level annuity under an effective period rate.
- Parameters:
payment (float) – Level payment amount in currency units per payment period.
period_rate (float) – Effective interest rate per payment period in decimal units.
periods (float) – Number of discrete compounding or payment periods.
due (bool, default=False) – Whether annuity payments occur at the beginning rather than end of each period.
- Returns:
Computed effective annuity present value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.effective_to_nominal_rate(effective_rate, compounds_per_year)¶
Convert an effective annual rate to a nominal annual rate.
- Parameters:
effective_rate (float) – Effective annual interest rate in decimal units.
compounds_per_year (int | float) – Positive number of nominal compounding periods per year.
- Returns:
Computed effective to nominal rate as a dimensionless decimal quantity.
- Return type:
float
- abaquant.rates.equal_weight(n_assets)¶
Construct or evaluate an equally weighted fully invested portfolio.
- Parameters:
n_assets (int) – Number of assets in the allocation problem.
- Returns:
Numeric array ordered consistently with the supplied strikes, time grid, assets, or state labels.
- Return type:
numpy.ndarray
- abaquant.rates.equal_weight_portfolio(asset_names, expected_returns, covariance, risk_free_rate)¶
Compute the result defined by
equal_weight_portfoliounder this module’s documented convention.- Parameters:
asset_names (list[str]) – Asset labels ordered consistently with expected returns and covariance.
expected_returns (np.ndarray) – Expected-return vector ordered consistently with portfolio weights and covariance.
covariance (np.ndarray) – Square covariance matrix ordered consistently with the weight vector.
risk_free_rate (float) – Annual risk-free rate in decimal units.
- Returns:
Positional outputs produced by the equal weight portfolio calculation.
- Return type:
tuple[float, float, float, dict[str, float]]
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.evaluate_custom_portfolio(prices, weights_by_asset, expected_return_fn, covariance_fn)¶
Compute the result defined by
evaluate_custom_portfoliounder this module’s documented convention.- Parameters:
prices (pd.DataFrame) – Price observations with dates on the index and assets on columns where applicable.
weights_by_asset (dict[str, float]) – Mapping from asset label to portfolio weight.
expected_return_fn (Callable[[pd.DataFrame], pd.Series]) – Callable that estimates expected returns from a price panel.
covariance_fn (Callable[[pd.DataFrame], pd.DataFrame]) – Callable that estimates a covariance matrix from a price panel.
- Returns:
Positional outputs produced by the evaluate custom portfolio calculation.
- Return type:
tuple[float, float, np.ndarray, list[str]]
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.evaluate_custom_portfolio_from_prices(prices, weights_by_asset)¶
Compute the result defined by
evaluate_custom_portfolio_from_pricesunder this module’s documented convention.- Parameters:
prices (pd.DataFrame) – Price observations with dates on the index and assets on columns where applicable.
weights_by_asset (dict[str, float]) – Mapping from asset label to portfolio weight.
- Returns:
Positional outputs produced by the evaluate custom portfolio from prices calculation.
- Return type:
tuple[float, float, np.ndarray, list[str]]
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.future_value(principal, rate, periods)¶
Compute the accumulated value of a present amount.
- Parameters:
principal (float) – Initial invested amount or loan principal in currency units.
rate (float) – Interest rate in decimal units under the stated compounding convention.
periods (float) – Number of discrete compounding or payment periods.
- Returns:
Computed future value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.geometric_gradient_future_value(R1, i_m, q_m, n_m)¶
Compute accumulated value of a geometric-gradient payment stream.
- Parameters:
R1 (float) – First payment in a gradient cash-flow stream, in currency units.
i_m (float) – Effective interest rate per gradient-payment period in decimal units.
q_m (float) – Growth rate of payments per gradient period in decimal units.
n_m (float) – Number of gradient-payment periods.
- Returns:
Computed geometric gradient future value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.geometric_gradient_present_value(R1, i, q, n)¶
Compute present value of a geometric-gradient payment stream.
- Parameters:
R1 (float) – First payment in a gradient cash-flow stream, in currency units.
i (float) – Effective interest rate per period in decimal units.
q (float) – Continuous dividend or carry yield in decimal annual units.
n (float) – Number of discrete periods, assets, or observations as determined by the callable.
- Returns:
Computed geometric gradient present value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.get_rate_curve(*, provider='fred', date='latest', api_key=None, series_by_maturity=None, cache_mode='memory', cache_directory=None, refresh_policy='if_stale', max_age_days=1.0)¶
Return a provider-backed risk-free-rate curve.
- Parameters:
provider ({"fred"} or provider object, default="fred") – Provider name or object exposing
rate_curve. FRED is the built-in live provider; manual providers can be used for deterministic examples.date (str | date, default="latest") – Curve date. A concrete date uses the latest available observation on or before that date.
api_key (str | None, default=None) – FRED API key. When omitted,
FRED_API_KEYis read by the provider.series_by_maturity (mapping of float to str, optional) – Custom FRED series mapping from maturity in years to series ID.
cache_mode ({"none", "memory", "disk"}, default="memory") – Observation cache mode.
cache_directory (str | pathlib.Path | None, default=None) – Disk cache directory used when
cache_mode='disk'.refresh_policy ({"cache_only", "if_missing", "if_stale", "refresh"}, default="if_stale") – Cache policy passed to the provider.
max_age_days (float | None, default=1.0) – Cache freshness threshold.
- Returns:
Provider-neutral curve exposing
zero_rateanddiscount_factor.- Return type:
- abaquant.rates.gordon_shapiro_valuation(next_dividend, required_return, growth_rate)¶
Value equity under the constant-growth Gordon–Shapiro dividend model.
- Parameters:
next_dividend (float) – Dividend expected in the next period, in currency units.
required_return (float) – Required equity return in decimal annual units.
growth_rate (float) – Constant growth rate in decimal annual units.
- Returns:
Computed gordon shapiro valuation as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.historical_mean_returns(prices, periods=TRADING_DAYS)¶
Estimate annualized arithmetic expected returns from historical prices.
- Parameters:
prices (pd.DataFrame) – Price observations with dates on the index and assets on columns where applicable.
periods (int, default=TRADING_DAYS) – Number of discrete compounding or payment periods.
- Returns:
One-dimensional labeled result aligned to the documented input order.
- Return type:
pd.Series
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.log_return_volatility(prices, periods=TRADING_DAYS)¶
Estimate annualized volatility from historical log returns.
- Parameters:
prices (pd.Series) – Price observations with dates on the index and assets on columns where applicable.
periods (int, default=TRADING_DAYS) – Number of discrete compounding or payment periods.
- Returns:
Computed log return volatility as a dimensionless decimal quantity.
- Return type:
float
- abaquant.rates.log_returns_from_prices(prices)¶
Compute logarithmic returns independently for each price series.
- Parameters:
prices (pd.DataFrame) – Price observations with dates on the index and assets on columns where applicable.
- Returns:
Tabular result with schema defined by the module-level convention.
- Return type:
pd.DataFrame
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.max_sharpe_portfolio(asset_names, expected_returns, covariance, risk_free_rate)¶
Compute the result defined by
max_sharpe_portfoliounder this module’s documented convention.- Parameters:
asset_names (list[str]) – Asset labels ordered consistently with expected returns and covariance.
expected_returns (np.ndarray) – Expected-return vector ordered consistently with portfolio weights and covariance.
covariance (np.ndarray) – Square covariance matrix ordered consistently with the weight vector.
risk_free_rate (float) – Annual risk-free rate in decimal units.
- Returns:
Positional outputs produced by the max sharpe portfolio calculation.
- Return type:
tuple[float, float, float, dict[str, float]]
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.maximum_sharpe_weights(mean_returns, covariance_matrix, risk_free_rate, bounds=(0.0, 1.0))¶
Solve the constrained maximum-Sharpe portfolio allocation problem.
- Parameters:
mean_returns (np.ndarray) – Expected-return vector ordered consistently with the covariance matrix.
covariance_matrix (np.ndarray) – Square covariance matrix ordered consistently with the asset order.
risk_free_rate (float) – Annual risk-free rate in decimal units.
bounds (tuple[float, float], default=(0.0, 1.0)) – Allocation bounds in the format accepted by the underlying optimizer.
- Returns:
Numeric array ordered consistently with the supplied strikes, time grid, assets, or state labels.
- Return type:
numpy.ndarray
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.min_variance_portfolio(asset_names, expected_returns, covariance, risk_free_rate)¶
Compute the result defined by
min_variance_portfoliounder this module’s documented convention.- Parameters:
asset_names (list[str]) – Asset labels ordered consistently with expected returns and covariance.
expected_returns (np.ndarray) – Expected-return vector ordered consistently with portfolio weights and covariance.
covariance (np.ndarray) – Square covariance matrix ordered consistently with the weight vector.
risk_free_rate (float) – Annual risk-free rate in decimal units.
- Returns:
Positional outputs produced by the min variance portfolio calculation.
- Return type:
tuple[float, float, float, dict[str, float]]
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.minimum_variance_weights(covariance_matrix, bounds=(0.0, 1.0))¶
Solve the constrained global minimum-variance allocation problem.
- Parameters:
covariance_matrix (np.ndarray) – Square covariance matrix ordered consistently with the asset order.
bounds (tuple[float, float], default=(0.0, 1.0)) – Allocation bounds in the format accepted by the underlying optimizer.
- Returns:
Numeric array ordered consistently with the supplied strikes, time grid, assets, or state labels.
- Return type:
numpy.ndarray
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.monte_carlo_portfolio_cloud(expected_returns, covariance, risk_free_rate, n_simulations=2500, seed=None)¶
Compute the result defined by
monte_carlo_portfolio_cloudunder this module’s documented convention.- Parameters:
expected_returns (np.ndarray) – Expected-return vector ordered consistently with portfolio weights and covariance.
covariance (np.ndarray) – Square covariance matrix ordered consistently with the weight vector.
risk_free_rate (float) – Annual risk-free rate in decimal units.
n_simulations (int, default=2500) – Number of simulated portfolio allocations.
seed (int | None, default=None) – Optional pseudo-random seed for reproducible simulation.
- Returns:
Positional outputs produced by the monte carlo portfolio cloud calculation.
- Return type:
tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.monte_carlo_var_cvar(annual_return, annual_volatility, portfolio_value, confidence_level, horizon_days, simulations=10000, seed=42)¶
Estimate value at risk and conditional value at risk by simulation.
- Parameters:
annual_return (float) – Annual expected return in decimal units.
annual_volatility (float) – Annual volatility in decimal units.
portfolio_value (float) – Current portfolio value in currency units.
confidence_level (float) – Confidence probability for a tail-risk measure.
horizon_days (int | float) – Risk-measure horizon in trading days.
simulations (int, default=10000) – Number of Monte Carlo simulations.
seed (int, default=42) – Optional pseudo-random seed for reproducible simulation.
- Returns:
Positional outputs produced by the monte carlo var cvar calculation.
- Return type:
tuple[float, float]
- abaquant.rates.multiples_valuation(value_metric, target_multiple)¶
Estimate value by applying a selected valuation multiple.
- Parameters:
value_metric (float) – Fundamental metric to which a valuation multiple is applied.
target_multiple (float) – Comparable-company valuation multiple applied to the selected metric.
- Returns:
Computed multiples valuation as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.mvsk_neg_utility(weights, daily_returns, lambda2=1.0, lambda3=0.5, lambda4=0.5)¶
Compute the result defined by
mvsk_neg_utilityunder this module’s documented convention.- Parameters:
weights (np.ndarray) – Portfolio weights, either a mapping keyed by asset or an ordered numeric vector as documented by the callable.
daily_returns (np.ndarray) – Daily simple-return matrix used by higher-moment portfolio objectives.
lambda2 (float, default=1.0) – Second-moment penalty coefficient in the MVSK utility.
lambda3 (float, default=0.5) – Third-moment reward or penalty coefficient in the MVSK utility.
lambda4 (float, default=0.5) – Fourth-moment penalty coefficient in the MVSK utility.
- Returns:
Computed mvsk neg utility as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.mvsk_portfolio(asset_names, expected_returns, covariance, daily_returns, risk_free_rate)¶
Compute the result defined by
mvsk_portfoliounder this module’s documented convention.- Parameters:
asset_names (list[str]) – Asset labels ordered consistently with expected returns and covariance.
expected_returns (np.ndarray) – Expected-return vector ordered consistently with portfolio weights and covariance.
covariance (np.ndarray) – Square covariance matrix ordered consistently with the weight vector.
daily_returns (np.ndarray) – Daily simple-return matrix used by higher-moment portfolio objectives.
risk_free_rate (float) – Annual risk-free rate in decimal units.
- Returns:
Positional outputs produced by the mvsk portfolio calculation.
- Return type:
tuple[float, float, float, dict[str, float]]
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.nominal_annuity_future_value(payment, nominal_rate, compounding_frequency, payment_frequency, years)¶
Compute accumulated value of a level annuity under nominal compounding.
- Parameters:
payment (float) – Level payment amount in currency units per payment period.
nominal_rate (float) – Nominal annual interest rate in decimal units.
compounding_frequency (int | float) – Positive number of nominal compounding periods per year.
payment_frequency (int | float) – Positive number of payments per year.
years (float) – Time horizon in years.
- Returns:
Computed nominal annuity future value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.nominal_annuity_present_value(payment, nominal_rate, compounding_frequency, payment_frequency, years)¶
Compute present value of a level annuity under nominal compounding.
- Parameters:
payment (float) – Level payment amount in currency units per payment period.
nominal_rate (float) – Nominal annual interest rate in decimal units.
compounding_frequency (int | float) – Positive number of nominal compounding periods per year.
payment_frequency (int | float) – Positive number of payments per year.
years (float) – Time horizon in years.
- Returns:
Computed nominal annuity present value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.nominal_to_continuous_rate(nominal_rate, compounds_per_year)¶
Convert a nominal annual rate to a constant force of interest.
- Parameters:
nominal_rate (float) – Nominal annual interest rate in decimal units.
compounds_per_year (int | float) – Positive number of nominal compounding periods per year.
- Returns:
Computed nominal to continuous rate as a dimensionless decimal quantity.
- Return type:
float
- abaquant.rates.nominal_to_effective_rate(nominal_rate, compounds_per_year)¶
Convert a nominal annual rate to an effective annual rate.
- Parameters:
nominal_rate (float) – Nominal annual interest rate in decimal units.
compounds_per_year (int | float) – Positive number of nominal compounding periods per year.
- Returns:
Computed nominal to effective rate as a dimensionless decimal quantity.
- Return type:
float
- abaquant.rates.number_of_periods(principal, future_amount, rate)¶
Solve for the number of compounding periods needed to reach a target amount.
- Parameters:
principal (float) – Initial invested amount or loan principal in currency units.
future_amount (float) – Target future amount in currency units.
rate (float) – Interest rate in decimal units under the stated compounding convention.
- Returns:
Computed number of periods as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.optimize_portfolio_strategies(prices, risk_free_rate=0.05, n_simulations=2500, seed=None)¶
Compute the result defined by
optimize_portfolio_strategiesunder this module’s documented convention.- Parameters:
prices (pd.DataFrame) – Price observations with dates on the index and assets on columns where applicable.
risk_free_rate (float, default=0.05) – Annual risk-free rate in decimal units.
n_simulations (int, default=2500) – Number of simulated portfolio allocations.
seed (int | None, default=None) – Optional pseudo-random seed for reproducible simulation.
- Returns:
Positional outputs produced by the optimize portfolio strategies calculation.
- Return type:
tuple[pd.Series, pd.DataFrame, dict[str, tuple[float, float, float, dict[str, float]]], tuple[np.ndarray, np.ndarray, np.ndarray]]
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.parametric_var(annual_return, annual_volatility, portfolio_value, confidence_level, horizon_days)¶
Estimate parametric value at risk under the implemented return distribution.
- Parameters:
annual_return (float) – Annual expected return in decimal units.
annual_volatility (float) – Annual volatility in decimal units.
portfolio_value (float) – Current portfolio value in currency units.
confidence_level (float) – Confidence probability for a tail-risk measure.
horizon_days (int | float) – Risk-measure horizon in trading days.
- Returns:
(var_amount, z_score, period_return, period_volatility). The second value is the normal quantile used in the VaR calculation; it is not CVaR.- Return type:
tuple[float, float, float, float]
- abaquant.rates.periods_for_annuity_future_value(future_value, payment, period_rate)¶
Solve the period count for a level-annuity accumulated-value target.
- Parameters:
future_value (float) – Target accumulated amount in currency units.
payment (float) – Level payment amount in currency units per payment period.
period_rate (float) – Effective interest rate per payment period in decimal units.
- Returns:
Computed periods for annuity future value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.periods_for_annuity_present_value(present_value, payment, period_rate)¶
Solve the period count for a level-annuity present-value target.
- Parameters:
present_value (float) – Target present amount in currency units.
payment (float) – Level payment amount in currency units per payment period.
period_rate (float) – Effective interest rate per payment period in decimal units.
- Returns:
Computed periods for annuity present value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.periods_for_arithmetic_gradient_future_value(future_value, R1, G, i_m)¶
Solve the period count for an arithmetic-gradient accumulated-value target.
- Parameters:
future_value (float) – Target accumulated amount in currency units.
R1 (float) – First payment in a gradient cash-flow stream, in currency units.
G (float) – Arithmetic increment added to each successive payment, in currency units per period.
i_m (float) – Effective interest rate per gradient-payment period in decimal units.
- Returns:
Computed periods for arithmetic gradient future value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.periods_for_arithmetic_gradient_present_value(present_value, R1, G, i_m)¶
Solve the period count for an arithmetic-gradient present-value target.
- Parameters:
present_value (float) – Target present amount in currency units.
R1 (float) – First payment in a gradient cash-flow stream, in currency units.
G (float) – Arithmetic increment added to each successive payment, in currency units per period.
i_m (float) – Effective interest rate per gradient-payment period in decimal units.
- Returns:
Computed periods for arithmetic gradient present value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.periods_for_geometric_gradient_future_value(future_value, R1, i_m, q_m)¶
Solve the period count for a geometric-gradient accumulated-value target.
- Parameters:
future_value (float) – Target accumulated amount in currency units.
R1 (float) – First payment in a gradient cash-flow stream, in currency units.
i_m (float) – Effective interest rate per gradient-payment period in decimal units.
q_m (float) – Growth rate of payments per gradient period in decimal units.
- Returns:
Computed periods for geometric gradient future value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.periods_for_geometric_gradient_present_value(present_value, R1, i_m, q_m)¶
Solve the period count for a geometric-gradient present-value target.
- Parameters:
present_value (float) – Target present amount in currency units.
R1 (float) – First payment in a gradient cash-flow stream, in currency units.
i_m (float) – Effective interest rate per gradient-payment period in decimal units.
q_m (float) – Growth rate of payments per gradient period in decimal units.
- Returns:
Computed periods for geometric gradient present value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.perpetuity_present_value(payment, rate)¶
Compute the present value of a level perpetuity.
- Parameters:
payment (float) – Level payment amount in currency units per payment period.
rate (float) – Interest rate in decimal units under the stated compounding convention.
- Returns:
Computed perpetuity present value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.portfolio_return(weights, expected_returns)¶
Compute the weighted expected return of a portfolio.
- Parameters:
weights (np.ndarray) – Portfolio weights, either a mapping keyed by asset or an ordered numeric vector as documented by the callable.
expected_returns (np.ndarray) – Expected-return vector ordered consistently with portfolio weights and covariance.
- Returns:
Computed portfolio return as a dimensionless decimal quantity.
- Return type:
float
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.portfolio_sharpe(return_, volatility, risk_free_rate=0.0)¶
Compute the annualized excess-return-to-volatility ratio.
- Parameters:
return (float) – Expected portfolio return in decimal annual units.
volatility (float) – Volatility input: a positive annualized decimal number,
"realized", or"market"as documented by the applied interface.risk_free_rate (float, default=0.0) – Annual risk-free rate in decimal units.
return_ (float)
- Returns:
Computed portfolio sharpe as a scalar in the units implied by the input values.
- Return type:
float
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.portfolio_variance(weights, covariance)¶
Compute portfolio variance from a weight vector and covariance matrix.
- Parameters:
weights (np.ndarray) – Portfolio weights, either a mapping keyed by asset or an ordered numeric vector as documented by the callable.
covariance (np.ndarray) – Square covariance matrix ordered consistently with the weight vector.
- Returns:
Computed portfolio variance as a scalar in the units implied by the input values.
- Return type:
float
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.portfolio_volatility(weights, covariance)¶
Compute portfolio volatility from a weight vector and covariance matrix.
- Parameters:
weights (np.ndarray) – Portfolio weights, either a mapping keyed by asset or an ordered numeric vector as documented by the callable.
covariance (np.ndarray) – Square covariance matrix ordered consistently with the weight vector.
- Returns:
Computed portfolio volatility as a dimensionless decimal quantity.
- Return type:
float
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.present_value(future_amount, rate, periods)¶
Compute the discounted value of a future amount.
- Parameters:
future_amount (float) – Target future amount in currency units.
rate (float) – Interest rate in decimal units under the stated compounding convention.
periods (float) – Number of discrete compounding or payment periods.
- Returns:
Computed present value as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.present_value_of_dividends(dividend_amount, payments_per_year, rate, total_years, compounding='Continuous')¶
Discount a level dividend stream to present value.
- Parameters:
dividend_amount (float) – Level dividend payment in currency units.
payments_per_year (int) – Coupon or payment frequency per year.
rate (float) – Interest rate in decimal units under the stated compounding convention.
total_years (float) – Number of years over which the dividend stream is paid.
compounding (str, default='Continuous') – Compounding convention or frequency accepted by the implementation.
- Returns:
Computed present value of dividends as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.present_value_of_irregular_cashflows(amounts, times_years, rate, compounding='Continuous')¶
Discount irregular dated cash flows to present value.
- Parameters:
amounts (list[float] | np.ndarray) – Cash-flow amounts in currency units, ordered consistently with
times_years.times_years (list[float] | np.ndarray) – Cash-flow times in years, ordered consistently with
amounts.rate (float) – Interest rate in decimal units under the stated compounding convention.
compounding (str, default='Continuous') – Compounding convention or frequency accepted by the implementation.
- Returns:
Computed present value of irregular cashflows as a scalar in the units implied by the input values.
- Return type:
float
- abaquant.rates.rate_of_return(principal, future_amount, periods)¶
Solve for the effective periodic return implied by two values and a horizon.
- Parameters:
principal (float) – Initial invested amount or loan principal in currency units.
future_amount (float) – Target future amount in currency units.
periods (float) – Number of discrete compounding or payment periods.
- Returns:
Computed rate of return as a dimensionless decimal quantity.
- Return type:
float
- abaquant.rates.reinvestment_table(principal, nominal_rate, years)¶
Build the deterministic year-by-year reinvestment table.
- Parameters:
principal (float) – Initial invested amount or loan principal in currency units.
nominal_rate (float) – Nominal annual interest rate in decimal units.
years (float) – Time horizon in years.
- Returns:
Tabular result with the index, column schema, units, and missing-value treatment defined by the module convention.
- Return type:
pandas.DataFrame
- abaquant.rates.required_equity_return(next_dividend, current_price, growth_rate)¶
Infer the constant-growth required equity return from dividend and price inputs.
- Parameters:
next_dividend (float) – Dividend expected in the next period, in currency units.
current_price (float) – Current equity price in currency units.
growth_rate (float) – Constant growth rate in decimal annual units.
- Returns:
Computed required equity return as a dimensionless decimal quantity.
- Return type:
float
- abaquant.rates.risk_parity_objective(weights, covariance)¶
Compute the result defined by
risk_parity_objectiveunder this module’s documented convention.- Parameters:
weights (np.ndarray) – Portfolio weights, either a mapping keyed by asset or an ordered numeric vector as documented by the callable.
covariance (np.ndarray) – Square covariance matrix ordered consistently with the weight vector.
- Returns:
Computed risk parity objective as a scalar in the units implied by the input values.
- Return type:
float
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.risk_parity_portfolio(asset_names, expected_returns, covariance, risk_free_rate)¶
Compute the result defined by
risk_parity_portfoliounder this module’s documented convention.- Parameters:
asset_names (list[str]) – Asset labels ordered consistently with expected returns and covariance.
expected_returns (np.ndarray) – Expected-return vector ordered consistently with portfolio weights and covariance.
covariance (np.ndarray) – Square covariance matrix ordered consistently with the weight vector.
risk_free_rate (float) – Annual risk-free rate in decimal units.
- Returns:
Positional outputs produced by the risk parity portfolio calculation.
- Return type:
tuple[float, float, float, dict[str, float]]
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.sample_covariance(prices, periods=TRADING_DAYS)¶
Estimate an annualized covariance matrix from historical prices.
- Parameters:
prices (pd.DataFrame) – Price observations with dates on the index and assets on columns where applicable.
periods (int, default=TRADING_DAYS) – Number of discrete compounding or payment periods.
- Returns:
Tabular result with schema defined by the module-level convention.
- Return type:
pd.DataFrame
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.simple_returns_from_prices(prices)¶
Compute simple returns independently for each price series.
- Parameters:
prices (pd.DataFrame) – Price observations with dates on the index and assets on columns where applicable.
- Returns:
Tabular result with schema defined by the module-level convention.
- Return type:
pd.DataFrame
Notes
This is an analytical in-sample calculation. It does not by itself model transaction costs, execution effects, taxes, or future return uncertainty.
- abaquant.rates.weighted_average_cost_of_capital(cost_of_equity, equity_weight, cost_of_debt, tax_rate)¶
Compute after-tax weighted average cost of capital.
- Parameters:
cost_of_equity (float) – Cost of equity in decimal annual units.
equity_weight (float) – Capital-structure equity weight, expressed as a fraction.
cost_of_debt (float) – Pre-tax cost of debt in decimal annual units.
tax_rate (float) – Corporate tax rate as a decimal fraction.
- Returns:
Computed weighted average cost of capital as a scalar in the units implied by the input values.
- Return type:
float