On Fri, May 07, 2021 at 07:24:58PM +0100, Caesar Schinas wrote:
> On 7 May 2021, at 18:51, James Cook <[email protected]> wrote:
> > I don't think I completely understand what you're doing. E.g. I'm not
> > sure where 977.88 GBP comes from.
>
> Ha, I’m not sure I do either, which is why I posted here :-)
>
> The 977.88 GBP is my profit (984.48 GBP by selling the shares, minus 6.60 GBP
> fee). It’s the actual profit I made – the amount that the purchase and
> subsequent sale altered my account balance.
> It’s about the only invariant here: the profit is 977.88 GBP. That must be
> the outcome of whatever accounting method I use, as it is the amount of
> profit I actually made.
>
> > I'm certainly no expert, but how I would account for this depends on
> > which country I'm doing my taxes for. (My plugin tries to do both at
> > once, at the cost of some added complexity.)
> >
> > For the US, (I think) my PnL should be computed just using the USD
> > amounts. So it should come out to (175.81-54.13456)*11 = 1338.43 USD.
>
> That would make sense if my account balance was in USD and so that could be
> conceived as the amount of profit I had made. But it isn’t (see above) so
> that figure is somewhat illusory – the change in exchange rate wiped out a
> chunk of it.
>
> > If you want to do taxes in GBP: well, you put in 482.60 GBP and got
> > back 1467.08 GBP, so your profit is 984.48 GBP.
>
> Yes, that’s what I want to achieve (minus the 6.60 GBP fee, making the real
> profit 977.88 GBP, but let’s ignore that for now for simplicity).
>
> > Here's how you can get that:
> >
> > option "operating_currency" "GBP"
> > option "inferred_tolerance_default" "GBP:0.005"
> > option "inferred_tolerance_default" "USD:0.005"
> > plugin "beancount.plugins.auto_accounts"
> >
> > 2020-03-31 * "Buy 11 shares of Square"
> > Assets:GB:Freetrade:GIA:Cash -482.60 GBP
> > Assets:GB:Freetrade:GIA:SQ 11 S_SQ {43.8727 GBP}
> >
> > 2020-11-16 * "Sell 11 shares of Square"
> > Assets:GB:Freetrade:GIA:SQ -11 S_SQ {43.8727 GBP} @ 133.3713 GBP
> > Assets:GB:Freetrade:GIA:Cash 1467.08 GBP
> > Income:Investments:PnL -984.48 GBP
> >
> > I simply removed all mention of USD.
>
> Right, so holding the stocks in GBP instead of in USD. That’s probably what
> I’ll end up doing, because I can’t find a better solution – but it is in my
> opinion not an elegant solution because the commodity is priced on the market
> in USD, not GBP. So holding it in my accounts in GBP means I can’t compare
> the price (using Beancount and Fava) to current market prices, as the
> currencies are different.
>
> Perhaps I can create a plugin to solve that issue, instead of trying to hold
> the stocks in USD.
I'm actually currently working on a plugin to convert all my cost bases
and capital gains computations to USD for the purposes of US taxes,
even if I enter them in CAD (because I actually did the trading in
CAD).
Hopefully the below test case illustrates how it's supposed to work.
It's a bit weird, because it expects the transaction-as-entered to
already have capital gains computed in USD. That kind of suits my own
use case, since I've been obsessing over making sure all my numbers add
up, and don't mind spending a bit of extra time filling in the capital
gains amounts.
Happy to share the current state if anyone is interested now. Otherwise
I was planning to wait until I've successfully converted my ledger to
use it, since I keep thinking of things to change.
(One planned change based on my experience so far: I need to add a work
around for the fact that prices and costs must be in the same currency.
I make liberal use of Norbert's gambit, so some of my postings make the
most sense (to me) as something like:
Assets:Brokerage -5 ACME {20.00 CAD} @ 15.00 USD
I'm thinking I'll just replace the "@ 15.00 USD" with metadata to be
interpreted by the plugin.)
class TestConvertAllCosts(cmptest.TestCase):
@loader.load_doc(expect_errors=False)
def test_simple_buy_sell(self, entries, _errors, _options_map):
"""
plugin "falsifian.convert_cost"
"conversion_account=Equity:Cost-conversion"
2000-01-01 open Assets:Brokerage
2000-01-01 open Assets:Chequing
2000-01-01 open Income:Capital-gains
2000-01-01 open Equity:Cost-conversion
; Buy transactions should balance as entered. The conversion_account
; will be used to make sure they still balance after being converted.
2000-01-01 * "Buy"
Assets:Chequing -100.00 CAD
Assets:Brokerage 5 ACME {20.00 CAD}
convert_buy_cost_to: "USD"
; Sell transactions should be written to balance after being converted.
; The capital gain portion of the sale will be converted to
; target_currency, but the rest will be left alone. In this example,
; that means the Assets:Chequing posting can reflect the actual CAD
; balance deposited.
2000-02-01 * "Sell"
Assets:Chequing 200.00 CAD
Assets:Brokerage -5 ACME {20.00 CAD} @ 40.00 CAD
convert_sell_cost_to: "USD"
Income:Capital-gains -90.00 USD
2000-01-01 price CAD 0.70 USD
2000-02-01 price CAD 0.80 USD
; Irrelevant prices that should be ignored
2000-01-01 price CAD 100.00 AUD
2000-01-01 price AUD 100.00 USD
"""
self.assertEqualEntries("""
2000-01-01 open Assets:Brokerage
2000-01-01 open Assets:Chequing
2000-01-01 open Income:Capital-gains
2000-01-01 open Equity:Cost-conversion
2000-01-01 * "Buy"
Assets:Chequing -100.00 CAD
Assets:Brokerage 5 ACME {14.0000 USD}
Equity:Cost-conversion -70.0000 USD
Equity:Cost-conversion 100.00 CAD
2000-02-01 * "Sell"
Assets:Chequing 200.00 CAD
Assets:Brokerage -5 ACME {14.0000 USD} @ 32.0000 USD
Income:Capital-gains -90.00 USD
Equity:Cost-conversion -200.00 CAD
Equity:Cost-conversion 160.0000 USD
2000-01-01 price CAD 0.70 USD
2000-02-01 price CAD 0.80 USD
2000-01-01 price CAD 100.00 AUD
2000-01-01 price AUD 100.00 USD
""", entries)
--
James
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/beancount/20210507184619.ikep2xoochlropql%40moth.falsifian.org.