Portfolio Overview
Calculate and provide an overview of the portfolio’s key statistics, including performance metrics and cost-related information.
The following columns are included:
- Identifier: The name of the asset, specifically the ticker (e.g. AAPL)
- Volume: The net volume of the asset, i.e. every buy minus every sell.
- Costs: The total costs associated with the asset transactions.
- Price: The volume-weighted average price paid for the units that were bought. Sells do not enter this figure, so it stays a purchase price rather than a net cash figure.
- Invested: The total capital deployed in the asset, i.e. the value of every buy plus the absolute transaction costs. Sale proceeds are deliberately not netted off, because a denominator that shrinks with every profitable sale inflates the reported return and flips its sign once more cash has come out than went in.
- Latest Price: The latest available price of the asset obtained from historical data.
- Latest Value: The market value of the position still held, i.e. Volume times Latest Price.
- Return: The total return on the capital deployed, i.e. Return Value divided by Invested. This covers realized and unrealized results together and is NaN when nothing was invested.
- Return Value: The absolute profit or loss, i.e. Latest Value plus all sale proceeds minus Invested. This equals realized PnL plus unrealized PnL minus the transaction costs, where the realized PnL is the figure reported by get_transactions_overview.
- Benchmark Return: The return the identical cash flows would have produced in the benchmark. Every transaction buys or sells benchmark units for the exact cash amount of that transaction on that date, so the comparison is matched in money rather than in share count.
- Volatility: The annualized volatility of the asset over the most recent year, calculated via the Risk module (risk_model.get_volatility). For the aggregated “Portfolio” row, this is derived from the full covariance matrix of the underlying asset returns (Var_p = w^T * Cov * w, Markowitz, 1952) rather than a weighted average of individual volatilities, since the latter ignores diversification from imperfectly correlated assets.
- Benchmark Volatility: The annualized volatility of the asset’s benchmark over the most recent year, calculated via the Risk module (risk_model.get_volatility).
- Alpha: The alpha is based on the difference between the asset’s return and the benchmark return.
- Beta: The beta is based on the asset’s return and the benchmark return. It measures the asset’s volatility compared to the benchmark. A beta >1 indicates that the asset is more volatile than the benchmark and a beta <1 indicates that the asset is less volatile than the benchmark.
- Weight: The weight of the asset in the portfolio based on the latest market value and the total market value of the portfolio.
No inventory method (FIFO, LIFO or average cost) is applied here: “Return” measures the result of every unit of currency put into the position rather than the basis of the units that happen to remain. The inventory methods drive the realized PnL in get_transactions_overview instead.
The “Portfolio” row sums or averages units of different assets for “Volume”, “Price” and “Latest Price”, so those three carry no economic meaning at the portfolio level.
When recalculating these numbers, it is important to note that results are calculated before the rounding parameter is applied which can lead to some discrepancies in the results.
This method computes a detailed overview of the portfolio, calculating various key statistics such as performance, costs, and returns. If necessary data has not been collected, it will automatically trigger data collection using the collect_historical_data and collect_benchmark_historical_data methods. The portfolio overview is generated based on the portfolio dataset and benchmark data, and is rounded to the specified precision before being returned.
Portfolio Overview in Python
get_portfolio_overview is part of the Portfolio module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_portfolio_overview as shown below.
from financetoolkit import Portfolio
portfolio = Portfolio(example=True, api_key="FINANCIAL_MODELING_PREP_KEY")
portfolio.get_portfolio_overview()
Which returns:
| Identifier | Volume | Costs | Price | Invested | Latest Price | Latest Value | Return | Return Value | Benchmark Return | Volatility | Benchmark Volatility | Alpha | Beta | Weight |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| MPWR | 116 | -27 | 246.737 | 30128.9 | 1381.1 | 160208 | 4.3313 | 130498 | 0.7745 | 0.5948 | 0.1389 | 3.5569 | 1.8291 | 0.143 |
| MSFT | 105 | -11 | 39.7562 | 4384.18 | 506.06 | 53136.3 | 11.1441 | 48857.7 | 3.0307 | 0.3895 | 0.1389 | 8.1134 | 1.1724 | 0.0474 |
| NFLX | 114 | -32 | 131.32 | 16446.9 | 76.29 | 8697.06 | -0.3426 | -5635.5 | 1.4502 | 0.3739 | 0.1389 | -1.7928 | 1.0751 | 0.0078 |
| NVDA | 69 | -27 | 2.1316 | 199.66 | 217.55 | 15011 | 74.3371 | 14842.1 | 1.0435 | 0.3857 | 0.1389 | 73.2936 | 1.8266 | 0.0134 |
| OXY | 27 | -15 | 37.5907 | 1443.45 | 58.65 | 1583.55 | 0.3434 | 495.69 | 2.4847 | 0.3943 | 0.1389 | -2.1413 | 1.155 | 0.0014 |
| SKY | 126 | -23 | 18.1967 | 2497.75 | 92.99 | 11716.7 | 3.7692 | 9414.6 | 4.4275 | 0.4715 | 0.1389 | -0.6583 | 1.4026 | 0.0105 |
| VOO | 77 | -12 | 236.365 | 18684.8 | 710.65 | 54720.1 | 1.9451 | 36343.6 | 1.6037 | 0.1385 | 0.1389 | 0.3414 | 0.9961 | 0.0488 |
| VSS | 98 | -21 | 77.1834 | 8433.99 | 158.38 | 15521.2 | 0.9349 | 7885.1 | 2.2186 | 0.1932 | 0.1389 | -1.2837 | 0.79 | 0.0138 |
| WMT | 92 | -18 | 17.4419 | 1779.63 | 112.66 | 10364.7 | 4.8904 | 8703.19 | 3.3096 | 0.2607 | 0.1389 | 1.5808 | 0.4848 | 0.0092 |
| Portfolio | 2142 | -532 | 57.823 | 139539 | 523.214 | 1.12e+06 | 7.1016 | 990950 | 1.6887 | 0.3058 | 0.1389 | 5.413 | 1.3848 | 1 |
Parameters
get_portfolio_overview accepts the following parameters:
- include_portfolio (bool): A boolean flag indicating whether the portfolio itself should be included
in the overview. Defaults to
True. - exclude_sold_positions (bool): A flag indicating whether to exclude sold positions from the overview.
- rounding (int | None): An optional integer specifying the number of decimal places to round the data. If None, the default rounding precision is used.