OctoBot
OctoBot copied to clipboard
Okx Exchange - API key unknown
Step 1: Have you search for this issue before posting it?
If you have discovered a bug in the bot, please search our issue tracker. If it hasn't been reported, please create a new issue.
Step 2: Describe your environment
- OS : Issue is platform independent
- Python Version: 3.10.11
- In case you are not using a binary version:
- Branch: Master
- Last Commit ID: 61926c3f8095b46ca867244947bb883fa608f1e8
https://github.com/ccxt/ccxt/issues/24601
Step 3: Describe the problem:
Describe the bug When entering working api credentials the Exchange accounts setup throws an unknow api key error
Expected behavior Succes: Account should be linked to api credentials
Steps to reproduce:
- Add an exchange account for okx according to octobot docs
- Use api credentials from your my.okx.com (EEA) account
Observed Results:
- Error, can't continue
- Start using my account
Relevant code exceptions or logs:
import ccxt
import logging
import traceback
# Configuration (replace with actual values)
API_KEY = 'redacted'
SECRET_KEY = 'redacted'
PASSPHRASE = 'redacted'
# Default domains
domain_myokx = 'https://my.okx.com'
domain_www = 'https://www.okx.com'
# Set up logging
logging.basicConfig(level=logging.DEBUG) # Use DEBUG level for more detailed logs
def get_account_balance(ticker='ETH'):
domains = [domain_www, domain_myokx]
failed_domains = []
for domain in domains:
try:
logging.debug(f"Attempting to create exchange object for domain: {domain}")
# Create the exchange object with API keys and domain
exchange = ccxt.okx({
'apiKey': API_KEY,
'secret': SECRET_KEY,
'password': PASSPHRASE,
'hostname': domain.split('//')[1], # Set the hostname to use in the URL structure
})
# Fetch the balance
logging.debug("Fetching balance...")
balance = exchange.fetch_balance()
logging.info(f"Balance for {ticker} on {domain}: {balance[ticker]}")
return balance[ticker]
except Exception as e:
failed_domains.append(domain)
logging.error(f"Failed to get balance from {', '.join(failed_domains)}: {e}")
raise Exception(f"Failed to get balance from all domains. Failed domains: {', '.join(failed_domains)}")
# Log the beginning of the script execution
result = get_account_balance('ETH')
logging.info("Script started")
# Final result output
if result is not None:
logging.info(f"Final account balance for ETH retrieved: {result}")
else:
logging.error("Failed to retrieve account balance for ETH from all domains.")
# End of script
logging.info("Script execution finished")
I would like to add a region variable overwriting the hardcoded ccxt hostname for the okx provider, as shown in the above code this works. We could expose the variable as a boolean switch on the exchange setup page.
Changes in OKX API server.
I recently received an email from OKX telling their API servers will be updated to another host. So Im trying to find a way to modify the config to change the host but I'm still trying. The new REST API server address is eea.okx.com and the new domain for the websocket will be changed to wseea.okx.com
I checked the "Updated Documentation" but I couldn't find this information so please check your email for more information. Guess this can solve the problem but I can't help any further then this so good luck!
Changes in OKX API server.
I recently received an email from OKX telling their API servers will be updated to another host. So Im trying to find a way to modify the config to change the host but I'm still trying. The new REST API server address is eea.okx.com and the new domain for the websocket will be changed to wseea.okx.com
I checked the "Updated Documentation" but I couldn't find this information so please check your email for more information. Guess this can solve the problem but I can't help any further then this so good luck!
Hi @TitaniumMaker, thanks for the update! It will help us fixing the issue.
Changes in OKX API server.
I recently received an email from OKX telling their API servers will be updated to another host. So Im trying to find a way to modify the config to change the host but I'm still trying. The new REST API server address is eea.okx.com and the new domain for the websocket will be changed to wseea.okx.com
I checked the "Updated Documentation" but I couldn't find this information so please check your email for more information. Guess this can solve the problem but I can't help any further then this so good luck!
Hi @TitaniumMaker,
I use okx myself and am currently working on a fix which might also solve your issue.
I wasn't aware of these okx changes. You got any docs or information regarding their go live? Also they are splitting the rest and websocket domains? What's the current behaviour?
I've fixed the issue with current eu servers 'my.okx' not working. I have to implement a user friendly way to select custom hostnames still. This might only be for rest though, will have to investigate websocket behaviour.
Soon as I find out where OctoBot is handling it's frontend expect me to push the changes to my fork and send a pull request for the team to review.