The "experimental_booking_algorith" still wouldn't work, so I did some
grepping on the source and the option is: "experiment_booking_method".
That seems to work great.  Thanks.


On Fri, Oct 14, 2016 at 9:20 PM, Martin Blais <bl...@furius.ca> wrote:

> On Fri, Oct 14, 2016 at 8:43 PM, <bud...@gmail.com> wrote:
>
>> When trying to use the book_algorithm option, I get an error: Invalid
>> option: 'booking_algorithm' .
>> I installed beancount from repository (hg id shows 5e2dcbfc81b1) using
>> pip install.   Not sure what I'm doing wrong.
>>
>> The head of beancount file verbatim is:
>> ;; -*- mode: org; mode: beancount; coding: utf-8; fill-column: 400; -*-
>> option "title" "Trading"
>> option "operating_currency" "CAD"
>> option "booking_algorithm" "FULL"
>>
>> 2016-01-01 open Assets:Broker:Cash CAD
>> 2016-01-01 open Equity:OpeningBalance CAD
>> 2016-01-01 open Assets:Broker:ABC ABC  "FIFO"
>> 2016-01-01 open Income:Broker:PnL CAD
>>
>
> Sorry I meant "experimental_booking_algorithm."
> I was leaping ahead, I'm in the process of normalizing that and making it
> "booking_algorithm".
>
>
>
>>
>> In some accounts I don't need to report capital gains so I'm very happy
>> to use LIFO or FIFO approach strctly for personal record keeping of
>> profit/loss.  So if I could get the booking_algorithm working that solves
>> half of my problems.
>>
>> For other accounts subject to capital gains in Canada I need to keep
>> track of "Adjusted" cost.  First type of adjustment is averaging the price
>> of stock when you buy more (http://www.adjustedcostbase.c
>> a/blog/how-to-calculate-adjusted-cost-base-acb-and-capital-gains/
>> although this formula includes broker fees in the cost adjustment I think
>> it all still works out if I record those fees separately as Expense).
>>
>
> Okay, this gets a bit more hairy. Two things:
>
> 1. This corresponds to holding positions at average cost. Beancount will
> _eventually_ support an "AVERAGE" method which will do exactly that: before
> and after any reduction of an inventory (a reduction is a sale, a trade),
> all the existing lots for that currency will be merged and the cost
> averaged. This should cover the case of Canada.
>
> 2. However, reducing by the expenses / fees / commission cannot currently
> be done at that time. The best way to do that will be to post-process the
> trades and distribution the fees at the moment of sale. This would allow
> one to deduct the correct portion of the fee for the subset of stock sold
> (this is the correct calculation AFAIK). For example, if you buy 100 shares
> and pay an $8 fee, selling 40 shares should deduct $3.20 from the P/L.
>
> This would have to be done with some custom code. Currently I deal with
> this once / year in calculating wash sales with a custom script, which you
> can find under experiments (it's unlikely to just be reusable, last year I
> didn't have the full booking method implemented yet and I had to hack a
> kludge in order to get the dates on each lot carried through; at this
> moment, with the FULL method, the dates are always attached and next year
> tax season I'll have this in the main branch).
>
> In other words, if you really care about correct calculation of fees,
> you'll have to write at least some code, because I haven't yet made that
> reusable. This is the bad news. The good news is that the data is there and
> there's Python, so if you do care... it's doable.
>
>
>
>> Other types of cost adjustments involve return of capital by an exchange
>> traded fund (ETF) (http://www.adjustedcostbase.c
>> a/blog/return-of-capital-and-how-it-affects-adjusted-cost-base/) which
>> decreases the cost basis uniformly for all units owned, and reinvested
>> distribution which increases the cost basis uniformly accross all units
>> owned (http://www.adjustedcostbase.ca/blog/phantom-distributions-a
>> nd-their-effect-on-adjusted-cost-base/).
>>
>
> That's different. How you handle a cost basis adjustment is by "selling"
> the entire lot and replacing it in the same transaction, carrying the
> original date manually, e.g.
>
>   2013-08-01 * "Purchase"
>     ...
>
>   2015-04-03 * "Cost basis adjustment"
>     Assets:Investments:XSP   -235 XSP {45.32 CAD}
>     Assets:Investments:XSP    235 XSP {48.23 CAD, 2013-08-01}
>
> Maintaining the original date is done on the augmenting lot (the posting
> with +235 above) by providing an explicit date. The default is to attach
> the date of the transaction. I have a few of those in my own file; this
> works.
>
>
>
> I'm trying to figure out a way to keep track of the adjustments above in
>> dual-entry ledger in general, and in beancount in particular.
>> 2015-01-01 * "Opening Balance"
>>            Assets:Broker:Cash       1000 CAD
>>            Equity:OpeningBalance   -1000 CAD
>>
>> 2015-01-01 * "Purchase abc"
>>            Assets:Broker:Cash      -1100 CAD
>>            Assets:Broker:ABC         100 ABC {11.0 CAD}
>>
>> 2015-01-02 * "Purchase abc"
>>            Assets:Broker:Cash      -1000 CAD
>>            Assets:Broker:ABC         100 ABC {10.0 CAD}
>>
>> 2015-01-02 * "Return of capital (1 cent per share)"
>>            Assets:Broker:ABC         -100 ABC {10 CAD)
>>            Assets:Broker:ABC         -100 ABC {11 CAD)
>>            Assets:Broker:ABC         100 ABC {10.50 CAD}
>>
>
> Yes but I'd put one of the two dates above.
>
>
>>
>> 2016-01-11 * "Selling some ABC"
>>            Assets:Broker:ABC        -100 ABC {10 CAD} ; this can be {*}
>> or nothing when FIFO works?
>>            Assets:Broker:Cash     500.05 CAD
>>            Income:Broker:PnL
>>
>
> You can leave it as {} if you use the FULL booking algorithm, and it will
> apply the default booking method for that account. The default booking
> method is "STRICT" which fails when the list of matching lots is ambiguous
> (and "{}" selects all existing lots, so you have two); using "FIFO" will
> simply select the old lots.
>
> I hope this helps,
>
>
>
>
>> Thanks for any suggestions.
>>
>> On Friday, October 14, 2016 at 7:00:12 PM UTC-4, Martin Blais wrote:
>>>
>>> On Fri, Oct 14, 2016 at 4:58 PM, <bud...@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Thank you for writing beancount as well as exellent documentation in
>>>> terms of introduction to accounting and beancount as a software package.  I
>>>> have read several of them like Getting Started Guide, Trading with
>>>> Beancount, Cookbook.  I still have a few questions as I'm coming to grips
>>>> with using the software effectively.
>>>>
>>>> Is there a way to define default currency so I don't have to enter it
>>>> beside a very large portion (over 50%) of entries?
>>>>
>>>
>>> Beancount does not have a concept of "default currency".
>>>
>>>
>>> When selling stocks, is there a quick way to generate credit entries for
>>>> the stocks with their book vaule?  For example if I purchase a stock 10
>>>> times, 20 stocks at a time, when I want to record the sale of 181 units I
>>>> need to track down all previous purchases to figure out book value of each,
>>>> and type 10 with book value in {}.  What's the quickest way to make this
>>>> type of entry?  If there's an "automatic" way to express this in beancount
>>>> language assume I don't care how stocks are picked - LIFO or FIFO.
>>>>
>>>
>>> Yes; see the booking_algorithm to FULL and make the default booking
>>> method on those accounts to e.g. "FIFO". Like this:
>>>
>>>  option "booking_algorithm" "FULL"
>>>
>>>   ...
>>>
>>>   2015-01-01 open Assets:JTrade:MSFT    MSFT   "FIFO"
>>>
>>> The new, "FULL" booking algorithm (as opposed to the older "SIMPLE",
>>> inferior one) will become the default at some point hopefully soon (I
>>> started to make that happen earlier this week but I still need to port a
>>> number of unit tests over to it).
>>>
>>>
>>>
>>>> I need to calculate adjusted cost base in some cases when selling
>>>> stock.
>>>>
>>>
>>> "Adjusted" is a heavily overloaded term. Could you be more specific?
>>>
>>>
>>>
>>>> Does anyone have any suggestions on the most effective way to do ths?
>>>> For example can you help me write a query/report to generate book value for
>>>> each purchase trade, since the last time stock count was 0.  The reason I
>>>> had 0 in there is for example if I purchase 5 stock, sell 5 stock, purchase
>>>> 10 stock, then another 10.  I'm only interested in the last 2 transactions
>>>> for this calculation, the fact that I previously had 5 stock at some price
>>>> is not relevant to current ACB calculation.
>>>>
>>>
>>> If you had this pattern, after the sale of 5 you'd have an empty
>>> inventory. Sales further on could only match on more recent purchases.
>>>
>>> Tell us what ACB calculation you'd expect and we can help.
>>>
>>> Once the booking_algorithm will be "FULL" by default I plan to
>>> automatically add metadata to link buy/sell pairs so you can easily produce
>>> lists of trades by any period.
>>>
>>>
>>>
>>> Thank you.
>>>>
>>>>
>>>>
>>>> --
>>>> 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+...@googlegroups.com.
>>>> To post to this group, send email to bean...@googlegroups.com.
>>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>>> gid/beancount/cb10e18b-6711-48e6-b301-5ebe8131080f%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/beancount/cb10e18b-6711-48e6-b301-5ebe8131080f%40googlegroups.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 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/ms
>> gid/beancount/9b828ca0-2ea1-4fad-8530-5d399c904780%40googlegroups.com
>> <https://groups.google.com/d/msgid/beancount/9b828ca0-2ea1-4fad-8530-5d399c904780%40googlegroups.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 a topic in the
> Google Groups "Beancount" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/beancount/VdK8VCFPHLI/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CAK21%2BhNvb%3DRFO9CX%2B0%3D3%
> 3DDatmzviJLceJmnOBKkSUNVRLpv0jw%40mail.gmail.com
> <https://groups.google.com/d/msgid/beancount/CAK21%2BhNvb%3DRFO9CX%2B0%3D3%3DDatmzviJLceJmnOBKkSUNVRLpv0jw%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 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/CADH3QDhtorgxVohXVZbw0FqX3Xyp1fe2n5gY6rtRr8tWc%2BWA6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to