| | |
| | | """ |
| | | from tkinter import * |
| | | from tkinter.messagebox import * |
| | | |
| | | import numpy |
| | | import tkintertable |
| | | |
| | | import win32gui |
| | | |
| | | import data_export_util |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from utils import data_export_util |
| | | import multiprocessing |
| | | |
| | | import log |
| | | from db import mysql_data, redis_manager |
| | | from log_module import log, log_export |
| | | from db import mysql_data_delegate as mysql_data, redis_manager_delegate as redis_manager |
| | | import server |
| | | import settings |
| | | from juejin import JueJinManager |
| | | from l2_code_operate import L2CodeOperate |
| | | from config import settings |
| | | from ths.l2_code_operate import L2CodeOperate |
| | | from trade.l2_trade_factor import L2TradeFactorUtil |
| | | from ocr import ocr_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): |
| | |
| | | t1.setDaemon(True) |
| | | t1.start() |
| | | |
| | | t1 = threading.Thread(target=createDataServer) |
| | | # 后台运行 |
| | | t1.setDaemon(True) |
| | | t1.start() |
| | | |
| | | laddr = "", 9001 |
| | | tcpserver = MyThreadingTCPServer(laddr, MyBaseRequestHandle, pipe_juejin=pipe_juejin) # 注意:参数是MyBaseRequestHandle |
| | | # tcpserver.handle_request() # 只接受一个客户端连接 |
| | | tcpserver.serve_forever() # 永久循环执行,可以接受多个客户端连接 |
| | | |
| | | |
| | | def createOCRServer(): |
| | | print("create OCRServer") |
| | | laddr = "", 9002 |
| | | tcpserver = ocr_server.MyThreadingTCPServer(laddr, ocr_server.MyBaseRequestHandle) |
| | | tcpserver = ocr_server.run("", 9002) |
| | | tcpserver.serve_forever() |
| | | |
| | | |
| | | def startJueJin(pipe): |
| | | juejin.JueJinManager(pipe).start() |
| | | def createDataServer(): |
| | | print("create OCRServer") |
| | | tcpserver = data_server.run("", 9004) |
| | | tcpserver.serve_forever() |
| | | |
| | | |
| | | |
| | | |
| | | class GUI: |
| | |
| | | gs_gui_pipe, gs_server_pipe = multiprocessing.Pipe() |
| | | |
| | | self.serverProcess = multiprocessing.Process(target=createServer, args=(p1, gs_server_pipe,)) |
| | | self.jueJinProcess = multiprocessing.Process(target=startJueJin, args=(p2,)) |
| | | self.jueJinTradeProcess = multiprocessing.Process(target=trade_juejin.run) |
| | | self.ocrServerProcess = multiprocessing.Process(target=createOCRServer) |
| | | |
| | | |
| | | |
| | | |
| | | self.p1 = p1 |
| | | self.p2 = p2 |
| | |
| | | self.codeActualPriceProcessor = CodeActualPriceProcessor() |
| | | # L2显示 |
| | | self.l2_codes = {} |
| | | self.selected_client = {} |
| | | # 获取l2的客户端列表 |
| | | clients = authority.get_l2_clients() |
| | | for client_id in clients: |
| | | self.l2_codes[client_id] = [] |
| | | for i in range(0, 8): |
| | | for i in range(0, constant.L2_CODE_COUNT_PER_DEVICE): |
| | | code = gpcode_manager.get_listen_code_by_pos(client_id, i) |
| | | self.l2_codes[client_id].append(code) |
| | | |
| | |
| | | time.sleep(0.1) |
| | | |
| | | def run(self): |
| | | # TODO |
| | | self.jueJinProcess.start() |
| | | self.serverProcess.start() |
| | | self.ocrServerProcess.start() |
| | | self.jueJinTradeProcess.start() |
| | | |
| | | L2CodeOperate.get_instance() |
| | | # 客户端队列操作 |
| | | process = multiprocessing.Process(target=L2CodeOperate.run()) |
| | |
| | | for i in range(0, len(content)): |
| | | text.tag_add('error', "{}.{}".format(line, i)) |
| | | |
| | | def sync_target_codes(): |
| | | server.sync_target_codes_to_ths() |
| | | |
| | | def click(): |
| | | text.delete('1.0', END) |
| | | |
| | | # 验证redis |
| | | redis = redis_manager.RedisManager().getRedis() |
| | | try: |
| | | redis = redis_manager.RedisManager().getRedis() |
| | | redis.set("test", "1") |
| | | redis.delete("test") |
| | | |
| | | RedisUtils.set( redis,"test", "1",auto_free=False) |
| | | RedisUtils.delete(redis, "test", auto_free=False) |
| | | text.insert(END, "redis连接成功!\n") |
| | | except: |
| | | error = "redis连接失败...\n" |
| | | text.insert(END, error) |
| | | _set_error_color(text, 1, error) |
| | | finally: |
| | | RedisUtils.realse(redis) |
| | | # 验证mongodb |
| | | try: |
| | | counts = mysql_data.Mysqldb().select_one("select count(*) from clients") |
| | |
| | | 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) |
| | | |
| | | 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): |
| | | def refresh_close_price_data(): |
| | | redis = redis_manager.RedisManager(0).getRedis() |
| | | count = len(redis.keys("price-pre-*")) |
| | | count = len(RedisUtils.keys(redis_manager.RedisManager(0).getRedis(), "price-pre-*")) |
| | | sv_num.set("获取到收盘价数量:{}".format(count)) |
| | | |
| | | def re_get_close_price(): |
| | | juejin.re_set_price_pres(gpcode_manager.get_gp_list()) |
| | | inited_data.re_set_price_pres(gpcode_manager.get_gp_list()) |
| | | |
| | | def get_limit_up_codes_win(): |
| | | width = 500 |
| | |
| | | win.geometry("{}x{}".format(width, height)) |
| | | win.mainloop() |
| | | |
| | | btn = Button(frame, text="刷新收盘价", command=refresh_close_price_data) |
| | | btn.place(x=5, y=150) |
| | | # 绘制代码交易窗口分配 |
| | | def refresh_trade_buy_win_data(): |
| | | code_wins = trade_gui.THSBuyWinManagerNew.get_distributed_code_wins() |
| | | # 获取代码涨幅 |
| | | codeActualPriceProcessor = trade_data_manager.CodeActualPriceProcessor() |
| | | datas = [] |
| | | for data in code_wins: |
| | | rate = codeActualPriceProcessor.get_current_rate(data[0]) |
| | | datas.append((data[0], rate, data[1])) |
| | | datas.sort(key=lambda tup: tup[1] if tup[1] is not None else 1) |
| | | datas.reverse() |
| | | index = 0 |
| | | table.model.deleteRows() |
| | | for data in datas: |
| | | table.model.addRow() |
| | | table.model.setValueAt(data[0], index, 0) |
| | | table.model.setValueAt(f"{data[1]}%", index, 1) |
| | | table.model.setValueAt(data[2], index, 2) |
| | | # 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 = 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=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 = 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) |
| | | |
| | | btn = Button(frame, text="今日涨停", command=get_limit_up_codes_win) |
| | | btn.place(x=300, y=150) |
| | | trade_win_datas = [] |
| | | # draw_trade_buy_win(360, 140) |
| | | table_width = 300 |
| | | 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=450, y=start_y) |
| | | refresh_trade_buy_win_data() |
| | | refresh_close_price_data() |
| | | |
| | | btn = FlatButton(frame, text="刷新", command=refresh_trade_buy_win_data) |
| | | btn.place(x=450 - 35, y=start_y) |
| | | |
| | | def re_distribute_buy_win(): |
| | | try: |
| | | if tool.trade_time_sub(tool.get_now_time_str(), "09:30:00") > 0: |
| | | raise Exception("只能9:30之前重新分配窗口") |
| | | datas = HistoryKDatasUtils.get_codes_limit_rate(gpcode_manager.get_gp_list()) |
| | | matrix = numpy.array(datas) |
| | | codes = matrix[:, 0].tolist() |
| | | trade_gui.re_distribute_buy_win(codes) |
| | | refresh_trade_buy_win_data() |
| | | showinfo("提示", "分配完成") |
| | | except Exception as e: |
| | | showerror("分配出错", str(e)) |
| | | |
| | | btn = FlatButton(frame, text="重新分配窗口", command=re_distribute_buy_win) |
| | | btn.place(x=450 - 83, y=start_y + 30) |
| | | |
| | | # 绘制交易状态 |
| | | def __draw_trade_state(self, frame): |
| | |
| | | normal = False |
| | | try: |
| | | trade_gui.THSGuiTrade.checkEnv() |
| | | cl_win.configure(text="正常", foreground="#008000") |
| | | cancel_win_num = trade_gui.THSGuiTrade.getCancelBuyWins() |
| | | cl_win.configure(text=f"正常({len(cancel_win_num)})", foreground="#008000") |
| | | except Exception as e: |
| | | normal = False |
| | | cl_win.configure(text="异常:{}".format(str(e)), foreground="#FF7F27") |
| | | |
| | | try: |
| | | juejin_length = JueJinManager.get_listen_codes_lenth() |
| | | juejin_length = 0 |
| | | codes_length = len(gpcode_manager.get_gp_list()) |
| | | 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: |
| | |
| | | |
| | | # 获取有效的L2客户端数量 |
| | | l2_client_count = client_manager.getValidL2Clients() |
| | | if len(l2_client_count) < 2: |
| | | if len(l2_client_count) < 6: |
| | | normal = False |
| | | |
| | | # 状态有问题,需要报警 |
| | |
| | | pass |
| | | time.sleep(2) |
| | | |
| | | start_y = 230 |
| | | 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() |
| | |
| | | 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: |
| | | client_state[client_id].configure(text="(离线:未知IP)", foreground="#999999") |
| | | |
| | | for i in range(0, 8): |
| | | for i in range(0, constant.L2_CODE_COUNT_PER_DEVICE): |
| | | code = gpcode_manager.get_listen_code_by_pos(client_id, i) |
| | | data_count = l2_data_util.get_l2_latest_data_number(code) |
| | | if data_count is None: |
| | |
| | | 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) |
| | |
| | | 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 |
| | |
| | | win.mainloop() |
| | | |
| | | def init(): |
| | | juejin.everyday_init() |
| | | inited_data.everyday_init() |
| | | |
| | | 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 |
| | | height = 360 |
| | | frame = Frame(root, {"height": height, "width": width, "bg": "#DDDDDD"}) |
| | | cl = Label(frame, text="L2采集状态", bg="#DDDDDD") |
| | | trade_info = "" |
| | | for_color = "#008000" |
| | | if constant.TEST: |
| | | trade_info += "测试环境" |
| | | for_color = "#FF7F27" |
| | | else: |
| | | trade_info += "正式环境" |
| | | trade_info += " " |
| | | if constant.TRADE_ENABLE: |
| | | trade_info += "初始允许交易" |
| | | else: |
| | | trade_info += "初始禁止交易" |
| | | for_color = "#FF7F27" |
| | | |
| | | cl = Label(frame, text=f"{trade_info}", bg="#DDDDDD", foreground=f"{for_color}") |
| | | cl.place(x=5, y=5) |
| | | |
| | | accept_l2 = IntVar() |
| | |
| | | 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", |
| | |
| | | code_sv_map = {} |
| | | code_labels = {} |
| | | client_state = {} |
| | | for key in self.l2_codes: |
| | | |
| | | client_lb = Label(frame, text="设备:{}".format(key), background="#DDDDDD") |
| | | # 右键菜单 |
| | | menu = Menu(frame, |
| | | tearoff=False, |
| | | # bg="black", |
| | | ) |
| | | menu.add_command(label="环境检测", command=check_env) |
| | | menu.add_command(label="同花顺测速", command=ths_test_speed) |
| | | |
| | | device_index = 0 |
| | | for key in self.l2_codes: |
| | | 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.bind('<Button-1>', check) |
| | | 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="(未知)", background="#DDDDDD", font=('微软雅黑', 8)) |
| | | client_state_lb.place(x=80, y=40 + l2_client_count * 30) |
| | | client_state_lb = Label(frame, text="(未知)", padx=0, pady=0, background="#DDDDDD", font=('微软雅黑', 8)) |
| | | 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] = [] |
| | | for i in range(0, 8): |
| | | for i in range(0, constant.L2_CODE_COUNT_PER_DEVICE): |
| | | sv = StringVar(value=self.l2_codes[key][i]) |
| | | code_sv_map[key].append(sv) |
| | | cframe = Frame(frame, {"height": 23, "width": 70, "bg": "#FFFFFF"}) |
| | | cframe = Frame(frame, {"height": 23, "width": 80, "bg": "#FFFFFF"}) |
| | | code_label = Label(cframe, textvariable=sv, background="#FFFFFF", foreground="#FF0000") |
| | | code_labels[key].append(code_label) |
| | | |
| | | code_label.place(x=0, y=0) |
| | | cframe.place(x=200 + i * 75, 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()) |
| | |
| | | time.sleep(1) |
| | | |
| | | def refresh_data(): |
| | | money = trade_manager.get_available_money() |
| | | money = trade_manager.AccountAvailableMoneyManager().get_available_money() |
| | | if money is not None: |
| | | sv_trade_money.set(money) |
| | | else: |
| | |
| | | index = 0 |
| | | for data in datas: |
| | | table_trade.model.addRow() |
| | | table_trade.model.setValueAt(data["code"], index, 0) |
| | | table_trade.model.setValueAt(data["time"], index, 1) |
| | | table_trade.model.setValueAt(data["num"], index, 2) |
| | | table_trade.model.setValueAt(data["price"], index, 3) |
| | | table_trade.model.setValueAt(data["money"], index, 4) |
| | | table_trade.model.setValueAt(data["trade_num"], index, 5) |
| | | if int(data["type"]) > 0: |
| | | table_trade.model.setValueAt("卖出", index, 6) |
| | | table_trade.model.setValueAt("卖出", index, 0) |
| | | else: |
| | | table_trade.model.setValueAt("买入", index, 6) |
| | | table_trade.model.setValueAt("买入", index, 0) |
| | | table_trade.model.setValueAt(data["code"], index, 1) |
| | | table_trade.model.setValueAt(data["time"], index, 2) |
| | | table_trade.model.setValueAt(data["num"], index, 3) |
| | | table_trade.model.setValueAt(data["price"], index, 4) |
| | | table_trade.model.setValueAt(data["money"], index, 5) |
| | | table_trade.model.setValueAt(data["trade_num"], index, 6) |
| | | |
| | | index += 1 |
| | | table_trade.redraw() |
| | | |
| | |
| | | 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", |
| | |
| | | cl = Label(frame, text="今日委托:", bg="#DDDDDD", fg="#666666") |
| | | cl.place(x=5, y=30) |
| | | delegate_datas = {} |
| | | delegate_datas["row{}".format(0)] = {'委托时间': '', '代码': '', '申报时间': '', '委托数量': '', '委托价格': '', '成交均价': '', '成交数量': '', |
| | | delegate_datas["row{}".format(0)] = {'委托时间': '', '代码': '', '申报时间': '', '委托数量': '', '委托价格': '', '成交均价': '', |
| | | '成交数量': '', |
| | | '操作': ''} |
| | | |
| | | cl = Label(frame, text="更新时间:", bg="#DDDDDD", fg="#666666") |
| | |
| | | cl.place(x=width - 70, y=30) |
| | | |
| | | trade_datas = {} |
| | | trade_datas["row{}".format(0)] = {'证券代码': '', '成交时间': '', '成交数量': '', '成交均价': '', '成交金额': '', |
| | | '合同编号': '', '操作': ''} |
| | | trade_datas["row{}".format(0)] = {'方向': '', '证券代码': '', '成交时间': '', '成交数量': '', '成交均价': '', '成交金额': '', |
| | | '合同编号': ''} |
| | | |
| | | table_frame = Frame(frame, {"height": table_height, "width": table_width, "bg": "#DDDDDD"}) |
| | | table_frame.place(x=width / 2, y=52) |
| | | table_trade = create_table(table_frame, trade_datas, 90) |
| | | table_trade = create_table(table_frame, trade_datas, 70) |
| | | table_trade.show() |
| | | |
| | | frame.grid(row=2, column=1, padx=5, pady=5, rowspan=2) |
| | |
| | | if len(account.strip()) < 1 or len(sid.strip()) < 1 or len(token.strip()) < 1: |
| | | showinfo('提示', "数据不完整") |
| | | return |
| | | juejin.setAccountInfo(account, sid, token) |
| | | inited_data.setAccountInfo(account, sid, token) |
| | | showinfo('提示', "设置成功") |
| | | |
| | | # 设置掘金信息 |
| | |
| | | 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) |
| | | |
| | | # 设置参数 |
| | | account, sid, token = juejin.getAccountInfo() |
| | | account, sid, token = inited_data.getAccountInfo() |
| | | account_var.set(account) |
| | | sid_var.set(sid) |
| | | token_var.set(token) |
| | |
| | | |
| | | def export_l2_data_origin(code): |
| | | redis = redis_manager.RedisManager(1).getRedis() |
| | | keys = redis.keys("big_data-{}-*".format(code)) |
| | | try: |
| | | keys = RedisUtils.keys(redis, "big_data-{}-*".format(code), auto_free=False) |
| | | for k in keys: |
| | | datas = redis.get(k) |
| | | datas = redis.get(k, auto_free=False) |
| | | datas = json.loads(datas) |
| | | _t = k.split("-")[2] |
| | | k = time.strftime("%Y_%m_%d_%H_%M_%S_", time.localtime(float(_t) / 1000)) |
| | |
| | | data_export_util.export_l2_data_origin(code, datas, k) |
| | | except Exception as e1: |
| | | showerror("导出失败", str(e1)) |
| | | finally: |
| | | RedisUtils.realse(redis) |
| | | |
| | | showinfo("提示", "导出完成") |
| | | |
| | |
| | | def clear_l2(code): |
| | | self.gs_gui_pipe.send(json.dumps({"type": "clear_l2", "data": {"code": code}})) |
| | | pass |
| | | |
| | | # 禁止代码 |
| | | def cancel_order(code_): |
| | | try: |
| | | l2.l2_data_util.load_l2_data(code_, True) |
| | | l2_data_manager_new.L2TradeDataProcessor.cancel_buy(code_, "手动撤销") |
| | | showinfo("提示", "撤单成功") |
| | | except Exception as e: |
| | | showwarning("提示", "撤单成功异常" + str(e)) |
| | | |
| | | frame = Frame(root, {"height": 280, "width": 300, "bg": "#DDDDDD"}) |
| | | frame.grid(row=2, column=2, rowspan=2, pady=5) |
| | |
| | | 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.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 = 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): |
| | |
| | | self.__draw_trade_data(root) |
| | | self.__draw_test(root) |
| | | |
| | | root.geometry("1120x600") |
| | | root.geometry("1120x660") |
| | | root.mainloop() |
| | | |
| | | |