Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitpanda changed fileformat #165

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

wullxz
Copy link

@wullxz wullxz commented May 13, 2024

This PR deals with some developments for Bitpanda, which are roughly:

  • Bitpanda Pro is now One Trading and doesn't share data with Bitpanda anymore. As a result, the Bitpanda Pro API, that was also used for Bitpanda to fetch prices, is moved to a different address and doesn't offer the same markets (coin/EUR) as Bitpanda anymore. (Related: Bitpanda (non-pro) pricing data API #159 )
  • The Bitpanda export has a new column (Related: Bitpanda (non-pro) pricing data API #159 )
  • Bitpandas logging of transactions changed a bit over time and didn't provide a lot of details in the beginning. As a result, staking actions (staking, unstaking, rewards) and other airdrops were logged as "transfer". Some of those cases can be handled and corrected automatically. (Fixes: Bitpanda staking transactions unknown #155 )
  • In the past years, there were at least two forks that I was affected by: ETHW (the PoW fork of ETH) and LUNC (crashed fork of LUNA). Users who held those coins when the fork happened received some amount of the fork coin as air drop. Taxation of those is not entirely clear but there are some arguments available (see the detailed changes for more info). My PR classifies those as AirdropGift (non-taxable) but doesn't try to add a history or fork operation as discussed in Add Type "fork" as possibility of getting a Coin #131 .

The detailed changes from 3 commits:

  • cfg fix: The de_DE locale doesn't work on my system. I've changed it to try different locales in order ("de_DE", "de_DE.utf-8")
  • general: Created AirdropGift (non-taxed) and AirdropIncome (taxed) as subclasses of Airdrop. AirdropGifts are always non-taxed and AirdropIncome are always taxed, no matter the setting ALL_AIRDROPS_ARE_GIFTS in the config. These subclasses can be used if it is save to say that a record is to be taxed or not.
  • bitpanda general: Current csv exports have an additional field that tripped up the parsing. Added the field _tax_fiat to the header definition. TODO: check if the contained information is relevant.
  • bitpanda airdrop types: Implemented AirdropGift for BEST and ETHW drops (see below).
  • bitpanda stocks: Ignore records where the asset type starts with "Stock" (for now)
  • bitpanda BEST transfer: BEST is bitpandas own coin and is rewarded for activity and holding a portfolio. These are classified as AirdropGift (non-taxable).
  • bitpanda ETHW transfer: ETHW is the old ETH chain. If a user held ETH with bitpanda when the fork to PoS happened, they received ETHW some time in September 2022. Classify that as AirdropGift according to the first reasoning described here
  • bitpanda staking: Implemented handling of staking for transfer(stake) and transfer(unstake) operation types.
  • general: Added new data field exported_price to Operation class
  • bitpanda general: For ETHW and BEST, the exported_price will be used because the ONE TRADING API doesn't return anything.
  • bitpanda general fix: The change calculation used a change from an earlier data record for some operation types,
    because the change variable was not touched (for Airdrops of any kind and Staking operations of any kind).
    The missing operations are now added in _read_bitpanda in book.py and an Exception has been added for anything else not
    included in my change.
  • bitpanda general: Bitpanda Pro, whose API we use to fetch prices for bitpanda transactions, is now One Trading. As a result, their API is available under a different address and with a slightly different response. This commit contains the fixes for both, the address and the parsing/usage of the result.
  • bitpanda general: Since One Trading doesn't offer the same coins as Bitpanda anymore, some coin/fiat pairs aren't available there (like BEST/EUR, ETHW/EUR, LTC/EUR and others). To differentiate between a "market" not being available and other errors, we raise a ValueError in case the "market" is not available. I chose ValueError because catching LookupError also catches errors with indices in lists, which should be thrown.
  • bitpanda general: The ValueError is caught in price_data.py in the get_cost method. In the last commit, I added a new field exported_price to the Operation data class, which is used in the exception handling to use the price from the csv export (it's better than nothing). For BEST, there is sadly no price available if the BEST transaction is a Withdrawal (Fee). For now, we assume a value of 0 in that case (I don't know how to fix this otherwise).
  • bitpanda LUNC airdrop: I added special handling for the LUNC airdrop that happened in May 2022 because of a blockchain crash and subsequent fork. Sadly, the price can't be retrieved using the API and the airdrop didn't have a price associated. CoinTaxman should throw an exception because it can't fetch a price and it should also say which line the airdrop is in. I used that to edit my csv export and input a ridiculously small price since the price was really low anyway.
  • bitpanda staking rewards: Sometime before 2022/6/14, bitpanda used "transfer" for staking rewards. Incoming crypto "transfers" before that date, that aren't BEST, are therefore classified as (staking-)reward.

Background of the Bitpanda Pro spin off into One Trading:

Bitpanda Pro, which is used to obtain historical prices for (crypto-)assets
is now ONE TRADING and a separate company to which Bitpanda only holds a minority stake.
After that split, BEST can't be used anymore on ONE TRADING and historical BEST price data isn't available anymore.
Also, ETHW, which stands for the Proof of Work branch of the ETH chain, isn't available on ONE TRADING.

This means, that we need to use the prices we have from the csv file as best as we can.
For normal transactions, that's possible by using the "Asset market price" column of the export but for fee withdrawals
from the BEST wallet, no price was actually associated with the withdrawal transaction.
For now, I'm using an asset price of 0 because I don't know how to fix this otherwise.

For the normal transactions, a new property has been added to the Operation class (exported_price) to be able to
carry the asset price for normal transactions into the processing classes like PriceData and use it there
if a proper price can't be obtained (see get_cost method in PriceData in price_data.py).

Source: https://support.bitpanda.com/hc/en-us/articles/9374684386332-Why-is-Bitpanda-Pro-evolving-to-become-One-Trading

… small cfg fix

* cfg fix: The de_DE locale doesn't work on my system. I've changed it to try different locales in order ("de_DE", "de_DE.utf-8")
* general: Created AirdropGift (non-taxed) and AirdropIncome (taxed) as subclasses of Airdrop. AirdropGifts are always non-taxed and AirdropIncome are always taxed, no matter the setting `ALL_AIRDROPS_ARE_GIFTS` in the config. These subclasses can be used if it is save to say that a record is to be taxed or not.
* bitpanda general: Current csv exports have an additional field that tripped up the parsing. Added the field `_tax_fiat` to the header definition. TODO: check if the contained information is relevant.
* bitpanda airdrop types: Implemented AirdropGift for BEST and ETHW drops (see below).
* bitpanda stocks: Ignore records where the asset type starts with "Stock" (for now)
* bitpanda BEST transfer: BEST is bitpandas own coin and is rewarded for activity and holding a portfolio. These are classified as AirdropGift (non-taxable).
* bitpanda ETHW transfer: ETHW is the old ETH chain. If a user held ETH with bitpanda when the fork to PoS happened, they received ETHW some time in September 2022. Classify that as AirdropGift according to the first reasoning described [here](https://www.winheller.com/bankrecht-finanzrecht/bitcointrading/bitcoinundsteuer/besteuerung-hardforks-ledger-splits.html)
* bitpanda staking: Implemented handling of staking for `transfer(stake)` and `transfer(unstake)` operation types.
Background info: Bitpanda Pro, which is used to obtain historical prices for (crypto-)assets
is now ONE TRADING and a separate company to which Bitpanda only holds a minority stake.
After that split, BEST can't be used anymore on ONE TRADING and historical BEST price data isn't available anymore.
Also, ETHW, which stands for the Proof of Work branch of the ETH chain, isn't available on ONE TRADING.

This means, that we need to use the prices we have from the csv file as best as we can.
For normal transactions, that's possible by using the "Asset market price" column of the export but for fee withdrawals
from the BEST wallet, no price was actually associated with the withdrawal transaction.
For now, I'm using an asset price of 0 because I don't know how to fix this otherwise.

For the normal transactions, a new property has been added to the Operation class (`exported_price`) to be able to
carry the asset price for normal transactions into the processing classes like PriceData and use it there
if a proper price can't be obtained (see `get_cost` method in `PriceData` in price_data.py).

Source: https://support.bitpanda.com/hc/en-us/articles/9374684386332-Why-is-Bitpanda-Pro-evolving-to-become-One-Trading

* general: Added new data field `exported_price` to `Operation` class
* bitpanda general: For ETHW and BEST, the `exported_price` will be used because the ONE TRADING API doesn't return anything.
* bitpanda general fix: The `change` calculation used a change from an earlier data record for some operation types,
  because the `change` variable was not touched (for Airdrops of any kind and Staking operations of any kind).
  The missing operations are now added in `_read_bitpanda` in book.py and an Exception has been added for anything else not
  included in my change.
* bitpanda general: Bitpanda Pro, whose API we use to fetch prices for bitpanda transactions, is now One Trading. As a result, their API is available under a different address and with a slightly different response. This commit contains the fixes for both, the address and the parsing/usage of the result.
* bitpanda general: Since One Trading doesn't offer the same coins as Bitpanda anymore, some coin/fiat pairs aren't available there (like BEST/EUR, ETHW/EUR, LTC/EUR and others). To differentiate between a "market" not being available and other errors, we raise a ValueError in case the "market" is not available. I chose ValueError because catching LookupError also catches errors with indices in lists, which should be thrown.
* bitpanda general: The ValueError is caught in price_data.py in the `get_cost` method. In the last commit, I added a new field `exported_price` to the `Operation` data class, which is used in the exception handling to use the price from the csv export (it's better than nothing). For BEST, there is sadly no price available if the BEST transaction is a Withdrawal (Fee). For now, we assume a value of 0 in that case (I don't know how to fix this otherwise).
* bitpanda LUNC airdrop: I added special handling for the LUNC airdrop that happened in May 2022 because of a blockchain crash and subsequent fork. Sadly, the price can't be retrieved using the API and the airdrop didn't have a price associated. CoinTaxman should throw an exception because it can't fetch a price and it should also say which line the airdrop is in. I used that to edit my csv export and input a ridiculously small price since the price was really low anyway.
* bitpanda staking rewards: Sometime before 2022/6/14, bitpanda used "transfer" for staking rewards. Incoming crypto "transfers" before that date, that aren't BEST, are therefore classified as (staking-)reward.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bitpanda staking transactions unknown
1 participant