Examples: - If you live in the USA, convert dollars to Euros, and the value of the Euro goes up, when you look at it from a US perspective, you experienced a gain (if you looked at it from a European perspective you made a loss). That's not an investment profit; that's a gain from a currency conversion. Usually this is not called a profit (1). That conversion also didn't carry a cost basis along with it, e.g. those Euros, you didn't keep a memory of the rate at the moment of conversion. - On the other hand, if you convert dollars to units of stock in a US company, and the value of the company shares goes up, you turned out an investment profit. That's a real profit, and that's 99.99% of the cases where people talk about tracking gains/losses. The cost basis is attached to the units you bought, and Beancount allows you to unambiguously book these so you can keep track of how much cost basis is locked into those shares you hold. This matters because your local tax authority bases their taxes on this. - Finally, if you buy shares in a foreign company whose shares are denominated in a foreign currency (2), first converting your local currency and then buying the shares, then you will incur two sources of change in value: the change in value relative to the native (foreign) currency due to the growth of the company, and a change in value due to the variation in the exchange rate. Right now there is no easy way to untangle these two separately.
(1) For technical pedants: Yes, that's not the case for people trading currencies, but in any case, those doing that would do it all on margin anyway, e.g. they wouldn't convert currencies that they own, they would instead enter a long/short collateralized (i.e., protected) by a margin in their home currency. That's not what I'm talking about here. And nobody who's clued in actually converts nominal amounts for the purpose of speculating. (2) Usually this requires a conversion and special access to those markets, features which only relatively sophisticated brokers will offer (e.g. IBKR, or buying US shares from a Canadian account). (For the entire list) This brings up an interesting point, one which I had never given much though before: if we wanted to solve this problem - and I think it may be worthwhile to do so - couldn't we just (optionally) store the original exchange rate at the time the lot was converted, with the lot (i.e., Position object) itself? That is, each lot would store: - units (amount, currency) - cost (amount, currency, acquistion-date, label, rate*) (*) This being the new bit. Given those rates, we should be able to compute the current value of the cost basis in the local currency, and that against how much it cost us originally, should tell us the proportion of gain/loss due solely to currency appreciation/depreciation (ignore the effect relative interest differences between the two currencies). On Sun, Mar 3, 2019 at 7:41 PM Chary Chary <[email protected]> wrote: > Ok, thanks. > I will have to do some more reading to be able to fully understand your > answer > > On Sunday, March 3, 2019 at 11:12:57 PM UTC+1, Martin Blais wrote: >> >> On Sun, Mar 3, 2019 at 5:03 PM Chary Chary <[email protected]> wrote: >> >>> Martin, >>> >>> just for my understanding. >>> >>> *Q1)* Why did you have to implement the *currency_accounts plugin* if >>> you already have *beancount.plugins.unrealized* >>> >>> Isn't the latter supposed to do exactly what I asked for in my starting >>> topic? >>> >> >> Because profits generated as a result of assert appreciate (above cost >> basis), within their denominated currency, are distinct from (usually >> accidental) profits generated from divergence of the investment's currency >> over the user's home currency. >> >> >> In the description, of the *beancount.plugins.unrealized *you write that >>> >>> *This will create a synthetic transaction at the date of the last of >>> directives, that reflects the unrealized P/L. * >>> >> >> Yes. >> >> In terms of reporting, it's also the wrong thing to do... it was >> implemented as a quick experiment to see if this could be used to include >> unrealized profits on the balance sheet. >> Turns out it sort-of works, but the transactions that should be inserted >> depend on the reporting period, so really, it's a function of the reporting >> parameters. >> Don't use it. >> The right thing to do is for the reporting code to calculate the produce >> the unrealized gain/loss at the time (usually end of period) of reporting. >> >> >> >> This was my understanding of exactly how Peter Selinger method >>> <https://www.mathstat.dal.ca/~selinger/accounting/tutorial.html> is >>> supposed to work >>> >> >> The Selinger doc explains one method for dealing with accidental profits >> due to holding a portfolio of currencies without a cost basis. >> Not handling gains/losses in investments. >> These are two very different things and should be treated distinctly. >> >> It's a long and complicated topic, but in short: >> - Treat your investmnets in their local currency, tracking their original >> cost basis in their home currency >> - If you want to track profits due to currency movements, in general, use >> the Selinger method (with or without my plugin) >> >> >> *Q2) *You write >>> <https://docs.google.com/document/d/1WjARst_cSxNE-Lq6JnJ5CC41T3WndEsiMw4d46r2694/edit#> >>> that >>> >>> *"beancount.plugins.unrealized" "Unrealized" will create a synthetic >>> transaction at the date of the last of directives, that reflects the >>> unrealized P/L. It books one side as Income and the other side as a change >>> in Asset.* >>> >>> Is my understanding correct, that this will be a virtual transaction, >>> kept only in memory and not to be seen in a text format anywhere? >>> >> >> Yes. >> But don't use that plugin. >> Use a report rendering thing like Fava instead, which should be render >> add unrealized gains for you, depending on the reporting period you seek >> to view. >> >> >> >> >> On Thursday, February 28, 2019 at 5:45:58 AM UTC+1, Martin Blais wrote: >>>> >>>> Here, I finally did implemented a prototype: >>>> >>>> https://bitbucket.org/blais/beancount/commits/ecf5229f65fd574676cd47a060cfbe22152d12fb >>>> I guess it took me two hours. >>>> >>>> It's not entirely trivial; there are a few issues that keep this at the >>>> level of "prototype": >>>> >>>> 1. the price annotations get stripped out, which means that if you used >>>> the implicit_prices plugin AFTER this one, your prices might disappear. >>>> Other plugins, such as sellgains, would also have to run BEFORE this one in >>>> order to take effect. Custom scripts also would not see price annotations. >>>> This could be fixed by changing the booking code to ignore the price >>>> annotation for modified postings (identified via flag of the presence of >>>> metadata). In other words, instead of removing the price annotations, keep >>>> them but make them "lame" by inserting some metadata and requiring >>>> collaboration with the booking code (it's a little bit ugly, but I'd be >>>> okay with it). >>>> >>>> 2. In some cases - a transaction with multiple currency groups, at >>>> least one price annotation, and some non-zero residual - a currency trading >>>> account posting will be inserted in lieu of a residual posting. This messes >>>> with the rounding feature that automatically inserts postings for residuals >>>> (maybe it's not that big a deal). I think it could be improved further by >>>> conditioning the insertion on multiple required currency account postings. >>>> >>>> For more about these limitations, see the test file (look for FIXME). >>>> >>>> I like this plugin. There's no need to change any of your input to use >>>> it (it worked on my ledger without modification). Maybe I should finesse it >>>> and this could become there by default in a future version. It works on my >>>> personal large input file and does adds only an insignificant amount of >>>> overhead. This is the most natural way to deal with conversions. >>>> >>>> See this file for usage instructions: >>>> >>>> https://bitbucket.org/blais/beancount/src/default/beancount/plugins/currency_accounts.py >>>> >>>> >>>> On Wed, Feb 27, 2019 at 9:17 PM Martin Blais <[email protected]> wrote: >>>> >>>>> I believe it's absent. >>>>> In Beancount, what would be required is basically to sum up the >>>>> balances of each currency group and insert new accounts. >>>>> It's not difficult, though it's not cheap, some optimizations might be >>>>> required. >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> On Wed, Feb 27, 2019 at 9:14 PM Callum Makkai <[email protected]> >>>>> wrote: >>>>> >>>>>> >>>>>> On 2/27/19 9:10 PM, Martin Blais wrote: >>>>>> >>>>>> An elegant way to handle this is to use the Selinger trading accounts >>>>>> method. >>>>>> It would be easy to write a Beancount plugin to do this automatically. >>>>>> >>>>>> >>>>>> Jumping in here ... Martin, I was reading about the Selinger method >>>>>> the other day. Do you know if ledger or hledger implements this method? >>>>>> Or >>>>>> it's totally absent from all plain text packages? >>>>>> >>>>>> Callum >>>>>> >>>>>> -- >>>>>> 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/73b3eb60-39b3-3d64-37e4-0b82543fe40e%40gmail.com >>>>>> <https://groups.google.com/d/msgid/beancount/73b3eb60-39b3-3d64-37e4-0b82543fe40e%40gmail.com?utm_medium=email&utm_source=footer> >>>>>> . >>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>> >>>>> -- >>> 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/33ac0b66-aa2f-4a5f-924a-a1aaa0ca5b6f%40googlegroups.com >>> <https://groups.google.com/d/msgid/beancount/33ac0b66-aa2f-4a5f-924a-a1aaa0ca5b6f%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > 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/939fe47e-382a-4272-94e6-dd29f660d519%40googlegroups.com > <https://groups.google.com/d/msgid/beancount/939fe47e-382a-4272-94e6-dd29f660d519%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CAK21%2BhMUQC-hGYhUopDBZVq%2BS%2Bke2ftX%3Dx2_yD1LAda5tdaBcA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
