-
-
Notifications
You must be signed in to change notification settings - Fork 323
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
periodic value reports should use the market prices of each period #329
Comments
Thanks for the report. Yes, balance -V uses the price as of the report period end date (or the end of your journal) (http://hledger.org/manual.html#market-prices). As I said in the thread, I think using the price at the end of each report interval (for a multi-column balance report) would be more useful. But this might still not be what you want; can you give an example showing how you think it should work ? What you say about statements depending only on past information makes perfect sense. Though, *ledger's basic commands, especially |
I guess I am mostly motivated by having 'real' balance sheets, and I don't know enough about hledger's internals to speculate how you'd want to implement. Here's how I, as a business person, would want to look at a Balance Sheet with some Gold on it. Say I obtain 1 oz of gold a week, and the prices are 500, 1000, 250 respectively at the end of the week per oz. The cumulative balance sheet without the -V I would expect to look like this:
And the Cumulative P&L would read
I then run the cumulative reports dollar denominated. (with -V as we've been discussing). I would expect something like the following:
The P&L would Contain
Those Income statements would obviously flow through to Equity on the Balance Sheet. Interpreted: Week 1 we made $500 mining. Week 2 we made $500 mining and $500 in market appreciation from holding the gold. Week 3 we made $250 in Mining Income and Lost $1000 due to gold prices dropping. NB, I'm also looking at beancount right now, which seems to have a lot here, including basis calculations. So, don't push ahead on this just on account of me. 😄 But I think this would add significant correctness to reports. I'd hate to think of people filing reports with tax authorities without this working. |
Yes beancount has more in this area, but this is very helpful - thanks. It sounds like using the price at the end of each report period will work well - good. "Mark to market" is a useful term I didn't know. Ledger reports that change as "capital gains/losses"; hledger doesn't report this explicitly yet. Isn't there some error in the last P&L example ? In week 2 I'd think you made $1000 mining (1 oz of gold at that week's price of $1000) and $500 on the revaluation of week 1's oz from $500 to $1000. |
Capital Gains/Losses makes sense to me as well. I think it's right -- it's a cumulative P&L by period. If the P&L isn't cumulative, then you're correct. Net Income for the week (marked to market) was $1500. In my example I carried forward the prior week's mining income (hence cumulative). This has the impact of allowing market change impacts on holdings to be pulled out into a separate row. |
This seems like an old issue, but I would also like to see this sort of functionality. I was surprised when the multi-column balance view showed the prices as of the latest date. |
Just adding my voice to the chorus of support for this feature. I have recently incorporated stocks into my hledger reporting and was also surprised to find hledger not reflecting then-current prices over reporting windows. |
Would someone like to work on this ? I guess it will be not too hard. |
Recent work following on from #999 has moved this forward. The new |
It seems not quite baked yet though; some reports work better than others. Robust soon I hope. |
Great to see this moving forward! I tested it and think I found an issue. If I run |
This feature turns out to be quite involved, as valuation interacts with the many report variations. Various bugs/specs have been fixed/clarified relating to register's running total, balance totals etc. Eg register's total should now be the sum of the posting amount values, not the values of the original sums. Current level of support has been documented. When valuing at transaction date, we once again do early valuation of all posting amounts, to get more correct results. variants. This means --value-at=t can be slower than other valuation modes when there are many transactions and many prices. This could be revisited for optimisation when things are more settled.
This turns out to be quite involved.. valuation strategies interact with every report mode! I've just pushed more work on it, here are the latest docs: @erikryb thanks for the testing. Would you mind retesting with the latest and sending a reproducible example. |
I tested the latest version. I have the following ledger:
The command
as is expected. However, if I change the begin date to
I would expect that the values should be the same as in the first example, but it seems that the last price is used for all periods. |
Agreed. Thanks for the test case! |
Here's a new UI proposal:
|
Amendment: in multiperiod reports, -V/-X use period end prices. |
That's perfect. |
This has landed in master, except for the -X/[,COMM] part. Basically I also thought of using |
I'm not sure this is a good solution, since |
I believe --change/--cumulative/--historical are mutually exclusive, and the rightmost is used. It looks ok from a quick test. |
A vagueness in my proposal above: it suggests Alternately, it could mean "convert to cost, then convert to COMM using market prices at the (sub)period end". This is easier to code, so I'll just try this first. |
Example:
When I query this with
As you can see, the "Total" is pointless since And when I query this with
This is a meaningful report (though, interestingly, the column headers are drastically different from the previous report for reasons I'm unable to grasp). Also, strangely, the balance change is from "2019/04/29" instead of "2019-05-01". "Total" makes sense here, since it is non-cumulative.
As you point out
There is no reason why "historical" should not be non-cumulative. |
Thanks for the examples, I haven't worked through them yet. I defined those terms at https://hledger.org/manual.html#multicolumn-balance-report , and you seem to be proposing new definitions. Could you write these out briefly and say how they are an improvement ? |
The only difference is that in place of:
"With --historical/-H: each column, by default is cumulative, and shows the actual historical ending balance for that period, starting with the historically accurate balance (including undisplayed prior postings) at the report start date. This is useful, e.g., for a multi-period balance sheet, and when you are showing only the data after a certain start date. You can override the default and choose to show only the difference between the periods/columns, instead of the ending balance, by using Explanation: "Historical" means that the balance will take into account undisplayed transactions prior to the |
Sorry, it's not clear to me.
In my usage, "historical" is equivalent to the real world balances you'd see on a bank statement. "Cumulative" is the word I picked to mean "accumulates across subperiods, but starts from zero at report start date". (Cumulative mode is very seldom used.)
… On May 29, 2019, at 9:43 AM, the-solipsist ***@***.***> wrote:
The only difference is that in place of:
With --historical/-H: each column shows the actual historical ending balance for that period, accumulating the changes across periods, starting from the actual balance at the report start date. This is useful eg for a multi-period balance sheet, and when you are showing only the data after a certain start date:
"With --historical/-H: each column, by default is cumulative, and shows the actual historical ending balance for that period, starting with the historically accurate balance (including undisplayed prior postings) at the report start date. This is useful, e.g., for a multi-period balance sheet, and when you are showing only the data after a certain start date. You can override the default and choose to show only the difference between the periods/columns, instead of the ending balance, by using --change flag. This will still start with the historically accurate balance at the report start date."
Explanation: "Historical" means that the balance will take into account undisplayed transactions prior to the -b date. This is the meaning it has with the register command. There is no need to create a new, and different meaning for multi-column layouts. But a "default" is needed as to whether the --historical flag will display total balance for each column (i.e., "cumulative"), or only the difference in balance (i.e., "change"). The only option right now is "cumulative". I'm suggesting that that be the default rather than the only option.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#329?email_source=notifications&email_token=AAACPIE6SJP4IMZSKMZGDI3PX2XDBA5CNFSM4B5QMLQKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWP542I#issuecomment-497016425>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAACPIEWTW34UXHFOCQ2PCTPX2XDBANCNFSM4B5QMLQA>.
|
Sorry I wasn't clearer. Let me try again. There are essentially two different variables:
I see these as independent variables. The first, to my mind, can be controlled by The second, to my mind, can be controlled by So, you should in theory be able to combine "include prior transactions' value" with "reflect the differences". There is no reason why "cumulative" should have "but starts from zero at report start date" as part of its definition, nor why "historical" should have "accumulates across subperiods" as part of its definition. They are two distinct variables. |
@the-solipsist: maybe. Please describe concisely the new report mode(s) you are imagining!
|
The only change from the current that I envision is the ability to combine For the example file given above, if I try:
I would expect either:
or:
|
My github reply got delayed. Thanks, I see what you're saying. I'll respond to a few things separately:
As you can see, the "Total" is pointless since --row-total is meaningless when...
Agreed, I think that's from an out of date build. If you build master you should not see a Total column in that example (I don't). "-H disables -T" as I said earlier.
interestingly, the column headers are drastically different from the previous report for reasons I'm unable to grasp)
It's because --historical and --cumulative reports show ending balances, on a date such as "2019/06/02", while --change shows the change during a period, such as the week before 6/2 (which we display as "2019/05/27w22", week 22 of the year, beginning 2019-05-27).
Also, strangely, the balance change is from "2019/04/29" instead of "2019-05-01"
I can see that might be surprising. It's because https://hledger.org/manual.html#multicolumn-balance-report : "the report start/end dates will be adjusted if necessary so that they encompass the displayed report periods. This is so that the first and last periods will be “full” and comparable to the others.".
I would expect either:
|| 2019/05/06w19 2019/05/13w20 2019/05/20w21 2019/05/27w22 Total
===++=====================================================================
A || ₹3.00 ₹3.00 ₹4.00 ₹5.00 ₹15.00
B || ₹-3.00 ₹-3.00 ₹-4.00 ₹-5.00 ₹-15.00
---++---------------------------------------------------------------------
|| 0 0 0 0 0
I see what you're proposing. Currently --historical/--cumulative/--change affects all periods in a multiperiod report. This is consistent across balance-style and register reports. You're showing a hybrid report: historical balance for the first period, but just the changes in the other periods.
That's interesting, but I'm not convinced it's useful enough to be worth the added confusion. Do you have a real world use case in mind ? What do others think ?
or:
|| Past balance 2019/05/06w19 2019/05/13w20 2019/05/20w21 2019/05/27w22 Total
===++===================================================================================
A || ₹1.00 ₹2.00 ₹3.00 ₹4.00 ₹5.00 ₹15.00
B || ₹-1.00 ₹-2.00 ₹-3.00 ₹-4.00 ₹-5.00 ₹-15.00
---++-----------------------------------------------------------------------------------
|| 0 0 0 0 0 0
I think this one is clearer. I'd still want to see a good use case, as it requires more complicated flag behaviour.
|
The use case, essentially, is the same as for I'm wondering: Would it be possible to remove the "accumulation" code from I'm sorry, I don't know the code-base, so I'm just spitballing. |
The code for this is easy, the hard part is keeping intuitive UX (writing the doc is a good test of this) and demonstrating real value from the change. I'm going to let others chime in on this.
|
With #131 merged, the new UI proposal above is complete, and we can close this. (Our side discussion about --historical could move elsewhere, but I've left it as is for now.) |
The text in the Track Investments page should be updated to reflect this issue being closed. |
I am having trouble with hledger's balance sheet reporting and I think there's a bug in how the reports work.
For reference, I have a business I'm modeling, something like a gold mine where I get revenues directly in a commodity. The business has a hedging component, so it might hold or sell the commodity on any given day. It also has (dollar-denominated) expenses.
To test out the hedging strategy, I'm using hledger against a file to see what period balance sheet reports would be, and I want to incorporate the mark-to-market impacts of hedging or not.
The --value flag sounded good, but it does something very strange: the balance command books commodities at what looks like their final price in the journal.
Perusing this conversation https://groups.google.com/forum/#!topic/hledger/e8Ss7ZL4ADI makes me think that might have been the intent for the initial push on this very, very useful functionality. But, I might be doing something wrong -- let me know.
My lines in the ledger for pricing are like this:
P 2015/03/16 AU 1200.23
implying a $1200.23 price per ounce of gold. There is one per day, and they are in order with other journal transactions.My reasoning on why this is wrong is pretty simple: balance sheets / statements should never change based on future information. They are supposed to be an immutable record of the state of finances at a moment in time.
Am I understanding the current situation correctly, and if so, any thoughts on a fix? I'm a total haskell newbie but would be willing to give it a go if you pointed me in the right direction.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: