I wrote some code to estimate and compare the tax efficiency of an algorithm. See the attached code. You will see 2 additional fields as shown below:

103224_1622390377.jpg

Please note:

  • I use LIFO (last in first out).
  • My unrealized gain is different from QuantConnect's. Wondering this can be attributed to LIFO and timing of the calculations (end of the month vs end of the day)
  •  

I am sharing it here with the following in mind:

  • The community can benefit from it.
  • The community can suggest ideas on how to improve it further, For example,:
    • Current implementation requires code insertions in multiple places in your algo. Is there way to simplify that?
  • The community can share updated and improved versions of the code.
  • QuantConnect team gets inspiration from this and incorporates. tax efficiency in their core platform as well as alpha marketplace,

 

Best, 

Manoj