Calculate the Skewness of an investment portfolio or asset’s returns.

Skewness is a statistical measure used in finance to assess the asymmetry in the distribution of returns for an investment portfolio or asset over a defined period. It offers valuable insights into the shape of the return distribution, indicating whether returns are skewed towards the positive or negative side of the mean. Skewness is a crucial tool for investors and analysts seeking to understand the potential risk and return characteristics of an investment, aiding in the assessment of the distribution’s tails and potential outliers. It provides a means to gauge the level of skew in returns, enabling more informed investment decisions and risk management strategies.

Also known as: return distribution asymmetry, tail skew.

No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Skewness for you. Just ask in plain English.

Calculate the Skewness in Python

The Skewness is available in the Risk module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_skewness as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(["MSFT", "AAPL", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")

toolkit.risk.get_skewness()

Which returns:

  MSFT AAPL TSLA
2019 -0.194 -0.9216 -0.0646
2020 -0.0747 -0.0586 -0.1824
2021 -0.0194 -0.0716 0.6572
2022 0.1478 0.3164 -0.0263
2023 0.5252 0.0318 -0.0972

Parameters

get_skewness accepts the following parameters:

  • period (str, optional): The data frequency for returns (daily, weekly, monthly, quarterly, or yearly). Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”.
  • within_period (bool, optional): Whether to calculate the Skewness within the specified period or for the entire period. Thus whether to look at the Skewness within a specific year (if period = ‘yearly’) or look at the entirety of all years. Defaults to True.
  • rolling (int, optional): The rolling window size to use for the calculation. If set, Skewness is calculated over a rolling window of this many periods across the full return history instead of per period. Defaults to None.
  • rounding (int | None, optional): The number of decimals to round the results to. Defaults to 4.
  • growth (bool, optional): Whether to calculate the growth of the Skewness values over time. Defaults to False.
  • lag (int | list[int], optional): The lag to use for the growth calculation. Defaults to 1.
  • standardize (bool, optional): Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.

The Risk module page introduces the module, and the sidebar lists all of its functions.

Share