Administrator
2024-06-17 30af2f297f4e412bac36c9678bb68ffb2f4c0709
文件读取bug修复
5个文件已修改
49 ■■■■ 已修改文件
cancel_strategy/s_l_h_cancel_strategy.py 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/l1_client.py 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
log_module/log_analyse.py 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
log_module/log_export.py 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_trade_server.py 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cancel_strategy/s_l_h_cancel_strategy.py
@@ -1252,12 +1252,18 @@
        # 计算监听的总条数
        total_num = 0
        max_num = 0
        thresh_hold_rate, must_buy = LCancelRateManager.get_cancel_rate(code,
                                                                        total_data[buy_exec_index]["val"]["time"])
        # 这是下单位置之后的索引: key为字符串
        after_place_order_index_dict = self.__get_cancel_l_down_after_place_order_index_dict(code)
        if after_place_order_index_dict is None:
            after_place_order_index_dict = {}
        for wi in watch_indexes:
            if str(wi) in after_place_order_index_dict:
                # 如果加红就需要计算分母
                if must_buy:
                    total_num += total_data[wi]["val"]["num"] * (
                            10 - after_place_order_index_dict[str(wi)]) // 10
                continue
            total_num += total_data[wi]["val"]["num"] * total_data[wi]["re"]
            if total_data[wi]["val"]["num"] > max_num:
@@ -1304,8 +1310,7 @@
                #     return True, total_data[-1]
            rate = round(canceled_num / total_num, 3)
            thresh_hold_rate, must_buy = LCancelRateManager.get_cancel_rate(code,
                                                                            total_data[buy_exec_index]["val"]["time"])
            # 除开最大单的影响权重
            if not must_buy:
                temp_thresh_hold_rate = round((total_num - max_num) * 0.9 / total_num, 2)
huaxin_client/l1_client.py
@@ -113,11 +113,12 @@
            return
        if pMarketDataField.SecurityName.find("ST") >= 0:
            return
        close_price = round(pMarketDataField.UpperLimitPrice / out_tool.get_limit_up_rate(pMarketDataField.SecurityID), 2)
        close_price = round(pMarketDataField.UpperLimitPrice / out_tool.get_limit_up_rate(pMarketDataField.SecurityID),
                            2)
        rate = round((pMarketDataField.LastPrice - close_price) * 100 / close_price, 2)
        if out_tool.get_limit_up_rate(pMarketDataField.SecurityID) > 1.1001:
            # 涨停板20%以上的打折
            rate = rate/2
            rate = rate / 2
        # print(pMarketDataField.SecurityID, pMarketDataField.SecurityName, rate, pMarketDataField.Volume)
@@ -260,20 +261,18 @@
            threshold_rate = constant.L1_MIN_RATE_PRE if int(tool.get_now_time_str().replace(":", "")) < int(
                "094000") else constant.L1_MIN_RATE
            for d in list_:
                if d[2] >= threshold_rate:
                    # 涨幅小于5%的需要删除
                    flist.append(d)
                if d[0] in __position_codes:
                    plist.append(d)
            flist.sort(key=lambda x: x[2], reverse=True)
            datas = flist[:1000]
            # 将持仓股加入进去
            datas.extend(plist)
            print("代码数量:", len(datas))
            logger_l2_codes_subscript.info("开始#华鑫L1上传代码:数量-{}", len(datas))
            __upload_codes_info(queue_l1_w_strategy_r, datas)
            if len(datas) > 0:
                logger_l2_codes_subscript.info("开始#华鑫L1上传代码:数量-{}", len(datas))
                __upload_codes_info(queue_l1_w_strategy_r, datas)
        except Exception as e:
            logging.exception(e)
        finally:
log_module/log_analyse.py
@@ -63,8 +63,8 @@
# 分析L2数据传输时间
def analyze_l2_data_transformation(path_):
    with open(path_, 'r', encoding="utf-8") as f:
        while True:
            line = f.readline()
        lines = f.readlines()
        for line in lines:
            if not line:
                break
            try:
log_module/log_export.py
@@ -82,8 +82,8 @@
        date = tool.get_now_date_str()
    try:
        with open("{}/logs/gp/l2/l2_data.{}.log".format(constant.get_path_prefix(), date), mode='r') as f:
            while True:
                data = f.readline()
            lines = f.readlines()
            for data in lines:
                if not data:
                    break
                index = data.find(' - ') + 2
@@ -127,8 +127,8 @@
    try:
        with open(path_, mode='r',
                  encoding="utf-8") as f:
            while True:
                line = f.readline()
            lines = f.readlines()
            for line in lines:
                if not line:
                    break
                if line.find("code:{}".format(code)) < 0:
@@ -154,8 +154,8 @@
    with open("{}/logs/gp/l2/l2_trade.{}.log".format(constant.get_path_prefix(), date), mode='r',
              encoding="utf-8") as f:
        latest_single = [None, None]
        while True:
            line = f.readline()
        lines = f.readlines()
        for line in lines:
            if not line:
                break
            if line.find("code={}".format(code)) < 0:
@@ -201,8 +201,8 @@
    pos_list = []
    with open("{}/logs/gp/l2/l2_real_place_order_position.{}.log".format(constant.get_path_prefix(), date), mode='r',
              encoding="utf-8") as f:
        while True:
            line = f.readline()
        lines = f.readlines()
        for line in lines:
            if not line:
                break
            if line.find("{}-".format(code)) < 0:
@@ -305,8 +305,8 @@
    msg_list = []
    if os.path.exists(path_str):
        with open(path_str, mode='r', encoding="utf-8") as f:
            while True:
                line = f.readline()
            lines = f.readlines()
            for line in lines:
                if not line:
                    break
                msg_list.append(line)
trade/huaxin/huaxin_trade_server.py
@@ -374,7 +374,7 @@
        datas = data["data"]
        cls.__save_l1_current_price(datas)
        # 9:30之前采用非线程
        if int(tool.get_now_time_str().replace(":","")) < int("093000"):
        if int(tool.get_now_time_str().replace(":", "")) < int("093000"):
            HuaXinL1TargetCodesManager.set_level_1_codes_datas(datas, request_id=request_id)
        else:
            cls.__process_l1_data_thread_pool.submit(
@@ -1071,7 +1071,6 @@
            except Exception as e:
                logger_debug.exception(e)
                fdata["trade_channel_access"] = 0
            # 获取CPU与内存适用情况
            memory_info = psutil.virtual_memory()