Transactions Performance
Calculate transaction performance metrics for a specified period.
This method calculates various transaction performance metrics, such as returns, costs, and benchmarks, for the specified period. The calculation is based on historical price data for the corresponding period, including both the portfolio and benchmark datasets. It provides an overview of how the portfolio’s transactions have performed in comparison to the benchmark over the given period.
Transactions Performance in Python
get_transactions_performance is part of the Portfolio module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_transactions_performance as shown below.
from financetoolkit import Portfolio
portfolio = Portfolio(example=True, api_key="FINANCIAL_MODELING_PREP_KEY")
portfolio.get_transactions_performance(period='quarterly')
Which returns:
| Date | Volume | Price | Costs | Invested Amount | Realized Proceeds | Current Value | Return | Benchmark Return | Alpha |
|---|---|---|---|---|---|---|---|---|---|
| 2023Q4 | 15 | 41.0726 | -3 | 619.088 | 0 | 580.2 | -0.0628 | 0.0853 | -0.1481 |
| 2024Q1 | 5 | 33.0126 | -3 | 168.063 | 0 | 180.05 | 0.0713 | 0.0276 | 0.0437 |
| 2024Q1 | 14 | 140.041 | 0 | 1960.57 | 0 | 2094.54 | 0.0683 | 0.071 | -0.0026 |
| 2024Q1 | 7 | 38.4963 | -1 | 270.474 | 0 | 264.04 | -0.0238 | 0.0291 | -0.0529 |
| 2024Q1 | 11 | 727.32 | 0 | 8000.52 | 0 | 7327.87 | -0.0841 | 0.0153 | -0.0994 |
| 2024Q2 | 4 | 94.4243 | 0 | 377.697 | 0 | 500.96 | 0.3264 | 0.0407 | 0.2856 |
| 2024Q2 | 8 | 505.574 | 0 | 4044.59 | 0 | 4006.96 | -0.0093 | 0.0158 | -0.0252 |
| 2024Q2 | 14 | 847.6 | -1 | 11867.4 | 0 | 11330.1 | -0.0453 | -0.0049 | -0.0404 |
| 2024Q4 | 6 | 48.8436 | 0 | 293.062 | 0 | 273.24 | -0.0676 | 0.0127 | -0.0803 |
| 2024Q4 | 11 | 552.136 | 0 | 6073.5 | 0 | 5819.66 | -0.0418 | -0.0173 | -0.0245 |
Parameters
get_transactions_performance accepts the following parameters:
- period (str | None): The time period for which transaction performance metrics should be calculated. This can be one of the following: ‘yearly’, ‘quarterly’, ‘monthly’, ‘weekly’, or ‘daily’. If None, the default is ‘quarterly’ if the ‘quarterly’ attribute is set to True, otherwise ‘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 specified in the configuration.