After reading
https://groups.google.com/g/beancount/c/Qvbcq-Sk5NY/m/WGkLFIb7AgAJ
more carefully I found a partial solution: Providing the cost currency in
the lot reducing transaction, FIFO booking works:
option "booking_method" "FIFO"
option "operating_currency" "EUR"
option "inferred_tolerance_default" "*:0.001"
option "inferred_tolerance_default" "EUR:0.001"
option "inferred_tolerance_default" "BTC:0.00000001"
2020-12-01 open Equity:Opening-Account
2020-12-01 open Assets:Cash:Coinbase-Pro
2020-12-01 open Assets:Cash:Binance
2020-12-01 open Assets:Crypto:BTC:Coinbase-Pro
2020-12-01 open Assets:Crypto:BTC:Binance
2020-12-01 open Expenses:Commission:Coinbase-Pro:EUR
2020-12-01 open Income:Day-trading:EUR
2020-12-17 * "Coinbase" "Opening"
Assets:Cash:Coinbase-Pro 5000 EUR
Equity:Opening-Account -5000 EUR
2020-12-17 * "Coinbase" "Trade EUR => BTC"
Assets:Cash:Coinbase-Pro -2500 EUR
Assets:Crypto:BTC:Coinbase-Pro 0.13833333 BTC {18,000 EUR,
2020-12-17} @ 18,000 EUR
Expenses:Commission:Coinbase-Pro:EUR 10 EUR
2020-12-18 * "Coinbase" "Trade EUR => BTC"
Assets:Cash:Coinbase-Pro -2500 EUR
Assets:Crypto:BTC:Coinbase-Pro 0.125 BTC {20,000 EUR,
2020-12-18} @ 20,000 EUR
Expenses:Commission:Coinbase-Pro:EUR 0 EUR
2020-12-19 * "Binance" "Transfer BTC Coinbase-Pro => Binance"
Assets:Crypto:BTC:Binance 0.2 BTC {}
; THAT ↓ MAKES THE
DIFFERENCE
Assets:Crypto:BTC:Coinbase-Pro -0.2 BTC {EUR}
; THAT ↑ MAKES THE
DIFFERENCE
2020-12-20 * "Binance" "Trade BTC => USDT"
Assets:Crypto:BTC:Binance -0.2 BTC {} @ 19500 EUR
Assets:Cash:Binance 3900 EUR
Income:Day-trading:EUR
But, unfortunately, there's a drawback: beancount creats only one lot
in Assets:Crypto:BTC:Binance—instead of copying the the old ones.
Here's what I mean:
$ bean-doctor context Krypto.bean 33
Hash:6987d379aededd533a9f0f9a50712dcd
Location: Krypto.bean:33
------------ Balances before transaction
Assets:Crypto:BTC:Binance
Assets:Crypto:BTC:Coinbase-Pro 0.13833333 BTC {18000 EUR,
2020-12-17}
Assets:Crypto:BTC:Coinbase-Pro 0.125 BTC {20000 EUR,
2020-12-18}
------------ Transaction
2020-12-19 * "Binance" "Transfer BTC Coinbase-Pro => Binance"
Assets:Crypto:BTC:Binance 0.2 BTC {18617 EUR, 2020-12-19} ;
3723.33334000 EUR
Assets:Crypto:BTC:Coinbase-Pro -0.1 BTC {18000 EUR, 2020-12-17} ;
-2489.99994000 EUR
Assets:Crypto:BTC:Coinbase-Pro -0.1 BTC {20000 EUR, 2020-12-18} ;
-1233.33340000 EUR
Tolerances: BTC=1E-8, EUR=0.001
------------ Balances after transaction
* Assets:Crypto:BTC:Binance 0.2 BTC {18616.6667000 EUR,
2020-12-19}
* Assets:Crypto:BTC:Coinbase-Pro 0.06333333 BTC {20000 EUR,
2020-12-18}
The new lot in Assets:Crypto:BTC:Binance is: 0.2 BTC {18616.6667000 EUR,
2020-12-19}.
What I'd like it to be:
Assets:Crypto:BTC:Binance 0.13833333 BTC {18000 EUR, 2020-12-17}
Assets:Crypto:BTC:Binance 0.125 BTC {20000 EUR, 2020-12-18}
So, basically a complete copy of the previous lots.
Why is that important? The average cost that beancount calculates is
sufficient to calculate profit and loss. BUT: The original lot dates are
important because I can sell coins that I held for longer than a year
without paying taxes. So, is it possible to prevent the creation of a new
summarized lot?
Regards
Peter schrieb am Dienstag, 22. Dezember 2020 um 22:27:08 UTC+1:
> Is there a way to automatically transfer lots from one account to another
> using FIFO and keeping the prices paid?
>
> E.g.:
>
> I bought `0.13833333 BTC` for `2500 EUR` and `0.125 BTC` for `2500 EUR` on
> Coinbase. I transferred `0.2 BTC` to Binance. I sold all `0.2 BTC` for
> `3500 EUR` on Binance.
>
> *(Which will actually become a swap to another coin. But for taxes I need
> to account an assumed BTC-EUR sell and an assumed X-Token buy. But since I
> got that lot issue the final step is omitted.)*
>
> option "booking_method" "FIFO"
> option "operating_currency" "EUR"
> option "inferred_tolerance_default" "EUR:0.001"
> option "inferred_tolerance_default" "BTC:0.00000001"
> 2020-12-01 open Equity:Opening-Account
> 2020-12-01 open Assets:Cash:Coinbase-Pro
> 2020-12-01 open Assets:Cash:Binance
> 2020-12-01 open Assets:Crypto:BTC:Coinbase-Pro
> 2020-12-01 open Assets:Crypto:BTC:Binance
> 2020-12-01 open Expenses:Commission:Coinbase-Pro:EUR
> 2020-12-01 open Income:Day-trading:EUR
> 2020-12-17 * "Coinbase" "Opening"
> Assets:Cash:Coinbase-Pro 5000 EUR
> Equity:Opening-Account -5000 EUR
>
> 2020-12-17 * "Coinbase" "Trade EUR => BTC"
> Assets:Cash:Coinbase-Pro -2500 EUR
> Assets:Crypto:BTC:Coinbase-Pro 0.13833333 BTC {18,000 EUR} @ 18,000 EUR
> Expenses:Commission:Coinbase-Pro:EUR 10 EUR
> 2020-12-18 * "Coinbase" "Trade EUR => BTC"
> Assets:Cash:Coinbase-Pro -2500 EUR
> Assets:Crypto:BTC:Coinbase-Pro 0.125 BTC {20,000 EUR} @ 20,000 EUR
> Expenses:Commission:Coinbase-Pro:EUR 0 EUR
>
> 2020-12-19 * "Binance" "Transfer BTC Coinbase-Pro => Binance"
> Assets:Crypto:BTC:Binance 0.2 BTC
> Assets:Crypto:BTC:Coinbase-Pro -0.2 BTC
>
> 2020-12-20 * "Binance" "Trade BTC => USDT"
> Assets:Crypto:BTC:Binance -0.2 BTC {} @ 17,500 EUR
> Assets:Cash:Binance 3,500 EUR
> Income:Day-trading:EUR
>
> The error I'm getting is:
>
> >$ bean-check Krypto.bean
> >
> >Krypto.bean:38: No position matches
> "Posting(account='Assets:Crypto:BTC:Binance', units=-0.2 BTC,
> cost=CostSpec(number_per=<class 'beancount.core.number.MISSING'>,
> number_total=None, currency='EUR', date=None, label=None, merge=False),
> price=17500 EUR, flag=None, meta={'filename': 'Krypto.bean', 'lineno':
> 39})" against balance (0.2 BTC)
> >
> > 2020-12-20 * "Binance" "Trade BTC => USDT"
> > Assets:Crypto:BTC:Binance -0.2 BTC {} @ 17500 EUR
> > Assets:Cash:Binance 3500 EUR
> > Income:Day-trading:EUR
>
> That's probably because the lot information isn't passed in the 2020-12-19
> transfer post.
>
> `--------------------`
>
> According to the manual keeping the lot information could be achieved
> writing the transfer post like this:
>
> 2020-12-16 * "Binance" "Transfer BTC Coinbase-Pro => Binance"
> Assets:Crypto:BTC:Binance 0.13833333 BTC {18,000 EUR} ; creates a lot
> manually. Not FIFO safe
> Assets:Crypto:BTC:Coinbase-Pro -0.13833333 BTC {} ; selects the lot
> automatically. Therefore, Assets:Crypto:BTC:Coinbase-Pro is FIFO safe
>
> But using this means I'm creating a lot in the second account
> `Assets:Crypto:BTC:Binance` manually. So, I'd need to look up which is/are
> the lot(s) that get transferred. Is there a syntax to solve automatically?
> Doing this manually would be cumbersome and error-prone. Dealing with
> cryptos many transfers between exchanges and privately owned wallets are a
> common thing. To keep track of them is crucial for any tax declaration.
>
> I think this is related to:
> * https://groups.google.com/g/beancount/c/gecmdDlrxWc/m/qRTJniqQAQAJ
> * https://groups.google.com/g/beancount/c/Qvbcq-Sk5NY
> * https://github.com/beancount/beancount/issues/168
>
> `--------------------`
>
> In order to do the FIFO manually I need to look up/query my lots, but I'm
> unable to do this. `bean-report FILE holdings` seemed appropriate, but the
> lot date is missing and the units are trimmed/rounded to two digits:
>
> >$ bean-report Krypto.bean holdings
> >
> >Account Units Currency Cost Currency Average Cost Price Book Value Market
> Value
> >------------------------------ ----- -------- ------------- ------------
> ----- ---------- ------------
> >Assets:Crypto:BTC:Binance 0.20 BTC BTC 0.20 0.20
> Assets:Crypto:BTC:Coinbase-Pro 0.14 BTC EUR 18,000.00 2,490.00
> Assets:Crypto:BTC:Coinbase-Pro 0.12 BTC EUR 20,000.00 2,500.00
> Assets:Crypto:BTC:Coinbase-Pro -0.20 BTC BTC -0.20 -0.20
> >------------------------------ ----- -------- ------------- ------------
> ----- ---------- ------------
> I also tried `bean-query`. I could add the date, but the unit size is
> rounded as well:
>
> >$ bean-query Krypto.bean 'SELECT account, date, position WHERE
> currency="BTC" ORDER BY account'
> >
> > account date position
> >------------------------------ ---------- --------------------
> >Assets:Crypto:BTC:Binance 2020-12-19 0.2 BTC
> >Assets:Crypto:BTC:Coinbase-Pro 2020-12-17 0.1 BTC {18000 EUR}
> >Assets:Crypto:BTC:Coinbase-Pro 2020-12-18 0.1 BTC {20000 EUR}
> >Assets:Crypto:BTC:Coinbase-Pro 2020-12-19 -0.2 BTC
>
> I'd like to have an output with the colums:
>
> account, lot_date, lot_units (using 8 decimal digits), lot_cost (using 8
> decimal digits)
> Lots which has been transferred/sold should be omitted, of course. (How)
> Is this possible?
>
> Regards.
>
--
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/33f58b72-9735-4303-a32c-a2efb288e445n%40googlegroups.com.