Custom Function to compute versus purchase gains (FIFO).
The passed range should contain exactly three columns of data (in chronological order to preserve first-in/first-out ordering of transactions). The three columns should contain:
- Date can be an actual date or id string (but rows of the range must be chronological).
- Shares is the number of shares purchased (if positive) or sold (if negative).
- Proceeds (in dollars) is the total received from sale (if positive) or paid to purchase (if negative).
The results of the function will fill in two columns for each sale in the range:
- Basis - Total amount paid for share sold.
- Versus - List of purchases which this sale is paired with (displaying: shares@price (date))
See Example Sheet.