question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OKEX-ccxt.base.errors.AuthenticationError: requires `apiKey`

See original GitHub issue

OS:WIN10

MY CODE:

import ccxt

#API登录
exchange = ccxt.okex({
    'apiKey': 'myapikey',
    'secret': 'mysecret',
    'password': 'mypassword',
})
#代理设置
exchange = ccxt.okex({
    'proxies': {
        'http': 'http://127.0.0.1:10809',  # these proxies won't work for you, they are here for example
        'https': 'http://127.0.0.1:10809',
    },
})

while True:
    data1 = exchange.fetch_ticker(symbol="ZEN-USDT-SWAP")
    new_price1 = data1["bid"]
    A = new_price1
    if A > 10:
        print(A)
        order_symbol = 'ZEN-USDT-SWAP'
        order_type = 'limit'
        order_side = 'sell'
        order_amount = 0.1
        order_price = 40
        take_order = exchange.create_order(order_symbol, order_type, order_side, order_amount, order_price)
        print(take_order)
    else:
        print("不挂单")
        slice(10)

RESPON:

C:\Users\baiyun\anaconda3\envs\pythonProject\python.exe C:/Users/baiyun/PycharmProjects/pythonProject/taoli.py
Traceback (most recent call last):
  File "C:/Users/baiyun/PycharmProjects/pythonProject/taoli.py", line 28, in <module>
    take_order = exchange.create_order(order_symbol, order_type, order_side, order_amount, order_price)
  File "C:\Users\baiyun\PycharmProjects\pythonProject\ccxt\okex.py", line 1883, in create_order
25.301
    response = getattr(self, method)(self.extend(request, params))
  File "C:\Users\baiyun\PycharmProjects\pythonProject\ccxt\base\exchange.py", line 465, in inner
    return entry(_self, **inner_kwargs)
  File "C:\Users\baiyun\PycharmProjects\pythonProject\ccxt\base\exchange.py", line 490, in request
    return self.fetch2(path, api, method, params, headers, body)
  File "C:\Users\baiyun\PycharmProjects\pythonProject\ccxt\base\exchange.py", line 485, in fetch2
    request = self.sign(path, api, method, params, headers, body)
  File "C:\Users\baiyun\PycharmProjects\pythonProject\ccxt\okex.py", line 3411, in sign
    self.check_required_credentials()
  File "C:\Users\baiyun\PycharmProjects\pythonProject\ccxt\base\exchange.py", line 1243, in check_required_credentials
    raise AuthenticationError('requires `' + key + '`')
ccxt.base.errors.AuthenticationError: requires `apiKey`

Process finished with exit code 1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dufu88commented, Jan 15, 2021

C:\Users\baiyun\anaconda3\envs\pythonProject\python.exe C:/Users/baiyun/PycharmProjects/pythonProject/ccxt/github.py CCXT Version: 1.40.41 23.536 {‘info’: {‘error_message’: ‘’, ‘result’: ‘true’, ‘error_code’: ‘0’, ‘client_oid’: ‘’, ‘order_id’: ‘677419540482527235’}, ‘id’: ‘677419540482527235’, ‘clientOrderId’: None, ‘timestamp’: None, ‘datetime’: None, ‘lastTradeTimestamp’: None, ‘symbol’: ‘ZEN-USDT-SWAP’, ‘type’: ‘2’, ‘timeInForce’: None, ‘postOnly’: None, ‘side’: ‘sell’, ‘price’: None, ‘stopPrice’: None, ‘average’: None, ‘cost’: None, ‘amount’: None, ‘filled’: None, ‘remaining’: None, ‘status’: None, ‘fee’: None, ‘trades’: None} 23.541 {‘info’: {‘error_message’: ‘’, ‘result’: ‘true’, ‘error_code’: ‘0’, ‘client_oid’: ‘’, ‘order_id’: ‘677419557779836929’}, ‘id’: ‘677419557779836929’, ‘clientOrderId’: None, ‘timestamp’: None, ‘datetime’: None, ‘lastTradeTimestamp’: None, ‘symbol’: ‘ZEN-USDT-SWAP’, ‘type’: ‘2’, ‘timeInForce’: None, ‘postOnly’: None, ‘side’: ‘sell’, ‘price’: None, ‘stopPrice’: None, ‘average’: None, ‘cost’: None, ‘amount’: None, ‘filled’: None, ‘remaining’: None, ‘status’: None, ‘fee’: None, ‘trades’: None}

