From 731a8c95635d9b524fd7811070023999e6415fe7 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Fri, 26 Jul 2024 20:12:49 -0700 Subject: [PATCH] hledger-flow: changelly: cost-basis comments for bitcoin.tax Issue #51 describes at least a few undocumented bitcoin.tax issues: - Bicoin.tax gives unexpected cost-basis results when `Fee` is given with `Total` (when `Total` is given in place of `Price`). The expectation is that bitcoin.tax will perform the cost-basis calculation on `Total` when `Fee` is also given. However, bitcoin.tax *will* give expected cost-basis results if `Price` is given in place of `Total` (with `Fee` also given) *or* if `Total` is given *after* local cost-basis adjustments are made (but *without* `Fee` given). The rationale for why docker-finance doesn't use `Price`: * docker-finance has all of the `Total`s; so `Price` isn't necessary. * Local price information isn't available for most trades (and shouldn't be necessary since all `Total`s are available). - Additionally, when `Fee` is non-fiat (crypto), it now must be marked as a SPEND in order to be disposed (and to produce an accurate closing report). - Finally, if `FeeCurrency` *does* not match either `Symbol` or `Currency` (e.g., BTC-ETH w/ BNB fee), it's unknown if cost-basis must be calculated locally as well (if `Total` is given). Local calculations cannot be done because `Fee` price information is (almost certainly) not available for this type of trade. Until upstream can assert that attaching the `Fee` will subsequently adjust the cost-basis of `Total` *and* dispose of the `Fee` in the process (while also allowing `Total` to be used in place of `Price`), the `Fee` (and `FeeCurrency`) column(s) must not be populated and values instead moved to SPEND (as described above). Upstream is aware of these issues (since May) and they're in the process of resolution. In the meantime, docker-finance work-arounds should suffice for all trades that have a fiat `Fee` and/or a `Fee`/`FeeCurrency` that matches one side of the trading pair. --- .../accounts/changelly/changelly-shared.rules | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/container/src/hledger-flow/accounts/changelly/changelly-shared.rules b/container/src/hledger-flow/accounts/changelly/changelly-shared.rules index aeaa0c0..20364be 100644 --- a/container/src/hledger-flow/accounts/changelly/changelly-shared.rules +++ b/container/src/hledger-flow/accounts/changelly/changelly-shared.rules @@ -26,10 +26,19 @@ account3 assets:changelly:%subaccount:%currency_from amount3 -%currency_from_amount %currency_from @@ %currency_to_amount %currency_to account4 equity:changelly:%subaccount:deposit:%currency_to -# NOTE: fee is not added to cost-basis here because currency_to_amount includes -# that automatically (it deducts the fee and computes into currency_to_amount). -# NOTE: because the fee is considered a facilitation fee for the trade, -# *don't* use the provided %fee and instead use the adjust cost-basis instead. +# NOTE: +# +# - %fee is not added to cost-basis here because %currency_to_amount includes +# the fee (it adjusts the proceeds and computes into %currency_to_amount). +# +# - %fee is considered a facilitation fee for the trade; so *don't* add to +# column (see above). +# +# - %currency_from_amount is fully disposed (as the adjustment happens to +# %currency_to_amount). +# +# - For details, see #51. +# comment rate:%rate, destination:%destination, taxed_as:SELL comment2 %date +0000,SELL,changelly,%currency_from,%currency_from_amount,%currency_to,%currency_to_amount,,