BTW, Ledger won't solve the problem either. There's simply no booking
against inventory state in Ledger.

The only reason "it works" in your Ledger example is that it simply sums up
all the lots, and you can aggregate units or cost at reporting time. You
can do exactly the same thing in Beancount, disabling booking, by setting
those accounts (or all accounts, see options) to the "NONE" booking method,
which will just accumulate all the lots. Thereafter, the only meaningful
numbers you can get are either the sum of units or the sum of cost for all
the lots in the inventory. You can get these numbers using SELECT
UNITS(SUM(position)) or SELECT COST(SUM(position)) using bean-query.




On Sat, Aug 12, 2017 at 11:40 PM, Martin Blais <bl...@furius.ca> wrote:

> Ouf... you're opening a number of cans of worms here.
>
>
> (1)
> The error you see happens because your 0.84429 reducing transaction has
> nothing to match against. You didn't add anything at a cost basis to reduce
> against. Check out the "bean-doctor context" command to help you debug
> what's going on, and "bean-query print".
>
> But mainly, you should not be using the book_conversions plugin. This is
> ancient and if I recall it was created to answer a question on the
> mailing-list (search for it for context) before FIFO support was
> implemented. Since then, Beancount has had proper support for FIFO, LIFO
> booking.
>
>
> (2)
> Now, the other can of worms you're opening is that you're using Bitcoin.
> Is Bitcoin to be used as a currency or as an investment? If it's to be used
> as a currency, you need not care about its cost basis and such. But more
> likely, if you're using Bitcoin like most of the other people - to
> speculate - surely you want to handle it like an investment, that is,
> tracking cost basis. Beancount can do this, though when you use your
> Bitcoins to buy things, you'll have to book reductions like sales. It's not
> difficult, but you'll have to use syntax that hints the expense is to be
> reduces with a cost basis (e.g., {}). There's no great intermediate
> solution here.
>
> So assuming you're happy doing that (that is, treating Bitcoins like
> investments) you'll have to be cognizant of writing appropriate syntax
> every time you add new bitcoins: supplying the cost basis when you add
> Bitcoins to an account, and making sure to let Beancount know reductions of
> Bitcoins from an account are to be carried out with the cost basis (using
> as little as {} should be possible, since FIFO should kick in).
>
> I would suggest you should become intimately familiar with this doc:
> http://furius.ca/beancount/doc/trading, and the FIFO and LIFO, etc.
> booking method bits of the language syntax documentation, and start
> treating all deposits and withdrawals of Bitcoins from accounts like you
> would shares of a company.
>
>
> (3)
> Thirdly, you're attempting to use both Bitcoin and Ethereum, both of which
> surely you'll be wanting to track cost basis for. It's not impossible, but
> you're making your life miserable if you're going to use this for any real
> world expenses. The analogy is like if you were going to buy shares of
> AAPL, and every time you go to the coffee shop you'll pay coffee with some
> fractions of shares of AAPL and always have to choose which lot to choose
> from every single time (yes, Beancount can figure out which lot to use, but
> still, you have to indicate as such). I don't think there's any system that
> is designed with that use case as the common case, neither Ledger,
> Beancount or any other, though Beancount comes the closest to having the
> features you need to do that.
>
> I think if you have the time you can probably come up with a clever system
> of accounts where you set aside some amount of Bitcoins to a separate
> account stripping away the cost basis and when you spend you always book
> against this account. This would segregate all the cost basis tracking and
> trading activities to another set of accounts. I think that would be a
> practical and probably nicely workable compromise. I haven't tried (and
> cannot afford to right now) but I think there's everything there to support
> that use case already.
>
>
>
>
>
> On Sat, Aug 12, 2017 at 5:02 PM, <jkep...@gmail.com> wrote:
>
>> Hello,
>>
>> So, since I got the plugin for dealing with lots and capital gains
>> running, I'm attempting to import my balanced ledger journal files into
>> beancount so I can have the plugin deal with reducing my lots rather than
>> doing it manually. But I've a significant number of transactions that
>> beancount says aren't balanced, in spite of their balancing in ledger.
>> Here's one example (including my header incase I missed something there):
>>
>> ; -*- mode: org; mode: beancount; coding: utf-8; fill-column: 400; -*-
>>
>> option "title" "My Personal Ledger"
>> option "operating_currency" "BTC"
>> option "operating_currency" "ETH"
>>
>>
>>   plugin "beancount.plugins.book_conversions"
>> "Assets:Crypto:Ethereum,Income:Capital-gains"
>>
>> * Equity
>> 2015-01-01 open Equity:Opening-Balances
>>
>> * Account declarations
>> 2015-01-01 open Assets:Crypto:Bitcoin                  BTC
>> 2015-01-01 open Assets:Crypto:Ethereum                 ETH
>> 2015-01-01 open Expenses:Crypto:NetworkFees           BTC
>>
>> * Income
>> 2015-01-01 open Income:Capital-gains
>>
>> * Expenses
>> 2015-01-01 open Expenses
>>
>> * Transactions
>> 2015-01-01 * ""Opening Bank balance""
>>     Assets:Crypto:Bitcoin                            0.05000000 BTC
>>     Assets:Crypto:Ethereum                           1.00000000 ETH
>>     Equity:Opening-Balances
>>
>> 2016-08-13 * "Ethereum sale "
>>      Assets:Crypto:Ethereum      -0.84429 ETH {0.02055 BTC, 2016-08-09} @
>> 0.01995 BTC
>>        trades: "trade-570f1d77bece"
>>      Income:Capital-gains
>>      Assets:Crypto:Bitcoin     0.01684358 BTC
>>
>>
>> bean-check complains about a half a satoshi (which can't exist in the
>> real world, only in spreadsheets) not balancing:
>>
>> /home/joel/beancount/temp2.bc:1333:    Transaction does not balance: (-
>> 0.0000000055 BTC)
>>
>>    2016-08-13 * "Ethereum sale "
>>      Assets:Crypto:Ethereum      -0.84429 ETH {0.02055 BTC, 2016-08-09} @
>> 0.01995 BTC
>>        trades: "trade-570f1d77bece"
>>      Income:Capital-gains    0.0005065740 BTC
>>
>>      Assets:Crypto:Bitcoin     0.01684358 BTC
>>
>> However, all the transaction in that file were balancing in ledger,
>> before I converted them to beancount format. I checked this one by running
>> it through ledger after commenting out the "trades" line
>>
>> 2016-08-13 * "Ethereum sale "
>>      Assets:Crypto:Ethereum      -0.84429 ETH {0.02055 BTC, 2016-08-09} @
>> 0.01995 BTC
>>        ;trades: "trade-570f1d77bece"
>>      Income:Capital-gains
>>      Assets:Crypto:Bitcoin     0.01684358 BTC
>>
>> and got the following result:
>>
>> joel@bregalad:~/beancount$ ledger -f temp3.dat bal
>>       0.01684358 BTC
>>         -0.84429 ETH  Assets:Crypto
>>       0.01684358 BTC    Bitcoin
>>         -0.84429 ETH    Ethereum
>>       0.00050658 BTC  Income:Capital-gains
>> --------------------
>>       0.01735016 BTC
>>         -0.84429 ETH
>> joel@bregalad:~/beancount$ nano temp3.dat
>> joel@bregalad:~/beancount$ ledger -f temp3.dat bal
>>       0.01684358 BTC
>>         -0.84429 ETH  Assets:Crypto
>>       0.01684358 BTC    Bitcoin
>>         -0.84429 ETH    Ethereum
>>       0.00050658 BTC  Income:Capital-gains
>> --------------------
>>       0.01735016 BTC
>>         -0.84429 ETH
>>
>> Any ideas what I'm missing in beancount? Or is there a way I can tell it
>> to force anything less than a satoshi(0.00000001 BTC) to balance?
>>
>> And another issue I don't understand:
>>
>> In the same file, I had four transactions that resulted in the following
>> output from bean-check:
>> Could not match position Posting(account='Assets:Crypto:Ethereum', units
>> =-44.08 ETH, cost=None, price=0.02439024 BTC, flag=None, meta={'filename'
>> : '/home/joel/beancount/temp2.bc', 'lineno': 99})
>>
>> The offending transaction here (same header as above, as its the in the
>> same beancount file) is:
>>
>> 2016-06-05 * "Sell ETH"
>>     Assets:Crypto:Bitcoin                 1.0751 BTC
>>     Assets:Crypto:Ethereum                   -44.08 ETH @ 0.02439024 BTC
>>     ; CSV: 06-05-2016,10:45:13 AM,Sell ETH via Bitsquare,a4453750,,,
>> 1.0751 BTC,0.02439024 BTC,44.08 ETH,Completed
>>     ; Imported: 2017-07-15
>>     ; Price per coin: 0.02439024 BTC
>>     ; Time: 10:45:13 AM
>>     ; Trade Status: Completed
>>     ; UUID: 7d96c7ac8441d01fbfa81c64628b5b963180c3f7
>>
>> Here again the transaction balances when I ran it through ledger,
>> unchanged from above. I don't understand why it could not match the
>> position posting. Does that mean that there's not enough ETH in the lots
>> inventory and I'm missing a transaction?
>>
>> Thanks,
>>
>> Joel
>>
>> --
>> 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 beancount+unsubscr...@googlegroups.com.
>> To post to this group, send email to beancount@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/beancount/23f40716-a471-4bac-8c24-d33a7ee8f6aa%40googlegroups.com
>> <https://groups.google.com/d/msgid/beancount/23f40716-a471-4bac-8c24-d33a7ee8f6aa%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 beancount+unsubscr...@googlegroups.com.
To post to this group, send email to beancount@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CAK21%2BhN0cgxt3qLwpQFJTcC0LghXzZhkcQgtqOzY%3DgBMKEfO5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to