Re: New tool: Tax loss harvester for beancount

2020-03-17 Thread Red S
Hello Martin,
I've combined both the beancount command line client and fava extension 
into https://github.com/redstreet/fava_tax_loss_harvester. It'd be great if 
you could point to that repo in the contributions doc. Thanks!

On Tuesday, March 10, 2020 at 11:35:44 PM UTC-7, Red S wrote:
>
> Thanks Martin!
>
> In case you're collecting fava extensions as well, here is the 
> corresponding TLH fava extension: 
> https://github.com/redstreet/fava_tax_loss_harvester
> I find the fava extension most useful and plan to maintain it. 'm not yet 
> sure if I'll maintain the command line tool, in addition.
>
> On Saturday, March 7, 2020 at 6:37:13 PM UTC-8, Martin Blais wrote:
>>
>> Thank you for sharing RedS! I've added a link to the contributions doc.
>>
>> On Sat, Mar 7, 2020 at 7:54 PM Red S  wrote:
>>
>>> I cleaned up a tool I've been using to find opportunities to do tax loss 
>>> harvesting from my beancount file, and am sharing it here 
>>> . A well 
>>> crafted query may get you a rough list, but I find a few bells and whistles 
>>> to be far more useful, and hence use this harvester tool. For example, this 
>>> finds possible wash sales and reports on the details.
>>>
>>> From the README in: 
>>> https://github.com/redstreet/beancount_tax_loss_harvester
>>>
>>> Tax loss harvester for Beancount personal finance software
>>>
>>> Reports the set of lots that can be tax loss harvested from your 
>>> beancount input file. Example:
>>>
>>> $ ./tlh.py ~/accounts/accounts.beancount -a "Assets:MyInvestments"
>>>
>>> Account  Qty  Ticker   Market  PurchasedW  Loss
>>> ---  ---    -  ---  ---  --
>>> HTrade-Main32.22   YYY1982.123  2019-11-22   41
>>> HTrade-Main 1.313  YYY 893.23   2019-11-23 1142
>>> HTrade-Main40.4APPLE   704.344  2019-11-20   83
>>> HTrade-Main   159.504  BETAX  7615.42019-07-10   *  384
>>> HTrade-Second  68.695  APPLE   526.55   2019-05-10   19
>>> HTrade-Second  77.786  BETAX  4437.66   2019-08-15   *   28
>>> 6 (5 sets) 020596.97   1697
>>>
>>> Wash sales: recent purchase (within 30 days):
>>> --   --- ---  -
>>> 2020-01-25  HTrade-Third   75.39  100.00  BETAX
>>> --  ---  --- ---  -
>>>
>>> The example above shows that 1697 USD of losses can be harvested by 
>>> selling the rows listed. However, 100 USD of that would be considered a 
>>> wash sale and will not be allowable. It also shows the account and 
>>> quantities of each commodity to sell total sale proceeds (20596.97 USD) if 
>>> all the recommended lots were sold.
>>> 
>>> Features 
>>>
>>>- reports on possible wash sales (US) in the second table above
>>>- optionally set a loss threshold. Useful to filter out minor TLH 
>>>opportunities
>>>- reports the total number of sale transactions needed
>>>- optionally takes: 
>>>   - account patterns to search for wash-sale creating purchases
>>>   - account patterns to exclude for wash-sale creating purchases 
>>>   (eg: tax deferred accounts)
>>>
>>> TODO:
>>>
>>>- show if a loss generated would be long term or short term
>>>
>>> -- 
>>> 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 bean...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/beancount/9efb8263-b248-4c77-8096-2538e57677c4%40googlegroups.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 beancount+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/2e041524-e051-4025-93ad-65fba1f0bd9f%40googlegroups.com.


Re: GROUP by financial year

2020-03-17 Thread kuba jamro
+1 for this as a feature request built into beancount.

I would be willing to help in the development of this feature too.


One of the ways I thought this could be done is in fava and actually it 
looks like it has already have been done to a basic level.

There is a fava option fiscal-year-end 
https://github.com/beancount/fava/blob/master/fava/help/options.md#fiscal-year-end
.

I've given it a quick test and it seems to only work in the time filter box 
of fava and not in the BQL queries but I could I stand to be corrected.

Jakub.

