| | |
| | | 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 |
| | |
| | | # 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回调结束") |
| | |
| | | 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()) |
| | |
| | | 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) |
| | |
| | | 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) |
| | | # 目标订单数量 |
| | |
| | | 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] |
| | |
| | | # 只统计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万以上的金额 |