Administrator
2023-09-01 be7fd23591e03d024baff417e7697085c9527bb4
添加测试
2个文件已修改
33 ■■■■ 已修改文件
huaxin_client/trade_client.py 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/trade_client.py
@@ -550,7 +550,8 @@
        try:
            if pInputOrderActionField and pRspInfoField:
                logger_local_huaxin_trade_debug.info('OnErrRtnOrderAction: Error! [%d] [%d] [%d] [%s]'
                                                     % (nRequestID, pInputOrderActionField.OrderSysID, pRspInfoField.ErrorID,
                                                     % (nRequestID, pInputOrderActionField.OrderSysID,
                                                        pRspInfoField.ErrorID,
                                                        pRspInfoField.ErrorMsg))
        except:
            pass
@@ -1003,7 +1004,9 @@
            #     json.dumps({"type": "response", "data": {"code": 0, "data": data}, "client_id": client_id,
            #                 "request_id": request_id}), type, client_id, request_id, temp_params[2])
            trade_response.OnTradeResponse({"type": "response", "data": {"code": 0, "data": data}, "client_id": client_id, "request_id": request_id})
            trade_response.OnTradeResponse(
                {"type": "response", "data": {"code": 0, "data": data}, "client_id": client_id,
                 "request_id": request_id})
            logger_local_huaxin_trade_debug.info("API回调结束 req_id-{} request_id-{}", req_id, request_id)
            print("API回调结束")
@@ -1035,6 +1038,21 @@
    tradeCommandManager.process_command(tradeRequest.type_, None, tradeRequest.data)
def __test():
    # 测试撤单
    for i in range(0, 10):
        code = "600190"
        orderSysID = "0190000229"
        sinfo = f"test_cancel_{i}"
        data = {"type": "trade", "trade_type": 2,
                "direction": 0,
                "code": code,
                "localOrderID": "",
                "orderSysID": orderSysID, "sinfo": sinfo}
        process_cmd(TradeRequest("trade", {"type": "trade", "data": data, "request_id": f"test-{i}"}, f"test-{i}"))
        time.sleep(2)
def run(trade_response_: TradeResponse, pipe_l2=None, pipe_strategy=None):
    try:
        logger_system.info("交易进程ID:{}", os.getpid())
@@ -1051,6 +1069,9 @@
        t1 = threading.Thread(target=lambda: trade_client_server.run(), daemon=True)
        t1.start()
        t1 = threading.Thread(target=lambda: __test(), daemon=True)
        t1.start()
        global tradeCommandManager
        tradeCommandManager = command_manager.TradeCommandManager()
        tradeCommandManager.init(MyTradeActionCallback(), l2pipe, pipe_strategy)
l2/l2_data_manager_new.py
@@ -1164,6 +1164,8 @@
            raise Exception("涨停价无法获取")
        # 目标手数
        threshold_num = round(threshold_money / (limit_up_price * 100))
        # 大目标手数(满足这个就不需要看安全笔数)
        threshold_max_num = int(threshold_num * 1.2)
        # place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count(code)
        # 目标订单数量
@@ -1184,7 +1186,7 @@
        big_num_count = cls.__l2PlaceOrderParamsManagerDict[code].get_big_num_count()
        # 较大单的手数
        bigger_num = round(5900 / limit_up_price)
        bigger_num = round(5000 / limit_up_price)
        for i in range(compute_start_index, compute_end_index + 1):
            data = total_datas[i]
@@ -1210,9 +1212,9 @@
                    # 只统计59万以上的金额
                    buy_nums += int(_val["num"]) * int(total_datas[i]["re"])
                    buy_count += int(total_datas[i]["re"])
                    if buy_nums >= threshold_num and buy_count >= threshold_count:
                    if (buy_nums >= threshold_num and buy_count >= threshold_count) or buy_nums >= threshold_max_num:
                        async_log_util.info(logger_l2_trade_buy,
                                            f"{code}获取到买入执行点:{i} 统计纯买手数:{buy_nums} 目标纯买手数:{threshold_num} 统计纯买单数:{buy_count} 目标纯买单数:{threshold_count}, 大单数量:{len(max_buy_num_set)}")
                                            f"{code}获取到买入执行点:{i} 统计纯买手数:{buy_nums} 目标纯买手数:{threshold_num}/{threshold_max_num} 统计纯买单数:{buy_count} 目标纯买单数:{threshold_count}, 大单数量:{len(max_buy_num_set)}")
            elif L2DataUtil.is_limit_up_price_buy_cancel(_val):
                if _val["num"] >= bigger_num:
                    # 只统计59万以上的金额