Administrator
2023-05-15 045a5aa6434da6e83c3d850b17e7e58cd7b55ef5
gui.py
@@ -22,13 +22,14 @@
from trade import l2_trade_util
from trade.l2_trade_factor import L2TradeFactorUtil
from ocr import ocr_server
from third_data import  data_server
from third_data import data_server, kpl_data_manager, kpl_util
from server import *
import l2.l2_data_util
# 读取server进程的消息
from trade.trade_data_manager import CodeActualPriceProcessor
from ui.my_widget import FlatButton
def __read_server_pipe(pipe):
@@ -217,7 +218,7 @@
        text = Text(frame, height=100, undo=True)
        text.place(x=0, y=40)
        btn = Button(frame, text="运行环境检测", command=click)
        btn = FlatButton(frame, text="运行环境检测", command=click)
        btn.place(x=5, y=5)
        frame.grid(row=1, column=2)
@@ -303,20 +304,27 @@
                # table.model.setValueAt(data["apply_time"], index, 2)
                index += 1
            table.redraw()
        # 刷新开盘啦数据
        def refresh_kpl_data():
            kpl_data_manager.KPLDataManager().get_data(kpl_util.KPLDataType.LIMIT_UP)
            kpl_data_manager.KPLDataManager().get_data(kpl_util.KPLDataType.OPEN_LIMIT_UP)
            kpl_data_manager.KPLDataManager().get_data(kpl_util.KPLDataType.BEST_FENG_KOU)
            kpl_data_manager.KPLDataManager().get_data(kpl_util.KPLDataType.FENG_KOU)
            kpl_data_manager.KPLDataManager().get_data(kpl_util.KPLDataType.FENG_XIANG)
        start_y = 225
        btn = Button(frame, text="刷新收盘价", command=refresh_close_price_data)
        btn = FlatButton(frame, text="刷新收盘价", command=refresh_close_price_data)
        btn.place(x=5, y=start_y)
        sv_num = StringVar(value="获取到收盘价数量:未知")
        cl = Label(frame, textvariable=sv_num, bg="#DDDDDD", fg="#666666")
        cl.place(x=5, y=start_y + 30)
        btn = Button(frame, text="重新获取收盘价", command=re_get_close_price)
        btn.place(x=130, y=start_y)
        btn = Button(frame, text="今日涨停", command=get_limit_up_codes_win)
        btn.place(x=250, y=start_y)
        btn = FlatButton(frame, text="重新获取收盘价", command=re_get_close_price)
        btn.place(x=80, y=start_y)
        kpl_data =  Label(text="涨停:\n炸板:\n最强:\n风向:\n风口:",bg="#DDDDDD",fg="#666666")
        kpl_data.place(x=190, y=start_y)
        trade_win_datas = []
        # draw_trade_buy_win(360, 140)
@@ -332,7 +340,7 @@
        refresh_trade_buy_win_data()
        refresh_close_price_data()
        btn = Button(frame, text="刷新", command=refresh_trade_buy_win_data, height=1)
        btn = FlatButton(frame, text="刷新", command=refresh_trade_buy_win_data)
        btn.place(x=450 - 35, y=start_y)
        def re_distribute_buy_win():
@@ -348,7 +356,7 @@
            except Exception as e:
                showerror("分配出错", str(e))
        btn = Button(frame, text="重新分配窗口", command=re_distribute_buy_win, height=1)
        btn = FlatButton(frame, text="重新分配窗口", command=re_distribute_buy_win)
        btn.place(x=450 - 83, y=start_y + 30)
    # 绘制交易状态
@@ -436,7 +444,7 @@
        start_y = 285
        btn = Button(frame, text="刷新状态", command=refresh_data)
        btn = FlatButton(frame, text="刷新状态", command=refresh_data)
        btn.place(x=10, y=start_y)
        auo_refresh = IntVar()
@@ -579,7 +587,7 @@
            win.resizable(height=False, width=False)
            text = Text(win, height=100, undo=True)
            text.place(x=0, y=30)
            btn = Button(win, text="一键修复", command=repair)
            btn = FlatButton(win, text="一键修复", command=repair)
            btn.place(x=0, y=0)
            line = 0
