2023-10-02 11:04:05,797 - bitmex_websocket - INFO - Connecting to ws://wss.testnet.bitmex.com/?subscribe=execution:XBTETH,instrument:XBTETH,margin,order:XBTETH,orderBookL2:XBTETH,position:XBTETH,quote:XBTETH,trade:XBTETH
2023-10-02 11:04:05,798 - bitmex_websocket - INFO - Authenticating with API Key.
2023-10-02 11:04:05,802 - bitmex_websocket - ERROR - Error : [Errno 8] nodename nor servname provided, or not known
2023-10-02 11:04:05,802 - websocket - ERROR - error from callback <bound method BitMEXWebsocket.__on_error of <bitmex_websocket.BitMEXWebsocket object at 0x1006ab550>>: [Errno 8] nodename nor servname provided, or not known
Code:
from bitmex_websocket import BitMEXWebsocket
import logging
from time import sleep
apiKey = 'myapikeyhere'
apiSecret = 'mysecretkeyhere'
def run():
logger = setup_logger()
ws = BitMEXWebsocket(endpoint="ws://wss.testnet.bitmex.com/",
symbol="XBTETH", api_key=apiKey, api_secret=apiSecret)
# logger.info("Instrument data: %s" % ws.get_instrument())
# Run forever
while (ws.ws.sock.connected):
# logger.info("Ticker: %s" % ws.get_ticker())
# if ws.api_key:
# logger.info("Funds: %s" % ws.funds())
# logger.info("Market Depth: %s" % ws.market_depth())
logger.info("Recent Trades: %s\n\n" % ws.recent_trades())
sleep(5)
def setup_logger():
# Prints logger info to terminal
logger = logging.getLogger()
# Change this to DEBUG if you want a lot more info
logger.setLevel(logging.INFO)
ch = logging.StreamHandler()
# create formatter
formatter = logging.Formatter(
"%(asctime)s - %(name)s - %(levelname)s - %(message)s")
# add formatter to ch
ch.setFormatter(formatter)
logger.addHandler(ch)
return logger
I am following BITMEX this example https://github.com/BitMEX/api-connectors/tree/master/official-ws/python but i am facing the following issue as defined below.
Error Log:
2023-10-02 11:04:05,797 - bitmex_websocket - INFO - Connecting to ws://wss.testnet.bitmex.com/?subscribe=execution:XBTETH,instrument:XBTETH,margin,order:XBTETH,orderBookL2:XBTETH,position:XBTETH,quote:XBTETH,trade:XBTETH 2023-10-02 11:04:05,798 - bitmex_websocket - INFO - Authenticating with API Key. 2023-10-02 11:04:05,802 - bitmex_websocket - ERROR - Error : [Errno 8] nodename nor servname provided, or not known 2023-10-02 11:04:05,802 - websocket - ERROR - error from callback <bound method BitMEXWebsocket.__on_error of <bitmex_websocket.BitMEXWebsocket object at 0x1006ab550>>: [Errno 8] nodename nor servname provided, or not known
Code: