I saw a few different questions in there:
- "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:"
Beancount tries to infer the right precision for a particular currency, but
provides you options to specify what it should be. See
https://beancount.github.io/docs/precision_tolerances.html and
https://beancount.github.io/docs/beancount_options_reference.html
I think that should set the precision you are getting in bean-query /
report.
- Maintaining basis when transferring lots.
The booking methods as they are now are only used to resolve reductions. So
reducing the lots in an account can select several possible lots for a
booking method like FIFO, and indeed those get expanded by the booking
method to reduce each of the original lots.
However, the augmentation code has no such notion. If you put an
augmentation with an empty basis spec, beancount's inference engine will
see a single new lot being created and try to infer the missing info by
calculating which values would make the transaction balance.
All of this code runs before plugins do, but I believe you could write a
fairly simple plugin to do this. Plugins have the opportunity to rewrite
the transaction completely, but do run after the booking code has run.
So you would write something like this in your ledger:
2020-12-19 * "Binance" "Transfer BTC Coinbase-Pro => Binance"
Assets:Crypto:BTC:Binance 0.2 BTC {}
Assets:Crypto:BTC:Coinbase-Pro -0.2 BTC {}
Beancount's booking code + FIFO method + inferences would resolve that into
something like:
Assets:Crypto:BTC:Binance 0.2 BTC {19000 EUR}
Assets:Crypto:BTC:Coinbase-Pro -0.1 BTC {18000 EUR}
Assets:Crypto:BTC:Coinbase-Pro -0.1 BTC {20000 EUR}
And then a plugin could rewrite that into the original lots:
Assets:Crypto:BTC:Binance 0.1 BTC {18000 EUR}
Assets:Crypto:BTC:Binance 0.1 BTC {20000 EUR}
Assets:Crypto:BTC:Coinbase-Pro -0.1 BTC {18000 EUR}
Assets:Crypto:BTC:Coinbase-Pro -0.1 BTC {20000 EUR}
On Tue, Dec 22, 2020 at 1:25 PM Tobias H <[email protected]> wrote:
> 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/4242c558-c761-4fcb-8703-6b17b9b2a4e5n%40googlegroups.com
> <https://groups.google.com/d/msgid/beancount/4242c558-c761-4fcb-8703-6b17b9b2a4e5n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
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/CACGEkZt%2BzUdirAz5ejcr3kQA%2BP6B2x1ctAObKnfsnxtjWVrWhQ%40mail.gmail.com.