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

Bitso "Invalid Nonce or Invalid Credentials" error on certain Private methods #1437

Closed
KoenBal opened this issue Jan 23, 2018 · 5 comments
Closed
Assignees

Comments

@KoenBal
Copy link

KoenBal commented Jan 23, 2018

  • OS: Windows 10
  • Programming Language version: Python 3.6
  • CCXT version: 1.10.810
  • Exchange: Bitso
  • Method: fetch_order

I'm getting an "Invalid Nonce or Invalid Credentials".
Though this does not happen when I try to fetch my balance or when I create an order.
Note the only private methods that seem to work for Bitso in the ccxt library are create_order and fetch_balance.
cancel_order should be using privateDeleteOrdersOid. That I already fixed. But I'm not getting any further with "Invalid Nonce or Invalid Credentials" error. Any ideas?

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
~\Anaconda3\envs\LambdaDeploymentPackage\TradingBotEnv\lib\site-packages\ccxt\base\exchange.py in fetch(self, url, method, headers, body)
    351             self.last_http_response = response.text
--> 352             response.raise_for_status()
    353 

~\Anaconda3\envs\LambdaDeploymentPackage\TradingBotEnv\lib\site-packages\requests\models.py in raise_for_status(self)
    934         if http_error_msg:
--> 935             raise HTTPError(http_error_msg, response=self)
    936 

HTTPError: 401 Client Error: Unauthorized for url: https://api.bitso.com/v3/orders/XS2aQZOlGB1zQ08e

During handling of the above exception, another exception occurred:

AuthenticationError                       Traceback (most recent call last)
<ipython-input-5-5bb3a58b2ab6> in <module>()
     11 # BuyOrder = Bitso.create_order('ETH/MXN', 'market', 'buy', 0.001)
     12 # BuyOrder
---> 13 CancelledOrder = Bitso.cancel_order('XS2aQZOlGB1zQ08e')
     14 
     15 # CancelledOrder = Bitso.privateDeleteOrdersOid({'oid': 'XS2aQZOlGB1zQ08e'})

~\Anaconda3\envs\LambdaDeploymentPackage\TradingBotEnv\lib\site-packages\ccxt\bitso.py in cancel_order(self, id, symbol, params)
    269     def cancel_order(self, id, symbol=None, params={}):
    270         self.load_markets()
--> 271         response = self.privateDeleteOrdersOid(self.extend({'oid': id}, params))
    272         return {
    273             'info': response,

~\Anaconda3\envs\LambdaDeploymentPackage\TradingBotEnv\lib\site-packages\ccxt\bitso.py in request(self, path, api, method, params, headers, body)
    299 
    300     def request(self, path, api='public', method='GET', params={}, headers=None, body=None):
--> 301         response = self.fetch2(path, api, method, params, headers, body)
    302         if 'success' in response:
    303             if response['success']:

~\Anaconda3\envs\LambdaDeploymentPackage\TradingBotEnv\lib\site-packages\ccxt\base\exchange.py in fetch2(self, path, api, method, params, headers, body)
    297         self.lastRestRequestTimestamp = self.milliseconds()
    298         request = self.sign(path, api, method, params, headers, body)
--> 299         return self.fetch(request['url'], request['method'], request['headers'], request['body'])
    300 
    301     def request(self, path, api='public', method='GET', params={}, headers=None, body=None):

~\Anaconda3\envs\LambdaDeploymentPackage\TradingBotEnv\lib\site-packages\ccxt\base\exchange.py in fetch(self, url, method, headers, body)
    363         except HTTPError as e:
    364             self.handle_errors(response.status_code, response.reason, url, method, None, self.last_http_response)
--> 365             self.handle_rest_errors(e, response.status_code, self.last_http_response, url, method)
    366             self.raise_error(ExchangeError, url, method, e, self.last_http_response)
    367 

~\Anaconda3\envs\LambdaDeploymentPackage\TradingBotEnv\lib\site-packages\ccxt\base\exchange.py in handle_rest_errors(self, exception, http_status_code, response, url, method)
    394             error = AuthenticationError
    395         if error:
--> 396             self.raise_error(error, url, method, exception if exception else http_status_code, response)
    397 
    398     def handle_rest_response(self, response, url, method='GET', headers=None, body=None):

~\Anaconda3\envs\LambdaDeploymentPackage\TradingBotEnv\lib\site-packages\ccxt\base\exchange.py in raise_error(self, exception_type, url, method, error, details)
    279                 method,
    280                 url,
--> 281                 details,
    282             ]))
    283         else:

