Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Tracking investments in hledger #624
First of all, I want to point out that everything worked for me.
Some things could still be improved.
The guide should also have a dividend example even though it is straightforward.
Some questions I came across and features I'd find helpful in hledger:
What do you think?
Hi Matthias, thanks for this useful discussion and issue round-up.
For instance, I would like to rewrite the guide from http://hledger.org/investments.html <http://hledger.org/investments.html>.
Some questions I came across and features I'd find helpful in hledger: CSV import should be able to generate transactions with more than 2 accounts. I imagine this would only require an extension of the field names that are currently allowed. It should be simpler than #507 <#507>.
I need this too. Even adding just 3rd/4th posting ability would be a help.
Tracking cost basis would be really helpful. Currently, I have to look up the cost basis of a lot and add it. This can probably not be fully automated because there are so many rules when positions are sold partially. However, it can be checked that the cost the user enters exists at least. I believe (but have not verified) that this is what ledger does. This is discussed, for instance, in #82 <#82> and #488 <#488>. How hard is that feature to implement?
Don't know. A simple matter of programming! I learned some things about this on #ledger yesterday. I will see about capturing the log.
register could show where transactions came from. That would make some reports easier.
Oh, how do you mean ?
Can hledger calculate inline? Say Expense:AAPL:Commission USD $(750-741.9)? Note: this should be in addition to deducing the last entry. Does this feature make sense to you?
Currently we don't have this feature and I don't miss it much yet. It seems a slippery slope, how far would you go with it ?
Mark-to-market performance as discussed in #329 <#329> would be nice but, for me, it is just "nice to have". I'd suggest tracking only realized performance, i.e., actual transactions for now.
Auto-generated capital gain/loss transactions, right ? Do you suggest not adding that feature ?
Is there a way to associate stock symbols and ISIN, RIC or other identification numbers in hledger? Probably out of scope. Maybe someone can suggest a tool to go along with hledger here.
You can use them as commodity symbols.. do you mean something more ?
I'll look at the documentation and I'll take a look at the CSV import. Not quite sure how well I will understand the latter though.
Let me address the other topics.
From column in register command
I was thinking it'd be helpful to have another "From" column.
Cost basis and mark-to-market
Please do capture the log on the cost basis implementation. I'd be quite interested in that.
As I understand it, mark-to-market performance is all about unrealized profits. I am quite interested in that but I believe it is more complicated than the transaction-based accounting that hledger is doing now.
Currently, we get
I'd be happy to get errors if I entered a non-existing price base.
If we wanted mark-to-market performance we'd also want ongoing reevaluation.
We now have to deduce that there was an unrealized profit or mark-to-market performance of 5x15 USD in 2015 and another 5x5 USD in 2016.
Stocks tend to have more than one symbol.
So overall, the register extension and the scripting language should probably be dropped.
I have taken a first look at implementing the additional CSV entry fields.
I have taken a first look at implementing the additional CSV entry fields. It appears that this can be done by understanding hledger-lib/Hledger/Read/CsvReader.hs. Is that so? Is it worth for me to have a go at it?
Correct! Please do have a go at it. Quick support available on #hledger if needed.
The aforementioned chat, and some new thoughts: https://gist.github.com/simonmichael/917f95da111365b81de1135496b00a3c . More later.
Thanks @MatthiasKauer, eg for pointing out the unrealized vs. realized distinction. I feel a bit clearer. Here are some things I think are true, comments welcome.
Mark to market, or market value, is the value of your assets according
Unrealized capital gain(/loss) is the difference between what you paid
The cost of your priced assets, ie what you paid for them, is given by
A lot is an amount of some commodity in an asset account, its purchase
Cost basis is a conventional name for a lot's purchase price.
In *ledger terms, basically each positive posting (deposit) to an
Realized capital gain(/loss) is an income(/expense) incurred when you
Calculating realized capital gain/loss is done following a strategy
These calculations require knowing exactly which lots or partial lots
Ledger does (and hledger does not) allow the user to identify which
The notation for this has been known to confuse at least some of us.
An alternative could be to just specify which calculation strategy is
one thing that should be considered too: how much do you want to be compatible with ledger's format? Or better: defining a "standard" format of plain text accounting?
Trying to make the lot prices (lot tracking) fit in existing boxes (@'s) it probably not a good idea and too limited
This was referenced
Oct 16, 2017
It's possible we'll try something new but end up coming back to Ledger's way, or add it as an alternative for syntax compatibility. I want something that's easy to understand, learn and use, and capable.
How well does Ledger's syntax work when there are many lots ? Eg say you bought small amounts of BTC weekly for a long time, then you sell a big chunk, say 50 of a hundred lots.
PS jkepler shared this python script, for inspiration: https://framagit.org/jkepler/TaxingLots/blob/master/TaxingLots.py
However. I would like to understand better these detailed lot-counting strategies, their variety, how much they are used and needed in practice. A quick search turned up not a single mention of them. Instead I found a bunch of US capital gains tax calculators which simply choose one of two tax rates based on whether you held the asset for more or less than a year. Perhaps I don't know the right search terms.
@simonmichael for French tax system, it’s explicit here: http://bofip.impots.gouv.fr/bofip/3619-PGP#3619-PGP_Les_titres_ou_droits_cedes__21
Section "B Les titres ou droits cédés sont fongibles (ou non individualisables)" ("sold actions are not distinguishable")
Yes, it's error prone, unless you allow to have expressions somehow.
Note that the example says that your lots have a mean value. You can write for each lot you buy an adjustment transaction that makes you always have one single lot (at the mean value of the previous). This is equivalent (except you have no "view" of your lots history). This of course doesn’t have an equivalent for US-style taxation
@simonmichael In response to your question about lot-counting strategies, I found this very helpful and informative: http://www.mscs.dal.ca/~selinger/accounting/tutorial.html#5
In India, for certain things we are required to follow FIFO as per the law (for capital gains calculation involving equity (directly or indirectly, through mutual funds, etc.)), but for other forms of capital gains, other methods may be used.
I'm glad my script might be helpful for inspiration improving how we can track investment or cryptocurrency lots with plain text accounting. I'm finally returning to my script as I may have some time in the coming weeks to improve it.
I also find Selinger's explanations helpful. While I started with FIFO, I'd like to include some other options in my TaxingLots script.