问题描述
我正在尝试在满足条件时退出 WebSocket。我找不到办法做到这一点。我已经尝试过表格,但我没有得到它们。在这些情况下可以做什么?一旦它满足我的条件,我想继续使用代码。
当它满足条件时我喜欢去我放print123的地方。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Versión: python-binance==0.7.9
# https://python-binance.readthedocs.io/en/latest/index.html
#
import sys
sys.path.insert(1,'/home/developer/cryptocontrol_venv/scripts/python')
import config
from binance.client import Client #pip install python-binance
from binance.websockets import BinanceSocketManager
client = Client(config.API_KEY,config.API_SECRET,tld='com')
def fuctiontest():
bm = BinanceSocketManager(client)
def handle_message(msg):
print("message: {}".format(msg['p']))
value = round(float(msg['p']),2) #Valor Actual de la cripto.
if float(value) >= 1:
print(str(msg['p'])+" is > 1")
else:
print(str(msg['p'])+" is < 1")
print("Condition done!")
bm.stop_socket(conn_key)
# When done go to print123
# Start Trade socket with 'ETHBTC' and use handle_message to.. handle the message.
conn_key = bm.start_Trade_socket('ETHBTC',handle_message)
# then start the socket manager
bm.start()
# stop the socket manager
#bm.stop_socket(conn_key)
fuctiontest()
print("test123:")
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)