5
$\begingroup$

I am working on an improvement of my company's order allocation system. We run a central Order Management System (OMS) but currently performance attribution from filled orders leaves room for improvement.

I look to understand how other systems handle order and trade allocation.

Example: Asset 'A'

Fill1; buy A 500 shares; avg px x1
Fill2; buy A 300 shares; avg px x2
Fill3; sell A 700 shares; avg px x3
Fill4; sell A 100 shares; avg px x4

One example how a trade could be defined is as follows:

Trade1, avg entry px=x1; avg exit px=x3 Trade2, avg entry px=x2; avg exit px=(2*x3+x4)/3

To compute performance of individual trades (not total performance as that is trivial) would you apply a FIFO-like approach or allocate filled shares and their filled price in a different way? The reason I attempt to break it down is for various reasons, among others TCA and to better analyze algorithm predictive power in detail.

Can you please share how you would approach this issue and if you know what you believe industry standard is? I want to have a better understanding before having it all spec'ed up and implemented by developers.

Edit:

To avoid confusion, my question is not at all related to order matching on the exchange/ecn side, but fill allocation and trade performance attribution on the liquidity taking side.

$\endgroup$
4
  • $\begingroup$ Are you asking about how electronic exchanges manage and match orders? $\endgroup$
    – Serg
    Oct 22, 2013 at 12:18
  • $\begingroup$ No, I am asking about how trades and fills are managed on the liquidity taking side as part of a larger order management and risk management system. I edited my question a little to make it clearer. $\endgroup$
    – Matt Wolf
    Oct 22, 2013 at 13:09
  • $\begingroup$ @MattWolf A decade later... what have you learned? $\endgroup$ Aug 30 at 20:32
  • $\begingroup$ @MattWolf as a separate follow-up, I think your example could be made more complex by needing to handle/test for intraday cancel-corrects on execution reports. Curious if you ran into that. Otherwise, would guess you have sampling bias introduced by broker error (however small/infrequent). $\endgroup$ Sep 1 at 0:19

3 Answers 3

8
$\begingroup$

Approaches like FIFO and LIFO are most useful for tax accounting. If you don't have a tax accounting reason to do them, I'd recommend avoiding them, as they don't reflect actual realized gains (it's very rare for a position accounting system to move cash in and out of your account based on FIFO or LIFO).

I'm going to discuss everything here in Gross of Fees terms, since Net of Fees complicates the discussion a bit.

Most position accounting systems use average cost accounting. So, the average cost of your position is zero when you are flat (you have no position), and changes as your position gets further away from zero.

You realize gains when your position gets closer to zero/flat. The average cost of that position does not change. Your realized gain or loss is the difference between this "closing" transaction value and the average cost.

Now, how to discuss trades? I think there are two practices that are rational and widely used in this space.

One approach is "flat to flat". If your positions are typically opened and closed in round lots, then flat to flat can make a lot of sense. Even if you tend to open or close positions with partial fills, flat to flat measurement can make a lot of sense, and is pretty easy to do as the cumulative realized P&L of all transactions between the first opening trade and the last closing trade.

The other approach is to count every transaction that reduces the position (moves it closer to zero/flat) as a "trade". This allows you to report the realized P&L from that "trade" as well as track other statistics like time in market, excursion, drawdown, etc.

The third approach that I'll discuss is very algorithm specific, and widely used but not exactly generic. If your algo can tag transactions as opening or closing fills, then you can do average cost accounting and use either the flat to flat or position-reducing methods described above on 'logical' rather than 'physical' positions and "trades". I think that this is some of the rationale behind things like LIFO and FIFO: trying to logically group transactions into "trades". I think that actually having the algo tag the fills and declare whether the transaction should be considered an opening or closing transaction avoids the subjective and arbitrary approaches provided by FIFO and LIFO, letting the intent of the algorithm control the definition.

$\endgroup$
3
  • $\begingroup$ Some interesting concepts, thanks a lot. Regarding your comment on the "reduced position transaction" approach, I still believe you need to define a rule around that in terms of where to allocate the shares to. If you had two buy orders, got filled, and now get a fill on a sell order then you still need to decide where to allocate the shares to, hence my mentioning of FIFO. I like the last suggestion, though I would need to think a little more because most our strategy algorithms have very limited knowledge of fills. But logically it makes sense to have the algo define what constitutes a trade $\endgroup$
    – Matt Wolf
    Oct 21, 2013 at 14:15
  • 2
    $\begingroup$ I think that you need to decide whether you want a 'neutral' accounting style treatment or an 'active' allocation treatment. If you want a neutral approach, either of the first two methods I described will be consistent with your accounting system. If you want an active treatment, then I think you need to have the algo decide. Allocating on LIFO or FIFO basis can create non-intuitive 'gains' and 'losses' on 'trades' as all of your profit or loss get swallowed by one fill. This is why I think approaches that more closely match the actual movement of cash in the account make more sense. $\endgroup$ Oct 21, 2013 at 14:52
  • $\begingroup$ Will take that into consideration. Thanks for your take on that. $\endgroup$
    – Matt Wolf
    Oct 21, 2013 at 15:31
