Dec-03-2022, 11:26 PM
(This post was last modified: Dec-18-2022, 09:03 PM by Yoriz.
Edit Reason: Added prefix
)
Hi.
I have 1 script that get data from Binance using websocket-client lib and save into data base, then second script get the best COIN from data base.
I would like put this scripts into GUI PySide6.
What I need is, press the button (btn_turn_on) to start stream and press a button (btn_turn_off) to close conection. This is possible?
I have 1 script that get data from Binance using websocket-client lib and save into data base, then second script get the best COIN from data base.
I would like put this scripts into GUI PySide6.
What I need is, press the button (btn_turn_on) to start stream and press a button (btn_turn_off) to close conection. This is possible?
import websocket import json import pandas as pd from sqlalchemy import create_engine engine = create_engine('sqlite:///COINS.db') endpoint = 'wss://stream.binance.com:9443/ws/!miniTicker@arr' def on_close(ws): print('Conexão encerrada!') def on_message(ws, message): out = json.loads(message) #print(out) df_import(out) def df_import(data): #Pegar os valores dos pares casados com USDT df_ = pd.DataFrame(data) df_ = df_[df_['s'].str.endswith('USDT')] df_.c = df_.c.astype(float) final = df_[['s','E','c']] for i in range(len(final)): row_ = final[i:i+1] #print(row_) row_[['E','c']].to_sql(row_.s.values[0], engine, index=False, if_exists='append') ws = websocket.WebSocketApp(endpoint, on_message=on_message, on_close=on_close) ws.run_forever()I tryed simulate, but doen't work.
from script_1 import * import time ws = call_ws() time.sleep(3) ws.close()