I'm having a hard time understanding how to write the bean-query I want; 
hopefully sharper minds can help me out.

I want to see if I have any tax loss harvesting opportunities. This just 
means I want a list of all lots whose current price is below their purchase 
price. But I'm having a hard time understanding how to get a list of just 
the lots I still currently have (i.e. ones I have not already sold).

2017-01-01 open Assets:A 
2017-01-01 open Assets:B 
2017-01-01 open Income:CapitalGains 
2017-12-27 price VWIUX 14.11000 USD 

2017-05-16 * "Buy VWIUX" 
  Assets:A 1 VWIUX {14.09 USD} 
  Assets:B 

2017-08-08 * "Buy VWIUX" 
  Assets:A 1 VWIUX {14.23 USD} @ 18,000 USD 
  Assets:B 

2017-09-08 * "Buy VWIUX" 
  Assets:A 1 VWIUX {14.32 USD} 
  Assets:B

2017-12-27 * "Sell VWIUX" 
  Assets:A -3 VWIUX {*} @ 14.11 USD 
  Assets:B

In this case, I've sold all of the lots. So there is nothing left to tax 
loss harvest. However, when I run this query

2017-01-01 query "TLH" "SELECT currency, number, cost(position), 
value(position) 
  WHERE 
    account ~ 'Assets:' 
    and number > 0 
    and cost(position) > value(position) 
  ORDER BY currency"

It still returns the last 2 lots, which isn't what I expect to happen.

curre n cost_posi value_pos 
----- - --------- --------- 
VWIUX 1 14.23 USD 14.11 USD 
VWIUX 1 14.32 USD 14.11 USD

So....where am I going wrong?

Cheers,
Justus

-- 
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/894cc5d3-4dac-405b-9342-7dc9965d9826%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to