Calculate portfolio performance metrics for a specified period.

This method calculates key performance metrics, such as returns, for the portfolio over a specified period. The available periods are ‘yearly’, ‘quarterly’, ‘monthly’, ‘weekly’, and ‘daily’. It uses the positions overview dataset for these calculations. If the necessary data has not been collected, it triggers the collection of historical and benchmark data.

Portfolio Performance in Python

get_portfolio_performance is part of the Portfolio module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_portfolio_performance as shown below.

from financetoolkit import Portfolio

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

portfolio.get_portfolio_performance(period='weekly')

Which returns:

Date Identifier Volume Costs Invested Amount Realized Proceeds Current Value Invested Weight Current Weight Return
2026-08-10/2026-08-16 META 15 -1 4796.75 0 8923.8 0.0344 0.008 0.8604
2026-08-10/2026-08-16 MPWR 116 -27 30128.9 419.755 160208 0.2159 0.143 4.3313
2026-08-10/2026-08-16 MSFT 105 -11 4384.18 105.59 53136.3 0.0314 0.0474 11.1441
2026-08-10/2026-08-16 NFLX 114 -32 16446.9 2114.39 8697.06 0.1179 0.0078 -0.3426
2026-08-10/2026-08-16 NVDA 69 -27 199.66 30.8599 15011 0.0014 0.0134 74.3371
2026-08-10/2026-08-16 OXY 27 -15 1443.45 355.587 1583.55 0.0103 0.0014 0.3434
2026-08-10/2026-08-16 SKY 126 -23 2497.75 195.613 11716.7 0.0179 0.0105 3.7692
2026-08-10/2026-08-16 VOO 77 -12 18684.8 308.375 54720.1 0.1339 0.0488 1.9451
2026-08-10/2026-08-16 VSS 98 -21 8433.99 797.842 15521.2 0.0604 0.0138 0.9349
2026-08-10/2026-08-16 WMT 92 -18 1779.63 118.103 10364.7 0.0128 0.0092 4.8904

Parameters

get_portfolio_performance accepts the following parameters:

  • period (str | None): The time period for which portfolio performance metrics should be calculated. It can be one of the following: ‘yearly’, ‘quarterly’, ‘monthly’, ‘weekly’, or ‘daily’. If None, the default period is ‘quarterly’ (if the ‘quarterly’ attribute is set to True), otherwise, it defaults to ‘yearly’.
  • exclude_sold_positions (bool): A flag indicating whether to exclude sold positions.
  • rounding (int | None): The number of decimal places to round the output to. If None, it defaults to the rounding precision specified in the configuration.
Share