Calendar Returns
Calculate the calendar returns of every ticker: the return of every month with the years as the rows and the months as the columns, and the return of the whole year, the monthly returns table of fund factsheets.
The formula is as follows:
\[\text{Month Return} = ((1 + \text{Daily Return}\; 1) \cdot (1 + \text{Daily Return}\; 2) x \ldots x (1 + \text{Daily Return}\; N)) - 1\] \[\text{Year Return} = ((1 + \text{Month Return}\; 1) x \ldots x (1 + \text{Month Return}\; 12)) - 1\]A month without any return (before the start date or a listing, or after the end date) is NaN, and the Year compounds the months it has, so a partial first or last year is the return over the months covered. The returns use the dividend-adjusted close, so they are total returns.
Also known as: monthly returns table, return table, calendar year returns.
Example · AAPL, MSFT · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_calendar_returns:
from financetoolkit import Toolkit
toolkit = Toolkit(
["AAPL", "MSFT"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.performance.get_calendar_returns()["AAPL"].T
Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:
What did Apple return in each month and each year from 2021 to 2025?
Which returns:
| Item | 2021 | 2022 | 2023 | 2024 | 2025 |
|---|---|---|---|---|---|
| Jan | 0.0197 | -0.0157 | 0.1105 | -0.0422 | -0.0576 |
| Feb | -0.0797 | -0.0541 | 0.0232 | -0.0185 | 0.0259 |
| Mar | 0.0073 | 0.0575 | 0.1186 | -0.0513 | -0.0815 |
| Apr | 0.0762 | -0.0971 | 0.0290 | -0.0067 | -0.0434 |
| May | -0.0505 | -0.0545 | 0.0461 | 0.1302 | -0.0536 |
| Jun | 0.0991 | -0.0814 | 0.0943 | 0.0956 | 0.0215 |
| Jul | 0.0650 | 0.1886 | 0.0128 | 0.0544 | 0.0117 |
| Aug | 0.0425 | -0.0312 | -0.0424 | 0.0324 | 0.1196 |
| Sep | -0.0680 | -0.1210 | -0.0887 | 0.0175 | 0.0969 |
| Oct | 0.0587 | 0.1096 | -0.0026 | -0.0304 | 0.0618 |
| Nov | 0.1051 | -0.0330 | 0.1138 | 0.0517 | 0.0324 |
| Dec | 0.0742 | -0.1223 | 0.0136 | 0.0552 | -0.0251 |
| Year | 0.3806 | -0.2640 | 0.4901 | 0.3071 | 0.0905 |
13 rows
Parameters
get_calendar_returns accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
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 |
References
- Library Shares similar logic as quantstats’ monthly_returns
- Library Shares similar logic as ffn’s PerformanceStats (return_table)
- Library Shares similar logic as PerformanceAnalytics (R)’s table.CalendarReturns