price.removeOld
Remove old prices, keeping the last of each week, month, quarter or fiscal year.
GnuCash's Edit > Prices > Remove Old Prices: removes prices of the named commodities (in every currency) from before
before, keeping the last price of each week, month, quarter or fiscal year (keep: none, lastOfWeek (the
default), lastOfMonth, lastOfQuarter, lastOfPeriod or scaled). Only prices from the chosen sources are
candidates: fetched (the default; Finance::Quote), user (only user:price) and app (every other source,
the price editor's and the transfer dialog's included).
Pitfall: GnuCash compares periods by number only, so January 2022 is "the same month" as January 2023; red-ale
reproduces that, so thinning prices over several years can remove more than you expect. Use lastOfPeriod for a
fiscal-year comparison without it.
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.removeOld","params":{"commodities":["GBP"],"before":"2001-01-01","sources":["app"],"keep":"none"}}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"removed": [
"e0000000000000000000000000000001"
]
}
}
Command line
red-ale exec --book book.gnucash price.removeOld '{"commodities":["GBP"],"before":"2001-01-01","sources":["app"],"keep":"none"}'
It prints:
{
"removed": [
"e0000000000000000000000000000001"
]
}
MCP tool call
Tool call:
{"name":"price.removeOld","arguments":{"commodities":["GBP"],"before":"2001-01-01","sources":["app"],"keep":"none"}}
Result:
{
"structuredContent": {
"removed": [
"e0000000000000000000000000000001"
]
}
}
Effect: destructive, on the Book.
Params
Params of price.removeOld.
commodities(array of CommodityId, required): The commodities whose prices (in any currency) are considered; at least one.before(Date, required): Only prices before this day's neutral time are considered.sources(array of RemoveSource): Which sources may be removed; default["fetched"].keep(KeepOption): What to keep; defaultlastOfWeek.fiscalYearEnd(Date or null): The last day of a fiscal year, for quarters and periods; default 31 December of the current year.
Result
What price.removeOld removed.
removed(array of Guid, required): The prices removed.