Returns
Calculate the Return of an investment portfolio or asset for a given period based on the daily historical returns.
The period Return is obtained by compounding the daily returns within each period. If cumulative is set to True, the period returns within the selected date range are compounded further into a cumulative return (growth of 1) instead.
The formula is as follows:
\[\text{Period Return} = ((1 + \text{Daily Return}\; 1) \cdot (1 + \text{Daily Return}\; 2) \cdot ... \cdot (1 + \text{Daily Return}\; N)) - 1\] \[\text{Cumulative Return} = (1 + \text{Period Return}\; 1) \cdot (1 + \text{Period Return}\; 2) \cdot ... \cdot (1 + \text{Period Return}\; N)\]The compounding starts at 1 at the beginning of the date range, so the first value is 1 plus the return of the first period.
The first daily return in the range is that of the second trading day: the prices start at the start_date, so the move from the previous close into the first day is not part of it. For a year-to-date or calendar-year return, set start_date to the last trading day of the previous year (e.g. start_date=”2025-12-31” for the return of 2026 so far), so the first period starts from that close.
A period without any daily return for a ticker (before it listed, or a gap in its history) is NaN rather than 0, and the cumulative return carries the previous value past such a period.
Also known as: periodic return.
Returns in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_returns as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(
["ASML.AS", "SAP.DE", "MC.PA"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.performance.get_returns()
Or, after setting up the Finance Toolkit MCP, ask:
What were the yearly returns of ASML, SAP, LVMH and the S&P 500 from 2021 to 2025?
Which returns:
| Date | ASML.AS | SAP.DE | MC.PA | Benchmark |
|---|---|---|---|---|
| 2021 | 0.748 | 0.2018 | 0.4345 | 0.3058 |
| 2022 | -0.2789 | -0.2049 | -0.0478 | -0.1818 |
| 2023 | 0.3664 | 0.4709 | 0.0958 | 0.2615 |
| 2024 | 0.0035 | 0.7229 | -0.1179 | 0.2493 |
| 2025 | 0.3709 | -0.115 | 0.0393 | 0.1778 |
Parameters
get_returns accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The data frequency for returns (weekly, monthly, quarterly, or yearly). Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”. | "quarterly" |
cumulative | bool | Whether to return the cumulative return over time instead of the discrete return per period. Defaults to False. | True |
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 |
growth | bool | Whether to calculate the growth of the Return values over time. Defaults to False. | True |
lag | int | list[int] | The lag to use for the growth calculation. Defaults to 1. | 4 |
standardize | bool | Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. | True |