Describe the bug
I am using the following code to execute some data preparations first and create an order first, listen to user_data_stream to update my trades and once a limit hit, close my trades and get out of listening and start again the main. I use the following code :
client = Client(binance_api_k, binance_api_sk)
asynclient = await AsyncClient.create(binance_api_k, binance_api_sk)
_dict_orders, symbol = rtrade(client, leverage)
bm = BinanceSocketManager(asynclient)
# start any sockets here, i.e a trade socket
ts = bm.futures_user_socket()
# then start receiving messages
async with ts as tscm:
while True:
message = await tscm.recv()
await rtrailmeo(message, symbol, client, _dict_orders, asynclient)
#print(res)
await asynclient.close_connection()
if name == "main":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Expected behavior
I was expecting that the first part will execute and start listening to user_data until my take profit is hit. From there, all other opened orders are deleted manually. It does delete everything once a particular message is received, but I am still stuck in the user_data_stream instead of closing the user stream and restart the main to track other signals.
Environment (please complete the following information):
Python version: 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:50:36) [MSC v.1929 64 bit (AMD64)]
OS: [Windows 11]
python-binance version 1.0.16
Logs or Additional context
p.s. :
Here, rtrade(client, leverage) is a function that scan for signals using some Technical Indicators.
rtrailmeo(message, symbol, client, _dict_orders, asynclient) updates orders by trailing and deleting unused trades once a message is received (SL or one of the TP hit)
Describe the bug I am using the following code to execute some data preparations first and create an order first, listen to user_data_stream to update my trades and once a limit hit, close my trades and get out of listening and start again the main. I use the following code :
To Reproduce
async def main():
client = await AsyncClient.create(binance_api_k, binance_api_sk)
if name == "main": loop = asyncio.get_event_loop() loop.run_until_complete(main())
Expected behavior
I was expecting that the first part will execute and start listening to user_data until my take profit is hit. From there, all other opened orders are deleted manually. It does delete everything once a particular message is received, but I am still stuck in the user_data_stream instead of closing the user stream and restart the main to track other signals.
Environment (please complete the following information):
Logs or Additional context p.s. :