Collect and align historical benchmark data with the portfolio’s data.

The following columns are included:

  • Open: the opening price for the benchmark over time.
  • High: the highest price for the benchmark over time.
  • Low: the lowest price for the benchmark over time.
  • Close: the closing price for the benchmark over time.
  • Adj Close: the adjusted closing price for the benchmark over time.
  • Volume: the volume of the benchmark over time.
  • Dividends: the dividends of the benchmark over time. -

Returns: the returns of the benchmark over time.

  • Cumulative Return: the cumulative return of the benchmark over time.

Volatility, Excess Return and Excess Volatility are not included here. These are available via the Risk module (e.g. toolkit.risk.get_volatility) and the Performance module (e.g. toolkit.performance.get_excess_return) instead.

This method retrieves historical benchmark data (daily and weekly) for the portfolio, based on a specified benchmark ticker or a mapping of portfolio tickers to their corresponding benchmark tickers. The retrieved benchmark data is then aligned with the portfolio’s historical data, ensuring that the dates of the benchmark data match the dates of the portfolio’s transactions.

The method can retrieve data for a single benchmark ticker or for multiple benchmarks depending on the portfolio tickers. The resulting benchmark data is returned in a structured DataFrame.

Benchmark Historical Data in Python

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call collect_benchmark_historical_data as shown below.

from financetoolkit import Portfolio

portfolio = Portfolio(example=True, api_key="FINANCIAL_MODELING_PREP_KEY")

portfolio.collect_benchmark_historical_data()

Which returns:

Date Open High Low Close Adj Close Volume Dividends Return Cumulative Return
2026-09-24 7666.99 7719.01 7662.57 7704.13 7704.13 5.31639e+09 0 -0.000246547 5.34463
2026-09-25 7709.86 7752.07 7693.08 7743.41 7743.41 4.49918e+09 0 0.0050986 5.37188
2026-09-28 7721.7 7724.15 7666.6 7683.69 7683.69 5.12971e+09 0 -0.0077124 5.33045
2026-09-29 7699.6 7699.6 7653.55 7670.84 7670.84 5.02359e+09 0 -0.00167239 5.32154
2026-09-30 7688.99 7722.88 7651.54 7651.54 7651.54 4.27655e+09 0 -0.002516 5.30815
2026-10-01 7666.47 7684.75 7616.78 7666.45 7666.45 5.7838e+09 0 0.00194865 5.31849
2026-10-02 7726.24 7754.67 7700.51 7722.72 7722.72 5.27743e+09 0 0.00733977 5.35753
2026-10-05 7730.86 7794.35 7727.59 7773.95 7773.95 5.8409e+09 0 0.00663367 5.39307
2026-10-06 7805.96 7844.52 7805.96 7818.93 7818.93 5.01965e+09 0 0.00578599 5.42428
2026-10-07 7792.98 7807.02 7763.34 7801.77 7801.77 5.11115e+09 0 -0.0021947 5.41237

Parameters

collect_benchmark_historical_data accepts the following parameters.

ParameterTypeDescriptionExample
benchmark_tickerstr | NoneThe benchmark ticker symbol. Defaults to None, the benchmark ticker given to the Portfolio, or the one of the configuration file when none was given."QQQ"
Share