| | |
| | | import settings |
| | | from juejin import JueJinManager |
| | | from l2_code_operate import L2CodeOperate |
| | | from trade import l2_trade_util |
| | | from trade.l2_trade_factor import L2TradeFactorUtil |
| | | from ocr import ocr_server |
| | | |
| | |
| | | |
| | | def createOCRServer(): |
| | | print("create OCRServer") |
| | | laddr = "", 9002 |
| | | tcpserver = ocr_server.MyThreadingTCPServer(laddr, ocr_server.MyBaseRequestHandle) |
| | | tcpserver = ocr_server.run("", 9002) |
| | | tcpserver.serve_forever() |
| | | |
| | | |
| | |
| | | self.codeActualPriceProcessor = CodeActualPriceProcessor() |
| | | # L2显示 |
| | | self.l2_codes = {} |
| | | self.selected_client = {} |
| | | # 获取l2的客户端列表 |
| | | clients = authority.get_l2_clients() |
| | | for client_id in clients: |
| | |
| | | index += 1 |
| | | table.redraw() |
| | | |
| | | start_y = 160 |
| | | btn = Button(frame, text="刷新收盘价", command=refresh_close_price_data) |
| | | btn.place(x=5, y=150) |
| | | |
| | | 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=180) |
| | | cl.place(x=5, y=start_y + 30) |
| | | |
| | | btn = Button(frame, text="重新获取收盘价", command=re_get_close_price) |
| | | btn.place(x=150, y=150) |
| | | btn.place(x=130, y=start_y) |
| | | |
| | | btn = Button(frame, text="今日涨停", command=get_limit_up_codes_win) |
| | | btn.place(x=300, y=150) |
| | | btn.place(x=250, y=start_y) |
| | | |
| | | trade_win_datas = [] |
| | | # draw_trade_buy_win(360, 140) |
| | | table_width = 300 |
| | | table_height = 90 |
| | | table_height = 95 |
| | | _frame = Frame(frame, {"height": table_height, "width": table_width, "bg": "#DDDDDD"}) |
| | | |
| | | table = tkintertable.TableCanvas(_frame, data={"row0": {'代码': '', '涨幅': '', '窗口句柄': ''}}, read_only=True, |
| | | width=table_width, height=table_height, thefont=('微软雅黑', 9), cellwidth=100, |
| | | rowheaderwidth=20) |
| | | table.show() |
| | | _frame.place(x=380-12, y=130) |
| | | _frame.place(x=450, y=start_y) |
| | | refresh_trade_buy_win_data() |
| | | refresh_close_price_data() |
| | | |
| | | btn = Button(frame, text="刷新", command=refresh_trade_buy_win_data,height=1) |
| | | btn.place(x=730-12, y=130) |
| | | btn = Button(frame, text="刷新", command=refresh_trade_buy_win_data, height=1) |
| | | btn.place(x=450 - 35, y=start_y) |
| | | |
| | | def re_distribute_buy_win(): |
| | | try: |
| | |
| | | showerror("分配出错", str(e)) |
| | | |
| | | btn = Button(frame, text="重新分配窗口", command=re_distribute_buy_win, height=1) |
| | | btn.place(x=730-12, y=165) |
| | | btn.place(x=450 - 83, y=start_y + 30) |
| | | |
| | | # 绘制交易状态 |
| | | def __draw_trade_state(self, frame): |
| | |
| | | cl_codes.configure(text="{}/{}".format(juejin_length, codes_length), foreground="#008000") |
| | | except Exception as e: |
| | | pass |
| | | |
| | | # 获取板块状态 |
| | | try: |
| | | ths_dead = client_manager.getTHSState(7) |
| | | if ths_dead is None: |
| | | cl_block.configure(text="离线", foreground="#FF7F27") |
| | | elif ths_dead: |
| | | normal = False |
| | | cl_block.configure(text="离线", foreground="#FF7F27") |
| | | else: |
| | | cl_block.configure(text="在线", foreground="#008000") |
| | | except: |
| | | pass |
| | | |
| | | |
| | | try: |
| | | codes = self.thsBuy1VolumnManager.get_current_codes() |
| | |
| | | except: |
| | | pass |
| | | |
| | | |
| | | |
| | | |
| | | # 获取有效的L2客户端数量 |
| | | l2_client_count = client_manager.getValidL2Clients() |
| | | if len(l2_client_count) < 2: |
| | |
| | | pass |
| | | time.sleep(2) |
| | | |
| | | start_y = 230 |
| | | start_y = 225 |
| | | |
| | | btn = Button(frame, text="刷新状态", command=refresh_data) |
| | | btn.place(x=10, y=start_y) |
| | |
| | | cl_queue.place(x=100, y=y_) |
| | | |
| | | cl = Label(frame, text="交易窗口状态:", bg="#DDDDDD") |
| | | cl.place(x=200, y=y_) |
| | | cl.place(x=170, y=y_) |
| | | cl_win = Label(frame, text="未知", bg="#DDDDDD") |
| | | cl_win.place(x=300, y=y_) |
| | | cl_win.place(x=270, y=y_) |
| | | |
| | | cl = Label(frame, text="板块状态:", bg="#DDDDDD") |
| | | cl.place(x=320, y=y_) |
| | | cl_block = Label(frame, text="未知", bg="#DDDDDD") |
| | | cl_block.place(x=380, y=y_) |
| | | |
| | | cl = Label(frame, text="掘金代码回调数量:", bg="#DDDDDD") |
| | | cl.place(x=350, y=y_) |
| | | cl.place(x=300, y=y_ + 20) |
| | | cl_codes = Label(frame, text="未知", bg="#DDDDDD") |
| | | cl_codes.place(x=450, y=y_) |
| | | cl_codes.place(x=410, y=y_ + 20) |
| | | |
| | | cl = Label(frame, text="买1代码数量:", bg="#DDDDDD") |
| | | cl.place(x=500, y=y_) |
| | | cl.place(x=10, y=y_ + 20) |
| | | cl_buy_1 = Label(frame, text="未知", bg="#DDDDDD") |
| | | cl_buy_1.place(x=580, y=y_) |
| | | cl_buy_1.place(x=10 + 90, y=y_ + 20) |
| | | |
| | | cl = Label(frame, text="现价代码数量:", bg="#DDDDDD") |
| | | cl.place(x=620, y=y_) |
| | | cl.place(x=170, y=y_ + 20) |
| | | cl_price_count = Label(frame, text="未知", bg="#DDDDDD") |
| | | cl_price_count.place(x=700, y=y_) |
| | | cl_price_count.place(x=170 + 100, y=y_ + 20) |
| | | |
| | | refresh_data() |
| | | # 添加更新线程 |
| | |
| | | else: |
| | | code_labels[client_id][i].configure(foreground="#999999") |
| | | |
| | | def check(event): |
| | | client = (event.widget["command"]) |
| | | def check(client): |
| | | msg_list = [] |
| | | try: |
| | | result = get_client_env_state(client) |
| | |
| | | def set_accept_l2(): |
| | | settings.set_accept_l2(accept_l2.get()) |
| | | |
| | | def pop_menu(event): |
| | | self.selected_client = event.widget["command"] |
| | | menu.post(event.x_root, event.y_root) |
| | | |
| | | def ths_test_speed(): |
| | | if self.selected_client is None: |
| | | showwarning("警告", "未选中客户端") |
| | | return |
| | | try: |
| | | server.repair_ths_main_site(self.selected_client) |
| | | showinfo("提示", "同花顺测速完成") |
| | | except Exception as e: |
| | | showerror("错误", str(e)) |
| | | |
| | | def check_env(): |
| | | if self.selected_client is None: |
| | | showwarning("警告", "未选中客户端") |
| | | return |
| | | check(self.selected_client) |
| | | |
| | | width = 800 |
| | | height = 290 |
| | | frame = Frame(root, {"height": height, "width": width, "bg": "#DDDDDD"}) |
| | |
| | | code_sv_map = {} |
| | | code_labels = {} |
| | | client_state = {} |
| | | |
| | | # 右键菜单 |
| | | menu = Menu(frame, |
| | | tearoff=False, |
| | | # bg="black", |
| | | ) |
| | | menu.add_command(label="环境检测", command=check_env) |
| | | menu.add_command(label="同花顺测速", command=ths_test_speed) |
| | | |
| | | for key in self.l2_codes: |
| | | |
| | | client_lb = Label(frame, text="设备:{}".format(key), background="#DDDDDD") |
| | | client_lb.place(x=38, y=40 + l2_client_count * 30) |
| | | btn = Button(frame, text="检测", command=key) |
| | | btn.bind('<Button-1>', check) |
| | | 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="(未知)", background="#DDDDDD", font=('微软雅黑', 8)) |
| | | client_state_lb = Label(frame, text="(未知)", padx=0, pady=0, background="#DDDDDD", font=('微软雅黑', 8)) |
| | | client_state_lb.place(x=80, y=40 + l2_client_count * 30) |
| | | client_state[key] = client_state_lb |
| | | |
| | | code_sv_map[key] = [] |
| | | code_labels[key] = [] |
| | | for i in range(0, 8): |
| | |
| | | self.gs_gui_pipe.send(json.dumps({"type": "clear_l2", "data": {"code": code}})) |
| | | pass |
| | | |
| | | # 禁止代码 |
| | | def forbidden_code(code_): |
| | | l2_trade_util.forbidden_trade(code_) |
| | | showinfo("提示","禁止成功") |
| | | |
| | | frame = Frame(root, {"height": 280, "width": 300, "bg": "#DDDDDD"}) |
| | | frame.grid(row=2, column=2, rowspan=2, pady=5) |
| | | btntext = StringVar() |
| | |
| | | btn = Button(frame, text="清空l2数据", command=lambda: clear_l2(code.get())) |
| | | btn.place(x=150, y=130) |
| | | |
| | | btn = Button(frame, text="禁止交易", command=lambda: forbidden_code(code.get())) |
| | | btn.place(x=230, y=130) |
| | | |
| | | # 交易按钮 |
| | | btn = Button(frame, textvariable=btntext, command=startJueJinGui) |
| | | btn.place(x=10, y=160) |