Administrator
2024-03-06 dde40bed2653bacfdaebc576ec739d3a322867a1
真实下单位寻找优化/延迟虚拟单的撤单
5个文件已修改
37 ■■■■ 已修改文件
huaxin_client/trade_client.py 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/cancel_buy_strategy.py 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/huaxin/huaxin_delegate_postion_manager.py 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_trade_server.py 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/trade_client.py
@@ -20,8 +20,6 @@
from log_module.log import logger_local_huaxin_trade_debug, logger_system, logger_trade
from utils import tool
########B类########
UserID = '388000013349'
# 登陆密码
@@ -208,9 +206,11 @@
                # 影子订单撤单
                # 撤掉影子单
                shadow_cancel_order_ref = shadow_order_ref + 1
                # 深证停留50ms上证停留200ms
                delay_s = 0.05 if code.find("00") == 0 else 0.2
                self.cancel_buy(code, f"s_c_{shadow_order_ref}", order_sys_id=None,
                                order_ref=shadow_order_ref,
                                order_action_ref=None, delay_s=0.05)
                                order_action_ref=None, delay_s=delay_s)
        return ret
@@ -756,9 +756,10 @@
                                   pRspInfoField: "CTORATstpRspInfoField", nRequestID: "int",
                                   bIsLast: "bool") -> "void":
        if bIsLast != 1:
            logger_local_huaxin_trade_debug.info('OnRspQryShareholderAccount[%d]: InvestorID[%s] ExchangeID[%s] ShareholderID[%s]'
                        % (nRequestID, pShareholderAccountField.InvestorID, pShareholderAccountField.ExchangeID,
                           pShareholderAccountField.ShareholderID))
            logger_local_huaxin_trade_debug.info(
                'OnRspQryShareholderAccount[%d]: InvestorID[%s] ExchangeID[%s] ShareholderID[%s]'
                % (nRequestID, pShareholderAccountField.InvestorID, pShareholderAccountField.ExchangeID,
                   pShareholderAccountField.ShareholderID))
        else:
            logger.info('查询股东账户结束[%d] ErrorID[%d] ErrorMsg[%s]'
                        % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg))
@@ -1147,7 +1148,7 @@
def run(trade_response_: TradeResponse = None, queue_other_w_l2_r_: multiprocessing.Queue = None,
        queue_strategy_trade_write_=None,
        queue_strategy_trade_read=None,queue_strategy_trade_read_for_read=None):
        queue_strategy_trade_read=None, queue_strategy_trade_read_for_read=None):
    try:
        logger_system.info("交易进程ID:{}", os.getpid())
        logger_system.info(f"trade 线程ID:{tool.get_thread_id()}")
l2/cancel_buy_strategy.py
@@ -1679,8 +1679,8 @@
        # 统计未撤订单的数量与金额
        total_datas = local_today_datas.get(code)
        # 是否是下单5分钟内
        if tool.trade_time_sub(tool.get_now_time_str(), total_datas[real_order_index]['val']['time']) > 3 * 60:
            return False, "下单超过5分钟"
        if tool.trade_time_sub(tool.get_now_time_str(), total_datas[real_order_index]['val']['time']) > 2 * 60:
            return False, "下单超过2分钟"
        total_left_count = 0
        total_left_num = 0
l2/huaxin/huaxin_delegate_postion_manager.py
@@ -26,8 +26,9 @@
# 获取下单信息
def get_order_info(code):
    info = _place_order_info_dict.get(code)
    if info and time.time() - info[3] > 3:
        async_log_util.info(logger_real_place_order_position, "get_order_info 间隔3s以上:code-{}", code)
    TIME_SPACE_THRESHHOD = 3 if code.find("00") == 0 else 20
    if info and time.time() - info[3] > TIME_SPACE_THRESHHOD:
        async_log_util.info(logger_real_place_order_position, "get_order_info 间隔{}s以上:code-{}",TIME_SPACE_THRESHHOD, code)
        # 间隔3s以上就无效了
        info = None
        _place_order_info_dict.pop(code)
@@ -126,7 +127,7 @@
            real_place_index_info = shadow_place_order_index, RELIABILITY_TYPE_VIRTUAL
        else:
            real_place_index_info = real_place_index, RELIABILITY_TYPE_REAL
    elif time.time() - order_time >= estimate_time_space:
    elif tool.trade_time_sub(datas[-1]['val']['time'], exec_data['val']['time']) >= estimate_time_space:
        # 下单超过2s
        estimate_index = __compute_estimate_order_position(code, exec_data["index"])
        if estimate_index:
l2/l2_data_manager_new.py
@@ -439,10 +439,10 @@
                    # if tool.trade_time_sub(latest_time, "09:32:00") < 0 or l2.l2_data_util.L2DataUtil.is_same_time(now_time_str, latest_time):
                    cls.__process_not_order(code, start_index, end_index, capture_timestamp, is_first_code)
            async_log_util.info(logger_l2_process, "code:{} 处理数据范围: {}-{} 处理时间:{} 截图时间戳:{}", code,
            async_log_util.info(logger_l2_process, "code:{} 处理数据范围: {}-{} 处理时间:{} 线程ID:{}", code,
                                add_datas[0]["index"],
                                add_datas[-1]["index"], round(t.time() * 1000) - __start_time,
                                capture_timestamp)
                                l2_log.threadIds.get(code))
    # 处理未挂单
    @classmethod
@@ -979,7 +979,7 @@
        # 判断板块
        # (可以买的板块列表, 是否是独苗, 消息简介,可买的强势主线, 板块关键词)
        can_buy_result = cls.__get_can_buy_block(code)
        l2_log.debug(code, "获取到的板块信息:{}", can_buy_result)
        # l2_log.debug(code, "获取到的板块信息:{}", can_buy_result)
        if can_buy_result is None:
            return False, True, "尚未获取到板块信息"
        # -------量的约束--------
trade/huaxin/huaxin_trade_server.py
@@ -382,10 +382,11 @@
    @classmethod
    def l2_order(cls, code, _datas, timestamp):
        now_timestamp = int(time.time() * 1000)
        async_log_util.info(hx_logger_l2_orderdetail,
                            f"{code}#耗时:{int((time.time() - timestamp) * 1000)}-{now_timestamp}#{_datas}")
        thread_id = random.randint(0, 100000)
        l2_log.threadIds[code] = thread_id
        async_log_util.info(hx_logger_l2_orderdetail,
                            f"{code}#耗时:{int((time.time() - timestamp) * 1000)}-{thread_id}#{_datas}")
        # l2_data_log.l2_time_log(code, "开始处理L2逐笔委托")
        try:
            l2_data_manager_new.L2TradeDataProcessor.process_huaxin(code, _datas)