On Sun, Apr 20, 2014 at 9:16 AM, Martin Michlmayr <[email protected]> wrote:
> * Martin Blais <[email protected]> [2014-04-19 14:37]: > > > 2014-03-02 * Calculate average cost of AAA > > > Assets:Investments -1 AAA {10.00 GBP} [2014-02-01] @ > 10.00 GBP > > > Assets:Investments -1 AAA {20.00 GBP} [2014-03-01] @ > 20.00 GBP > > > Assets:Investments 2 AAA @@ 30.00 GBP > > > > That defeats the purpose of using an accounting system: you're having to > > calculate the sum yourself. > > I wouldn't go as far in saying that it defeats the purpose, but it's > definitely a very manual process. I see two solutions: either ledger > should implement a function for average cost, or there could be an > external script that generates a transaction you can easily paste into > your journal. > > In any case, I agree that this is the biggest weakness of ledger. > While the core is very powerful and flexible, we need more business > logic on top of it. > I thought about this problem a lot and I don't think it can be solved without adding a new feature. > Related: For the next iteration of Beancount, I'm adding a feature to book > > shares with the avg. cost method (in case that's what you're trying to > do). > > Can you share how you're going to implement this feature and what > other features does beancount have that ledger doesn't? > Ledger also has a lot of features Beancount doesn't, so it's not simple to compare them. Beancount has no features for customizing filtering and such, it has no embedded selection language for transactions. Instead, it provides a simpler grammar and a simple data structure. You should be able to process the data structure - a list of immutable transaction objects - to perform the same kinds of additions, filterings, etc. I need to document this at some point - I'm really busy - but you can always dig in the code. Average cost booking will require a new feature, as I mentioned. I think this will need some new syntax. What I have in mind so far is to allow the user to replace the cost by a special symbol which means "book at the average cost". This operation would reset all of the units of that commodity in the wallet into a single one at the new average cost. YYYY-MM-DD * "Buy some Apple" Assets:Investments 10 AAPL {301.00 USD} Assets:Cash -3020 USD Expenses:Commissions 10 USD YYYY-MM-DD * "Buy some more Apple" Assets:Investments 10 AAPL {305.00 USD} Assets:Cash -3060 USD Expenses:Commissions 10 USD Here, the Inventory of Assets:Invesments is 10 AAPL {301.00 USD} 10 AAPL {305.00 USD} YYYY-MM-DD * "Sell some Apple - at average cost" Assets:Investments -10 AAPL {* USD} @ 308.00 USD Assets:Cash 3070 USD Expenses:Commissions 10 USD Income:CapitalGains The gain that would get automatically calculated would be of 3070 + 10 + (-10 x 303.00) = 50 USD The new "Inventory" of Assets:Investments after the same would be 10 AAPL {303.00 USD} that is, it gets reset. Another idea would be to try to apportion a number of shares between all the positions in the inventory. But I thought about that hard, and it's not always possible to do that. What's more, in _all_ of the cases where I've seen average cost come up, this condition is valid for the entire account, that is, it's some tax sheltered account that treats _all_ of the trades with the average cost booking method. What this tells me is that there's no real need to try to preserve the original positions before booking at average cost (this makes solving the problem as above possible). Technically, you could designate an account as such, and always maintain its Inventory at average cost, even without sales, but IMHO having the special transaction trigger the reallocation of the inventory is good enough, it works, and the result is the same. If I don't have to designate the account with a flag, that's less complexity to be added. Ideas welcome... how do you think we should solve this problem? > -- > Martin Michlmayr > http://www.cyrius.com/ > > -- > > --- > You received this message because you are subscribed to the Google Groups > "Ledger" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- --- You received this message because you are subscribed to the Google Groups "Ledger" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
