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 closing price of the asset obtained from historical data.
- Latest Value: The market value of the position still held, i.e. Volume times Latest Price.
- Dividends: The cash dividends received on the units held on every ex-dividend date.
- Return: The total return on the capital deployed, i.e. Return Value divided by Invested. This covers realized and unrealized results and the dividends together and is NaN when nothing was invested. The “Portfolio” row divides by the capital contributed to the portfolio instead: the peak of the cumulative net contribution, i.e. every buy plus the costs minus the sale proceeds and the dividends received up to that date, summed over the assets per date. The buys of a rebalancing are paid for by the sells and dividends of the portfolio itself, so a portfolio that invests 10,000 once has 10,000 of capital however often it is rebalanced, while its “Invested” adds up every rebalancing buy. A portfolio of buys has its “Invested” as its capital, less the part of a later buy that a dividend received before it paid for.
- Return Value: The absolute profit or loss, i.e. Latest Value plus all sale proceeds plus Dividends minus Invested. This equals realized PnL plus unrealized PnL plus dividends 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 at the benchmark’s closing price for the exact cash amount of that transaction on that date, so the comparison is matched in money rather than in share count, and the benchmark’s dividends are received as cash as well. The “Portfolio” row divides by the same capital as its Return, so its Alpha compares like with like.
- Volatility: The annualized volatility of the asset’s daily returns over the most recent 252 trading days. For the aggregated “Portfolio” row, this is derived from the full covariance matrix of the underlying asset returns over the same days (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 benchmark’s daily returns over the most recent 252 trading days.
- Alpha: The alpha is based on the difference between the asset’s return and the benchmark return.
- Beta: The beta of the asset’s daily returns against the benchmark’s over the most recent 252 trading days, the window of the Volatility column. 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.
Positions are valued at the traded closing price, the basis of the transaction prices, and dividends are added as cash, for the asset and the benchmark alike, so Return and Benchmark Return are total returns on the same basis.
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
Install the Finance Toolkit 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 | Dividends | Return | Return Value | Benchmark Return | Volatility | Benchmark Volatility | Alpha | Beta | Weight |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| MPWR | 116 | -27 | 250.893 | 30636 | 1140.12 | 132254 | 3301.39 | 3.4394 | 105369 | 0.7644 | 0.5485 | 0.1274 | 2.675 | 2.5783 | 0.1365 |
| MSFT | 105 | -11 | 50.1726 | 5529.99 | 524.51 | 55073.6 | 3367.52 | 9.5947 | 53058.8 | 3.3786 | 0.3292 | 0.1274 | 6.2161 | 1.0354 | 0.0569 |
| NFLX | 114 | -32 | 13.0791 | 1666.89 | 65.85 | 7506.9 | 0 | 3.6304 | 6051.53 | 1.3813 | 0.3572 | 0.1274 | 2.2491 | 0.2488 | 0.0077 |
| NVDA | 69 | -27 | 2.1717 | 202.909 | 210.96 | 14556.2 | 49.646 | 71.138 | 14434.5 | 1.0556 | 0.3761 | 0.1274 | 70.0824 | 1.9435 | 0.015 |
| OXY | 27 | -15 | 52.3833 | 2005.56 | 64.17 | 1732.59 | 876.077 | 0.5181 | 1039 | 2.7097 | 0.3494 | 0.1274 | -2.1916 | -0.7819 | 0.0018 |
| SKY | 126 | -23 | 24.4134 | 3343.23 | 78.92 | 9943.92 | 901.062 | 2.3234 | 7767.74 | 4.8301 | 0.4542 | 0.1274 | -2.5067 | 1.0893 | 0.0103 |
| VOO | 77 | -12 | 256.027 | 20238.2 | 698.58 | 53790.7 | 3863.3 | 1.867 | 37784.6 | 1.6782 | 0.1268 | 0.1274 | 0.1888 | 0.9928 | 0.0555 |
| VSS | 98 | -21 | 94.9125 | 10366.5 | 149.35 | 14636.3 | 3122.51 | 0.8093 | 8390.01 | 2.4396 | 0.1664 | 0.1274 | -1.6303 | 1.0607 | 0.0151 |
| WMT | 92 | -18 | 22.2477 | 2265.02 | 119.89 | 11029.9 | 965.758 | 4.37 | 9898.01 | 3.409 | 0.2626 | 0.1274 | 0.9609 | -0.0971 | 0.0114 |
| Portfolio | 2142 | -532 | 55.8595 | 134818 | 452.235 | 968688 | 35730.9 | 8.8928 | 878276 | 2.5365 | 0.2752 | 0.1274 | 6.3563 | 1.7913 | 1 |
Parameters
get_portfolio_overview accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
include_portfolio | bool | A boolean flag indicating whether the portfolio itself should be included in the overview. Defaults to True. | False |
exclude_sold_positions | bool | A flag indicating whether to exclude sold positions from the overview. Defaults to True. | False |
rounding | int | None | An optional integer specifying the number of decimal places to round the data. If None, the default rounding precision is used. | 2 |