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
66 stars 42 forks source link

fiat access key required when not needed #238

Closed X1011 closed 2 months ago

X1011 commented 6 months ago

When I tried to run DaLI, it stopped with an error requesting an access key for exchangerate.host, even though all my fiat transactions are in USD. I went and signed up for exchangerate.host and configured the key and ran it again, but the key was never used, according to my exchangerate.host dashboard, so it seems the check for this key is too eager. It looks like this was introduced in PR #212

rp2.rp2_error.RP2ValueError: No fiat access key. To convert fiat assets, please acquire an access key from exchangerate.host.The access key will then need to be added to the configuration file. For more details visit https://github.com/eprbell/dali-rp2/blob/main/docs/configuration_file.md

full log
2024-04-15 12:59:44,442/dali/INFO: Country: us
2024-04-15 12:59:44,445/dali/INFO: Initialized input plugin 'dali.plugin.input.csv.manual'
2024-04-15 12:59:44,445/dali/WARNING: No Fiat Access Key. Fiat pricing will NOT be available. To enable fiat pricing, an access key from exchangerate.host is required.
2024-04-15 12:59:44,445/dali/WARNING: No Fiat Access Key. Fiat pricing will NOT be available. To enable fiat pricing, an access key from exchangerate.host is required.
2024-04-15 12:59:44,445/dali/INFO: No pair converter plugins found in configuration file: using default pair converters.
2024-04-15 12:59:44,468/dali/INFO: Reading crypto data using plugin 'dali.plugin.input.csv.manual'
2024-04-15 12:59:44,642/dali/INFO: Building manifest to optimize price calculation with the pair converters.
2024-04-15 12:59:44,645/dali/INFO: Resolving transactions
2024-04-15 12:59:47,316/dali/ERROR: Fatal exception occurred:
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/dali/dali_main.py", line 193, in _dali_main_internal
    resolved_transactions: List[AbstractTransaction] = resolve_transactions(transactions, dali_configuration, args.read_spot_price_from_web)
                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/dali/transaction_resolver.py", line 286, in resolve_transactions
    transaction = _update_spot_price_from_web(transaction, global_configuration)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/dali/transaction_resolver.py", line 138, in _update_spot_price_from_web
    conversion: RateAndPairConverter = _get_pair_conversion_rate(
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/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 "/opt/homebrew/lib/python3.11/site-packages/dali/abstract_pair_converter_plugin.py", line 172, in get_conversion_rate
    historical_bar = self.get_historic_bar_from_native_source(timestamp, from_asset, to_asset, exchange)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/dali/plugin/pair_converter/ccxt.py", line 281, in get_historic_bar_from_native_source
    if self._is_fiat_pair(from_asset, to_asset):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/dali/abstract_pair_converter_plugin.py", line 245, in _is_fiat_pair
    return self._is_fiat(from_asset) and self._is_fiat(to_asset)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/dali/abstract_pair_converter_plugin.py", line 249, in _is_fiat
    self._build_fiat_list()
  File "/opt/homebrew/lib/python3.11/site-packages/dali/abstract_pair_converter_plugin.py", line 193, in _build_fiat_list
    self._check_fiat_access_key()
  File "/opt/homebrew/lib/python3.11/site-packages/dali/abstract_pair_converter_plugin.py", line 343, in _check_fiat_access_key
    raise RP2ValueError(
rp2.rp2_error.RP2ValueError: No fiat access key. To convert fiat assets, please acquire an access key from exchangerate.host.The access key will then need to be added to the configuration file. For more details visit https://github.com/eprbell/dali-rp2/blob/main/docs/configuration_file.md
2024-04-15 12:59:47,321/dali/INFO: Log file: ./log/rp2_2024_04_15_12_59_43_015390.log
2024-04-15 12:59:47,321/dali/INFO: Generated output directory: output/
2024-04-15 12:59:47,321/dali/INFO: Done
X1011 commented 6 months ago

I was looking through PRs, and it looks like #236 may fix this when implemented.

macanudo527 commented 6 months ago

Actually, #225 will ultimately fix this. I have the entire forex code taken apart at the moment. We will be mostly doing away with exchangerates.host and making it an option only.

Do you need it right away? Are you filing taxes? If so, you can implement the monkey patch #236 in the meantime.

X1011 commented 6 months ago

Sounds good 👍 I don't need it now; I got past it by configuring an access key.

rapus95 commented 4 months ago

Is there an ETA for it?

Running into this:

INFO: Resolving transactions
  0% |                                                                                                                                                                                                                                           | Elapsed Time: 0:00:00 ETA:  --:--:--
ERROR: Fatal exception occurred:
Traceback (most recent call last):
  File "C:\Python312\Lib\site-packages\dali\dali_main.py", line 193, in _dali_main_internal
    resolved_transactions: List[AbstractTransaction] = resolve_transactions(transactions, dali_configuration, args.read_spot_price_from_web)
                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\dali\transaction_resolver.py", line 259, in resolve_transactions
    transaction = _convert_fiat_fields_to_native_fiat(transaction, global_configuration)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\dali\transaction_resolver.py", line 179, in _convert_fiat_fields_to_native_fiat
    conversion: RateAndPairConverter = _get_pair_conversion_rate(
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\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 "C:\Python312\Lib\site-packages\dali\abstract_pair_converter_plugin.py", line 172, in get_conversion_rate
    historical_bar = self.get_historic_bar_from_native_source(timestamp, from_asset, to_asset, exchange)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\dali\plugin\pair_converter\ccxt.py", line 281, in get_historic_bar_from_native_source
    if self._is_fiat_pair(from_asset, to_asset):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\dali\abstract_pair_converter_plugin.py", line 245, in _is_fiat_pair
    return self._is_fiat(from_asset) and self._is_fiat(to_asset)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\dali\abstract_pair_converter_plugin.py", line 249, in _is_fiat
    self._build_fiat_list()
  File "C:\Python312\Lib\site-packages\dali\abstract_pair_converter_plugin.py", line 193, in _build_fiat_list
    self._check_fiat_access_key()
  File "C:\Python312\Lib\site-packages\dali\abstract_pair_converter_plugin.py", line 343, in _check_fiat_access_key
    raise RP2ValueError(
rp2.rp2_error.RP2ValueError: No fiat access key. To convert fiat assets, please acquire an access key from exchangerate.host.The access key will then need to be added to the configuration file. For more details visit https://github.com/eprbell/dali-rp2/blob/main/docs/configuration_file.md
INFO: Log file: ./log/rp2_2024_06_24_12_02_41_209051.log
INFO: Generated output directory: output
INFO: Done
macanudo527 commented 4 months ago

Have you pulled the latest release? #225 did away with the need for a fiat access key. It just got merged yesterday. You will need to pull it from github.

Or, you can just put in a bogus fiat access key and it will work just fine.

macanudo527 commented 2 months ago

I'm closing this as it seems resolved. Let us know if you are still having issues.