AuthenticationError: bitso DELETE https://api.bitso.com/v3/orders/XS2aQZOlGB1zQ08e 401 Client Error: Unauthorized for url: https://api.bitso.com/v3/orders/XS2aQZOlGB1zQ08e {"success":false,"error":{"code":"0201","message":"Invalid Nonce or Invalid Credentials"}}
@kroitor kroitor self-assigned this Jan 23, 2018
@userzc
Copy link

userzc commented Jan 24, 2018

I am getting a similar error in ubuntu 16.04 with python 3.5.2 using virtualenv (ccxt: 1.10.833) when fetching balance:

In [9]: bitso_api.fetchBalance()
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
~/.virtualenvs/ccxt-test/lib/python3.5/site-packages/ccxt/base/exchange.py in fetch(self, url, method, headers, body)
    351             self.last_http_response = response.text
--> 352             response.raise_for_status()
    353

~/.virtualenvs/ccxt-test/lib/python3.5/site-packages/requests/models.py in raise_for_status(self)
    934         if http_error_msg:
--> 935             raise HTTPError(http_error_msg, response=self)
    936

HTTPError: 400 Client Error: Bad Request for url: https://api.bitso.com/v3/balance

During handling of the above exception, another exception occurred:

ExchangeNotAvailable                      Traceback (most recent call last)
<ipython-input-9-c1bddc0e3ac0> in <module>()
----> 1 bitso_api.fetchBalance()

~/.virtualenvs/ccxt-test/lib/python3.5/site-packages/ccxt/bitso.py in fetch_balance(self, params)
    114     def fetch_balance(self, params={}):
    115         self.load_markets()
--> 116         response = self.privateGetBalance()
    117         balances = response['payload']['balances']
    118         result = {'info': response}

~/.virtualenvs/ccxt-test/lib/python3.5/site-packages/ccxt/bitso.py in request(self, path, api, method, params, headers, body)
    239
    240     def request(self, path, api='public', method='GET', params={}, headers=None, body=None):
--> 241         response = self.fetch2(path, api, method, params, headers, body)
    242         if 'success' in response:
    243             if response['success']:

~/.virtualenvs/ccxt-test/lib/python3.5/site-packages/ccxt/base/exchange.py in fetch2(self, path, api, method, params, headers, body)
    297         self.lastRestRequestTimestamp = self.milliseconds()
    298         request = self.sign(path, api, method, params, headers, body)
--> 299         return self.fetch(request['url'], request['method'], request['headers'], request['body'])
    300
    301     def request(self, path, api='public', method='GET', params={}, headers=None, body=None):

~/.virtualenvs/ccxt-test/lib/python3.5/site-packages/ccxt/base/exchange.py in fetch(self, url, method, headers, body)
    363         except HTTPError as e:
    364             self.handle_errors(response.status_code, response.reason, url, method, None, self.last_http_response)
--> 365             self.handle_rest_errors(e, response.status_code, self.last_http_response, url, method)
    366             self.raise_error(ExchangeError, url, method, e, self.last_http_response)
    367

~/.virtualenvs/ccxt-test/lib/python3.5/site-packages/ccxt/base/exchange.py in handle_rest_errors(self, exception, http_status_code, response, url, method)
    394             error = AuthenticationError
    395         if error:
--> 396             self.raise_error(error, url, method, exception if exception else http_status_code, response)
    397
    398     def handle_rest_response(self, response, url, method='GET', headers=None, body=None):

~/.virtualenvs/ccxt-test/lib/python3.5/site-packages/ccxt/base/exchange.py in raise_error(self, exception_type, url, method, error, details)
    279                 method,
    280                 url,
--> 281                 details,
    282             ]))
    283         else:

ExchangeNotAvailable: bitso GET https://api.bitso.com/v3/balance 400 Client Error: Bad Request for url: https://api.bitso.com/v3/balance {"success":false,"error":{"code":104,"message":"Cannot perform request - nonce must be higher than 1516654742054"}}

@kroitor
Copy link
Member

kroitor commented Jan 24, 2018

@userzc create a new api key and retry again with it, then report back, please.
https://github.com/ccxt/ccxt/wiki/Manual#troubleshooting

@kroitor
Copy link
Member

kroitor commented Jan 24, 2018

@KoenBal looking into it...

@userzc
Copy link

userzc commented Jan 24, 2018

@kroitor , yeah that worked, why?

@kroitor
Copy link
Member

kroitor commented Jan 24, 2018

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