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

exchange.fetchConvertTradeHistory: "KeyError: 'currency'" on binance #22261

Closed
egabosh opened this issue Apr 23, 2024 · 8 comments
Closed

exchange.fetchConvertTradeHistory: "KeyError: 'currency'" on binance #22261

egabosh opened this issue Apr 23, 2024 · 8 comments
Assignees

Comments

@egabosh
Copy link

egabosh commented Apr 23, 2024

Operating System

Debian Linux 12.5

Programming Languages

Python

CCXT Version

4.3.6

Description

Moin,

getting the following error in fetchConvertTradeHistory:

Traceback (most recent call last):
  File "/ccxt/examples/py/fetch-orders.py", line 54, in <module>
    print(exchange.fetchConvertTradeHistory(limit=200, since=1691618400000, params={'until': 1693519200000}))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ccxt/python/ccxt/binance.py", line 11884, in fetch_convert_trade_history
    return self.parse_conversions(rows, fromCurrencyKey, toCurrencyKey, since, limit)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ccxt/python/ccxt/base/exchange.py", line 5703, in parse_conversions
    return self.filter_by_currency_since_limit(sorted, code, since, limit)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ccxt/python/ccxt/base/exchange.py", line 4909, in filter_by_currency_since_limit
    return self.filter_by_value_since_limit(array, 'currency', code, since, limit, 'timestamp', tail)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ccxt/python/ccxt/base/exchange.py", line 2065, in filter_by_value_since_limit
    entryFiledEqualValue = entry[field] == value
                           ~~~~~^^^^^^^
KeyError: 'currency'

Query in binance WebUI gives trades in specified timeframe.
Without any option:
print(exchange.fetchConvertTradeHistory)
The outout is:
[]

Any ideas whats wrong?

Code

#print(exchange.fetchConvertTradeHistory(code='ADA', limit=200, since=1690840800000, params={'until': 1693519200000}))
print(exchange.fetchConvertTradeHistory(limit=200, since=1691618400000, params={'until': 1693519200000}))
@carlosmiei carlosmiei self-assigned this Apr 24, 2024
@carlosmiei
Copy link
Collaborator

Hello @egabos, thanks for reporting it. Can you please post a verbose log?

How to enable the verbose log:

await exchange.load_markets()
exchange.verbose = True

@egabosh
Copy link
Author

egabosh commented Apr 25, 2024

Moin,

here the output:

fetch Request: binance GET https://api.binance.com/sapi/v1/convert/tradeFlow?timestamp=1714028108127&startTime=1691618400000&endTime=1693519200000&limit=200&recvWindow=10000&signature=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX RequestHeaders: {'X-MBX-APIKEY': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'User-Agent': 'python-requests/2.28.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} RequestBody: None

