I am trying to track holdings in several retirement accounts where the 
average cost method is the appropriate one. I have read the various 
documents and discussions on the topic I managed to find in the Beancount 
universe. I decided that "NONE" booking with manually computed average 
basis values will do fine for me until an AVERAGE method is implemented. 
(Thanks for the workaround, and for Beancount, of course.) I also 
discovered and started using the check_average_cost plugin. In the process, 
I encountered a shortcoming in check_average_cost -- or in my understanding 
of average-cost basis computation.

My accounts have two types of reductions: 1. The common 
sale/redemption/transfer out or 2. administrative fee paid in fund shares. 
It seems to me that the two reductions have very different effects on the 
cost basis of remaining shares even though the Beancount posting for the 
account is identical. I set up a simple example where I buy 20 shares of 
MFUND1 at $10 and sell 4 at $12. I repeat the same operations with MFUND2 
at the same prices except that the second operation, the reduction, is a 
fee payment in shares.

In the first case, the average cost basis for the 16 shares remaining after 
the sale is $10. Cost basis is unaffected by the units or the price of the 
sale -- as one would expect from average booking.

In the second case, average the cost basis of the 16 shares is $15.5 
(($20*10+$12*4)/16) because the proceeds from the "sale" are a fee paid to 
the administrator and thus increase the total cost of the remaining shares. 
Such reductions as a fee to the administrator always increase the average 
cost of the remaining shares.

At least, this is my understanding of how average-cost basis works. 
However, the check_average_cost plugin does not agree. To illustrate, I 
added third operation to both sequences above, a sale of 10 shares at $14. 
Here is the entire file:

plugin "beancount.plugins.check_average_cost"
option "operating_currency" "USD"

1900-01-01 commodity MFUND1
1900-01-01 commodity MFUND2

2019-01-01 open Assets:Bank:Checking                        USD
1980-05-12 open Equity:Opening-Balances
2019-01-01 open Assets:Investments:MFUND1       MFUND1   "NONE"
2019-01-01 open Assets:Investments:MFUND2       MFUND2   "NONE"
2019-01-01 open Expenses:Fees                   USD
2019-01-01 open Income:Gains                    USD

2019-01-01 * "Opening Balance for checking account"
  Assets:Bank:Checking                        10000.00 USD
  Equity:Opening-Balances                    -10000.00 USD

2019-01-02 * "Buy 20 shares of MFUND1 at 10 USD"
  Assets:Bank:Checking              -200 USD                          
  Assets:Investments:MFUND1           20 MFUND1 {} @ 10 USD

2019-01-03 * "Sell 4 shares of MFUND1 at 12 USD"
  Assets:Bank:Checking                48.00 USD                          
  Assets:Investments:MFUND1           -4 MFUND1 {10 USD}  @ 12.00 USD
  Income:Gains

2019-01-04 * "Sell 10 shares of MFUND1 at 14 USD"
  Assets:Bank:Checking               140.00 USD                          
  Assets:Investments:MFUND1          -10 MFUND1 {10 USD}  @ 14.00 USD
  Income:Gains

2019-01-02 * "Buy 20 shares of MFUND2 at 10 USD"
  Assets:Bank:Checking              -200 USD                          
  Assets:Investments:MFUND2           20 MFUND2 {} @ 10 USD

2019-01-03 * "Pay account fee of 48 USD in MFUND2, 4 at 12 USD"
  Expenses:Fees                       48.00 USD                          
  Assets:Investments:MFUND2           -4 MFUND2 {10 USD}  @ 12.00 USD
  Income:Gains

2019-01-04 * "Sell 10 shares of MFUND2 at 14 USD"
  Assets:Bank:Checking               140.00 USD                          
  Assets:Investments:MFUND2          -10 MFUND2 {15.5 USD}  @ 14.00 USD
  Income:Gains

This fails bean-check with
...:41:Cost basis on reducing posting is too far from the average cost 
(15.5 vs. 10)...
    2019-01-04 * "Sell 10 shares of MFUND2 at 14 USD"
    ...
Changing the 15.5 to 10 satisfies the plugin.

-- 
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/a721a519-5690-4f6e-9551-136e7dc22e71%40googlegroups.com.

Reply via email to