Open duggar opened 1 month ago
Would you be able to share your code that leads to the error please?
@samgermain , I got the same error
watch_positions() failed: can only concatenate str (not "NoneType") to str [ERROR]: can only concatenate str (not "NoneType") to str File "/Users/nadezhda/Documents/Finance/CCXTConnector/min_work_example.py", line 48, in watch_balance balance = await exchange.watch_balance(params=params) File "/Users/nadezhda/miniforge3/envs/forced_python/lib/python3.9/site-packages/ccxt/pro/okx.py", line 1069, in watch_balance return await self.subscribe('private', 'account', 'account', None, params) File "/Users/nadezhda/miniforge3/envs/forced_python/lib/python3.9/site-packages/ccxt/pro/okx.py", line 168, in subscribe return await self.watch(url, messageHash, request, messageHash) File "/Users/nadezhda/Documents/Finance/CCXTConnector/min_work_example.py", line 58, in watch_positions positions = await exchange.watch_positions() File "/Users/nadezhda/miniforge3/envs/forced_python/lib/python3.9/site-packages/ccxt/pro/okx.py", line 1222, in watch_positions newPositions = await self.watch(url, channel, nonSymbolRequest, channel) File "/Users/nadezhda/miniforge3/envs/forced_python/lib/python3.9/site-packages/ccxt/async_support/base/ws/fast_client.py", line 27, in handler self.handle_message(message) File "/Users/nadezhda/miniforge3/envs/forced_python/lib/python3.9/site-packages/ccxt/async_support/base/ws/aiohttp_client.py", line 34, in handle_message self.handle_text_or_binary_message(message.data) File "/Users/nadezhda/miniforge3/envs/forced_python/lib/python3.9/site-packages/ccxt/async_support/base/ws/aiohttp_client.py", line 29, in handle_text_or_binary_message self.on_message_callback(self, decoded) File "/Users/nadezhda/miniforge3/envs/forced_python/lib/python3.9/site-packages/ccxt/pro/okx.py", line 1869, in handle_message method(client, message) File "/Users/nadezhda/miniforge3/envs/forced_python/lib/python3.9/site-packages/ccxt/pro/okx.py", line 1307, in handle_positions cache.append(position) File "/Users/nadezhda/miniforge3/envs/forced_python/lib/python3.9/site-packages/ccxt/async_support/base/ws/cache.py", line 197, in append self._index.append(item['symbol'] + item['side'])
How to reproduce:
import asyncio
import sys
import ccxt.pro as ccxt
api_key = <>
api_secret=<>
password=<>
SYMBOL='BTC/USDT:USDT'
def print_error_info(error, message=''):
print(f"[ERROR]: {message, type(error).__name__, error.args}")
print(f"[ERROR]:{sys.exc_info()[1]}")
exchange = ccxt.okx({
'apiKey': api_key,
'secret': api_secret,
'password': password,
'options': {
'defaultType': 'swap',
'newUpdates': False,
'watchOrderBook': {
'depth': 'bbo-tbt', # tick-by-tick best bidask
},
},
'verbose': False,
})
async def watch_balance():
params = {'symbol': SYMBOL,
'type': 'swap'}
while True:
try:
balance = await exchange.watch_balance(params=params)
print(balance['USDT']['total'])
except Exception as e:
print_error_info(e)
print(f'watch_balance() failed: {e}')
async def watch_positions():
while True:
try:
positions = await exchange.watch_positions()
print(f"watch_positions: {positions}")
except Exception as e:
print_error_info(e)
print(f'watch_positions() failed: {e}')
async def run_watchers():
watchers = [watch_balance(),
watch_positions(),
]
await asyncio.gather(*watchers)
await exchange.close()
t = asyncio.ensure_future(run_watchers())
asyncio.get_event_loop().run_until_complete(t)
Operating System
Linux Debian
Programming Languages
Python
CCXT Version
4.3.59
Description
Order/Balance/Position Streamer giving issues after the trade is closed that is there is no position