| | |
| | | |
| | | # 代码对应的价格是否正确 |
| | | def is_same_code_with_price(code, price): |
| | | if code == '600066': |
| | | print('进入调试') |
| | | # 昨日收盘价 |
| | | price_close = gpcode_manager.CodePrePriceManager.get_price_pre_cache(code) |
| | | max_price = tool.to_price(decimal.Decimal(str(price_close)) * decimal.Decimal(tool.get_limit_up_rate(code))) |
| | |
| | | # if max_price > float(limit_up_price): |
| | | # return False |
| | | rate = (float(limit_up_price) - min_price_info[1]["close"]) / min_price_info[1]["close"] |
| | | print(rate) |
| | | if rate >= 0.319: |
| | | return True, rate |
| | | return False, rate |
| | |
| | | max_limit_up_info = x |
| | | |
| | | if not max_limit_up_info or max_limit_up_info[0] < 3: |
| | | print("无3连板") |
| | | return False |
| | | start_index = max_limit_up_info[1] |
| | | max_price_info = [0, None] |
| | |
| | | for i in range(max_price_info[1] + 1, len(datas)): |
| | | item = datas[i] |
| | | if item["low"] < lowest_price_threhhold: |
| | | print("回踩足够") |
| | | return False |
| | | return True |
| | | |
| | |
| | | min_price = 1000000 |
| | | for i in range(len(datas) - 5, len(datas)): |
| | | item = datas[i] |
| | | print(item) |
| | | limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(code, item["pre_close"])) |
| | | if abs(limit_up_price - item["high"]) < 0.001 and abs( |
| | | limit_up_price - datas[i - 1]["high"]) >= 0.001: |
| | |
| | | |
| | | def process_first_codes_datas(dataList, request_id=None): |
| | | logger_l2_codes_subscript.info(f"{request_id}加载l2代码相关数据") |
| | | print("首板代码数量:", len(dataList)) |
| | | # 获取最近5天的交易日期,为后面的数据计算做准备 |
| | | HistoryKDatasUtils.get_latest_trading_date_cache(5) |
| | | limit_up_price_dict = {} |
| | |
| | | # gpcode_manager.get_limit_up_price(code), |
| | | # volumes_data) |
| | | except Exception as e: |
| | | logger_first_code_record.error(f"{code}:{str(e)}") |
| | | logger_first_code_record.error(f"{request_id}-{code}:{str(e)}") |
| | | logger_first_code_record.exception(e) |
| | | |
| | | logger_l2_codes_subscript.info(f"{request_id}加载l2代码K线结束") |
| | |
| | | value = json.loads(value) |
| | | if value.get("type") == "clear_l2": |
| | | code = value["data"]["code"] |
| | | print("清除l2数据", code) |
| | | if len(code) != 6: |
| | | continue |
| | | l2_data_manager.clear_l2_data(code) |
| | |
| | | |
| | | |
| | | def createServer(pipe_juejin, pipe_gui): |
| | | print("create SocketServer") |
| | | # 初始化参数 |
| | | global_data_loader.init() |
| | | |
| | |
| | | |
| | | |
| | | def createOCRServer(): |
| | | print("create OCRServer") |
| | | tcpserver = ocr_server.run("", 9002) |
| | | tcpserver.serve_forever() |
| | | |
| | | |
| | | def createDataServer(): |
| | | print("create OCRServer") |
| | | tcpserver = data_server.run("", 9004) |
| | | tcpserver.serve_forever() |
| | | |
| | |
| | | if value.get("type") == "l2_data_notify": |
| | | code = value["data"]["code"] |
| | | count = value["data"]["count"] |
| | | print("l2数据通知:{}-{}", code, count) |
| | | |
| | | time.sleep(0.1) |
| | | |
| | |
| | | str_list.sort() |
| | | str_list.append("%Yeshi2014@#.") |
| | | root_data["sign"] = crypt.md5_encrypt("&".join(str_list)) |
| | | print("请求前对象", root_data) |
| | | # print("请求前对象", root_data) |
| | | # 添加请求头 |
| | | client[1].sendall(socket_util.load_header(json.dumps(root_data).encode(encoding='utf-8'))) |
| | | result = client[1].recv(1024) |
| | | print("请求发送成功", result.decode(encoding='utf-8')) |
| | | # print("请求发送成功", result.decode(encoding='utf-8')) |
| | | except BrokenPipeError as e: |
| | | ClientSocketManager.del_client(client[0]) |
| | | raise e |
| | |
| | | # price:价格(如果是卖时不传价格就按照5挡价卖) |
| | | # blocking是否阻塞进程 |
| | | def order(direction, code, volume, price, price_type=2, blocking=True): |
| | | print("客户端", ClientSocketManager.socket_client_dict) |
| | | # print("客户端", ClientSocketManager.socket_client_dict) |
| | | request_id, client = __request(ClientSocketManager.CLIENT_TYPE_TRADE, |
| | | {"type": ClientSocketManager.CLIENT_TYPE_TRADE, "trade_type": 1, |
| | | "direction": direction, |
| | |
| | | |
| | | def subscribe_codes(self, codes_sh, codes_sz): |
| | | # 重新订阅代码 |
| | | print(f"订阅数量:sh-{len(codes_sh)} sz-{len(codes_sz)}") |
| | | if codes_sh: |
| | | ret = self.__api.SubscribeMarketData(codes_sh, xmdapi.TORA_TSTP_EXD_SSE) |
| | | if ret != 0: |
| | | print('SubscribeMarketData fail, ret[%d]' % ret) |
| | | # print('SubscribeMarketData fail, ret[%d]' % ret) |
| | | pass |
| | | else: |
| | | print('SubscribeMarketData success, ret[%d]' % ret) |
| | | # print('SubscribeMarketData success, ret[%d]' % ret) |
| | | pass |
| | | |
| | | if codes_sz: |
| | | ret = self.__api.SubscribeMarketData(codes_sz, xmdapi.TORA_TSTP_EXD_SZSE) |
| | | if ret != 0: |
| | | print('SubscribeMarketData fail, ret[%d]' % ret) |
| | | # print('SubscribeMarketData fail, ret[%d]' % ret) |
| | | pass |
| | | else: |
| | | print('SubscribeMarketData success, ret[%d]' % ret) |
| | | # print('SubscribeMarketData success, ret[%d]' % ret) |
| | | pass |
| | | |
| | | def OnRspUserLogin(self, pRspUserLoginField, pRspInfoField, nRequestID): |
| | | if pRspInfoField.ErrorID == 0: |
| | | print('Login success! [%d]' % nRequestID) |
| | | # print('Login success! [%d]' % nRequestID) |
| | | |
| | | ''' |
| | | 订阅行情 |
| | |
| | | |
| | | |
| | | else: |
| | | print('Login fail!!! [%d] [%d] [%s]' |
| | | % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | pass |
| | | # print('Login fail!!! [%d] [%d] [%s]' |
| | | # % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | |
| | | def OnRspSubMarketData(self, pSpecificSecurityField, pRspInfoField): |
| | | if pRspInfoField.ErrorID == 0: |
| | | print('OnRspSubMarketData: OK!') |
| | | # print('OnRspSubMarketData: OK!') |
| | | pass |
| | | else: |
| | | print('OnRspSubMarketData: Error! [%d] [%s]' |
| | | % (pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | # print('OnRspSubMarketData: Error! [%d] [%s]' |
| | | # % (pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | pass |
| | | |
| | | def OnRspUnSubMarketData(self, pSpecificSecurityField, pRspInfoField): |
| | | if pRspInfoField.ErrorID == 0: |
| | | print('OnRspUnSubMarketData: OK!') |
| | | # print('OnRspUnSubMarketData: OK!') |
| | | pass |
| | | else: |
| | | print('OnRspUnSubMarketData: Error! [%d] [%s]' |
| | | % (pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | pass |
| | | # print('OnRspUnSubMarketData: Error! [%d] [%s]' |
| | | # % (pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | |
| | | def OnRtnMarketData(self, pMarketDataField): |
| | | if pMarketDataField.SecurityName.find("S") == 0: |
| | |
| | | codes_sz.append(code.encode("utf-8")) |
| | | else: |
| | | codes_sh.append(code.encode("utf-8")) |
| | | print("获取订阅目标代数量:", len(codes_sh), len(codes_sz)) |
| | | return codes_sh, codes_sz |
| | | except ConnectionResetError: |
| | | SendResponseSkManager.del_send_response_sk(type_) |
| | |
| | | |
| | | |
| | | def add_subscript_codes(codes): |
| | | print("add_subscript_codes", codes) |
| | | # print("add_subscript_codes", codes) |
| | | # 加入上传队列 |
| | | common_queue.put(('', "l2_subscript_codes", list(codes))) |
| | | |
| | |
| | | return True |
| | | else: |
| | | # 再次发送 |
| | | print("再次发送") |
| | | # print("再次发送") |
| | | return __send_response(sk, msg) |
| | | except ConnectionResetError as e: |
| | | SendResponseSkManager.del_send_response_sk(type) |
| | |
| | | |
| | | |
| | | def __run_upload_common(): |
| | | print("__run_upload_common") |
| | | # print("__run_upload_common") |
| | | logger_system.info(f"l2_client __run_upload_common 线程ID:{tool.get_thread_id()}") |
| | | while True: |
| | | try: |
| | |
| | | |
| | | |
| | | def __run_log(): |
| | | print("__run_log") |
| | | # print("__run_log") |
| | | logger_system.info(f"l2_client __run_log 线程ID:{tool.get_thread_id()}") |
| | | async_log_util.huaxin_l2_log.run_sync() |
| | | |
| | |
| | | raise Exception("L2尚未登录") |
| | | add_codes = codes - self.subscripted_codes |
| | | del_codes = self.subscripted_codes - codes |
| | | print("add del codes", add_codes, del_codes) |
| | | self.__subscribe(add_codes) |
| | | self.__unsubscribe(del_codes) |
| | | # 设置最近的代码列表 |
| | |
| | | |
| | | # 订阅代码,[代码,...] |
| | | def set_codes_data(self, codes): |
| | | print("订阅代码数量:", len(codes)) |
| | | try: |
| | | self.__process_codes_data(codes) |
| | | except Exception as e: |
| | |
| | | return [] |
| | | |
| | | def OnFrontConnected(self): |
| | | print("OnFrontConnected") |
| | | logger_system.info(f"l2_client OnFrontConnected 线程ID:{tool.get_thread_id()}") |
| | | logout_req = lev2mdapi.CTORATstpUserLogoutField() |
| | | self.__api.ReqUserLogout(logout_req, 1) |
| | |
| | | self.__api.ReqUserLogin(login_req, 2) |
| | | |
| | | def OnRspUserLogin(self, pRspUserLogin, pRspInfo, nRequestID, bIsLast): |
| | | print("OnRspUserLogin: ErrorID[%d] ErrorMsg[%s] RequestID[%d] IsLast[%d]" % ( |
| | | pRspInfo['ErrorID'], pRspInfo['ErrorMsg'], nRequestID, bIsLast)) |
| | | if pRspInfo['ErrorID'] == 0: |
| | | print("----L2行情登录成功----") |
| | | self.is_login = True |
| | | logger_system.info(f"L2行情登录成功") |
| | | # 初始设置值 |
| | |
| | | |
| | | |
| | | def __init_l2(l2_data_upload_manager): |
| | | print(lev2mdapi.CTORATstpLev2MdApi_GetApiVersion()) |
| | | # print(lev2mdapi.CTORATstpLev2MdApi_GetApiVersion()) |
| | | # case 1: Tcp方式 |
| | | # g_SubMode=lev2mdapi.TORA_TSTP_MST_TCP |
| | | # case 2: 组播方式 |
| | |
| | | datas = flist[:1000] |
| | | # 将持仓股加入进去 |
| | | datas.extend(plist) |
| | | print("代码数量:", len(datas)) |
| | | __upload_codes_info(queue_l1_w_strategy_r, datas) |
| | | except Exception as e: |
| | | pass |
| | |
| | | self.__set_l2_second_money_record(code, t_, time_dict_num[t_], time_dict_num_index[t_]["s"], |
| | | time_dict_num_index[t_]["e"]) |
| | | |
| | | print("保存涨停封单额时间:", round(time.time() * 1000) - start_time) |
| | | # print("保存涨停封单额时间:", round(time.time() * 1000) - start_time) |
| | | |
| | | # 累计最新的金额 |
| | | total_num, index = self.__get_l2_latest_money_record(code) |
| | |
| | | if not with_cancel: |
| | | cancel_index = None |
| | | |
| | | print("封单额计算时间:", round(time.time() * 1000) - start_time) |
| | | # print("封单额计算时间:", round(time.time() * 1000) - start_time) |
| | | process_end_index = end_index |
| | | if cancel_index: |
| | | process_end_index = cancel_index |
| | |
| | | self.__set_processed_end_index(code, end_index) |
| | | big_money_num_manager.add_num(code, total_num) |
| | | |
| | | print("m值大单计算范围:{}-{} 时间:{}".format(max(start_index, processed_index), end_index, |
| | | round(t.time() * 1000) - start_time)) |
| | | # print("m值大单计算范围:{}-{} 时间:{}".format(max(start_index, processed_index), end_index, |
| | | # round(t.time() * 1000) - start_time)) |
| | | |
| | | |
| | | class L2TradeDataProcessor: |
| | |
| | | # 加载历史数据,返回数据是否正常 |
| | | is_normal = l2.l2_data_util.load_l2_data(code) |
| | | if not is_normal: |
| | | print("历史数据异常:", code) |
| | | # print("历史数据异常:", code) |
| | | # 数据不正常需要禁止交易 |
| | | l2_trade_util.forbidden_trade(code, msg="L2历史数据异常") |
| | | # 纠正数据 |
| | |
| | | try: |
| | | cancel_datas.sort(key=lambda t: t["index"]) |
| | | except Exception as e: |
| | | print("测试") |
| | | # print("测试") |
| | | pass |
| | | for item in cancel_datas: |
| | | # 提前做计算 |
| | | cls.__get_buy_index_with_cancel_data(code, item, local_today_num_operate_map) |
| | |
| | | |
| | | # 运行同步日志 |
| | | def run_sync(self, add_to_common_log=False): |
| | | print("run_sync", add_to_common_log) |
| | | # print("run_sync", add_to_common_log) |
| | | logger_system.info(f"run_sync 线程ID:{tool.get_thread_id()}") |
| | | while True: |
| | | try: |
| | |
| | | while line: |
| | | time_ = line.split(":")[-1] |
| | | if int(time_) > 150: |
| | | print(line) |
| | | # print(line) |
| | | pass |
| | | line = f.readline() |
| | | |
| | | |
| | |
| | | for key in today_data: |
| | | # news = sorted(today_data[key], key=lambda x: x["index"]) |
| | | # today_data[key] = news |
| | | print(key, len(today_data[key]) - 1, today_data[key][-1]["index"]) |
| | | # print(key, len(today_data[key]) - 1, today_data[key][-1]["index"]) |
| | | pass |
| | | except: |
| | | pass |
| | | return today_data |
| | |
| | | |
| | | if line.find("真实下单位置") > 0: |
| | | |
| | | print(line) |
| | | # print(line) |
| | | str_ = line.split(":")[1].strip() |
| | | print(str_) |
| | | # print(str_) |
| | | try: |
| | | pos = int(eval(str_.split("-")[1].strip())[0]) |
| | | except: |
| | |
| | | elif _type == 201: |
| | | imgdata = base64.b64decode(data["img"]) |
| | | results = ocr_util.OcrUtil.easy_ocr(imgdata) |
| | | print(results) |
| | | # print(results) |
| | | kpl_datas = kpl_util.parse_kpl_datas(results) |
| | | if kpl_datas: |
| | | bidding_money_manager.set_bidding_money(kpl_datas) |
| | |
| | | handler = OCRServer |
| | | try: |
| | | httpd = socketserver.TCPServer((addr, port), handler) |
| | | print("HTTP server is at: http://%s:%d/" % (addr, port)) |
| | | # print("HTTP server is at: http://%s:%d/" % (addr, port)) |
| | | httpd.serve_forever() |
| | | except Exception as e: |
| | | logger_system.exception(e) |
| | |
| | | |
| | | if __name__ == "__main__": |
| | | str_={"id":"123"} |
| | | print(type(str_)==str) |
| | | # print(type(str_)==str) |
| | |
| | | |
| | | |
| | | def __get_base_html_content(): |
| | | print("路径", sys.path[0]) |
| | | if base_output_content.get('css') is None: |
| | | __base_html_content = "" |
| | | with open("./output/css/style.css", mode='r') as f: |
| | |
| | | # 发送心跳 |
| | | cls.__heartbeats_thread(type, key, sk) |
| | | cls.__listen_command_thread(type, key, sk) |
| | | print("create_and_run_client success", type, key) |
| | | # print("create_and_run_client success", type, key) |
| | | return key, sk |
| | | |
| | | @classmethod |
| | |
| | | if result: |
| | | start_time = time.time() |
| | | try: |
| | | print("接收数据", _type, result) |
| | | # print("接收数据", _type, result) |
| | | result_json = json.loads(result) |
| | | if result_json["type"] == MSG_TYPE_HEART: |
| | | # 返回内容 |
| | |
| | | |
| | | data = result_json["data"] |
| | | content_type = data["type"] |
| | | print("接收内容", data) |
| | | # print("接收内容", data) |
| | | request_id = result_json.get('request_id') |
| | | if not socket_util.is_client_params_sign_right(result_json): |
| | | print("签名错误") |
| | | # print("签名错误") |
| | | # 签名出错 |
| | | SendResponseSkManager.send_error_response(_type, request_id, client_id, |
| | | {"code": -1, "msg": "签名错误"}) |
| | |
| | | _str += d.decode(encoding='gbk') |
| | | type = data_process.parseType(_str) |
| | | except Exception as e: |
| | | print("接受到的异常数据:", f"{_str[:10]}...{_str[-10:]}") |
| | | if str(e).find("Unterminated string starting") > -1: |
| | | _str = _str.replace("\n", "") |
| | | type = data_process.parseType(_str) |
| | |
| | | from code_attribute.gpcode_manager import CodesNameManager |
| | | from huaxin_client import l1_subscript_codes_manager |
| | | from third_data.history_k_data_util import JueJinHttpApi |
| | | from utils import tool |
| | | from utils import tool, init_data_util |
| | | |
| | | |
| | | def test_active_buy(): |
| | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | s1 = {"0", "1", "2"} |
| | | s2 = {"3", "4", "5"} |
| | | s1 |= s2 |
| | | print(s1) |
| | | datas = init_data_util.get_volumns_by_code("000333") |
| | | print(datas[0]) |
New file |
| | |
| | | """ |
| | | 分析L2逐笔委托的时间数据 |
| | | """ |
| | | from l2.huaxin import l2_huaxin_util |
| | | from log_module import log_export |
| | | from utils import tool |
| | | |
| | | |
| | | def print_slow_l2_delegates(): |
| | | fdatas = log_export.load_huaxin_order_detail() |
| | | times = set() |
| | | for l in fdatas: |
| | | local_time = l[0] |
| | | if int(local_time.replace(":", "")) < int("093000"): |
| | | continue |
| | | l2_time = l2_huaxin_util.convert_time(l[1][5]) |
| | | if abs(tool.trade_time_sub(local_time, l2_time)) > 10: |
| | | # print("慢数据:", l) |
| | | times.add(f"{l[1][0][:2]}-{local_time}") |
| | | ts = list(times) |
| | | ts.sort(key=lambda x: x.split('-')[1]) |
| | | for t in ts: |
| | | print(t) |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | print_slow_l2_delegates() |
| | |
| | | |
| | | |
| | | async def coroutine_function(): |
| | | print("Start coroutine function") |
| | | # print("Start coroutine function") |
| | | time.sleep(1) |
| | | print("Coroutine function completed") |
| | | # print("Coroutine function completed") |
| | | |
| | | |
| | | async def main(): |
New file |
| | |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from third_data import code_plate_key_manager |
| | | |
| | | if __name__ == "__main__": |
| | | print(code_plate_key_manager.ForbiddenBlockManager().get_blocks()) |
| | | code_plate_key_manager.ForbiddenBlockManager().add("测试2") |
| | | code_plate_key_manager.ForbiddenBlockManager().add("测试3") |
| | | print(code_plate_key_manager.ForbiddenBlockManager().get_blocks()) |
| | | print( code_plate_key_manager.ForbiddenBlockManager().is_in("测试")) |
| | | print(code_plate_key_manager.ForbiddenBlockManager().is_in("测试1")) |
| | | RedisUtils.run_loop() |
New file |
| | |
| | | import logging |
| | | |
| | | from l2.l2_transaction_data_manager import HuaXinSellOrderStatisticManager |
| | | |
| | | if __name__ == "__main__": |
| | | |
| | | fdatas = {} |
| | | with open("D:\\test\\transaction.log", 'r') as f: |
| | | lines = f.readlines() |
| | | for line in lines: |
| | | if line.find("run_sync") < 0: |
| | | continue |
| | | line = line[line.find(']') + 1:].strip() |
| | | data = eval(line) |
| | | if data["SecurityID"] not in fdatas: |
| | | fdatas[data["SecurityID"]] = [] |
| | | fdatas[data["SecurityID"]].append( |
| | | (data['SecurityID'], data['TradePrice'], data['TradeVolume'], |
| | | data['OrderTime'], data['MainSeq'], data['SubSeq'], data['BuyNo'], |
| | | data['SellNo'], data['ExecType'])) |
| | | for code in fdatas: |
| | | try: |
| | | HuaXinSellOrderStatisticManager.statistic_total_deal_volume(code, fdatas[code]) |
| | | print(HuaXinSellOrderStatisticManager.get_latest_3s_continue_deal_volumes(code)) |
| | | pass |
| | | except Exception as e: |
| | | logging.exception(e) |
| | |
| | | if r["sec_level"] != 1: |
| | | normal = False |
| | | break |
| | | print(normal) |
| | | # print(normal) |
| | |
| | | data, header = socket_util.recv_data(sk) |
| | | if data: |
| | | data_str = data |
| | | # print("收到数据------", f"{data_str[:20]}......{data_str[-20:]}") |
| | | data_json = json.loads(data_str) |
| | | type_ = data_json['type'] |
| | | |
| | |
| | | round(float(price), 2)) |
| | | if result: |
| | | resultJSON = result |
| | | print("下单结果:", resultJSON) |
| | | # |
| | | # {'code': 0, 'data': {'sinfo': 'b_600480_1689060343812', 'securityId': '600480', |
| | | # 'orderLocalId': '0190000809', 'orderStatus': '7', 'statusMsg': |
| | |
| | | if code and orderSysID and accountId: |
| | | result = huaxin_trade_api.cancel_order(huaxin_trade_api.TRADE_DIRECTION_BUY, code, |
| | | orderSysID, True) |
| | | print("---撤单结果----") |
| | | print(result) |
| | | if result["code"] == 0: |
| | | if result["data"]["cancel"] == 1: |
| | |
| | | except json.decoder.JSONDecodeError as e: |
| | | if not result: |
| | | sk.close() |
| | | print("JSON解析出错", result, header) |
| | | # print("JSON解析出错", result, header) |
| | | time.sleep(1) |
| | | except ConnectionResetError as ee: |
| | | trade_api.ClientSocketManager.del_client(rid) |
| | |
| | | try: |
| | | data = data_json["data"] |
| | | datas = data["data"] |
| | | print("l2_subscript_codes", data_json) |
| | | # print("l2_subscript_codes", data_json) |
| | | # 订阅的代码 |
| | | huaxin_target_codes_manager.HuaXinL2SubscriptCodesManager.save_subscript_codes(datas) |
| | | # 上传数据 |
| | |
| | | finally: |
| | | sk.sendall(socket_util.load_header(json.dumps({"code": 0}).encode(encoding='utf-8'))) |
| | | elif data_json["type"] == "get_level1_codes": |
| | | print("get_level1_codes") |
| | | # print("get_level1_codes") |
| | | # 获取level1的代码 |
| | | list_ = JueJinApi.get_exchanges_codes(["SHSE", "SZSE"]) |
| | | fdatas = [] |
| | |
| | | val = queue_l1_w_strategy_r.get() |
| | | if val: |
| | | val = json.loads(val) |
| | | print("收到来自L1的数据:", val["type"]) |
| | | # print("收到来自L1的数据:", val["type"]) |
| | | # 处理数据 |
| | | type_ = val["type"] |
| | | timestamp = val.get("time") |
| | |
| | | if val: |
| | | async_log_util.info(logger_local_huaxin_l1_trade_info, f"客户端接收:{val}") |
| | | val = json.loads(val) |
| | | print("收到来自L1的数据:", val["type"]) |
| | | # print("收到来自L1的数据:", val["type"]) |
| | | # 处理数据 |
| | | type_ = val["type"] |
| | | if type_ == "upload_l1_trade_datas": |
| | |
| | | for i in range(3): |
| | | try: |
| | | self.__send_response(data_bytes) |
| | | print("发送数据成功") |
| | | # print("发送数据成功") |
| | | break |
| | | except Exception as e1: |
| | | logging.exception(e1) |
| | |
| | | blocking=True, request_id=request_id) |
| | | self.send_response({"code": 0, "data": result}, client_id, request_id) |
| | | elif trade_type == outside_api_command_manager.TRADE_TYPE_CANCEL_ORDER: |
| | | print("手动撤单:", data) |
| | | # print("手动撤单:", data) |
| | | code = data["code"] |
| | | direction = data["direction"] |
| | | accountID = data["accountID"] |
| | |
| | | try: |
| | | code = data["code"] |
| | | excel_file_name = data_export_util.export_l2_excel(code) |
| | | print("导出L2数据目录:", excel_file_name) |
| | | # print("导出L2数据目录:", excel_file_name) |
| | | self.send_response({"code": 0, "data": {}, "msg": ""}, client_id, request_id) |
| | | except Exception as e: |
| | | logging.exception(e) |
| | |
| | | |
| | | # 获取交易通道 |
| | | result = {"code": 0, "data": fdata, "msg": ""} |
| | | print("OnGetEnvInfo 成功") |
| | | # print("OnGetEnvInfo 成功") |
| | | self.send_response(result, client_id, request_id) |
| | | except Exception as e: |
| | | self.send_response({"code": 1, "msg": str(e)}, client_id, request_id) |
| | |
| | | cls.__instance.buy_lock = threading.RLock() |
| | | cls.__instance.buy_cancel_locks = {} |
| | | cls.__instance.buy_win_list = cls.get_buy_wins() |
| | | print("交易窗口", cls.__instance.buy_win_list) |
| | | # print("交易窗口", cls.__instance.buy_win_list) |
| | | cls.__instance.using_buy_wins = set() |
| | | cls.__instance.cancel_wins = cls.__instance.getCancelBuyWins() |
| | | return cls.__instance |
| | |
| | | |
| | | def init(context): |
| | | __context_dict["init"] = context |
| | | print("掘金交易初始化成功") |
| | | |
| | | |
| | | # 可用金额 |
| | |
| | | str_list.sort() |
| | | str_list.append("%Yeshi2014@#.") |
| | | new_sign = crypt_util.md5_encrypt("&".join(str_list)) |
| | | # print("加密前字符串","&".join(str_list)) |
| | | if sign == new_sign: |
| | | return True |
| | | else: |