Process finished with exit code -1

Thank you! It is ok!

1reaction
dufu88commented, Jan 15, 2021
C:\Users\baiyun\anaconda3\envs\pythonProject\python.exe C:/Users/baiyun/PycharmProjects/pythonProject/ccxt/github.py
CCXT Version: 1.40.41
24.374

Request: POST https://www.okex.com/api/swap/v3/order {'OK-ACCESS-KEY': 'my', 'OK-ACCESS-PASSPHRASE': 'my', 'OK-ACCESS-TIMESTAMP': '2021-01-15T11:35:39.992Z', 'Content-Type': 'application/json', 'OK-ACCESS-SIGN': 'V2qtXA4KpfRS6pOBZSUUDa01qY7zmOH/wElS2WduGCs=', 'User-Agent': 'python-requests/2.25.1', 'Accept-Encoding': 'gzip, deflate'} {"instrument_id":"ZEN-USDT-SWAP","type":"limit","size":"0","price":"40"}

Response: POST https://www.okex.com/api/swap/v3/order 400 {'Date': 'Fri, 15 Jan 2021 11:35:40 GMT', 'Content-Type': 'application/json', 'Content-Length': '91', 'Connection': 'keep-alive', 'Set-Cookie': 'locale=en_US; Max-Age=604800; Expires=Fri, 22-Jan-2021 11:35:40 GMT; Path=/', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Frame-Options': 'DENY', 'X-BrokerID': '0'} {"error_message":"Invalid order type","result":"true","error_code":"35040","order_id":"-1"}
Traceback (most recent call last):
  File "C:\Users\baiyun\PycharmProjects\pythonProject\ccxt\base\exchange.py", line 588, in fetch
    response.raise_for_status()
  File "C:\Users\baiyun\anaconda3\envs\pythonProject\lib\site-packages\requests\models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error:  for url: https://www.okex.com/api/swap/v3/order

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/baiyun/PycharmProjects/pythonProject/ccxt/github.py", line 31, in <module>
    take_order = exchange.create_order(order_symbol, order_type, order_side, order_amount, order_price)
  File "C:\Users\baiyun\PycharmProjects\pythonProject\ccxt\okex.py", line 1883, in create_order
    response = getattr(self, method)(self.extend(request, params))
  File "C:\Users\baiyun\PycharmProjects\pythonProject\ccxt\base\exchange.py", line 465, in inner
    return entry(_self, **inner_kwargs)
  File "C:\Users\baiyun\PycharmProjects\pythonProject\ccxt\base\exchange.py", line 490, in request
    return self.fetch2(path, api, method, params, headers, body)
  File "C:\Users\baiyun\PycharmProjects\pythonProject\ccxt\base\exchange.py", line 486, in fetch2
    return self.fetch(request['url'], request['method'], request['headers'], request['body'])
  File "C:\Users\baiyun\PycharmProjects\pythonProject\ccxt\base\exchange.py", line 604, in fetch
    self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body)
  File "C:\Users\baiyun\PycharmProjects\pythonProject\ccxt\okex.py", line 3464, in handle_errors
    self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
  File "C:\Users\baiyun\PycharmProjects\pythonProject\ccxt\base\exchange.py", line 504, in throw_exactly_matched_exception
    raise exact[string](message)
ccxt.base.errors.InvalidOrder: okex {"error_message":"Invalid order type","result":"true","error_code":"35040","order_id":"-1"}

Process finished with exit code 1
Read more comments on GitHub >

github_iconTop Results From Across the Web

fetch_my_trades - binance requires `apiKey` · Issue #4936
ccxt.base.errors.AuthenticationError: binance requires apiKey. I'm fairly certain my apikeys are valid as I'm sending an order that gets ...
Read more >
ccxt-dev/ccxt - Gitter
ccxt.base.errors.AuthenticationError: binance userDataStream endpoint requires apiKey credential. if I'm trying to do the same auth as on regular cctx.
Read more >
Apikey is not authorize - Futures API
So the error is related to the test server. It is a new account and I am new at market currency. I just...
Read more >
How to fix Invalid API-key, IP, or permissions for action error?
I believe this was the error I was running across in python. ... You will need to navigate to the directory your github-downloaded...
Read more >
Exchanges — ccxt 2.4.71 documentation
Each class implements the public and private API for a particular crypto exchange. All exchanges are derived from the base Exchange class and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found