price.latest
The latest price of a commodity in a currency, either direction.
Gives the newest price of a commodity in a currency, looking in both directions. The result has the stored price,
reversed (true when the price is stored the other way round) and rate, the value in the direction you asked for:
the exact inverse when reversed. The result is null when there is no price.
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.latest","params":{"commodity":"USD","currency":"GBP"}}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"price": {
"guid": "e0000000000000000000000000000001",
"…": "…"
},
"reversed": true,
"rate": {
"num": "2",
"denom": "3"
}
}
}
Command line
red-ale exec --book book.gnucash price.latest '{"commodity":"USD","currency":"GBP"}'
It prints:
{
"price": {
"guid": "e0000000000000000000000000000001",
"…": "…"
},
"reversed": true,
"rate": {
"num": "2",
"denom": "3"
}
}
MCP tool call
Tool call:
{"name":"price.latest","arguments":{"commodity":"USD","currency":"GBP"}}
Result:
{
"structuredContent": {
"price": {
"guid": "e0000000000000000000000000000001",
"…": "…"
},
"reversed": true,
"rate": {
"num": "2",
"denom": "3"
}
}
}
Effect: read.
Params
Params of price.latest.
commodity(CommodityId, required): The commodity priced.currency(CommodityId, required): The currency wanted.
Result
Type: FoundPrice or null.