Calculating Portfolio Returns from Trade Activity Records
Summary
The document describes the challenge of calculating portfolio returns from transaction records such as buys, sells, shorts, and covers. Its example tracks purchases and a later sale, showing that holdings change over time and raising the question of how to calculate return when the portfolio is valued using current security prices. Fees, quantities, prices, and other reference data may also be present in the activity file.
The author considers reconstructing portfolio value on each date by aggregating all earlier activity to determine current holdings, but finds the return calculation unclear when trading occurs. The document does not provide a return methodology, code, or answer; it is a request for rules or tools to handle the cases systematically. It therefore highlights the need to define how transactions and cash flows affect performance measurement, but leaves choices such as timing conventions and return method unresolved.
Key ideas
- Trade activity records can be aggregated over time to reconstruct security holdings.
- Purchases and sales change portfolio exposure, complicating return calculations between valuation dates.
- A complete return process must account for transaction details such as quantities, prices, and fees.
- The document raises the problem but does not supply a calculation method or implementation.
Tags
Full text
# Portfolio returns from activity records # Portfolio returns from activity records I am looking for a clean and efficient way to obtain the portfolio returns from a list of activity records. Specifically, the activity file consist of BUY, SELL, COVER, SHORT, etc. records with additional referential data (e.g. SecurityID, Quantity, Fees, BaseAmount, etc.). Here is an example file. A possible layout for a security: ``` t TransactionType Quantity Price 1 BUY 100 5 2 BUY 50 4 ... 3 SELL 50 6 ``` So what I thought would be the best to do is to create a time series of the portfolio value over time. Hence, for each date, I take the current stock price and I check all the past records up to that date to determine the quantity that the user has in its portfolio of that particular security. In the previous example, this would give the following evolution: ``` t Quantity_Portfolio Return 1 100 - 2 150 150*4 / ( (50*4)+(100*5) ) ... 3 100 ...? ``` As you can see it becomes quite complex to calculate the portfolio value at time 3, as then - even in this simple example. What is the return at t=3? I was therefore wondering whether there are some sets of rules or resources that I could use (preferably Matlab or Python) to parse such activity records, instead of reinventing the wheel and trying to think of all possible situations?
Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.