sf_quant.performance.generate_leverage_chart#

sf_quant.performance.generate_leverage_chart(leverage: LeverageSchema, title: str, subtitle: str | None = None, file_name: str | None = None) None#

Plot portfolio leverage over time.

This function generates a line chart of leverage. Leverage is expressed as the sum of absolute weights (e.g., 1.0 = fully invested).

Parameters#

leverageLeverageSchema

Portfolio leverage validated against LeverageSchema. Must include the following columns:

  • date (date): The observation date.

  • leverage (float): Daily portfolio leverage.

titlestr

The chart’s main title.

subtitlestr or None, optional

The chart’s subtitle, shown beneath the main title. Defaults to None.

file_namestr, optional

If not None, the plot is saved to the given file path. Defaults to just displaying the chart.

Returns#

None

Displays the leverage chart using Matplotlib and Seaborn.

Notes#

  • Leverage = 1.0 indicates fully invested with no leverage or shorting.

  • Leverage > 1.0 indicates use of margin or shorting.

  • Leverage is expressed as a ratio (not percentage).