qis.lever_returns

qis.lever_returns(returns, leverage, financing_rate=0.0, periods_per_year=None)[source]

Apply constant leverage to an unlevered asset return series.

Forward direction of delever_returns:

r_portfolio = (1 + L) * r_asset - L * r_financing

Useful for stress-testing unlevered strategies under hypothetical leverage, or for comparing managed-account performance against a levered benchmark.

Parameters:
  • returns (Series | DataFrame) – Period returns of the unlevered asset (Series or DataFrame).

  • leverage (float) – Finite, nonnegative leverage ratio L (debt / equity). Booleans are invalid.

  • financing_rate (float | Series) – Annualised financing rate. A scalar must be finite and real. Observed Series values must be finite and real; ordinary or nullable missing values remain unavailable. For nonzero leverage, both date axes must be DatetimeIndex objects without NaT and must both be timezone-naive or timezone-aware. Different aware zones align by absolute instant. Series observations are sorted chronologically; the period (t-1, t] is charged the rate known at the previous return date t-1, the latest quote dated on or before it, and the first return date the latest quote dated strictly before it (missing when there is none). Duplicate funding dates are invalid.

  • periods_per_year (int) – Strictly positive integer annualisation factor. If None, inferred from the index.

Returns:

Levered returns matching the input shape and pandas labels. Zero leverage returns an independent copy, even when financing data is unavailable.

Raises:

ValueError – If leverage is not a finite nonnegative real scalar; if an explicit periods_per_year is not a positive integer; or, for nonzero leverage, if financing values or date axes violate the contract described above.

Return type:

Series | DataFrame

Example

Apply debt/equity of 1 to synthetic arithmetic returns, with a 6% annual financing cost on a 252-period basis.

>>> from qis.datasets import generate_synthetic_prices
>>> prices = generate_synthetic_prices(start='2024-01-02', end='2024-03-28')
>>> asset_returns = to_returns(prices['SEQ_US'], is_log_returns=False).dropna()
>>> levered = lever_returns(asset_returns, leverage=1.0,
...                         financing_rate=0.06, periods_per_year=252)
>>> np.testing.assert_allclose(levered, 2 * asset_returns - 0.06 / 252)