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:
| Bin Center | VTI | BND | Benchmark |
|---|---|---|---|
| -0.1 | 1 | 0 | 1 |
| -0.08 | 0 | 0 | 0 |
| -0.06 | 4 | 0 | 3 |
| -0.04 | 11 | 0 | 13 |
| -0.02 | 59 | 27 | 53 |
| 0.0 | 90 | 210 | 93 |
| 0.02 | 70 | 23 | 76 |
| 0.04 | 16 | 0 | 14 |
| 0.06 | 9 | 0 | 7 |
9 rows
Parameters
get_return_distribution accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The data frequency for returns. Options are: “daily”, “weekly”, “monthly”, “quarterly”, “yearly”. Defaults to “daily”. | "weekly" |
bin_width | float | The width of each bin as a return, e.g. 0.02 for two percentage points. Defaults to 0.01. | 0.01 |
relative | bool | Whether to give each bin’s share of the asset’s returns instead of the count. Defaults to False. | False |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 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 |