I know this has been discussed a few times, but the docs are still incorrect 
and I’m unable to find a complete example.  I’m using beancount v2 because 
Fava’s not been updated for v3, yet.

NVDA recently split 10:1. I previously purchased 2 shares:

option "operating_currency" "USD"

2024-02-14 open Equity:Opening-Balances                                         
USD

2024-02-14 open Assets:Cash                                                     
USD
2024-02-14 pad Assets:Cash Equity:Opening-Balances

2024-02-14 open Assets:Stocks:NVDA                                              
NVDA
2024-02-14 commodity NVDA

2024-02-14 * "Buying some NVDA" ""
    Assets:Stocks:NVDA                                                     2.00 
NVDA {733.09 USD}
    Assets:Cash

2024-05-31 balance Assets:Stocks:NVDA                                         2 
NVDA
2024-05-31 balance Assets:Cash                                             0.00 
USD

The pre-split stock price (per Yahoo and bean-price) was 1,096.33, and my 
Fidelity account confirms that I have 20 shares.  Per the docs[1], I would do 
(I think):

2024-06-02 * "NVDA 10:1 stock split" ""
    Assets:Stocks:NVDA                                                       -2 
NVDA {1,096.33 USD}
    Assets:Stocks:NVDA                                                       50 
NVDA {109.633 USD}

bean-check fails, however:

nvidia_split.beancount:24:      No position matches 
"Posting(account='Assets:Stocks:NVDA', units=-2 NVDA, 
cost=CostSpec(number_per=Decimal('1096.33'), number_total=None, currency='USD', 
date=None, label=None, merge=False), price=None, flag=None, meta={'filename': 
'nvidia_split.beancount', 'lineno': 29})" against balance (2.00 NVDA {733.09 
USD, 2024-02-14})

Explicitly using the lot in that transaction fails, too:

2024-06-02 * "NVDA 10:1 stock split" ""
    Assets:Stocks:NVDA -2 NVDA {733.09 USD, 2024-02-14} @ 1096.33 USD
    Assets:Stocks:NVDA 20 NVDA {109.633 USD}

The error is:

nvidia_split.beancount:24:      Transaction does not balance: (726.4800 USD)

   2024-06-02 * "NVDA 10:1 stock split" ""
     Assets:Stocks:NVDA  -2.00 NVDA {733.09 USD, 2024-02-14} @ 1096.33 USD
     Assets:Stocks:NVDA     20 NVDA {109.633 USD, 2024-06-02}

So it seems the price of 1096.33 is being ignored and I’m trying to purchase 20 
shares at 109.633 USD using 2*733.09 USD and the “gain” of 363.24 USD per share 
is being lost.

What is the proper way to reflect a stock split?

Thanks,
Brian

[1]: https://beancount.github.io/docs/trading_with_beancount.html#stock-splits
— 
Brian Lalor (he/him)
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/C9EBE17D-A95F-4018-B979-59831C301DFB%40bravo5.org.

Reply via email to