Okay, here's the situation.2000-01-01 open Assets:Investments:AA AA2000-01-01 open Assets:Investments:BB BB2000-01-01 *Assets:Investments:AA -1 AA @@ 1 USDAssets:Investments:BB 1 BB @@ 1 USDLedger likes this. Beancount says the first posting should have a negative cost: "@@ -1 USD". Ledger forbids negative costs.
Since Beancount's @@ syntax appears to be undocumented, is this a bug in Beancount, or should I switch to using negative costs? (I'm guessing it's a bug. Otherwise you'll need to correct for it in your Beancount-to-Ledger converter too.)
(Normally I don't use @@, but I've got some really old Fidelity 401(k) statements that are slightly ambiguous.)
The value after @@ is not a cost. This is a price conversion. This is an important distinction: the units of AA will not have a cost basis...
Anyhow, you have to put the negative amount on the right.
(Normally I don't use @@, but I've got some really old Fidelity 401(k) statements that are slightly ambiguous.)
Hmmm, there's really no way you can back out some sort of reasonable cost basis for them?
* Martin Blais <bl...@furius.ca> [2015-01-08 22:48]:
> > 2000-01-01 *
> > Assets:Investments:AA -1 AA @@ 1 USD
> > Assets:Investments:BB 1 BB @@ 1 USD
> >
> The value after @@ is not a cost. This is a price conversion.
>
> Anyhow, you have to put the negative amount on the right.
Does it make sense to have a negative price conversion?
Just FYI, you sent this directly to me instead of via the group.
On Wed Jan 07 2015 at 9:25:28 PM Martin Blais <bl...@furius.ca> wrote:The value after @@ is not a cost. This is a price conversion. This is an important distinction: the units of AA will not have a cost basis...I think we're saying the same thing with different words. The Ledger manual calls it a total posting cost, and the Ledger error message is "A posting's cost may not be negative."
The lack of a cost basis here is the least of my worries; I'm actually using @ instead of {} throughout my file because lots have caused me nothing but trouble so far. In general, I've got 401(k) contributions every other week and dividends as often as every month and up to eight different buckets in my 401(k) even if they're all a single target-date fund, and if each was recorded as a separate lot, I'd have a big mess every time the 401(k) plan replaced one fund with another, and I don't even know what I'd do with the quarterly account fee, which you've already discussed in your proposal for improving inventory booking. At least it's all in a tax-deferred account where it doesn't matter much. Maybe lots will be more useful with my taxable account.
Anyhow, you have to put the negative amount on the right.
Be aware that Ledger is different in that regard then. In your code to export to Ledger format, you'll need to flip the sign.
(Normally I don't use @@, but I've got some really old Fidelity 401(k) statements that are slightly ambiguous.)
Hmmm, there's really no way you can back out some sort of reasonable cost basis for them?
No, the old Fidelity 401(k) statements are close to useless.
At least with my wife's statements, which led to this example, I have transactions with numbers of shares and total transaction costs. A number of funds are specific to the plan and don't have publicly available prices. With my (older) statements, I don't even have transactions; I have the number of shares and the share price for each month, plus my contributions, employer contributions, change in market value, and dividends, all only in dollar amounts for the month. I haven't bothered to Ledgerize those statements because there doesn't seem to be enough to go on.
On Thu, Jan 8, 2015 at 2:47 AM, Matthew S. Harris <mharr...@gmail.com> wrote:On Wed Jan 07 2015 at 9:25:28 PM Martin Blais <bl...@furius.ca> wrote:The value after @@ is not a cost. This is a price conversion. This is an important distinction: the units of AA will not have a cost basis...I think we're saying the same thing with different words. The Ledger manual calls it a total posting cost, and the Ledger error message is "A posting's cost may not be negative."Do you prefer that semantic? I could switch it around (but I wouldn't call it a cost). I'm indifferent. Maybe it's better to match Ledger just for the sake of people converting, plus in a sense, it would match the semantics for the cost. Hmmmm I think I should do that...
I have a 401k account with a similar setup (maybe a bit less buckets), and I track lots with cost basis despite the fact they won't be taxed, because that allows me to compute the returns. It also works out fine for the fees. You just have to declare those account's default booking method as "NONE" to disable strict booking.
Despite this, I still recommend that you use a cost, even if it's incorrect (since this is not taxed, this is no worse than using a price conversion... just bring up the EOY price for that year and use that maybe, and make sure to disable strict booking for those accounts so you can book sales without having to worry about matching lots); price conversions are really just for that: conversions of currencies, there should be few of them. Using a cost will allow you to compute market value for those funds, and I think there is some code in holdings reporting that might treat "things held at cost" vs. "non-operating currencies" somewhat differently (though not incorrectly). Your fund units not held at cost will look like "non-operating currencies" to this code, just saying, there's only so much information the holdings reporting has access to when it looks at the contents of inventories and is requested to make aggregations. I think what you're doing now will work anyway though. Ideally I'd have to review the code with an eye towards that to make sure.
Note that there is code in LedgerHub that you could leverage to fetch prices at required dates, you could write a little Python script that finds relevant transactions and fetches the prices from G.Finance for all the dates you need and then either automate the repricing of those transactions or change them manually.
One thing I want to do soon is to issue warnings when the price database is looked up and the price point is too far from the requested date, so that the user could go fill in the missing prices. I'd probably issue price entries with the approximated price (approximated with a distant date) and then feed that into another script that would fetch prices for those directives.
On Friday, January 9, 2015 at 7:08:29 PM UTC-8, Martin Blais wrote:On Thu, Jan 8, 2015 at 2:47 AM, Matthew S. Harris <mharr...@gmail.com> wrote:On Wed Jan 07 2015 at 9:25:28 PM Martin Blais <bl...@furius.ca> wrote:The value after @@ is not a cost. This is a price conversion. This is an important distinction: the units of AA will not have a cost basis...I think we're saying the same thing with different words. The Ledger manual calls it a total posting cost, and the Ledger error message is "A posting's cost may not be negative."Do you prefer that semantic? I could switch it around (but I wouldn't call it a cost). I'm indifferent. Maybe it's better to match Ledger just for the sake of people converting, plus in a sense, it would match the semantics for the cost. Hmmmm I think I should do that...My gut says you should try to match Ledger except where you gain something by being different. The gain isn't clear here, so I assumed this was just a bug.
I have a 401k account with a similar setup (maybe a bit less buckets), and I track lots with cost basis despite the fact they won't be taxed, because that allows me to compute the returns. It also works out fine for the fees. You just have to declare those account's default booking method as "NONE" to disable strict booking.Ah. You should document this feature in the language manual. :-) After you described it, I found it in the CHANGES file.
Despite this, I still recommend that you use a cost, even if it's incorrect (since this is not taxed, this is no worse than using a price conversion... just bring up the EOY price for that year and use that maybe, and make sure to disable strict booking for those accounts so you can book sales without having to worry about matching lots); price conversions are really just for that: conversions of currencies, there should be few of them. Using a cost will allow you to compute market value for those funds, and I think there is some code in holdings reporting that might treat "things held at cost" vs. "non-operating currencies" somewhat differently (though not incorrectly). Your fund units not held at cost will look like "non-operating currencies" to this code, just saying, there's only so much information the holdings reporting has access to when it looks at the contents of inventories and is requested to make aggregations. I think what you're doing now will work anyway though. Ideally I'd have to review the code with an eye towards that to make sure.You say it works for you, so I'll start doing that and ask for help if I get stuck. So I should use {{}} syntax here, where I have the total posting cost but not a fund price?
Note that there is code in LedgerHub that you could leverage to fetch prices at required dates, you could write a little Python script that finds relevant transactions and fetches the prices from G.Finance for all the dates you need and then either automate the repricing of those transactions or change them manually.Yeah, I think I considered fetching prices manually at one point, but some of these funds are specific to the 401(k) plan, so there are no prices available. It didn't seem worth it to have prices for some funds and not others, so I dropped it.
I haven't really looked into LedgerHub yet.One thing I want to do soon is to issue warnings when the price database is looked up and the price point is too far from the requested date, so that the user could go fill in the missing prices. I'd probably issue price entries with the approximated price (approximated with a distant date) and then feed that into another script that would fetch prices for those directives.Sounds like a good idea.
--
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+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/29d783a5-d5fe-4697-b41b-982a6695e6c5%40googlegroups.com.
Despite this, I still recommend that you use a cost, even if it's incorrect (since this is not taxed, this is no worse than using a price conversion... just bring up the EOY price for that year and use that maybe, and make sure to disable strict booking for those accounts so you can book sales without having to worry about matching lots); price conversions are really just for that: conversions of currencies, there should be few of them. Using a cost will allow you to compute market value for those funds, and I think there is some code in holdings reporting that might treat "things held at cost" vs. "non-operating currencies" somewhat differently (though not incorrectly). Your fund units not held at cost will look like "non-operating currencies" to this code, just saying, there's only so much information the holdings reporting has access to when it looks at the contents of inventories and is requested to make aggregations. I think what you're doing now will work anyway though. Ideally I'd have to review the code with an eye towards that to make sure.You say it works for you, so I'll start doing that and ask for help if I get stuck. So I should use {{}} syntax here, where I have the total posting cost but not a fund price?Haaa yes, that'll make it easier, this way you won't have to calculate the per-unit price.I'll admit I'm using per-unit prices everywhere exclusively in my own file.{{...}} may be a little bit undertested.Please LMK if you encounter any turbulence.
As for the"A valid price for ABC/USD could not be found"message: it is emitted from the unrealized gains plugin.I'll have to hunt it down, sounds like a bug.
That does mostly help. I agree with your description of the current situation as "precarious" and "intolerable"; it shouldn't be so much work to make closed accounts worth $0. :-)
Your workaround of computing the cost basis has been mostly effective, though my balance report now shows a bunch of accounts with value 0.00 USD and -0.00 USD, presumably due to rounding issues. bean-doctor has been helpful here, though because I'm doing this workaround a lot, I wonder if it should compute the total cost for me.
I recently discovered one interesting case in my records: In my old IRA account, I received dividends on the 25th of every month. On the 24th of one month, I transferred everything out of the account, including the dividends that didn't arrive until the next day. I'm not sure how that's possible. Maybe the 25th was just the settlement date and the statements were unclear, not that that fully explains it. Gotta love old statements.
--
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+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/b396ecfa-ba4f-41a9-bfd0-31ac063daf9c%40googlegroups.com.
On Wed, Jan 21, 2015 at 5:23 PM, Matthew Harris <mharr...@gmail.com> wrote:That does mostly help. I agree with your description of the current situation as "precarious" and "intolerable"; it shouldn't be so much work to make closed accounts worth $0. :-)So how were you booking these transactions with Ledger?I can only assume that the errors were going undetected (but I might be wrong).
Your workaround of computing the cost basis has been mostly effective, though my balance report now shows a bunch of accounts with value 0.00 USD and -0.00 USD, presumably due to rounding issues. bean-doctor has been helpful here, though because I'm doing this workaround a lot, I wonder if it should compute the total cost for me.Hmmm interesting.Do you think you'd be able to build some minimal example that reproduces the 0.00 problem that you could share with me?
I recently discovered one interesting case in my records: In my old IRA account, I received dividends on the 25th of every month. On the 24th of one month, I transferred everything out of the account, including the dividends that didn't arrive until the next day. I'm not sure how that's possible. Maybe the 25th was just the settlement date and the statements were unclear, not that that fully explains it. Gotta love old statements.Probably settlement.
Note that both Ledger and Beancount will not bitch about an Asset account's balance going under zero, so from their perspective you will not get an error, just a temporary negative balance.(OH! That could be an interesting plugin idea to add! Yet another constraint. You could configure it with a tolerance.)
Now, some observations:- The Right Thing to do would be to implement average cost booking. I'm working on it. It'll be there eventually, I find this "ignore booking" situation intolerable myself. When I do you'll be able to book at average cost using the {*...} syntax and it'll automatically calculate the per-share price to fulfill all the conditions and not leak any cost basis yet do what you want, and automate the calculations.- In the meantime, you can just reduce the lot at its remaining cost basis (sum up the cost bases and you will find 26493.04998 USD) and your cost basis will cancel to zero and your DEF position will have the correct cost basis (assuming you did not realize any gain when you made that conversion):
It's not ideal from the POV of data entry (it forces you to calculate the cost basis), but it'll work. Solving the problem correctly is not trivial (which is likely why Ledger did not implement it in the first place) but my new inventory booking method is a good general solution for this and hopefully will make such situations easy to handle without having to disable any checks.
As for the"A valid price for ABC/USD could not be found"message: it is emitted from the unrealized gains plugin.I'll have to hunt it down, sounds like a bug.This is indeed, a bug triggered by this situation and I'll have to fix it.The unrealized gains plugin computes the list of holdings in order to insert the gains, and it ends up with a holding object like this for your leaked cost basis:
On Wednesday, January 14, 2015 at 7:48:51 PM UTC-8, Martin Blais wrote:Now, some observations:- The Right Thing to do would be to implement average cost booking. I'm working on it. It'll be there eventually, I find this "ignore booking" situation intolerable myself. When I do you'll be able to book at average cost using the {*...} syntax and it'll automatically calculate the per-share price to fulfill all the conditions and not leak any cost basis yet do what you want, and automate the calculations.- In the meantime, you can just reduce the lot at its remaining cost basis (sum up the cost bases and you will find 26493.04998 USD) and your cost basis will cancel to zero and your DEF position will have the correct cost basis (assuming you did not realize any gain when you made that conversion):It's not ideal from the POV of data entry (it forces you to calculate the cost basis), but it'll work. Solving the problem correctly is not trivial (which is likely why Ledger did not implement it in the first place) but my new inventory booking method is a good general solution for this and hopefully will make such situations easy to handle without having to disable any checks.FYI, I gave up on this manual average-cost-booking hack a few weeks ago. When my 401(k) has contributions every couple weeks and a fee every quarter, the manual effort required quickly becomes intolerable. I'm waiting for {*} before I finish correcting the cost basis in my investment accounts.
As for the"A valid price for ABC/USD could not be found"message: it is emitted from the unrealized gains plugin.I'll have to hunt it down, sounds like a bug.This is indeed, a bug triggered by this situation and I'll have to fix it.The unrealized gains plugin computes the list of holdings in order to insert the gains, and it ends up with a holding object like this for your leaked cost basis:Would you like me to file a bug? A bunch of these pollute my bean-check output, which discourages me from running bean-check as often as I should.
I see you recently updated export_reports.py to use commodity metadata. What should the "export" and "ticker" metadata fields contain? What's the difference between "CASH" and "MONEY"? What metadata should I apply to a commodity that has no ticker symbol?
Matthew
--
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+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/41903068-9c5a-46d7-ae45-4763127890d2%40googlegroups.com.
As for the"A valid price for ABC/USD could not be found"message: it is emitted from the unrealized gains plugin.I'll have to hunt it down, sounds like a bug.This is indeed, a bug triggered by this situation and I'll have to fix it.The unrealized gains plugin computes the list of holdings in order to insert the gains, and it ends up with a holding object like this for your leaked cost basis:Would you like me to file a bug? A bunch of these pollute my bean-check output, which discourages me from running bean-check as often as I should.Yes. I forgot to deal with it. I'm overwhelmed... too much to do and the weekends go by really fast. I try to focus on one thing at a time. There are so many things to prioritize. Logging a ticket will help.
I've been trying to complete a document specifically about this, and I did, and then I realized I should revisit the feature to make it even simpler, and I revised the code this weekend, and now I need to update the document. I'm planning to do this over the weekend. Expect a new "export to OFX" feature that will allow you to keep an eye on changes in your portfolio throughout the day.
I've been trying to complete a document specifically about this, and I did, and then I realized I should revisit the feature to make it even simpler, and I revised the code this weekend, and now I need to update the document. I'm planning to do this over the weekend. Expect a new "export to OFX" feature that will allow you to keep an eye on changes in your portfolio throughout the day.Sounds cool. It isn't one of my immediate priorities, but it will be fun to play with anyway.