# PnL with FIFO and LIFO

Sequence Side Quantity @ Price
4.       Sell   9      @ 101
5.       Sell   4      @ 105

with sold quantity = 9+4 = 13
and current position size = (12+17+3)-13 = 19
and markPrice = 99

I want to calculate the netPnL, realizedPnl and unrealizedPnl by using the most precise valuation type. I only know 3 valuation types: FIFO, LIFO, WAC. I did not choose WAC because it is not precise enough. So I want to choose either FIFO or LIFO. Here the calculations:

FIFO:

realizedPnL = (9*101 + 4*105) - (12*100 + 1*99) = +30
unrealizedPnL = 19*99 - (16*99 + 3*103) = -12
netPnL = 30 + (-12) = 18

LIFO:

realizedPnL = (9*101 + 4*105) - (3*103 + 10*100) = +20
unrealizedPnL = 19*99 - (7*99 + 12*100) = -12
netPnL = 20 + (-12) = 8

Now my questions:

1. Are the calculations right? I thought that the netPnl must be always the same - regardless of the valuation type. But this is not the case here. Why?
2. Which is more precise? FIFO or LIFO? Which should I use?
3. Is there any other valuation type which is more precise than FIFO or LIFO? I need the most accurate valuation type.

EDIT:

The error was within the LIFO calculation:

realizedPnL = (9*101 + 4*105) - (3*103 + 10*100) = +20

this must be used:

realized PnL = (9*101 + 4*105) - (3*103 + 10*99) = +30

You are right that the Total P&L (or as you call it the Net P&L) must be the same for the two methods, so something went wrong. In addition, by a strange coincidence, the realized P&L's although different (9,21 versus 6,24) add up to the same amount at the end (30), which does not usually happen.

Here are my calculations

First let's use FIFO:
=====================

After the three buys we have the following Lot Table:
Lot Shrs Price Extensn
1   12   100    1200
2   17    99    1683
3    3   103     309
--          ----
Tot 32 at cost  3192

Sell 9 at 101
take 9 from lot 1
realized P&L on this trade = 9(101-100) = 9
Updated lot table:
Lot Shrs Price Extensn
1    3   100     300
2   17    99    1683
3    3   103     309
--          ----
total 23 at cost  2292

Sell 4 at 105
take 3 from lot 1 and 1 from lot 2
realized P&L on this trade = 3(105-100)+1(105-99)= 21
Updated lot table:
Lot Shrs Price Extensn
1    0   100       0
2   16    99    1584
3    3   103     309
--          ----
total 19 at cost  1893

mark to market of final holdings
value =19*99 = 1881
cost of final holdings = 0*100+16*99+3*103 = 1893
unrealized P&L = 1881-1893 = -12
cumulative realized P&L = 9+21=30
total P&L = 30-12 = 18

Now let's do it again using LIFO this time:
===========================================

After the three buys we have the following Lot Table:
Lot Shrs Price Extensn
1   12   100    1200
2   17    99    1683
3    3   103     309
--          ----
Tot 32 at cost  3192

Sell 9 at 101
take 3 from lot 3 and 6 from lot 2
realized P&L on this trade = 3(101-103)+6(101-99) = 6
Updated lot table:
Lot Shrs Price Extensn
1   12   100    1200
2   11    99    1089
3    0   103       0
--          ----
total 23 at cost  2289

Sell 4 at 105
take 4 from lot 2
realized P&L on this trade = 4(105-99) = 24
Updated lot table:
Lot Shrs Price Extensn
1   12   100    1200
2    7    99     693
3    0   103       0
--          ----
total 19 at cost  1893 /*by coincidence we again have 1893, unusual */

mark to market of final holdings
value =19*99 = 1881
cost of final holdings = 12*100+7*99+0*103 = 1893
unrealized P&L = 1881-1893 = -12
cumulative realized P&L = 6+24 = 30
total P&L = 30-12 = 18