On Tue, Aug 28, 2018 at 10:38 AM Bill Harris <[email protected]> wrote:
> I copied the previously-posted excerpt to a file and ran it to see if it
> worked. That showed me I left out one line from the original file. Here's
> the code that works:
>
> 1970-01-01 open Assets:Certs:AAPL
> 1970-01-01 open Assets:MYBroker:AAPL
> 1970-01-01 open Assets:Cash:Basis
>
> 1983-01-05 * "A Note"
> Assets:Certs:AAPL 20 AAPL {34.31 USD, 1983-01-05}
> Assets:Cash:Basis
>
> 1983-04-05 * "A Note"
> Assets:Certs:AAPL 18 AAPL {47.57 USD, 1983-04-05}
> Assets:Cash:Basis
>
> 1983-05-10 * "stock move"
> Assets:MYBroker:AAPL 20 AAPL
> Assets:MYBroker:AAPL 18 AAPL
> Assets:Certs:AAPL -20 AAPL
> Assets:Certs:AAPL -18 AAPL
>
> ; zero local shares now
> 1983-05-11 balance Assets:Certs:AAPL 0 AAPL
>
> What seems to be key is dropping the date specifier on the MYBroker
> shares.
>
It checks, but it didn't work.
>
> Is it safe to assume that the bought date (and the basis) comes along with
> the stock move? I didn't think it did, and I haven't found a report that
> shows that yet.
>
It did not.
Use bean-doctor to view how the transaction gets completed and booked:
bean-doctor context stockmove.beancount 16
Hash:46c2aeba25e78d18ef8072dafabe47ae
Location:
/home/blais/r/q/beancount-data/user/wharris13/stockmove.beancount:14
------------ Balances before transaction
Assets:MYBroker:AAPL
Assets:Certs:AAPL 20 AAPL {34.31 USD, 1983-01-05}
Assets:Certs:AAPL 18 AAPL {47.57 USD, 1983-04-05}
------------ Transaction
1983-05-10 * "stock move"
Assets:MYBroker:AAPL 20 AAPL
Assets:MYBroker:AAPL 18 AAPL
Assets:Certs:AAPL -20 AAPL
Assets:Certs:AAPL -18 AAPL
------------ Balances after transaction
* Assets:MYBroker:AAPL 38 AAPL
Assets:Certs:AAPL 20 AAPL {34.31 USD, 1983-01-05}
Assets:Certs:AAPL 18 AAPL {47.57 USD, 1983-04-05}
* Assets:Certs:AAPL -38 AAPL
But let's get back to your first question.
The failure to categorize is in the booking: the first stage of booking is
to attempt to associate each posting to a currency group. USD with USD. EUR
with EUR, etc. as those may all occur on the same transaction. Then it will
proceed in interpolating a single missing amount in each currency group.
In your example, you have an inventory with a negative number of AAPL
shares and two augmenting legs (the first two). It has no way to know that
these are to be priced in USD, so it says "I don't know which currency
this is, I failed to categorize those. If you add {USD, <date>} on the
first two legs, they will categorize, and the other two will be booked
against the inventory state and also get categorized as such (without
having to put USD on them).
Finally, the partial specification, say, just specifying the date, is used
to narrow down the lot against the list of possible lots in the Inventory
of the account before applying the transaction, but NOT against the list of
other postings. That would be an interesting power to add to the booking
system, as it could disambiguate this case.
More constraints could potentially be added to make a tighter booking
system: one could assume a single currency group in each transaction when
there's at least one posting at cost. One could also assume that in that
account a commodity is never priced in terms of two different currencies.
But frankly, the book constraints code is really already complicated
enough... these seem like corner cases to me. It would be nice if they
could be inferred, but it's definitely a lot of work to handle all the
potential cases properly.
I would say:
- If this isn't a common occurrence, just put all the information about
costs explicitly.
- If this is a common occurrence, write a plugin that will automatically
insert the missing informations based on your assumptions.
I hope this helps,
>
> Bill
>
> On Tue, Aug 28, 2018 at 7:04 AM <[email protected]> wrote:
>
>> I'm a long-time Ledger user but new to beancount. I moved, because I
>> think I see functionality I can use right now (so thanks!).
>>
>> I'm starting by trying to handle some investments, and I'm stuck on a
>> seemingly simple transaction that gets the above error.
>>
>> The goal:
>>
>>
>> - Open a few accounts for a stock. In this case, I have an account
>> of certificated shares and an account of book-entry shares at a broker.
>> - Acquire shares as certificates, and then move them to book entry.
>>
>> The code (excerpted and cleaned*)
>>
>> 1970-01-01 open Assets:Certs:AAPL
>> 1970-01-01 open Assets:MYBroker:AAPL
>>
>> 1983-01-05 * "A Note"
>> Assets:Certs:AAPL 20 AAPL {34.31 USD, 1983-01-05}
>> Assets:Cash:Basis
>>
>> 1983-04-05 * "A Note"
>> Assets:Certs:AAPL 18 AAPL {47.57 USD, 1983-04-05}
>> Assets:Cash:Basis
>>
>> 1983-05-10 * "stock move"
>> Assets:MYBroker:AAPL 20 AAPL {1983-01-05}
>> Assets:MYBroker:AAPL 18 AAPL {1983-04-05}
>> Assets:Certs:AAPL -20 AAPL {1983-01-05}
>> Assets:Certs:AAPL -18 AAPL {1983-04-05}
>>
>> ; zero local shares now
>> 1983-05-11 balance Assets:Certs:AAPL 0 AAPL
>>
>>
>>
>> If I run bean-report filename print on that (real) file, i get
>> "beancount:84: Failed to categorize posting 1", where 84 points to the
>> first leg of the "stock move" transaction. I also get the same error on
>> line 85, the second leg. If I swap the first two legs with the second two,
>> the error follows the "MBroker" legs.
>>
>> The subsequent balance assertion obviously fails.
>>
>> Any tips? It's probably obvious, but I can't see it.
>>
>>
>> Thanks,
>>
>> Bill
>>
>> * Has anyone ever made a routine to "clean"--remove PII--from a beancount
>> file? I don't really want to share my financial information, but I know
>> it's often useful to share actual data files. It would be nice to have a
>> script that could take entries such as Assets:Certificate:AAPL and turn
>> turn it into something like Assets:LevelA1:LevelB1 or the like.
>>
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Beancount" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/beancount/-8YsnPkuLLc/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> To post to this group, send email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/beancount/9c9dcc5f-72bf-44b2-aaf9-4e0c07cbff77%40googlegroups.com
>> <https://groups.google.com/d/msgid/beancount/9c9dcc5f-72bf-44b2-aaf9-4e0c07cbff77%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Bill Harris
> http://makingsense.facilitatedsystems.com/
>
> --
> 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 post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beancount/CAOBquGqaearjAvRWor%3DeXXnz2US31o5_okTiz8srBo_Yv3N93Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/beancount/CAOBquGqaearjAvRWor%3DeXXnz2US31o5_okTiz8srBo_Yv3N93Q%40mail.gmail.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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/beancount/CAK21%2BhOkifyG5qctWiq5nNXgicq3_Wf3GzmipPw5p%2BDKTaFKhQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.