Trailing Returns

Calculate the trailing returns of every ticker up to its last close: month to date, the last 3 and 6 months, year to date, the last year, the last 3, 5 and 10 years (annualized) and since the start of the data (annualized), the table of returns fund factsheets show.

The formula is as follows:

\[\text{Trailing Return} = \frac{\text{Last Close}}{\text{Close at the Start of the Window}} - 1\] \[\text{Annualized Trailing Return} = (1 + \text{Trailing Return})^{\frac{365.25}{\text{Calendar Days in the Window}}} - 1\]

The close at the start of a window is the last close on or before the date the window lies before the last close (e.g. 3 months earlier). When the last close falls on the last business day of its month, the windows run from month end to month end (a history up to 30 June has its 3 month return from the close of 31 March). Month to date and year to date start from the last close of the previous month and year. The returns of 3 years and longer are annualized over the calendar days of the window, and the return since inception is the Compound Annual Growth Rate over the date range (see get_compound_growth_rate). The returns use the dividend-adjusted close, so they are total returns.

Also known as: trailing performance, period returns, MTD, YTD, 1Y, 3Y, 5Y, 10Y returns.

Example · AAPL, MSFT, KO · 2015 to 2025

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

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["AAPL", "MSFT", "KO"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2015-01-01",
    end_date="2025-12-31",
)

toolkit.performance.get_trailing_returns()

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

What were the trailing returns of Apple, Microsoft, Coca-Cola and the S&P 500 at the end of 2025, from month to date to ten years and since 2015?

Which returns:

Parameters

get_trailing_returns accepts the following parameters.

ParameterTypeDescriptionExample
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

References

Share