Try TT Now

FIX Adapter Reference

Understanding P&L Calculations

Overview

This appendix describes how you can calculate a trader’s total P&L from the realized P&L provided by TT FIX Adapter in Tag 16210 (RealizedPandL) and the unrealized P&L you calculate from a theoretical exit price. For any contract, you can use the following formula to determine total P&L:

P&LTotal = P&LRealized + P&LUnrealized

You can choose from many fill-matching methodologies when calculating realized and unrealized P&L, such as FIFO, LIFO, and Averaging, and so on. TT FIX Adapter uses the Averaging methodology because it provides a distinct speed advantage over the other methods. (The Averaging methodology is mathematical whereas the LIFO and FIFO methodologies are algorithmic.)

Note: Each methodology might derive different values when calculating values for intermediate variables, but all of them arrive at the same result for total P&L.

Illustrating total P&L calculations

To help you understand how you can calculate total P&L, this appendix uses a set of hypothetical fills to establish a baseline position and realized P&L. Then, using these fills, it shows you how to calculate both unrealized and total P&L.

These P&L values represent the status after the initial fill download. Rather than using all of the fills to recalculate P&L when additional fills arrive, you can streamline performance by saving the initial state and basing future calculations on only the new fills. To demonstrate, this example walks you through calculations in the following scenarios:

Initial fill download

Assume the initial fill download includes the following fills (all prices in points):

  • Buy 12 @ 100
  • Buy 17 @ 99
  • Sell 9 @ 101
  • Sell 4 @ 105
  • Buy 3 @ 103

TT FIX Adapter uses the following formula to calculate the average price of the buys and sells.

Initial P&L calculations

From these fills, TT FIX Adapter calculates the following base values:

  • Total Buy Quantity = 12 + 17 + 3 = 32
  • Average Buy Price = ((12 * 100) + (17 * 99) + (3 * 103)) / 32 = 99.75 (points)
  • Total Sell Quantity = 9 + 4 = 13
  • Average Sell Price = ((9 * 101) + (4 * 105)) / 13 = 102.230769 (points)

To determine the realized P&L, TT FIX Adapter matches thirteen Buys with thirteen Sells using the Averaging technique, as follows:

  • P&LRealized (points) = (Sell Price - Buy Price) * Qty = (102.230769 - 99.75) * 13 = 32.249997
  • P&LRealized (contract currency) = P&LRealized (points) * Contract Point Value

which results in the following starting state after the initial fill download:

  • Position = +19
  • Average Open Price = 99.75

With the Average Open Price for the initial fills, the FIX client can calculate the unrealized P&L for the initial position. To do so, you must use some Theoretical Exit Price to calculate the unrealized P&L. This example, and all of the scenarios, assumes a Theoretical Exit Price of 99 (points), which results in the following calculations:

  • P&LUnrealized (points) = (Theoretical Exit Price - Average Open Price) * Position = (99 - 99.75) * (+19) = -14.25
  • P&LUnrealized (contract currency) = P&LUnrealized (points) * Contract Point Value

With these values, you can calculate the total P&L after the initial fill download as follows:

  • P&LTotal (points) = P&LRealized (points) + P&LUnrealized (points) = 32.249997 + (-14.25) = 17.999997
  • P&LTotal (contract currency) = P&LTotal (points) * Contract Point Value

Scenario 1: receiving new fills that increase your position

After calculating the initial position and P&L, suppose you receive a fill that increases your position (adding Buys to a positive position or Sells to a negative one). In this example, you receive a fill for a Buy order, as follows:

Start state

Position = +19 Average Open Price = 99.75

New Fill

Buy 10 @ 100

In this scenario, the fills do not affect the realized P&L, but they do affect the unrealized and total P&L, as follows:

  • Position = 19 + 10 = +29
  • Average Open Price = ( (19 * 99.75) + (10 * 100) ) / (19 + 10) = 99.83620

Scenario 2: receiving new fills that partially decrease your position

Instead of increasing a position, suppose the new fill partially decreases the position, still leaving an open position. In this example, you receive a fill for a Sell order, as follows:

Start state

P&LRealized (points) = 32.249997 Position = +19 Average Open Price = 99.75

New Fill

Sell 12 @ 101

In this scenario, the reduced open position does affect the realized P&L, as well as the unrealized and total P&L. The following calculations show how TT FIX Adapter derives the new realized P&L and how you can calculate the updated unrealized and total P&L (with Theoretical Exit Price = 99):

  • P&LRealized (points) = P&LRealized + ((Sell Price – Buy Price) * Qty) = 32.249997 + ((101 – 99.75) * 12) = 47.249997
  • Position = 19 – 12 = 7
  • Average Open Price = 99.75 (does not change)
  • P&LUnrealized (points) = (Theoretical Exit Price – Average Open Price) * Position = (99 – 99.75) * 7 = -5.25
  • P&LTotal (points) = (P&LRealized (points)) + (P&LUnrealized (points)) = 47.249997 + (-5.25) = 41.999997

Scenario 3: receiving fills that flatten your position

When a fill flattens a position, the average price becomes unavailable, as does the unrealized P&L. In this example, you receive a fill for a Sell order that matches the current position, as follows:

Start state

P&LRealized (points) = 32.249997 Position = +19 Average Open Price = 99.75

New Fill

Sell 19 @ 101

In this scenario, flattening a position causes the realized and total P&L to derive the same value. The following calculations show how TT FIX Adapter derives the new realized P&L and how you can calculate the updated unrealized and total P&L (with Theoretical Exit Price = 99):

  • P&LRealized (points) = P&LRealized + ((Sell Price – Buy Price) * Qty) = 32.249997 + ((101 – 99.75) * 19) = 55.999997
  • Position = 19 – 19 = 0
  • Average Open Price = none (as position = 0)
  • P&LUnrealized (points) = (Theoretical Exit Price – Average Open Price) * Position = none (as position = 0)
  • P&LTotal (points) = (P&LRealized (points)) + (P&LUnrealized (points)) = 55.999997 + 0 = 55.999997

Scenario 4: receiving fills that reverse your position

Finally, you can also receive fills that reverse a position. In this example, you receive a fill for a Sell order than exceeds the current position, as follows:

Start state

P&LRealized (points) = 32.249997 Position = +19 Average Open Price = 99.75

New Fill

Sell 22 @ 101

In this scenario, reversing the position affects the realized P&L, as well as the unrealized and total P&L. The following calculations show how TT FIX Adapter derives the new realized P&L and how you can calculate the updated unrealized and total P&L (with Theoretical Exit Price = 99):

  • P&LRealized (points) = P&LRealized + ((Sell Price – Buy Price) * Qty) = 32.249997 + ((101 – 99.75) * 19) = 55.999997
  • Position = 19 – 22 = -3
  • Average Open Price = 101
  • P&LUnrealized (points) = (Theoretical Exit Price – Average Open Price) * Position = (99 – 101) * (-3) = 6
  • P&LTotal (points) = (P&LRealized (points)) + (P&LUnrealized (points)) = 59.749997 + 6 = 61.999997