My data looks like this
| Date | Transaction | Quantity | Security | |
| 01/01/2018 | Buy | 100000 | Apple | |
| 01/02/2018 | Buy | 200000 | Apple | |
| 01/05/2018 | Sell | 50000 | Apple | |
| 05/02/2018 | Buy | 200000 | Banana | |
| 05/03/2018 | Buy | 200000 | Banana | |
| 13/03/2018 | Sell | 180000 | Banana | |
| 17/03/2018 | Sell | 50000 | Banana | |
and after applying the first in first out method, I would like to figure out the remaining quantities, and thus the data should look something like this
| Date | Transaction | Quantity | Security | Remaining | | |
| 01/01/2018 | Buy | 100000 | Apple | 50000 | | |
| 01/02/2018 | Buy | 200000 | Apple | 200000 | | |
| 01/05/2018 | Sell | 50000 | Apple | | | |
| 05/02/2018 | Buy | 200000 | Banana | 0 | | |
| 05/03/2018 | Buy | 200000 | Banana | 170000 | | |
| 13/03/2018 | Sell | 180000 | Banana | | | |
| 17/03/2018 | Sell | 50000 | Banana | | | |
Appreciate your assistance in advance.