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, following the formula:
\[\text{Period Return} = ((1 + \text{Return} 1) \cdot (1 + \text{Return} 2) \cdot ... \cdot (1 + \text{Return} N)) - 1\]If cumulative is set to True, the period returns are compounded further into a cumulative return over time instead. The cumulative return is always rebased to start at 1 at the beginning of the selected date range.
Also known as: periodic return.
No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Returns for you. Just ask in plain English.
Calculate the Returns in Python
The Returns is available in the Performance module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_returns as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(["AMZN", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")
toolkit.performance.get_returns(period="yearly")
Which returns:
| Date | AMZN | TSLA | Benchmark |
|---|---|---|---|
| 2021 | 0.0236 | 0.4983 | 0.2701 |
| 2022 | -0.496 | -0.6503 | -0.1949 |
| 2023 | 0.8089 | 1.0174 | 0.2429 |
| 2024 | 0.4449 | 0.6255 | 0.2339 |
| 2025 | 0.0516 | 0.1129 | 0.1638 |
| 2026 | 0.0508 | -0.1254 | 0.0918 |
Parameters
get_returns accepts the following parameters:
- period (str, optional): The data frequency for returns (weekly, monthly, quarterly, or yearly). Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”.
- cumulative (bool, optional): Whether to return the cumulative return over time instead of the discrete return per period. Defaults to False.
- 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 Return 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.
Related Performance Metrics
The Performance module page introduces the module, and the sidebar lists all of its functions.