@@ -652,10 +660,10 @@
        else:
            accept_l2.set(0)
        btn = Button(frame, text="每日初始化", command=init)
        btn = FlatButton(frame, text="每日初始化", command=init)
        btn.place(x=width - 250, y=5)
        btn = Button(frame, text="刷新数据", command=refresh_data)
        btn = FlatButton(frame, text="刷新数据", command=refresh_data)
        btn.place(x=width - 150, y=5)
        auo_refresh = IntVar()
        ch1 = Checkbutton(frame, text='自动刷新', variable=auo_refresh, onvalue=1, offvalue=0, background="#DDDDDD",
@@ -676,16 +684,17 @@
        menu.add_command(label="环境检测", command=check_env)
        menu.add_command(label="同花顺测速", command=ths_test_speed)
        device_index =0
        for key in self.l2_codes:
            client_lb = Label(frame, text="设备:{}".format(key), background="#DDDDDD")
            device_index += 1
            client_lb = Label(frame, text="设备:{} ID:{}".format(device_index,key), background="#DDDDDD")
            client_lb.place(x=38, y=40 + l2_client_count * 30)
            btn = Button(frame, text="检测", command=key)
            btn = FlatButton(frame, text="检测", command=key)
            btn.bind('<Button-3>', lambda event: pop_menu(event))
            btn.place(x=5, y=35 + l2_client_count * 30)
            client_state_lb = Label(frame, text="(未知)", padx=0, pady=0, background="#DDDDDD", font=('微软雅黑', 8))
            client_state_lb.place(x=82, y=40 + l2_client_count * 30)
            client_state_lb.place(x=112, y=40 + l2_client_count * 30)
            client_state[key] = client_state_lb
            code_sv_map[key] = []
            code_labels[key] = []
@@ -697,7 +706,7 @@
                code_labels[key].append(code_label)
                code_label.place(x=0, y=0)
                cframe.place(x=200 + i * 85, y=40 + l2_client_count * 30)
                cframe.place(x=250 + i * 85, y=40 + l2_client_count * 30)
            l2_client_count += 1
        # 添加更新线程
        t1 = threading.Thread(target=lambda: update_data())
@@ -794,7 +803,7 @@
        cl = Label(frame, textvariable=sv_trade_money, bg="#DDDDDD", fg="#666666")
        cl.place(x=190, y=5)
        btn = Button(frame, text="刷新数据", command=refresh_data)
        btn = FlatButton(frame, text="刷新数据", command=refresh_data)
        btn.place(x=width - 150, y=5)
        auo_refresh = IntVar()
        ch1 = Checkbutton(frame, text='自动刷新', variable=auo_refresh, onvalue=1, offvalue=0, background="#DDDDDD",
@@ -887,7 +896,7 @@
        entry = Entry(frame, textvariable=token_var, width=30)
        entry.place(x=left + 60, y=top + 60)
        btn = Button(frame, text="设置掘金参数", command=click)
        btn = FlatButton(frame, text="设置掘金参数", command=click)
        btn.place(x=left + 60, y=top + 90)
        # frame.place(x=260,y=10)
        frame.grid(row=0, column=2, pady=5, padx=5)
@@ -991,40 +1000,40 @@
        code = Entry(frame)
        code.place(x=50, y=70)
        btn = Button(frame, text="设置代码", command=lambda: setGPCode(ep_client.get(), ep.get(), code.get()), )
        btn = FlatButton(frame, text="设置代码", command=lambda: setGPCode(ep_client.get(), ep.get(), code.get()), )
        btn.place(x=10, y=100)
        btn = Button(frame, text="修复L2数据", command=lambda: L2CodeOperate.get_instance().repaire_l2_data(code.get()))
        btn = FlatButton(frame, text="修复L2数据", command=lambda: L2CodeOperate.get_instance().repaire_l2_data(code.get()))
        btn.place(x=70
                  , y=100)
        btn = Button(frame, text="导出L2数据", command=lambda: export_l2_data(code.get()))
        btn = FlatButton(frame, text="导出L2数据", command=lambda: export_l2_data(code.get()))
        btn.place(x=145, y=100)
        btn = Button(frame, text="导出L2原始数据", command=lambda: export_l2_data_origin(code.get()))
        btn = FlatButton(frame, text="导出L2原始数据", command=lambda: export_l2_data_origin(code.get()))
        btn.place(x=220, y=100)
        btn = Button(frame, text="获取m值", command=lambda: compute_m(code.get()))
        btn = FlatButton(frame, text="获取m值", command=lambda: compute_m(code.get()))
        btn.place(x=10, y=130)
        btn = Button(frame, text="导出交易日志", command=lambda: log.export_l2_log(code.get()))
        btn = FlatButton(frame, text="导出交易日志", command=lambda: log.export_l2_log(code.get()))
        btn.place(x=80, y=130)
        btn = Button(frame, text="清空l2数据", command=lambda: clear_l2(code.get()))
        btn = FlatButton(frame, text="清空l2数据", command=lambda: clear_l2(code.get()))
        btn.place(x=150, y=130)
        btn = Button(frame, text="撤销挂单", command=lambda: cancel_order(code.get()))
        btn = FlatButton(frame, text="撤销挂单", command=lambda: cancel_order(code.get()))
        btn.place(x=230, y=130)
        # 交易按钮
        btn = Button(frame, textvariable=btntext, command=startJueJinGui)
        btn = FlatButton(frame, textvariable=btntext, command=startJueJinGui)
        btn.place(x=10, y=160)
        btntext.set("启动掘金")
        btn = Button(frame, text="重新订阅行情", command=resub)
        btn = FlatButton(frame, text="重新订阅行情", command=resub)
        btn.place(x=10, y=190)
        btn = Button(frame, text="刷新窗口句柄", command=refresh_hwnds)
        btn = FlatButton(frame, text="刷新窗口句柄", command=refresh_hwnds)
        btn.place(x=200, y=190)
    def create_gui(self):