Stock splits and mergers
Record a stock split with stock.split, which adds shares at no cost; record a merger by hand with ordinary transactions.
A stock split gives you more shares for the ones you have, without changing what the holding is worth: two-for-one doubles your shares and halves each one's price. The cost of the holding stays the same. A merger or takeover exchanges your shares of one company for shares of another, or for cash.
Stock split
- Work out how many shares you gain. A two-for-one split of 90 shares gives 90 more; the
sharesyou pass is the increase, and a negative number records a reverse split. - Call stock.split with the share
account, thedateandshares. Addprice(the new price per share) if you want it recorded in the price database. It posts a transaction that adds shares with a value of zero, so no cash moves and the cost basis is unchanged. - Check the new share count with account.balance.
If a different price is already stored for that day, blockingPrice shows it and the new price is not stored.
Merger
There is no merger method. Record one as ordinary transactions, which keeps your records easy to follow:
- In the old share account, post a transaction that takes out the old shares at their cost: old shares
-(value the cost,amountthe old share count). - In a new share account for the new company, bring in the new shares with the same total value: new shares
+(value the cost,amountthe new shares). - If you also received cash, add a cash split, and put any gain in an income account, as in Buy and sell shares.
- Add the new company's price with price.add.
Example
Example: with a copy of the reports/investment-lots example book open as book.gnucash.
JSON-RPC
Request:
{"jsonrpc":"2.0","id":1,"method":"stock.split","params":{"account":"Root:Assets:Broker:AAPL","date":"2021-01-01","shares":"90","price":"55.00"}}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"transaction": "…",
"priceStatus": "added",
"price": "…",
"blockingPrice": null
}
}
Request:
{"jsonrpc":"2.0","id":2,"method":"account.balance","params":{"account":"Root:Assets:Broker:AAPL"}}
Response:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"balances": {
"commodity": "NASDAQ::AAPL",
"balance": {
"num": "180",
"denom": "1"
},
"…": "…"
},
"…": "…"
}
}
Command line
red-ale exec --book book.gnucash --script - <<'EOF'
stock.split {"account":"Root:Assets:Broker:AAPL","date":"2021-01-01","shares":"90","price":"55.00"}
account.balance {"account":"Root:Assets:Broker:AAPL"}
EOF
It prints:
[
{
"transaction": "…",
"priceStatus": "added",
"price": "…",
"blockingPrice": null
},
{
"balances": {
"commodity": "NASDAQ::AAPL",
"balance": {
"num": "180",
"denom": "1"
},
"…": "…"
},
"…": "…"
}
]
MCP tool call
Tool call:
{"name":"stock.split","arguments":{"account":"Root:Assets:Broker:AAPL","date":"2021-01-01","shares":"90","price":"55.00"}}
Result:
{
"structuredContent": {
"transaction": "…",
"priceStatus": "added",
"price": "…",
"blockingPrice": null
}
}
Tool call:
{"name":"account.balance","arguments":{"account":"Root:Assets:Broker:AAPL"}}
Result:
{
"structuredContent": {
"balances": {
"commodity": "NASDAQ::AAPL",
"balance": {
"num": "180",
"denom": "1"
},
"…": "…"
},
"…": "…"
}
}