Administrator
2024-06-13 cbe19ea6066a600cbd0b5110db5d43f8252d14a8
L撤成交进度相关改进
4个文件已修改
84 ■■■■ 已修改文件
cancel_strategy/s_l_h_cancel_strategy.py 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code_attribute/code_data_util.py 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/huaxin/huaxin_target_codes_manager.py 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
log_module/log_export.py 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cancel_strategy/s_l_h_cancel_strategy.py
@@ -772,7 +772,7 @@
            return
        # 获取成交进度位与真实下单位置
        real_place_order_index_info = self.__real_place_order_index_dict.get(code)
        last_trade_progress_index = self.__last_trade_progress_dict.get(code)
        last_trade_progress_index, is_default = TradeBuyQueue().get_traded_index(code)
        if big_sell_info:
            last_trade_progress_index = big_sell_info[0]
@@ -959,29 +959,26 @@
        self.__real_place_order_index_dict[code] = (index, is_default)
        RedisUtils.setex_async(self.__db, f"l_cancel_real_place_order_index-{code}", tool.get_expire(),
                               json.dumps((index, is_default)))
        trade_index, is_default = TradeBuyQueue().get_traded_index(code)
        if trade_index is None:
            trade_index = 0
        if buy_single_index is not None:
            if code in self.__last_trade_progress_dict:
                # L撤从成交进度位开始计算
                self.compute_watch_index(code, buy_single_index,
                                         self.__last_trade_progress_dict[code], index)
            else:
                self.compute_watch_index(code, buy_single_index, buy_single_index, index)
            # L后撤从成交进度位开始计算
            self.compute_watch_index(code, buy_single_index, trade_index, index)
        self.__compute_trade_progress_near_by_indexes(code, buy_single_index, trade_index, index)
        if self.__last_trade_progress_dict.get(code):
            self.__compute_trade_progress_near_by_indexes(code, buy_single_index,
                                                          self.__last_trade_progress_dict.get(code) + 1, index)
        else:
            self.__compute_trade_progress_near_by_indexes(code, buy_single_index, buy_single_index, index)
    # 重新计算L上
    # 重新计算L前
    def re_compute_l_up_watch_indexes(self, code, buy_single_index):
        if code not in self.__last_trade_progress_dict:
        trade_index, is_default = TradeBuyQueue().get_traded_index(code)
        if trade_index is None:
            return
        if code not in self.__real_place_order_index_dict:
            return
        if code not in self.__last_l_up_compute_info or time.time() - self.__last_l_up_compute_info[code][0] >= 3:
            self.__compute_trade_progress_near_by_indexes(code, buy_single_index,
                                                          self.__last_trade_progress_dict.get(code) + 1,
                                                          trade_index + 1,
                                                          self.__real_place_order_index_dict.get(code)[0])
    # 计算范围内的成交位临近未撤大单
@@ -1043,7 +1040,10 @@
            if not l_down_cancel_info:
                return
            trade_progress = self.__last_trade_progress_dict.get(code)
            trade_progress, is_default = TradeBuyQueue().get_traded_index(code)
            if trade_progress is None:
                trade_progress = 0
            if trade_progress is None:
                return
@@ -1319,7 +1319,9 @@
            if rate >= thresh_cancel_rate:
                # 计算成交进度位置到当前下单位置的纯买额
                real_place_order_index_info = self.__real_place_order_index_dict.get(code)
                trade_progress_index = self.__last_trade_progress_dict.get(code)
                trade_progress_index, is_default = TradeBuyQueue().get_traded_index(code)
                if trade_progress_index is None:
                    trade_progress_index = 0
                if real_place_order_index_info and trade_progress_index:
                    total_num = 0
                    thresh_hold_money = l2_trade_factor.L2PlaceOrderParamsManager.get_base_m_val(code)
@@ -1356,7 +1358,9 @@
        watch_indexes_info = self.__get_watch_indexes_cache(code)
        if not watch_indexes_info:
            return True
        trade_index = self.__last_trade_progress_dict.get(code)
        trade_index, is_default = TradeBuyQueue().get_traded_index(code)
        if trade_index is None:
            trade_index = 0
        if trade_index is None:
            return True
        # 计算已经成交的比例
code_attribute/code_data_util.py
@@ -84,7 +84,9 @@
        @return:
        """
        fresults = cls.__mysql.select_one(f"select count(code) from kpl_zylt_volume where update_time >= '{tool.get_now_date_str()}'")
        return fresults[0]
        if fresults:
            return fresults[0]
        return 0
l2/huaxin/huaxin_target_codes_manager.py
@@ -10,7 +10,7 @@
from code_attribute.code_data_util import ZYLTGBUtil
from db import redis_manager_delegate as redis_manager
from log_module import async_log_util
from log_module.log import logger_l2_codes_subscript
from log_module.log import logger_l2_codes_subscript, logger_debug
from third_data import kpl_data_manager, kpl_api
from trade import current_price_process_manager
from utils import tool, global_util, init_data_util
@@ -144,7 +144,7 @@
            tick_datas = first_target_code_data_processor.process_first_codes_datas(flist, request_id)
            current_price_process_manager.accept_prices(tick_datas, request_id)
        except Exception as e:
            logging.exception(e)
            logger_debug.exception(e)
if __name__ == "__main__":
log_module/log_export.py
@@ -123,22 +123,24 @@
    if not date:
        date = datetime.datetime.now().strftime("%Y-%m-%d")
    pos_list = []
    with open("{}/logs/gp/l2/l2_process.{}.log".format(constant.get_path_prefix(), date), mode='r',
              encoding="utf-8") as f:
        while True:
            line = f.readline()
            if not line:
                break
            if line.find("code:{}".format(code)) < 0:
                continue
            time_ = __get_log_time(line)
            line = line[line.find("处理数据范围") + len("处理数据范围") + 1:line.find("处理时间")].strip()
            if len(pos_list) == 0 or pos_list[-1][1] < int(line.split("-")[0]):
                if int("093000") <= int(time_.replace(":", "")) <= int("150000"):
                    try:
                        pos_list.append((int(line.split("-")[0]), int(line.split("-")[1])))
                    except Exception as e:
                        logging.exception(e)
    path_ = "{}/logs/gp/l2/l2_process.{}.log".format(constant.get_path_prefix(), date)
    if os.path.exists(path_):
        with open(path_, mode='r',
                  encoding="utf-8") as f:
            while True:
                line = f.readline()
                if not line:
                    break
                if line.find("code:{}".format(code)) < 0:
                    continue
                time_ = __get_log_time(line)
                line = line[line.find("处理数据范围") + len("处理数据范围") + 1:line.find("处理时间")].strip()
                if len(pos_list) == 0 or pos_list[-1][1] < int(line.split("-")[0]):
                    if int("093000") <= int(time_.replace(":", "")) <= int("150000"):
                        try:
                            pos_list.append((int(line.split("-")[0]), int(line.split("-")[1])))
                        except Exception as e:
                            logging.exception(e)
    return pos_list