5
$\begingroup$

I'll add my own experience here based on what we do at our firm, simply to provide more support for what Brian said in his answer.

Fills that move a position further away from 0 contribute to the average price of the position.

Fills that move a position closer to 0 "book profits" against the average price of the position to that point in time.

Any fill that causes a position to cross 0 must be handled so that it hits 0 first, and then crosses to the other side to ensure proper accounting.

In our world we refer to a "trade" as having an open time of the timestamp of the first fill that moves away from open position size of 0. The trade is closed or finalized when the size reaches 0 again. So the lifetime of the trade is simply the time spent not at position size of 0.

From your example, what you refer to as "trades" we call fills. The "trade" is the entire sequence of events that encompass moving from net position size of 0 and back again.

t0 we own 0 shares of A
t1 buy  500 A at x1
t2 buy  300 A at x2, average price is now the wavg of the fills
t3 sell 700 A at x3, book x3 - avg price, position now 100 shares
t4 sell 100 A at x4, book x4 - avg price, position now 0 shares
position or "trade" is now closed and we start over again

t1 is the open time of the trade. t4 is the closing time of the trade. The trade is made up of 4 total fills, 2 of which are "opening" fills and 2 are "closing" fills. A fill is an opening fill if it moves net size farther from 0. It is a closing fill if it moves net size closer to 0. Any time you reach 0 (or cross it) you close the trade and, in the case of crossing 0, start a new one. When I refer to "crossing 0" it is because we model long positions as positive size and short positions as negative size.

$\endgroup$
6
  • $\begingroup$ Louis, thanks for adding your take. I get what you mean, and it answers the computation of cost to enter and pnl when releasing utilized capital. What would interest me beyond that is how your firm defines trades. Do you just end up in any given day with one big trade and one pnl or do you break it down into smaller trades and if yes by what metric? $\endgroup$
    – Matt Wolf
    Oct 22, 2013 at 16:03
  • 1
    $\begingroup$ I've added a bit more detail, hope that helps. Let me know if you want more clarification. $\endgroup$ Oct 22, 2013 at 16:15
  • $\begingroup$ Thanks for adding more color, it really helps. And of course I was also referring to fills in my above example, I edited to replace 'trade' with 'fill'. $\endgroup$
    – Matt Wolf
    Oct 22, 2013 at 18:00
  • $\begingroup$ Very interesting and I guess it goes in hand with what Brian described, I guess. I come from a slightly different direction in that we mico benchmarked and analyzed each individual fill, hence my ending up with two trades as per my example above. I find the way you described it definitely intriguing, though one issue I am worried about is loss of statistical metrics when defining a trade as essentially "going flat" rather than being able to get a finer-grained average price and the given fills absorbed into more trades. I guess I will ponder about it a little longer, thanks for the edit. $\endgroup$
    – Matt Wolf
    Oct 23, 2013 at 17:58
  • $\begingroup$ @MattWolf The metrics you would lose would include venue fragmentation stats, lit vs. dark, taker vs. maker rebates, etc. Also, mean reversion stats to check for venue toxicity as well as routing delay. You also want to measure effectiveness of order types like mid, mid-away, and size effects like bid/ask tilt at time of order book entry/time of order book match ("trade"), IOI offering size from your "back pocket" of shares. "You can't control what you can't measure." - W. Edwards Deming. Background: I briefly ran transactioncostanalysis.com as the product owner/sole developer. $\endgroup$ Sep 1 at 0:30
0
$\begingroup$

Here is a suggestion for performance analysis. It visualizes the quality of individual decisions, taken by the trading strategy. For simplicity purposes lets consider only BUY trades (the SELL trades may be multiplied by -1). Define reasonable trading horizon. Organize all trades in the same graph where:

  • x-axis is time around the execution, such that executions always occurs at t=0.
  • y-axis is the asset's price minus avg. execution price

Optionally, multiply each timeseries by corresponding trade's size. In this case the timeseries represents each trade's P&L.

enter image description here

Such view may provide very important insights about the strategy in addition to total performance. For example, you may observe that only a few trades contribute to total performance while the rest are "noise" trades. Then you can study what distinguishes these "special" decisions. Also, different effect like slippage can be easily observed and measured. You can also add a line that represents the average response. However, this method has its drawbacks, for instance, it doesn't account the position, but only the quality of individual decisions.

$\endgroup$
1
  • $\begingroup$ While that looks neat and is called "excursion", it does not answer any of my question unfortunately. $\endgroup$
    – Matt Wolf
    Oct 22, 2013 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.