I am familiar with the FIFO methodology of netting buys and sells to obtain a realized P&L and outstanding position. Suppose there's a strategy which runs in two different places A, and B and tries to place trades at A and B which are offsetting (like pair trading). In practice, they will both generate a log of trades (A.trades and B.trades). When I backtest the strategy I look at the trades in the order from concatenating B.trades to A.trades. This pnl can be very different from concatenating the other way, or interleaving more realistically by matching timezone adjusted trades. For example. For illustration only. Suppose we had:
Sell 1 for 10$ Buy 2 for 10$ Sell 3 for 7$
Buy 1 for 5$ Buy 2 for 5$
If I concatenate B.trades to A.trades and run a fifo algorithm I get a realized PNL of 1$ with 1 share left long. However, if interleave them I could have:
Sell 1 for 10$ Buy 1 for 5$ Buy 2 for 5$ Buy 2 for 10$ Sell 3 for 7$
And then in that case the FIFO algorithm gives me a realized P&L of 6$ with one share long in the end. I can see from running this by hand that the reason is that the "more expensive" buy is left unmatched in the second case. But it illustrates how strongly it can influence P&L. Now, it's not always straightforward to interleave trades in correct order of time if the units are small and there is clock drift (measuring time in two different places with different clocks) so it's not always clear we can capture a universal ordering. What could be done or is done in practice with a situation like this?