Gross Leverage
Calculate the gross leverage of the portfolio, the value of its long and short positions together as a multiple of its net value:
\[\text{Gross Leverage} = \frac{\sum\left|\text{value of every position}\right|}{\sum \;\text{value of every position}}\]A portfolio of long positions has a gross leverage of 1; short positions raise it, e.g. to 1.6 for a 130/30 portfolio. Over weeks, months, quarters or years the values at the end of the period are shown. The measure is defined in pyfolio (Quantopian).
Also known as: gross exposure, leverage ratio.
Example
Install the Finance Toolkit with pip install financetoolkit -U, then call get_gross_leverage:
from financetoolkit import Portfolio
portfolio = Portfolio(example=True, api_key="FINANCIAL_MODELING_PREP_KEY")
portfolio.get_gross_leverage(period="yearly")
Which returns:
| Date | Gross Value | Net Value | Gross Leverage |
|---|---|---|---|
| 2000 | 2,392.28 | 2,392.28 | 1 |
| 2001 | 4,798.28 | 4,798.28 | 1 |
| 2002 | 5,422.30 | 5,422.30 | 1 |
| 2003 | 8,204.56 | 8,204.56 | 1 |
| 2004 | 10,365.30 | 10,365.30 | 1 |
| 2005 | 13,539.30 | 13,539.30 | 1 |
| 2006 | 16,209.00 | 16,209.00 | 1 |
| 2007 | 19,071.40 | 19,071.40 | 1 |
| 2008 | 12,108.20 | 12,108.20 | 1 |
| 2009 | 20,985.50 | 20,985.50 | 1 |
| 2010 | 25,801.10 | 25,801.10 | 1 |
| 2011 | 26,933.10 | 26,933.10 | 1 |
| 2012 | 34,851.30 | 34,851.30 | 1 |
| 2013 | 49,217.50 | 49,217.50 | 1 |
| 2014 | 54,772.70 | 54,772.70 | 1 |
| 2015 | 61,747.10 | 61,747.10 | 1 |
| 2016 | 78,378.20 | 78,378.20 | 1 |
| 2017 | 117,708.00 | 117,708.00 | 1 |
| 2018 | 125,233.00 | 125,233.00 | 1 |
| 2019 | 206,431.00 | 206,431.00 | 1 |
| 2020 | 328,089.00 | 328,089.00 | 1 |
| 2021 | 435,818.00 | 435,818.00 | 1 |
| 2022 | 337,393.00 | 337,393.00 | 1 |
| 2023 | 547,989.00 | 547,989.00 | 1 |
| 2024 | 739,785.00 | 739,785.00 | 1 |
| 2025 | 908,218.00 | 908,218.00 | 1 |
| 2026 | 892,993.00 | 892,993.00 | 1 |
27 rows
Parameters
get_gross_leverage accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The period whose last values are shown. Options are: “daily”, “weekly”, “monthly”, “quarterly”, “yearly”. Defaults to “daily”. | "weekly" |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the Portfolio’s rounding. | 2 |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
References
- Library Shares similar logic as pyfolio’s gross_lev