Transactions Overview
Calculate and collect transaction overview ratios based on the provided data.
This method calculates various transaction overview ratios, such as returns, costs, and profit & loss (PnL), based on the transaction dataset. The calculated ratios are added as new columns to the portfolio dataset. It also provides the option to use different methods for calculating PnL (FIFO, LIFO, or AVERAGE). The method ensures that necessary historical and benchmark data is available before performing calculations.
Transactions Overview in Python
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_transactions_overview as shown below.
from financetoolkit import Portfolio
portfolio = Portfolio(example=True, api_key="FINANCIAL_MODELING_PREP_KEY")
portfolio.get_transactions_overview()
Which returns:
| Name | Price | Volume | Costs | Currency | Invested Amount | Current Value | Dividends | % Return | Return | PnL | Cumulative PnL | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| (Period(‘2024-02-01’, ‘D’), ‘GOOGL’) | GOOGL | 141.16 | 14 | 0 | USD | 1976.24 | 4482.94 | 29.12 | 1.2832 | 2535.82 | 0 | 0 |
| (Period(‘2024-02-12’, ‘D’), ‘BAC’) | BAC | 33.62 | 5 | -3 | USD | 171.1 | 252.8 | 14.8 | 0.564 | 96.5 | 0 | 22.7994 |
| (Period(‘2024-02-22’, ‘D’), ‘MCHI’) | MCHI | 39.77 | 7 | -1 | USD | 279.39 | 343 | 18.9952 | 0.2957 | 82.6052 | 0 | -19.26 |
| (Period(‘2024-03-12’, ‘D’), ‘MPWR’) | MPWR | 736.55 | 11 | 0 | USD | 8102.05 | 12541.3 | 189.64 | 0.5713 | 4628.91 | 0 | 399.48 |
| (Period(‘2024-05-14’, ‘D’), ‘CAMT’) | CAMT | 94.11 | 4 | 0 | USD | 376.44 | 484.64 | 0 | 0.2874 | 108.2 | 0 | 102.7 |
| (Period(‘2024-06-11’, ‘D’), ‘META’) | META | 507.47 | 8 | 0 | USD | 4059.76 | 5140.96 | 41.4 | 0.2765 | 1122.6 | 0 | 0 |
| (Period(‘2024-06-18’, ‘D’), ‘MPWR’) | MPWR | 852.56 | 14 | -1 | USD | 11936.8 | 15961.7 | 223.86 | 0.3559 | 4248.7 | 0 | 399.48 |
| (Period(‘2024-07-30’, ‘D’), ‘AMD’) | AMD | 138.44 | 3 | 0 | USD | 415.32 | 1550.37 | 0 | 2.733 | 1135.05 | 0 | 13.3825 |
| (Period(‘2024-10-25’, ‘D’), ‘MCHI’) | MCHI | 49.85 | 6 | 0 | USD | 299.1 | 294 | 15.138 | 0.0336 | 10.038 | 0 | -19.26 |
| (Period(‘2024-11-13’, ‘D’), ‘VOO’) | VOO | 549.03 | 11 | 0 | USD | 6039.33 | 7684.38 | 159.099 | 0.2987 | 1804.15 | 0 | 140.84 |
Parameters
get_transactions_overview accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
rounding | int | None | The number of decimal places to round the output to. If None, it defaults to the rounding specified in the configuration. | 2 |
exclude_sold_positions | bool | Whether to leave out the sell transactions. Profit & loss is realized when shares are sold, so it is booked on the sell transactions: with True, every remaining (buy) transaction shows a PnL of 0 and the realized total is in the Cumulative PnL column. Pass False to see the PnL of each sale. Defaults to True. | False |
pnl_method | str | The method for calculating profit & loss. Options are: ‘FIFO’ (First In, First Out), ‘LIFO’ (Last In, First Out), or ‘AVERAGE’. Defaults to ‘FIFO’. | "LIFO" |