Thoughts on building systems that calculate P&L
by Maksim Kozyarchuk
|
|
Action
|
Quantity
|
Price
|
Cost/Proceeds
|
Buy
|
1000
|
10 EUR
|
-10,000 EUR
|
Buy
|
1000
|
12 EUR
|
-12,000 EUR
|
Sell
|
-1200
|
15 EUR
|
18,000 EUR
|
Three common method of calculating P&L in today’s trading, middle office and accounting systems are:
Average Cost method: This method of calculation supports Average Cost, Realized and Unrealized P&L. Applying this method to above trades, yields the following:
- RPL = 1200*(15-(1000*10+1000*12)/2000) = 1200*4 = 4800
- UPL = 800*(15-(1000*10+1000*12)/2000) = 800*4 = 3200
- TPL = UPL + RPL = 8000
FIFO(Tax Lot) method: This method of calculation supports Realized and Unrealized P&L breakdown as well as Tax Lots allowing breakdown of cost by date of acquisition. Applying this method to above trades, yields the following:
- RPL = 1200*15- 1000*10 - 200*12= 18000 - 10000 - 2400 = 5600
- UPL = 800*15- 800*12= 800*3 = 2400
- TPL = URL + RPL = 8000
CashFlows method: This method only supports calculation of Total P&L and works by summing past and future cashflows associated with a given position. Applying this method to above trades, yields the following:
- TPL = MtM + CashFlows = 800 * 15 + ( 18000 - 12000 - 10000) = 12000 - 4000 = 8000
Comparing P&L calculation methods
All three methods produce the same value for TPL, however each has it’s own pros/cons and usage.
CashFlow method: This is the simplest and the most computationally efficient method. It can support incremental daily activity including trade amendments and cancels. This is often used for tracking intraday P&L of active portfolios.
Average Cost method: This method is popular with trading systems designers because it can produce Average Price, UPL/RPL breakdown, and with some simplifications, it can be calculated with computational overhead similar to that of the CashFlow method. However, these simplifications lead to lack of stability and transparency in RPL/UPL breakdown, especially when trades are canceled or amended. Furthermore, Average Cost based UPL/RPL breakdown is rarely used on financial statements, hence information it provides is not representative of actual UPL/PRP breakdown used for books and records.
FIFO(Tax Lot) method: Calculation of FIFO based UPL/RPL breakdown requires pairing off buys and sells via an intermediary object called Tax Lot. This calculation is more complex and computationally intensive than the other two, especially in portfolios with large number of trades. Furthermore, cancels and amendments of dated trades cause a ripple effect through the Tax Lot hierarchy making it difficult to predict the cost of calculating P&L impact of a given trade.
Daily and Period P&L
So far we’ve looked at P&L calculation outside of the concept of time. In practice, P&L is rarely useful without a time period constraint. Above described methodologies can be adapted to produce P&L for an arbitrary period by finding the difference in perpetual P&L calculated at the beginning and the end of a given period. While this method is effective, the need to calculate P&L twice leaves system designers searching for more efficient methods.
One such method relies on change in MtM for a given period combined with P&L impact of trading activity during the period. This method gives us ability to see change in total P&L broken down into three components. Change in Market Value of the position, P&L resulting from new trades, P&L resulting from closing trades. This method is very efficient as it only needs to look at current position and trading activity for the period to come up with the results. This method may produce rather strange outcomes for cases when a position is traded in/out multiple times per day. Calculations for this method are done as follows:
- TPL = MtM + NewTradesP&L + ClosedTradesP&L
- MtM = (Current Positions - New Trade Quantity) * ( Current Price - Prior Period Price )
- NewTradesP&L = New Trade Quantity * ( Current Price - Trade Price )
- ClosedTradesP&L = -1* (Closed Trade Quantity * ( Trade Price - Prior Period Price ))
Below table extends earlier example to demonstrate calculations produced for daily P&L using the two methods.
Trading Activity
Trade Date
|
Action
|
Quantity
|
Price
|
Cost or Proceeds
|
4/14/2015
|
Buy
|
1000
|
10 EUR
|
-10,000 EUR
|
4/15/2015
|
Buy
|
1000
|
12 EUR
|
-12,000 EUR
|
4/16/2015
|
Sell
|
-1200
|
15 EUR
|
18,000 EUR
|
Positions and P&L
Date
|
Position
|
MtM Price
|
Daily p&l
|
Daily Mtm
|
Daily New Trade pl
|
Daily Close Trade pl
|
Daily RPL(AvgCost)
|
Daily UPL(AvgCost)
|
4/14/15
|
1000
|
11
|
1000
|
0
|
1000
|
0
|
0
|
1000
|
4/15/15
|
2000
|
14
|
5000
|
3000
|
2000
|
0
|
0
|
5000
|
4/16/15
|
800
|
15
|
2000
|
800
|
0
|
1200
|
4800
|
-2800
|
Methods described in this article, are generic in nature and have broad applications across asset classes. However, there are many other methods for breaking down and bucketization of period based P&L to help explain it. The idea of explaining P&L falls under a very broad topic of P&L attribution and tends to be specific to a particular product or trading strategy.
Summary
Traditionally, trading, middle office and accounting systems have different ways of calculating and presenting P&L. Trading systems would typically focus on breadth of features available and real time nature of the data, while middle office and accounting systems would focus on quality and depth of the data. These requirements used to be considered irreconcilable leading to proliferation of expert systems dedicated to trading, middle office and accounting. This in turn led to ambiguity in data, lack of transparency and often big surprises on dealing and financial reporting dates. Leveraging ideas described in this post, it is both necessary and feasible to have a single system that is capable of displaying various P&L metrics side by by side and derived off the same data. One system can present P&L views that would include:
- Daily P&L, calculated as MtM plus activity
- Month to Date and Year to Date P&L with ability to highlight Realized P&L
- Total Realized and UnRealized P&L
- P&L calculated for an arbitrary period in time
- P&L calculated using different methodologies side by side including Average Cost, FIFO, LIFO, MinTax and others
- Rich P&L attribution methods
More to come
This article provided an introduction into the domain of implementing P&L calculation and highlighted typical way portfolio management systems display P&L. In the future posts, I will dive deeper into supporting P&L calculated in Fund Currency as well as for products that involve margining and financing.
No comments:
Post a Comment