| | |
| | | |
| | | import win32gui |
| | | |
| | | import data_export_util |
| | | import data_process |
| | | import juejin |
| | | import multiprocessing |
| | |
| | | self.l2_codes[client_id].append(code) |
| | | |
| | | def run(self): |
| | | # TODO |
| | | self.jueJinProcess.start() |
| | | self.serverProcess.start() |
| | | L2CodeOperate.get_instance() |
| | |
| | | |
| | | self.create_gui() |
| | | |
| | | |
| | | |
| | | def _draw_check(self, root): |
| | | |
| | | def _set_error_color(text, line, content): |
| | | for i in range(0, len(content)): |
| | | text.tag_add('error', "{}.{}".format(line, i)) |
| | | |
| | | def sync_target_codes(): |
| | | server.sync_target_codes_to_ths() |
| | | print(result) |
| | | |
| | | def click(): |
| | | text.delete('1.0', END) |
| | |
| | | btn = Button(frame, text="运行环境检测", command=click) |
| | | btn.place(x=5, y=5) |
| | | |
| | | frame.grid(row=1, column=2) |
| | | btn = Button(frame, text="同步THS目标标的", command=sync_target_codes) |
| | | btn.place(x=100, y=5) |
| | | |
| | | frame.grid(row=1, column=2) |
| | | |
| | | #绘制开盘前的数据准备情况 |
| | | def __draw_pre_data_check(self,frame): |
| | |
| | | sv_num.set("获取到收盘价数量:{}".format(count)) |
| | | |
| | | def re_get_close_price(): |
| | | juejin.set_price_pres(gpcode_manager.get_gp_list()) |
| | | juejin.re_set_price_pres(gpcode_manager.get_gp_list()) |
| | | |
| | | def get_limit_up_codes_win(): |
| | | width=400 |
| | |
| | | |
| | | table_frame = Frame(win, {"height": table_height, "width": table_width, "bg": "#DDDDDD"}) |
| | | table_frame.place(x=10, y=45) |
| | | table_limit_up = tkintertable.TableCanvas(table_frame, data=limit_up_datas, read_only=True, width=table_width, |
| | | table_limit_up = tkintertable.TableCanvas(table_frame, data=limit_up_datas, read_only=True, |
| | | width=table_width, |
| | | height=table_height, thefont=('微软雅黑', 10), cellwidth=90, |
| | | rowheaderwidth=20) |
| | | table_limit_up.show() |
| | |
| | | table_limit_up.model.setValueAt(data["code"], index, 0) |
| | | table_limit_up.model.setValueAt(data["time"], index, 1) |
| | | table_limit_up.model.setValueAt(float(data["price"]), index, 2) |
| | | table_limit_up.model.setValueAt("{}{}".format(float( data["limitMoney"]),("亿" if data["limitMoneyUnit"]==0 else "万") ), index, 3) |
| | | table_limit_up.model.setValueAt( |
| | | "{}{}".format(float(data["limitMoney"]), ("亿" if data["limitMoneyUnit"] == 0 else "万")), index, 3) |
| | | index += 1 |
| | | table_limit_up.redraw() |
| | | |
| | | |
| | | win.geometry("{}x{}".format(width,height)) |
| | | win.mainloop() |
| | | |
| | | |
| | | btn = Button(frame, text="刷新收盘价", command=refresh_close_price_data) |
| | | btn.place(x=5, y=150) |
| | |
| | | |
| | | btn = Button(frame, text="今日涨停", command=get_limit_up_codes_win) |
| | | btn.place(x=300, y=150) |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | # 绘制l2数据状态 |
| | | def __draw_l2_state(self, root): |
| | |
| | | else: |
| | | code_labels[client_id][i].configure(foreground="#999999") |
| | | |
| | | def check(event): |
| | | client = (event.widget["command"]) |
| | | msg_list = [] |
| | | try: |
| | | result = get_client_env_state(client) |
| | | if result["ths_l2_win"]: |
| | | msg_list.append(("同花顺L2屏正常!", 0)) |
| | | else: |
| | | msg_list.append(("同花顺L2屏未打开...", 1)) |
| | | if result["ths_fp_1"]: |
| | | msg_list.append(("同花顺副屏1正常!", 0)) |
| | | else: |
| | | msg_list.append(("同花顺副屏1未打开...", 1)) |
| | | |
| | | if result["ths_fp_2"]: |
| | | msg_list.append(("同花顺副屏2正常!", 0)) |
| | | else: |
| | | msg_list.append(("同花顺副屏2未打开...", 1)) |
| | | |
| | | if result["ths_trade_success"]: |
| | | msg_list.append(("交易成功页面正常!", 0)) |
| | | else: |
| | | msg_list.append(("交易成功页面未打开...", 1)) |
| | | |
| | | if result["l2_channel_invalid_count"] <= 0: |
| | | msg_list.append(("L2监控线程正常数:{} 异常数:{}...".format(result["l2_channel_valid_count"], |
| | | result["l2_channel_invalid_count"]), 0)) |
| | | else: |
| | | msg_list.append(("L2监控线程正常数:{} 异常数:{}!".format(result["l2_channel_valid_count"], |
| | | result["l2_channel_invalid_count"]), 1)) |
| | | |
| | | if result["limitUp"]: |
| | | msg_list.append(("涨停监控线程正常!", 0)) |
| | | else: |
| | | msg_list.append(("涨停监控线程异常...", 1)) |
| | | |
| | | if result["tradeSuccess"]: |
| | | msg_list.append(("当日成交监控线程正常!", 0)) |
| | | else: |
| | | msg_list.append(("当日成交监控线程异常...", 1)) |
| | | |
| | | except Exception as e: |
| | | msg_list.append((str(e), 1)) |
| | | |
| | | def repair(): |
| | | try: |
| | | server.repair_client_env(client) |
| | | showinfo("提示", "修复完成") |
| | | except Exception as e: |
| | | showerror("修复出错", str(e)) |
| | | |
| | | # 创建界面 |
| | | win = Tk() |
| | | win.title("检测结果") |
| | | 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.place(x=0, y=0) |
| | | |
| | | line = 0 |
| | | for msg in msg_list: |
| | | line += 1 |
| | | if msg[1] == 0: |
| | | text.insert(END, "{}\n".format(msg[0])) |
| | | else: |
| | | text.insert(END, "{}\n".format(msg[0])) |
| | | for i in range(0, len(msg[0])): |
| | | text.tag_add('error', "{}.{}".format(line, i)) |
| | | |
| | | text.tag_config('error', foreground='red') |
| | | |
| | | win.geometry("300x300") |
| | | win.mainloop() |
| | | |
| | | width = 800 |
| | | height = 290 |
| | | frame = Frame(root, {"height": height, "width": width, "bg": "#DDDDDD"}) |
| | |
| | | client_state = {} |
| | | for key in self.l2_codes: |
| | | |
| | | client_lb = Label(frame, text="设备号:{}".format(key), background="#DDDDDD") |
| | | client_lb.place(x=5, y=40 + l2_client_count * 30) |
| | | client_lb = Label(frame, text="设备:{}".format(key), background="#DDDDDD") |
| | | client_lb.place(x=30, y=40 + l2_client_count * 30) |
| | | btn = Button(frame, text="检测", command=key) |
| | | btn.bind('<Button-1>', check) |
| | | btn.place(x=0, y=35 + l2_client_count * 30) |
| | | |
| | | client_state_lb = Label(frame, text="(未知)", background="#DDDDDD", font=('微软雅黑', 8)) |
| | | client_state_lb.place(x=60, y=40 + l2_client_count * 30) |
| | | client_state_lb.place(x=75, y=40 + l2_client_count * 30) |
| | | client_state[key] = client_state_lb |
| | | |
| | | code_sv_map[key] = [] |
| | |
| | | code_labels[key].append(code_label) |
| | | |
| | | code_label.place(x=0, y=0) |
| | | cframe.place(x=180 + i * 75, y=40 + l2_client_count * 30) |
| | | cframe.place(x=200 + i * 75, y=40 + l2_client_count * 30) |
| | | l2_client_count += 1 |
| | | # 添加更新线程 |
| | | t1 = threading.Thread(target=lambda: update_data()) |
| | |
| | | if gpcode is None or len(gpcode) < 6: |
| | | return |
| | | l2_code_operate.L2CodeOperate.setGPCode(client,position,gpcode) |
| | | |
| | | def resub(): |
| | | self.p1.send("resub") |
| | | |
| | |
| | | print(e) |
| | | showwarning('警告', e) |
| | | |
| | | def export_l2_data(code): |
| | | if code not in l2_data_manager.local_today_datas: |
| | | l2_data_manager.load_l2_data(code) |
| | | datas = l2_data_manager.local_today_datas[code] |
| | | try: |
| | | path=data_export_util.export_l2_data(code,datas) |
| | | showinfo("提示","导出成功,路径为:"+path) |
| | | except Exception as e1: |
| | | showerror("导出失败",str(e1)) |
| | | |
| | | def export_l2_data_origin(code): |
| | | redis = redis_manager.RedisManager(1).getRedis() |
| | | keys = redis.keys("big_data-{}-*".format(code)) |
| | | try: |
| | | for k in keys: |
| | | datas=redis.get(k) |
| | | datas=json.loads(datas) |
| | | datas=datas["data"]["data"] |
| | | _t = k.split("-")[2] |
| | | k = time.strftime("%Y_%m_%d_%H_%M_%S_",time.localtime(float(_t)/1000)) |
| | | k = "{}{}".format(k,_t[-3:]) |
| | | data_export_util.export_l2_data_origin(code, datas,k) |
| | | except Exception as e1: |
| | | showerror("导出失败", str(e1)) |
| | | |
| | | showinfo("提示", "导出完成") |
| | | |
| | | |
| | | frame = Frame(root, {"height": 280, "width": 300, "bg": "#DDDDDD"}) |
| | | frame.grid(row=2, column=2, rowspan=2, pady=5) |
| | | btntext = StringVar() |
| | | |
| | | el = Label(frame, text="测试区域", bg="#DDDDDD",fg="#A0A000") |
| | | el.place(x=240, y=10) |
| | | |
| | | |
| | | el = Label(frame, text="客户端ID:", bg="#DDDDDD") |
| | | el.place(x=10, y=10) |
| | |
| | | btn = Button(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.place(x=100, y=100) |
| | | |
| | | btn = Button(frame, text="导出L2数据", command=lambda: export_l2_data(code.get())) |
| | | btn.place(x=200, y=100) |
| | | |
| | | btn = Button(frame, text="导出L2原始数据", command=lambda: export_l2_data_origin(code.get())) |
| | | btn.place(x=260, y=100) |
| | | |
| | | # 交易按钮 |
| | | btn = Button(frame, textvariable=btntext, command=startJueJinGui) |
| | | btn.place(x=10, y=150) |