adding fifo unrealized gain function