fetch Response: binance GET https://api.binance.com/sapi/v1/convert/tradeFlow?timestamp=1714028108127&startTime=1691618400000&endTime=1693519200000&limit=200&recvWindow=10000&signature=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 200 ResponseHeaders: {'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Date': 'Thu, 25 Apr 2024 06:55:08 GMT', 'Server': 'nginx', 'Vary': 'Accept-Encoding', 'X-SAPI-USED-UID-WEIGHT-1M': '3000', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains', 'X-Frame-Options': 'SAMEORIGIN', 'X-Xss-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': "default-src 'self'", 'X-Content-Security-Policy': "default-src 'self'", 'X-WebKit-CSP': "default-src 'self'", 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, HEAD, OPTIONS', 'Content-Encoding': 'gzip', 'X-Cache': 'Miss from cloudfront', 'Via': '1.1 def5acc189db6e2856a956225d5cd100.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'FRA56-P6', 'X-Amz-Cf-Id': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'} ResponseBody: {"list":[{"quoteId":"XXXXXXXXXXXXXXXXXXXXXXXXXXX","orderId":1,"orderStatus":"SUCCESS","fromAsset":"USDT","fromAmount":"10.5","toAsset":"SFP","toAmount":"1.0000000","ratio":"1.0000000","inverseRatio":"1.0000000","createTime":1693320370590,"orderType":"MARKET","side":"BUY"},{"quoteId":"XXXXXXXXXXXXXXXXXXXXXXXXXXX","orderId":1,"orderStatus":"SUCCESS","fromAsset":"USDT","fromAmount":"10.5","toAsset":"KDA","toAmount":"1.0000000","ratio":"1.0000000","inverseRatio":"1.0000000","createTime":1693322165993,"orderType":"MARKET","side":"BUY"},{"quoteId":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX","orderId":1534097592974412619,"orderStatus":"SUCCESS","fromAsset":"USDT","fromAmount":"1.0000000","toAsset":"DOT","toAmount":"1.0000000","ratio":"1.0000000","inverseRatio":"1.0000000","createTime":1693328465806,"orderType":"MARKET","side":"BUY"},{"quoteId":"XXXXXXXXXXXXXXXXXXXXXXXXXXXX","orderId":1,"orderStatus":"SUCCESS","fromAsset":"BNB","fromAmount":"1.00000008","toAsset":"USDT","toAmount":"1.0000000","ratio":"1.0000000","inverseRatio":"1.0000000","createTime":1693341057389,"orderType":"MARKET","side":"SELL"},{"quoteId":"XXXXXXXXXXXXXXXXXXXXXXXXXXXX","orderId":1,"orderStatus":"SUCCESS","fromAsset":"ANT","fromAmount":"1.0000000","toAsset":"USDT","toAmount":"1.0000000","ratio":"1.0000000","inverseRatio":"1.0000000","createTime":1693351849368,"orderType":"MARKET","side":"SELL"},{"quoteId":"XXXXXXXXXXXXXXXXXXXXXXXXXXXX","orderId":1,"orderStatus":"SUCCESS","fromAsset":"KDA","fromAmount":"1.0000000","toAsset":"USDT","toAmount":"1.0000000","ratio":"1.0000000","inverseRatio":"1.0000000","createTime":1693366248195,"orderType":"MARKET","side":"SELL"},{"quoteId":"XXXXXXXXXXXXXXXXXXXXXXXXXXXX","orderId":1,"orderStatus":"SUCCESS","fromAsset":"ADA","fromAmount":"1.0000000","toAsset":"USDT","toAmount":"1.0000000","ratio":"1.0000000","inverseRatio":"1.0000000","createTime":1693406750163,"orderType":"MARKET","side":"SELL"},{"quoteId":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXa","orderId":1,"orderStatus":"SUCCESS","fromAsset":"DYDX","fromAmount":"1.0000000","toAsset":"USDT","toAmount":"1.0000000","ratio":"1.0000000","inverseRatio":"1.0000000","createTime":1693407662909,"orderType":"MARKET","side":"SELL"},{"quoteId":"XXXXXXXXXXXXXXXXXXXXXXXXXXXX","orderId":1,"orderStatus":"SUCCESS","fromAsset":"BNB","fromAmount":"1.0000000","toAsset":"USDT","toAmount":"1.0000000","ratio":"1.0000000","inverseRatio":"1.0000000","createTime":1693409448970,"orderType":"MARKET","side":"SELL"}],"startTime":1691618400000,"endTime":1693519200000,"limit":200,"moreData":false}
Traceback (most recent call last):
  File "/ccxt/examples/py/fetch-orders.py", line 56, in <module>
    print(exchange.fetchConvertTradeHistory(limit=200, since=1691618400000, params={'until': 1693519200000}))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ccxt/python/ccxt/binance.py", line 11884, in fetch_convert_trade_history
    return self.parse_conversions(rows, fromCurrencyKey, toCurrencyKey, since, limit)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ccxt/python/ccxt/base/exchange.py", line 5703, in parse_conversions
    return self.filter_by_currency_since_limit(sorted, code, since, limit)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ccxt/python/ccxt/base/exchange.py", line 4909, in filter_by_currency_since_limit
    return self.filter_by_value_since_limit(array, 'currency', code, since, limit, 'timestamp', tail)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ccxt/python/ccxt/base/exchange.py", line 2065, in filter_by_value_since_limit
    entryFiledEqualValue = entry[field] == value
                           ~~~~~^^^^^^^
KeyError: 'currency'

XXXX'ed some things out and set amount/Ratios to 1.00000 but looks like the response from binance is OK.

@carlosmiei
Copy link
Collaborator

@egabosh Thanks, we found indeed an issue but we will patch it shortly.

@egabosh
Copy link
Author

egabosh commented Apr 25, 2024

Great, thank you!

@ttodua
Copy link
Member

ttodua commented Apr 25, 2024

@egabosh the PR was merged, in few hours update your package and retry, the issue should be gone. if not, let us know again. thanks

@ttodua ttodua closed this as completed Apr 25, 2024
@carlosmiei
Copy link
Collaborator

@egabosh We just released a new version, can you please update your ccxt version and try again?

@egabosh
Copy link
Author

egabosh commented Apr 26, 2024

Thanks a lot! I am now receiving data.
But there seem to be other problems.

If I enter a period of more than 6 months, I get nothing or '[]'.

If there are tokens in the selected period that are no longer traded on Binance, I get the following error:

Traceback (most recent call last):
  File "/ccxt/examples/py/fetch-orders.py", line 57, in <module>
    print(exchange.fetchConvertTradeHistory(limit=200, since=1672527600000, params={'until': 1688248800000}))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ccxt/python/ccxt/binance.py", line 11886, in fetch_convert_trade_history
    return self.parse_conversions(rows, code, fromCurrencyKey, toCurrencyKey, since, limit)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ccxt/python/ccxt/base/exchange.py", line 5698, in parse_conversions
    toCurrency = self.currency(toId)
                 ^^^^^^^^^^^^^^^^^^^
  File "/ccxt/python/ccxt/base/exchange.py", line 4659, in currency
    raise ExchangeError(self.id + ' does not have currency code ' + code)
ccxt.base.errors.ExchangeError: binance does not have currency code TOMO

@egabosh
Copy link
Author

egabosh commented Apr 26, 2024

Created new issues for this.
#22287
#22289

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

No branches or pull requests

3 participants