New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report unrealized capital gains/losses #1029
Comments
My $.02:
If you dont care about lots, then you could just periodically record value of your holdings by entering transactions like: YYYY-MM-DD valuation You can then use "hledger roi" (pointing it to these two accounts) to track performance of your holdings. The more valuations you have - the better. |
I've been tracking my lots manually like this: http://rantsideasstuff.com/posts/2018/07/01-tracking-investments-in-lots-with-hledger/ Something I haven't seen being talked about in this context are fees. Any thoughts on those? |
Here is my proposal for how this should be done. First of all, we will require that all transactions in the ledger are balanced. Hledger currently checks this for transactions containing only one commodity, but not when multiple commodities are included in the transaction. One way to do this in a way that is backwards-compatible is to introduce a new account named
This transaction is currently unbalanced, since the amounts sum up to -$1000, and 1 AAPL. When generating reports, this transaction would be turned into this:
An additional flag (
Now that all transactions are balanced, I will explain how the Balance sheets
All questions we may have about the performance of our investments may be answered by looking at the balances (historical or changes) of the Print / registerThe print / register commands show individual transactions. When
The two trading postings add up to zero, so this transaction should be displayed as
Now, for each commodity valuation, for instance
This transaction involves all accounts that have a non-zero balance of AAPL, and corrects the balance of each account with the updated price. This may result in a lot of valuation transactions, so if we want to we may add a flag Implementation stepsThe proposal may be implemented in several steps:
Closing remarks
|
@adept, I think we are generally in agreement.
Yes, unrealised gains could be calculated from individual lots, but
I don't quite follow.. I'm expecting unrealised gains to be calculated Maybe the term "Unrealized PnL" is a little confusing ? It's not on
I don't understand your terminology here. I wonder if you're pointing |
@zoranzaric: what's the problem with fees ? Thank you all for the thoughtful input. When I don't respond quickly it's because of limited time & brain space. There's an awful lot to think about in this space. :) |
Never mind, just getting my terms straight. |
@simonmichael: It would be helpful to have fees subtracted from unrealised gains to see my "real" gains. |
I guess Ledger/hledger use that word differently.. they consider the
Related to #758, "Treacherous multi-currency auto-inference".
I'm too long away from the code to comment on this in detail; maybe later.
This has been my original thought too - model revaluation in depth, ie as Then there is the "top down", shortcut method where we would only Calculating for every account, depending on which commodities it Including revaluations in balance and register reports is necessary to
Hiding postings written explicitly in the journal would be quite a new
In non-periodic balance reports, one revaluation for the whole report In periodic register/balance reports, the periods are a natural In print reports and non-periodic register reports, there's no |
Thanks for the reply.
Yes, this is a mistake in my opinion. If we allow such transactions, then it becomes possible to create money out of nowhere, as explained here. If we want to add valuation transactions the way I described, all transactions must be balanced for each commodity.
Yes, there are performance issues that must be considered here. I would guess that the implicit top down method would be faster for balance reports, but for register and print reports we need explicit valuation transactions (bottom up).
Having revaluation transactions in print would indeed be good for consistency. It would be nice if
gave the same output as
Yes, this is not strictly necessary. Perhaps we could add a normalization option to print if we want to.
Agreed!
My preference would be a new flag, with daily revaluations being the default. Note that there would not be any revaluations in the periods where there are no price directives, so the number of revaluations are limited to the number of price directives. |
I guess something to possibly keep in mind on this would be tracking things like automatic dividend reinvestment (e.g. dividend paid out, converted to a stock purchase >> shares). This gets a little tricky because, over time, you could have many tiny "purchases" (gotta love owning like 1/10000 of a share in a company 😁...) ... each of these purchases has it's own cost basis and it's own unrealized gain/loss. (And it's own Capital Gains loss position long/short). It really isn't much different to having multiple purchases on different dates at different prices -- you could buy 100 MSFT on 01-JAN @ $10.00 and another 100 MSFT on 01-FEB @ $20.00 ... if today is 01-MAR and MSFT is @ $30.00, (1: 100x10=$1000 cost basis; current= $3000; 2: 100x20=2000; current =$3000; total unrealized = $3000 ...) |
Not sure about accounting for fixed assets but sometimes these are explicitly acknowledged in the books with a transaction, i.e. once a year. |
Quite the contrary, I think un/realized gains/losses can't even be calculated without lots. More about how I see lots, here: #1022 (comment) |
I am going to re-read everything that happened on #1022 recently, but I am going to strongly disagree with your statement even before I've done that :) Let's say I am buying stock and I am recording this as transactions like this one:
(notice how I am not even recording WHICH stocks I bought or the current price). Let's say I am doing this every month, so at the end of the year by checking accoung is down $1200 and my investment account is up $1200. At this point I get current valuation of investment account (by going online, receiving statement, etc) and it is $1234 at this point. So i record:
Right there, my investment account has correct balance, and "unrealized pnl" account has $34 of unrealized PnL. Yet I recorded no prices, no lots, no stock tickers etc. If your taxation/accounting regime does not require you to do LIFO/FIFO accounting of lots, it is perfectly feasible. |
To address this point : "But with stocks, this does not happen. Their current market value is calculated in comparison to the current market price and this seems the most common scenario. It would be too much (and quite pointless) too revalue stock holdings explicitly, considering that the current price is just an information and not necessarily what we would get in a sale." I am going to make another bold claim here: for a person investing in stocks (long-term) and not day-trading them daily fluctuations in price are always meaningless and it is perfectly fine to get somewhat-accurate valuations of the total of your holdings from some sort of benchmar source (be it Yahoo prices, Bloomberg prices, or a report from your brokerage even if you dont know which prices they are going to use). As long as you are using the same valuation report source consistently, it would not matter how precise your prices are (provided that they are reasonably precise), how do they lag behind the market, are they open or close prices, etc. For the duration of typical investment (years) none of this would matter, and precisely tracking your share lots and prices of shares would just create unnecessary burden for you. Now, if you need this information for other purposes as well (like FIFO taxation) - fine, thats completely different story. But I claim that you should not be tracking or recording stock prices in a typical investment scenario otherwise, unless you have copious amounts of free time. |
Unfortunately it does unless you live in a perfect world. Mutual funds and agents go out of business, brokerage accounts change owners and rules, companies disappear, ETFs stop trading in certain markets, regulation changes, people move states and continents, citizenships and tax residence, and so on and so forth. |
We seem to circle back to the "but you also need this for taxes" argument. I do agree that if you have to do fifo capital gains, you absolutely need lots. But I think it is a mistake to think that it is a general requirement. It is in US (as far as I know), but for example in the UK you could happily invest in stocks without having any need to report capital gains or losses, and tracking lots would be just extra burden for you. Title of this ticket is "unrealized gain/losses", and all my arguments are focused on not equating this to "tracking lots for tax purposes" (which is a valid and related goal, but IMO separate one) |
How would you envision tracking unrealized gains for standard stocks and mutual funds without lots? |
Why ("current valuation" - "amount invested" ) would not be applicable to common stocks and mutual funds? |
That's what it is. The question is just how you get to "current valuation". |
In my experience it is usually included in paper or electronic on-demand statement of one's broker. |
Good. So, now that solution is limited to institutions that provide accurate financial statements with current balances. We can then forget about my sugar example, where we bought 18 units (tons?) of sugar at A$2.39 per kg. There is no financial institution that will provide us with the statement of the current market value, so we are dead in the water. I once worked at a company that was trading natural gas and electricity. If there was no accurate information about the potential profit, how would they even operate? Probably no need to mention the case of shares which trade on multiple exchanges, in multiple currencies. Ledger also can't handle these. Taxation is not the only reason to have an accurate picture of what's going on with our finances or other commodities. What I'm saying, among other things, is that, if you have accurate statements already, why would you need hledger? Edit: corrections in spelling and meaning. |
Well, it looks to me like we are in some sort of violent agreement here :) You are arguing that there are scenarios where having precise lots information is highly beneficial (for the purposes of computing/tracking gains/losses and for other purposes as well). In your sugar example you would obviously be better off tracking lots I am arguing that, on the other hand, there are practical scenarios where tracking gains/losses could be achieved without tracking lots, and therefore it is not prudent to say that "you can never ever do gains/losses without tracking lots". In my "casual investor" example you would be better off NOT tracking lots. Furthermore, tracking lots is not cost-free (forgive me the pun). As soon as you start tracking lots, you have to maintain information about lot quantites. To go back to shares example, you now commit yourself to tracking forward and reverse stock spilts, rights and warrants issue, mergers and acquisitions, secondary offerings and other things that potentially change quantity of shares that you have without you actively trading them. If all you want is gains/losses, and you have access to information about wholesale value of your portfolio (from you broker, for example), then you will save yourself quite a lot of work by not tracking quantities. This most recent chain of comments have started with "I think un/realized gains/losses can't even be calculated without lots". Do you still firmly believe that this is the case, or do you see some merit in my arguments that dependency between these two things is not quite as strong? |
That summarizes it well, I'd say. :) |
Thanks for the input. I (still) agree with Dmitry: you need to track lots only for calculating realized gains. Not for calculating unrealized gains.
|
In that case I did not properly understand the following explanation:
Where is the "end value" coming from? Is this something we have to enter manually and does it replace/ignore the Price records? |
In technical terms, it could come from some form of a balance assertion. |
“End value” there is the market value, based on market prices, which we assume are available. These are a requirement for any calculation of “capital gains”, unless I’m missing something ?
|
Ah, the balance expressed in the non-currency commodity, yes. Times the last price. |
What happens with share transfers, gifts, dividend participation programs, etc. where there is no explicit value on the record? |
I completely agree. Another way of putting it is: "Lots only become important when you sell a commodity for a profit/loss." Until that point of sale, your (unrealized) profit or loss only depends on the aggregate difference between the amount spent to acquire the commodity and the current market price of the commodity (which can even be a guess, and need not be exact), and not on the lots. One way of simulating lots without any additional software support is with dated sub-accounts.
Depending on the purpose of your tracking (taxation, self-knowledge, etc.), you have to provide a value that is acceptable for that purpose, whether it is a guess or derived through some method. For instance, tax authorities might require you to follow a particular method of valuation, and so forth. All of cost accountancy is about such valuation. There are guides on how to arrive at the fair value. |
I would add that as I see it, lots don't become important unless a non-averaging cost basis (such as FIFO/LIFO/High Cost/Low Cost) is used. Because if you use average cost basis, then you don't need to specify which precise units of the commodity (bought on which date at which price) were sold. This, for instance, is usually the case with currency conversions for the purpose of purchasing (as opposed to forex investment). If you're going on a trip from India to the USA and are converting from INR to USD multiple times, and then converting back, the gain/loss you'd look at is the difference between the weighted average cost of all purchases of USD and the final sale of the remaining USD back into INR (and subtracting conversion fees). Unlike in the case of investments, you wouldn't use FIFO, etc., and thus would not need to track the currencies you've bought and sold in the form of lots. |
I'm new here. I have not completely parsed #1022 yet. Please bear with me if the following is redundant, inaccurate or insane.
I go a step further and claim that the recording of lots is only important if you want to do something special. As long as you stick to one of the standard deterministic methods, you do not have to track your lots. The software can do it for you, e.g., by maintaining a stack or queue on the account level. Let me propose a something radical: a new equity account type which I will call T(rading) for now. T-accounts will track losses/gains due to change in valuation. With signed account values, the new bookkeeping equation is
Pros:
Cons:
What do you think? |
I think we can get rid of the
|
I'm way behind on this issue, is someone able to summarise rather briefly the current status and some reasonable next goal & actions ? Does balance --gain resolve it ? |
There was an interesting discussion about whether reporting unrealized gains requires tracking lots. I think the conclusion was that basic reporting can be achieved without lots but in order to handle all edge-cases we have to track lots. My previous two messages in this thread are about automatic lotting with predefined rules like FIFO or LIFO. I think the recent hledger updates go into the proposed direction.
It might be better to continue the lot tracking discussion in #1022 though. |
Indeed, |
I believe I understand this case a bit better but I'm not sure that
would work right now. It is inferring twice. Technically, it could work by first ordering the calculations. I think that explicitly using the
The case is pretty limited, though. Because it completely ignores the cases which involve the current market valuation based on price information. It does work for the case you suggest, in any case, where the valuation is calculated by a 3rd party. What I assume by reporting unrealized capital gains/losses is what
Ledger lists it in
But it is not stored in the book anywhere. I am going to try the conversion of the portfolio and see how this works with my data. |
Some reference: https://www.investopedia.com/terms/u/unrealizedgain.asp |
Hi, @alensiljak. I'm not quite sure what you're trying to do. There are two ways of showing what the Unrealized P/L is. The first is via a dynamic report (such as They are just two different ways of seeing the same thing. You could do:
or you could do
In the latter case, one would denominate You ought not be trying to mix both. Having said that, I think the only thing left in this issue is "how best to display gains/losses: as part of the 'parent' account or as a separate |
Part of #1015. Related: #82, #377, #1019. With --value-at (#329) It's now easier to see the changes in value due to market price changes over time. However we don't yet fully model those gains/losses/revaluations as transactions, so the accounting equation is not satisfied and balance report row totals look wrong.
Notes
what are some events of interest ?
What is the relationship between "revaluation", recognising (unrealised) capital gains, and realising capital gains ?
I think:
While
How could you report unrealised gains using current features ?
Are there any relevant, different procedures recommended in the Selinger multicurrency tutorial ?
When should unrealised gains appear in reports ?
Should gains be shown with all account types ? (revenues, expenses, equity.. )
The text was updated successfully, but these errors were encountered: