title: How to calculate realized P&L of stock trades using the FIFO method?
body: <p>I'm looking for a Python plugin that would calculate the realized P&amp;L for a number of stock transactions using the FIFO method.</p>
  <p>For example, assume we have the following three MSFT trades:</p>
  <p>+75 MSFT 25.10<br />
  +50  MSFT 25.12<br />
  -100 MSFT 25.22</p>
  <p>The sell of 100 shares at 25.22 would fully net against the buy of 75 at 25.10 and partially net against the buy of 50 at 25.12 i.e.</p>
  <p>Realized P&amp;L = 75 * (25.22 - 25.10) + 25 * (25.22 - 25.12) = $ 11.50</p>
  <p>The outstanding position would be:</p>
  <p>+25 MSFT 25.12</p>