Method

price.list

List prices, by commodity, currency and date range, in GnuCash's order.

Lists prices in the order GnuCash writes them: by commodity, then currency, newest first. Give commodity to list one commodity's prices, currency as well to narrow it to a pair, bothDirections to include the pair's prices the other way round, and from and to (inclusive local days) to limit the dates. The result is a plain array.

A book may hold several prices of a pair on one day (loading a file applies no same-day rule).

Examples

Example: with a copy of the reports/test-data example book open as book.gnucash.

JSON-RPC

Request:

{"jsonrpc":"2.0","id":1,"method":"price.list","params":{"commodity":"GBP","currency":"USD","bothDirections":true}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "guid": "e0000000000000000000000000000001",
      "commodity": "CURRENCY::GBP",
      "currency": "CURRENCY::USD",
      "value": {
        "num": "3",
        "denom": "2"
      },
      "…": "…"
    },
    {
      "guid": "e0000000000000000000000000000000",
      "commodity": "CURRENCY::USD",
      "currency": "CURRENCY::GBP",
      "value": {
        "num": "5",
        "denom": "7"
      },
      "…": "…"
    }
  ]
}

Command line

red-ale exec --book book.gnucash price.list '{"commodity":"GBP","currency":"USD","bothDirections":true}'

It prints:

[
  {
    "guid": "e0000000000000000000000000000001",
    "commodity": "CURRENCY::GBP",
    "currency": "CURRENCY::USD",
    "value": {
      "num": "3",
      "denom": "2"
    },
    "…": "…"
  },
  {
    "guid": "e0000000000000000000000000000000",
    "commodity": "CURRENCY::USD",
    "currency": "CURRENCY::GBP",
    "value": {
      "num": "5",
      "denom": "7"
    },
    "…": "…"
  }
]

MCP tool call

Tool call:

{"name":"price.list","arguments":{"commodity":"GBP","currency":"USD","bothDirections":true}}

Result:

{
  "content": [
    {
      "type": "text",
      "text": "[{\"guid\":\"e0000000000000000000000000000001\",\"commodity\":\"CURRENCY::GBP\",\"currency\":\"CURRENCY::USD\",\"value\":{\"num\":\"3\",\"denom\":\"2\"},\"…\":\"…\"},{\"guid\":\"e0000000000000000000000000000000\",\"commodity\":\"CURRENCY::USD\",\"currency\":\"CURRENCY::GBP\",\"value\":{\"num\":\"5\",\"denom\":\"7\"},\"…\":\"…\"}]"
    }
  ]
}

Effect: read.

Params

Params of price.list.

  • commodity (CommodityId or null): Only prices of this commodity.
  • currency (CommodityId or null): Only prices in this currency (needs commodity).
  • bothDirections (boolean): Also prices of currency in commodity (needs both).
  • from (Date or null): Only prices from local 00:00:00 on this day.
  • to (Date or null): Only prices up to local 23:59:59 on this day.

Result

Type: array of PriceInfo.