Skip to content

Instantly share code, notes, and snippets.

@mckoss
Last active April 12, 2017 17:41
Show Gist options
  • Save mckoss/0971e8f818062e2b5dc41b7a33496c60 to your computer and use it in GitHub Desktop.
Save mckoss/0971e8f818062e2b5dc41b7a33496c60 to your computer and use it in GitHub Desktop.
VS_PURCHASE Custom Function Documentation

VS_PURCHASE(range)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment