Currently I have a transaction that looks like the transaction below
2024-11-28 ! "XYZ Exchange" "Exchange 2.3300947 XXX for 1.62965293 YYY"
Assets:Crypto:PrivateWallets:EXCHANGE:XXX -2.3300947 XXX {} @70.43 USD
Assets:Crypto:PrivateWallets:EXCHANGE:YYY 1.62965293 YYY {100.701546 USD, "Swap XXX for YYY on EXCHANGE 2024-11-28"}
Income:CapitalGains
Is this the best way to set up an exchange like this?
In this example there are two lots the XXX are taken from - the first lot size is 2.0851416 XXX and has a &66.21451 basis and the other has a size of 0.2449531 XXX and has a 55.94963 basis
The capital gains on this transaction equals 12.34 USD
Essentially I use a script to calculate the basis of the coin being bought based on the price of the coin I'm using the pay for it. So the $100.701546 price of YYY is based on the price of XXX at purchase. Then Beancount figures out the basis and subtracts that from the price I paid for the new coin to get the Capital Gains.
I want to make sure this is a proper way to do this or is there a better way?
Also, since many of the transactions break down into multiple lots, how do you go about getting a report for something like an IRS form 8949? What query would get the transactions for a time period but also give the individual basis amounts? I'm assuming a script would then need to be used to get the data in the correct format, but can the base data be brought up relatively easy?
-Chris