Report

Investment Lots

The Investment Lots report.

For each investment account, its lots: when each was opened and closed, the amount and basis bought, what was sold, what is left, and the realized and unrealized gains (short term and long term) and annualized returns. Use it to see how each purchase has done. Warnings flag lots that look wrong, such as a split in no lot. In GnuCash: Reports ▸ Assets & Liabilities ▸ Investment Lots.

The options that matter are General/Start date and End date, Accounts/Accounts, the Columns options that turn groups of columns on and off, Columns/Long term gains age (years) and General/Price source. An account with no price at the end date shows No price found. Create lots with lot.create.

Examples

Example: with a copy of the reports/lots-baseline example book open as book.gnucash, at 2024-03-15T12:00:00Z.

JSON-RPC

Request:

{"jsonrpc":"2.0","id":1,"method":"report.run","params":{"report":"Investment Lots","options":{"General":{"Start date":{"absolute":"2019-12-31"},"End date":{"absolute":"2020-12-31"}}}}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "title": "Investment Lots, 12/31/19 to 12/31/20",
    "sections": [
      {
        "blocks": [
          "…",
          {
            "kind": "table",
            "rows": [
              "…",
              "…",
              "…",
              "…",
              "…",
              "…",
              {
                "role": "data",
                "cells": [
                  "…",
                  {
                    "display": "01/01/20",
                    "…": "…"
                  },
                  "…",
                  {
                    "text": "100. AAPL",
                    "…": "…"
                  },
                  {
                    "display": "$5,000.00",
                    "…": "…"
                  },
                  "…"
                ],
                "…": "…"
              },
              "…"
            ],
            "…": "…"
          },
          "…"
        ],
        "…": "…"
      },
      "…"
    ],
    "…": "…"
  }
}

Command line

red-ale exec --book book.gnucash report.run '{"report":"Investment Lots","options":{"General":{"Start date":{"absolute":"2019-12-31"},"End date":{"absolute":"2020-12-31"}}}}'

It prints:

{
  "title": "Investment Lots, 12/31/19 to 12/31/20",
  "sections": [
    {
      "blocks": [
        "…",
        {
          "kind": "table",
          "rows": [
            "…",
            "…",
            "…",
            "…",
            "…",
            "…",
            {
              "role": "data",
              "cells": [
                "…",
                {
                  "display": "01/01/20",
                  "…": "…"
                },
                "…",
                {
                  "text": "100. AAPL",
                  "…": "…"
                },
                {
                  "display": "$5,000.00",
                  "…": "…"
                },
                "…"
              ],
              "…": "…"
            },
            "…"
          ],
          "…": "…"
        },
        "…"
      ],
      "…": "…"
    },
    "…"
  ],
  "…": "…"
}

MCP tool call

Tool call:

{"name":"report.run","arguments":{"report":"Investment Lots","options":{"General":{"Start date":{"absolute":"2019-12-31"},"End date":{"absolute":"2020-12-31"}}}}}

Result:

{
  "structuredContent": {
    "title": "Investment Lots, 12/31/19 to 12/31/20",
    "sections": [
      {
        "blocks": [
          "…",
          {
            "kind": "table",
            "rows": [
              "…",
              "…",
              "…",
              "…",
              "…",
              "…",
              {
                "role": "data",
                "cells": [
                  "…",
                  {
                    "display": "01/01/20",
                    "…": "…"
                  },
                  "…",
                  {
                    "text": "100. AAPL",
                    "…": "…"
                  },
                  {
                    "display": "$5,000.00",
                    "…": "…"
                  },
                  "…"
                ],
                "…": "…"
              },
              "…"
            ],
            "…": "…"
          },
          "…"
        ],
        "…": "…"
      },
      "…"
    ],
    "…": "…"
  }
}

Template GUID: ab2acc24afd14630a551f98f1a35fa81 · Script: standard/investment-lots.rhai

Options

Accounts

  • Accounts (accountList, default []): Stock Accounts to report on.
  • Include accounts with no shares (boolean, default true): Include accounts that have a zero share balances.
  • Include accounts with no lots (boolean, default false): Include accounts with no lots

Chart

  • Show Chart (boolean, default true): Include a chart that shows lot gains, grouped by account and gain type
  • Chart type (multichoice, default "bar-stacked"): What kind of chart to include
  • Chart location (multichoice, default "top"): Where to place the chart
  • Plot width (plotSize, default {"percent":100}): Width of plot, 10 - 100 in percent, above in pixels.
  • Plot height (plotSize, default {"percent":50}): Height of plot, 10 - 100 in percent, above in pixels.

Columns

  • Show lot GUID column (boolean, default false): Show the lot GUID table column
  • Show date columns (boolean, default true): Show the lot open and close table columns
  • Show bought columns (boolean, default true): Show purchase-related table columns
  • Show sold columns (boolean, default true): Show sale-related table columns
  • Show end columns (boolean, default true): Show end date amount and value table columns
  • Show realized gain columns (boolean, default true): Show realized gain table column(s) for sold shares
  • Show unrealized gain columns (boolean, default true): Show unrealized gain table column(s) for unsold shares
  • Group gains by age (short term and long term) (multichoice, default "gains-only"): Group gains (and sales?) by long-term (LT) and short-term (ST)
  • Long term gains age (years) (numberRange, default 1): Commodities held longer than this many years count as long-term (LT).
  • Show ROI columns (boolean, default false): Show Return On Investment (ROI) columns
  • Show CAGR columns (boolean, default true): Show Compound Annual Growth Rate (CAGR) columns

Display

  • Show long account names (boolean, default true): Show long (instead of short) account names
  • Show mnemonic in amounts (boolean, default true): Show mnemonics with commodity amounts
  • Include closed lots (boolean, default true): Include closed lots in addition to open lots
  • Show blanks instead of zeros in table cells (boolean, default true): Show blank text instead of zero values for inner table cells. Does not apply to footer rows.
  • Show lot split rows (boolean, default false): Add a row for each split belonging to a lot, under the lot row.

General

  • Report name (string, default "Investment Lots"): Enter a descriptive name for this report.
  • Stylesheet (multichoice, default "Default"): Select a stylesheet for the report.
  • Add options summary (multichoice, default "never"): Add summary of options.
  • Start date (date, default {"relative":"start-accounting-period"}): Start of reporting period.
  • End date (date, default {"relative":"today"}): End of reporting period.
  • Report's currency (currency, default "CURRENCY::USD"): Select the currency to display the values of this report in.
  • Price source (multichoice, default "pricedb-before"): The source of price information.

Validation

  • Include only accounts with warnings (boolean, default false): Only show accounts that contain warnings. This is useful for quickly finding potential lot errors.
  • Warn if a lot has more than one bought split (boolean, default true): Lots with more than one purchase split are not well formed. It may make ambiguous the capital gains age
  • Warn if a lot's balance drops below zero (boolean, default true): Lots with a negative balance are not well formed.
  • Warn if a lot has a blank title (boolean, default false): Lot titles are optional. This warning applies to titles that are empty or only whitespace.
  • Warn if the 'Realized Gain/Loss' split(s) sum does not match the computed gains (boolean, default true): Detect possible errors in 'Realized Gain/Loss' splits that are created when adding a sale split to a lot
  • Warn if a split is not assigned to a lot (multichoice, default "count"): Detect splits that have not been assigned to a lot.
  • Warn if the account balance does not match the computed lots' end balance (boolean, default true): Balance mismatches may indicate a split that is not yet included in a lot