Re: balanced ledger transaction(s) imported to beancount won't balance... help!

2017-08-12 Thread jkepler
Thanks for pointing me in the direction of the commands and document 
resources I can use to debug my file. I'll re-read your trading 
documentation, as well as the docs on beancount's many tools. I had no idea 
the book_conversions plugin is ancient.

Regarding my Bitcoin use, my primary use is to buy it with USD in the US 
(where I get paid) and sell it for EUR here in Europe (where I live and 
work). Its significantly cheaper and faster than using traditional 
international wires or a service like Transferwise. Plus by using bisq.io I 
don't have to trust a third-party company with my money, other than my 
banks---which I already have to trust. I also occasionally use it to buy 
stuff our family needs on Amazon at a discount using purse.io. However, due 
to a super-busy work and family period the past two years, I've neglected 
keeping my journal file current, and that's created a ton of work for me 
(and its forcing me to dig in to learn interesting things and revive my 
programming skills).

About those Ethereum transactions - last year I did some trading between 
Bitcoin and Ethereum, but then I stopped, due to the time-consuming nature 
of accounting for those transactions... I've more important things to spend 
my time on.

Thanks again for your response.





Le dimanche 13 août 2017 05:41:16 UTC+2, Martin Blais a écrit :
>
> 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,  wrote:
>
>> Hello,
>>
>> So, since I got the plugin for dealing with lots and capital gains 
>> 

Re: balanced ledger transaction(s) imported to beancount won't balance... help!

2017-08-12 Thread Martin Blais
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  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,  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"
>> 

balanced ledger transaction(s) imported to beancount won't balance... help!

2017-08-12 Thread jkepler
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:Bitcoin0.0500 BTC
Assets:Crypto:Ethereum   1. 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.55 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-gains0.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 BTCBitcoin
-0.84429 ETHEthereum
  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 BTCBitcoin
-0.84429 ETHEthereum
  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.0001 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/msgid/beancount/23f40716-a471-4bac-8c24-d33a7ee8f6aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to I run a beancount plugin? beancount.plugins.book_conversions

2017-08-12 Thread jkepler
Duh! I found it in the documentation, 
https://docs.google.com/document/d/1QftxNvQPdH-MikMBHupftU6F4IsNZP5FlFh1LCbVgk8/edit:
 
a plugin is added to the input file via the optional syntax.

In my case, that was simply adding this line:

  plugin "beancount.plugins.book_conversions" 
"Assets:Bitcoin,Income:Capital-gains"

and the sample data works.



Le samedi 12 août 2017 15:58:02 UTC+2, jke...@gmail.com a écrit :
>
> Hi there,
>
> I'm a beginning beancount user, if I can get the 
> beancount.plugins.book_conversions to run on my journal for calculating my 
> capital gains/losses.
>
> I found that the source for that plugin is in the plugins directory on my 
> beancount install, but I'm at a loss for how to use it.
>
> Can someone point me to the appropriate documentation?
>
> 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/msgid/beancount/30257e38-52c3-4551-9753-ba6cc1ca106e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.