On Tuesday, 17 March 2020 06:26:27 UTC, Martin Michlmayr wrote:
>
> I wasn't sure how to interpret Martin's reply.  At first, I thought he 
> was saying that he's not aware of circumstances where the FY != 
> calendar year.  But then I realized that he he was just stating that 
> beancount doesn't have a concept of FY. 
>
> As you say (and I'm sure as Martin is full aware), the FY often 
> differs.  The tax year is also different in some countries, e.g. in 
> the UK it starts on April 6. 
>
> What would the best way be to implement FY in beancount? 
>
> * Oon-Ee Ng > [2020-03-17 14:23]: 
> > Fairly common for some organizations to have financial years starting on 
> > (say) 1st August or something similar. Sometimes to sync up with 
> regulatory 
> > requirements, sometimes so that bonuses/promotions hit a particular 
> period 
> > of the year, sometimes due to expected peak dates for a particular 
> industry. 
> > 
> > On Mon, Mar 16, 2020 at 8:08 PM Martin Blais  > wrote: 
> > 
> > > I don't think there's a concert of financial year that's != calendar 
> year. 
> > > 
> > > On Mon, Mar 16, 2020, 04:19 Martin Michlmayr  > wrote: 
> > > 
> > >> I can use: 
> > >> 
> > >> SELECT YEAR, SUM(position) WHERE account ~ '^Income' GROUP BY YEAR 
> ORDER 
> > >> BY YEAR 
> > >> 
> > >> to see all income per year. 
> > >> 
> > >> Unfortunately, the financial year is not the calendar year.  Is there 
> > >> a way to use bean-query to do a GROUP BY on a fiancial year or do I 
> > >> have to write a script? 
> > >> 
> > >> -- 
> > >> Martin Michlmayr 
> > >> https://www.cyrius.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 bean...@googlegroups.com . 
> > >> To view this discussion on the web visit 
> > >> 
> https://groups.google.com/d/msgid/beancount/20200316075211.GW25911%40jirafa.cyrius.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 bean...@googlegroups.com . 
> > > To view this discussion on the web visit 
> > > 
> https://groups.google.com/d/msgid/beancount/CAK21%2BhNDs0kbdkH-%3DJi%3Df7Lqmd9Ecw3hKbEu_7ab60%2BtL%2BWXuQ%40mail.gmail.com
>  
> > > <
> https://groups.google.com/d/msgid/beancount/CAK21%2BhNDs0kbdkH-%3DJi%3Df7Lqmd9Ecw3hKbEu_7ab60%2BtL%2BWXuQ%40mail.gmail.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 bean...@googlegroups.com . 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/beancount/CAGQ70euz0fJfv3rT%2BBZWCr5G89bjLsEG5MfNp2KgPUdSzc10HQ%40mail.gmail.com.
>  
>
>
> -- 
> Martin Michlmayr 
> https://www.cyrius.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 beancount+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/8dc37b9c-42cb-4661-8dc7-65b21b8afb17%40googlegroups.com.


Re: GROUP by financial year

2020-03-17 Thread kuba jamro
FYI the format quite simple

# this matches a financial year like FY2018 for the financial year ending 
2018
FY_RE = re.compile(r"^fy(\d{4})$")

# this matches a quarter in a financial year like FY2018-Q2
FY_QUARTER_RE = re.compile(r"^fy(\d{4})-q(\d)$")

On Tuesday, 17 March 2020 13:47:36 UTC, kuba jamro wrote:
>
> +1 for this as a feature request built into beancount.
>
> I would be willing to help in the development of this feature too.
>
>
> One of the ways I thought this could be done is in fava and actually it 
> looks like it has already have been done to a basic level.
>
> There is a fava option fiscal-year-end 
> https://github.com/beancount/fava/blob/master/fava/help/options.md#fiscal-year-end
> .
>
> I've given it a quick test and it seems to only work in the time filter 
> box of fava and not in the BQL queries but I could I stand to be corrected.
>
> Jakub.
>
> On Tuesday, 17 March 2020 06:26:27 UTC, Martin Michlmayr wrote:
>>
>> I wasn't sure how to interpret Martin's reply.  At first, I thought he 
>> was saying that he's not aware of circumstances where the FY != 
>> calendar year.  But then I realized that he he was just stating that 
>> beancount doesn't have a concept of FY. 
>>
>> As you say (and I'm sure as Martin is full aware), the FY often 
>> differs.  The tax year is also different in some countries, e.g. in 
>> the UK it starts on April 6. 
>>
>> What would the best way be to implement FY in beancount? 
>>
>> * Oon-Ee Ng  [2020-03-17 14:23]: 
>> > Fairly common for some organizations to have financial years starting 
>> on 
>> > (say) 1st August or something similar. Sometimes to sync up with 
>> regulatory 
>> > requirements, sometimes so that bonuses/promotions hit a particular 
>> period 
>> > of the year, sometimes due to expected peak dates for a particular 
>> industry. 
>> > 
>> > On Mon, Mar 16, 2020 at 8:08 PM Martin Blais  wrote: 
>> > 
>> > > I don't think there's a concert of financial year that's != calendar 
>> year. 
>> > > 
>> > > On Mon, Mar 16, 2020, 04:19 Martin Michlmayr  
>> wrote: 
>> > > 
>> > >> I can use: 
>> > >> 
>> > >> SELECT YEAR, SUM(position) WHERE account ~ '^Income' GROUP BY YEAR 
>> ORDER 
>> > >> BY YEAR 
>> > >> 
>> > >> to see all income per year. 
>> > >> 
>> > >> Unfortunately, the financial year is not the calendar year.  Is 
>> there 
>> > >> a way to use bean-query to do a GROUP BY on a fiancial year or do I 
>> > >> have to write a script? 
>> > >> 
>> > >> -- 
>> > >> Martin Michlmayr 
>> > >> https://www.cyrius.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 bean...@googlegroups.com. 
>> > >> To view this discussion on the web visit 
>> > >> 
>> https://groups.google.com/d/msgid/beancount/20200316075211.GW25911%40jirafa.cyrius.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 bean...@googlegroups.com. 
>> > > To view this discussion on the web visit 
>> > > 
>> https://groups.google.com/d/msgid/beancount/CAK21%2BhNDs0kbdkH-%3DJi%3Df7Lqmd9Ecw3hKbEu_7ab60%2BtL%2BWXuQ%40mail.gmail.com
>>  
>> > > <
>> https://groups.google.com/d/msgid/beancount/CAK21%2BhNDs0kbdkH-%3DJi%3Df7Lqmd9Ecw3hKbEu_7ab60%2BtL%2BWXuQ%40mail.gmail.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 bean...@googlegroups.com. 
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/beancount/CAGQ70euz0fJfv3rT%2BBZWCr5G89bjLsEG5MfNp2KgPUdSzc10HQ%40mail.gmail.com.
>>  
>>
>>
>> -- 
>> Martin Michlmayr 
>> https://www.cyrius.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 beancount+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/7c8668c7-81cb-4d73-b86a-b8228ab2c521%40googlegroups.com.