Hi,
I've added a powerful new feature to Beancount this weekend, as a plugin.

Take this transaction:

1999-07-31 * "Sell"
  Assets:US:BRS:Company:ESPP          -81 ADSK {26.3125 USD} @ 26.4375 USD
  Assets:US:BRS:Company:Cash      2141.36 USD
  Expenses:Financial:Fees            0.08 USD
  Income:US:Company:ESPP:PnL      -10.125 USD

By default, the balance check that will be performed is against the
"weight" of each posting, for each currency. Here we have just USD's:

  -81 x 26.3125 + 2141.36 + 0.08 + -10.125 = 0 USD

However, because a price annotation is attached to the first posting, there
is another check we can do:

  -81 x 26.4375 + 2141.36 + 0.08 = 0 USD

In generic terms: if a price annotation is present on a posting, we can
compute an alternative balance using the price (instead of the cost) if
present on a posting, or the simple value, for all postings EXCEPT those
posted against Income accounts. This is an idea I had talked about a long
while ago on one of the mailing-lists, that had been sitting in the back of
my mind.

Recently I was on a long train ride and was integrating some really old
data I had written down more than 10 years ago, translating it in Beancount
format, some of which wasn't well noted down, so it had occasional mistakes
(this was an old text file I started in the 90's where I used to copy-paste
transaction details but it wasn't parsed nor verified... I suppose it was
the very beginnings of what would become the current system, at the time I
wasn't sure how I could represent and use that data).

So I built a plugin to perform this extra check and help me avoid errors
with the translation. It can be enabled with

  plugin "beancount.plugins.sellgains"

It only kicks in on transactions that have price annotations attached to
them, and ignores the other ones.

Interestingly enough, when I turned it on in my personal file (I have a
single large text file with basically _all_ my transactions), ... it
discovered some invalid transactions!  This is because most of the time the
Income leg amount is left unspecified and Beancount automatically
calculates the gains from the transaction. However, this freedom leaves
space for making mistakes in the transcription of amounts. (This yet again
reinforced my belief that without a lot of automated assertions it's
practically impossible to manually enter a meaningful number of stock
trading transactions without making a mistake.)

Anyhow, within an hour I had fixed all the errors that were now showing due
to the tighter verification. My personal file is now error free and I've
got this enabled permanently... I'll leave this extra check as an optional
plugin, but I would recommend Beancount users turn it on and tighten their
input file with this extra check; you might find some errors in your data
entry.

Enjoy,

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to