eprbell / dali-rp2

DaLI (Data Loader Interface) is a data loader and input generator for RP2 (https://pypi.org/project/rp2), the privacy-focused, free, open-source cryptocurrency tax calculator: DaLI removes the need to manually prepare RP2 input files. Just like RP2, DaLI is also free, open-source and it prioritizes user privacy.
https://pypi.org/project/dali-rp2/
Apache License 2.0
63 stars 42 forks source link

Error with coinbase asking for apikey #190

Closed Larision closed 1 year ago

Larision commented 1 year ago

here ini file.

[dali.plugin.input.rest.coinbase fran]
account_holder = fran
api_key = xxxxxxxxxxxxxxxxxx
api_secret = xxxxxxxxxxxxxxxxxxxxxxxx
native_fiat = EUR

[dali.plugin.pair_converter.ccxt]
historical_price_type = nearest
;default_exchange = Gate
google_api_key = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

and error.

INFO: Resolving transactions
  0% |                                                                                                                                                                                                                          | Elapsed Time: 0:00:00 ETA:  --:--:--
ERROR: Fatal exception occurred:
Traceback (most recent call last):
  File "/home/kali/renta/dali-rp2/src/dali/dali_main.py", line 178, in _dali_main_internal
    resolved_transactions: List[AbstractTransaction] = resolve_transactions(transactions, dali_configuration, args.read_spot_price_from_web)
                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/renta/dali-rp2/src/dali/transaction_resolver.py", line 286, in resolve_transactions
    transaction = _update_spot_price_from_web(transaction, global_configuration)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/renta/dali-rp2/src/dali/transaction_resolver.py", line 138, in _update_spot_price_from_web
    conversion: RateAndPairConverter = _get_pair_conversion_rate(
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/renta/dali-rp2/src/dali/transaction_resolver.py", line 110, in _get_pair_conversion_rate
    rate = cast(AbstractPairConverterPlugin, pair_converter).get_conversion_rate(timestamp, from_asset, to_asset, exchange)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/renta/dali-rp2/src/dali/abstract_pair_converter_plugin.py", line 182, in get_conversion_rate
    historical_bar = self.get_historic_bar_from_native_source(timestamp, from_asset, to_asset, exchange)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/renta/dali-rp2/src/dali/plugin/pair_converter/ccxt.py", line 258, in get_historic_bar_from_native_source
    self._add_exchange_to_memcache(exchange)
  File "/home/kali/renta/dali-rp2/src/dali/plugin/pair_converter/ccxt.py", line 480, in _add_exchange_to_memcache
    for market in filter(lambda x: x[_TYPE] == "spot" and x[_QUOTE] in _QUOTE_PRIORITY, current_exchange.fetch_markets()):
                                                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/renta/.venv/lib/python3.11/site-packages/ccxt/coinbase.py", line 863, in fetch_markets
    return getattr(self, method)(params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/renta/.venv/lib/python3.11/site-packages/ccxt/coinbase.py", line 935, in fetch_markets_v3
    response = self.v3PrivateGetBrokerageProducts(params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/renta/.venv/lib/python3.11/site-packages/ccxt/base/exchange.py", line 507, in inner
    return entry(_self, **inner_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/renta/.venv/lib/python3.11/site-packages/ccxt/base/exchange.py", line 2889, in request
    return self.fetch2(path, api, method, params, headers, body, config, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/renta/.venv/lib/python3.11/site-packages/ccxt/base/exchange.py", line 2885, in fetch2
    request = self.sign(path, api, method, params, headers, body)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/renta/.venv/lib/python3.11/site-packages/ccxt/coinbase.py", line 2597, in sign
    self.check_required_credentials()
  File "/home/kali/renta/.venv/lib/python3.11/site-packages/ccxt/base/exchange.py", line 3040, in check_required_credentials
    raise AuthenticationError(self.id + ' requires "' + key + '" credential')
ccxt.base.errors.AuthenticationError: coinbase requires "apiKey" credential
INFO: Log file: ./log/rp2_2023_06_07_15_08_48_680425.log
macanudo527 commented 1 year ago

It appears Coinbase has no public API, according to this. If we want to use it for pricing data it seems like we need an account.

eprbell commented 1 year ago

The Historic_crypto package gets price data from Coinbase Pro without needing an account. It's probably different for Coinbase though.

Larision commented 1 year ago

i need disable coinbase lines in ccxt.py to save those errors..

# Currently supported exchanges
_BINANCE: str = "Binance.com"
_BINANCEUS: str = "Binance US"
# _COINBASE: str = "Coinbase"     <-------
_COINBASE_PRO: str = "Coinbase Pro"
_GATE: str = "Gate"
_HUOBI: str = "Huobi"
_KRAKEN: str = "Kraken"
_OKEX: str = "Okex"
_UPBIT: str = "Upbit"
_FIAT_EXCHANGE: str = "Exchangerate.host"
_DEFAULT_EXCHANGE: str = _KRAKEN
_EXCHANGE_DICT: Dict[str, Any] = {
    _BINANCE: binance,
    _BINANCEUS: binanceus,
    # _COINBASE: coinbase,         <--------
    _COINBASE_PRO: coinbasepro,
    _GATE: gateio,
    _HUOBI: huobi,
    _KRAKEN: kraken,
    _OKEX: okex,
    _UPBIT: upbit,
macanudo527 commented 1 year ago

@Larision Can you submit a PR that deletes Coinbase? I would think most people that use Coinbase wouldn't need routing.

We can implement something later that uses coinbase_pro for coinbase exchange if it is needed.