BittyTax / BittyTax

Crypto-currency tax calculator with support for all popular wallets, exchanges, explorers and migration from other crypto tax platforms
GNU Affero General Public License v3.0
408 stars 111 forks source link

Kucoin futures parser. #370

Open AnthonyFJGarner opened 1 week ago

AnthonyFJGarner commented 1 week ago
          OK, here is a question on the Kucoin parser.

# Futures Orders_Realized PNL (Bundle) DataParser( ParserType.EXCHANGE, "KuCoin Bundle Futures Orders Realized PNL", [ "UID", "Account Type", "Symbol", "Close Type", "Realized PNL", "Total Realized PNL", "Total Funding Fees", "Total Trading Fees", lambda c: re.match(r"(^Position Opening Time\((UTC[-+]\d{2}:\d{2})\))", c), lambda c: re.match(r"(^Position Closing Time\((UTC[-+]\d{2}:\d{2})\))", c), ], worksheet_name="Kucoin F", all_handler=parse_kucoin_futures,

Note the item "Total Funding Fees" Funding fees accrue in small amounts each day. While it is far more convenient to account for it all in one go at the end of the trade, will this suffice for the ghastly HMRC?

I sent you an email with a Deribit transaction log and I will post the details below so that others can see. You will note that Deribit gives each day's funding payment separately in the log.

Originally posted by @AnthonyFJGarner in https://github.com/BittyTax/BittyTax/issues/22#issuecomment-2172955141

AnthonyFJGarner commented 1 week ago

cantcodeatall thinks funding fees can be wrapped into the P&L at the close of the trade and need not be accounted for on a daily basis as income https://github.com/BittyTax/BittyTax/issues/22#issuecomment-2172967366

Note the item "Total Funding Fees" Funding fees accrue in small amounts each day. While it is far more convenient to account for it all in one go at the end of the trade, will this suffice for the ghastly HMRC?

Yes, it will.

From the horse's mouth here:

[https://www.gov.uk/hmrc-internal-manuals/capital-gains-manual/cg56100]

"All debits and credits to the account, including commission and sums equivalent to interest and dividends, are brought

within the computation of the net chargeable gain or allowable loss when the contract is closed out."

AnthonyFJGarner commented 1 week ago

Here is a sample from my Kucoin file "futures orders realised PNL"

Note that Kucoin does NOT offer on its website the ability to download a list of the daily Funding Fee payments. Neither of the two futures files produced by the download facility on the Kucoin website provide this information.

Screenshot 2024-06-19 145505

`<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">

UID | Account Type | Symbol | Close Type | Realized PNL | Total Realized PNL | Total Funding Fees | Total Trading Fees | Position Opening Time(UTC+08:00) | Position Closing Time(UTC+08:00) -- | -- | -- | -- | -- | -- | -- | -- | -- | -- ***** | mainAccount | XBTMM23 | CLOSE_LONG | -2.7875E-06 | 0.000002377 | 0 | 4.105E-07 | 29/04/2023 00:01 | 04/05/2023 23:14 ***** | mainAccount | XBTUSDM | CLOSE_SHORT | 2.8261E-06 | -0.000002559 | 0.00000068 | 4.129E-07 | 29/04/2023 00:02 | 04/05/2023 23:14

`

AnthonyFJGarner commented 1 week ago

You can only get a record of the daily funding fees on your positions via the API here:

https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-private-funding-history

Which means a separate entry in Bittytax Kucoin parser if fees do indeed count as income and need to be accounted for on a daily basis (rather than in a lump sum on the date the position is closed)

AnthonyFJGarner commented 6 days ago

Here is the heading for the funding fee data. Each instrument will have its own file (EG you might have positions in a number of different perpetuals each of which will have its own csv file).

Let me know when you want a couple of full data files and i will send them over to you.

Although I guess you could ask that people concat all symbols into one CSV.

`<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">

symbol | code | timestamp | datetime | id | amount | fundingRate | markPrice | positionQty | positionCost | info.id | info.symbol | info.timePoint | info.fundingRate | info.markPrice | info.positionQty | info.positionCost | info.funding | info.settleCurrency -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | --

`

AnthonyFJGarner commented 6 days ago

Funding Fees on Perpetuals Just found this: https://www.kucoin.com/assets/futures-account/assets-history Perhaps you can get funding fees from the website after all.....there again, its probably best to set it up with the API given the hassle of ever changing websites....

nanonano commented 5 days ago

BittyTax does not support APIs for a couple of reasons.

  1. Security risk
  2. It is undocumented data, there is a legal requirement to keep records for HMRC.

If this data is available as an CSV export, please share details.

AnthonyFJGarner commented 5 days ago

No my reference to the API was not for incorporation into Bittytax. I'm any event it's "private data" and would require the input of keys etc.

It was only to say to people that IF it is decided funding fees have to be declared on a daily basis, this is where they can get the info