Return Distribution

Calculate the Return Distribution: how many of each asset’s returns fall in each bin of equal width, the table behind a histogram of the returns.

The bins are centred on multiples of the width, so with a width of 0.02 (two percentage points) they are centred on …, -0.02, 0, 0.02, …, each running from half a width below its centre to half a width above it. It shows the shape the summary statistics (Volatility, Skewness, Kurtosis) condense into single numbers: whether the returns cluster around zero, lean to one side or have a few far out in the tails.

The formula is as follows:

\[\text{Bin of a return} = \left\lfloor \frac{\text{Return}}{\text{Bin Width}} + 0.5 \right\rfloor\] \[\text{Bin Center} = \text{Bin} \cdot \text{Bin Width}\] \[\text{Count} = \text{the number of returns in the bin},\;\; \text{or that number divided by the asset's number of returns when relative}\]

Also known as: return histogram, frequency distribution of returns.

Example · VTI, BND · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_return_distribution:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["VTI", "BND"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.risk.get_return_distribution(period="weekly", bin_width=0.02)

Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:

How were the weekly returns of VTI, BND and the S&P 500 from 2021 to 2025 spread over bins of two percentage points?

Which returns:

Parameters

get_return_distribution accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe data frequency for returns. Options are: “daily”, “weekly”, “monthly”, “quarterly”, “yearly”. Defaults to “daily”."weekly"
bin_widthfloatThe width of each bin as a return, e.g. 0.02 for two percentage points. Defaults to 0.01.0.01
relativeboolWhether to give each bin’s share of the asset’s returns instead of the count. Defaults to False.False
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise).2
show_columnsstr | list[str] | NoneThe 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
Share