Administrator
2024-11-14 eadc6b2c939d7b412b942703fbcdba63c3f2e3e0
触发扫入的成交比例阈值修改
3个文件已修改
41 ■■■■■ 已修改文件
constant.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
servers/data_server.py 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/buy_radical/radical_buy_data_manager.py 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constant.py
@@ -108,7 +108,7 @@
BUY_SCORE_RANK_3 = 260
# 开盘啦
KPL_INVALID_BLOCKS = {"一季报增长", "二季报增长", "三季报增长", "四季报增长", "业绩增长", "中报增长", "年报增长", "年报预增", "无", "次新股", "ST摘帽", "超跌",
KPL_INVALID_BLOCKS = {"一季报增长", "二季报增长", "三季报增长", "四季报增长", "业绩增长", "中报增长", "年报增长", "年报预增", "无", "次新股", "ST摘帽", "ST板块", "超跌",
                      "股权转让", "并购重组", "再融资", "年报预增", " 专精特新", "壳资源", "行业龙头", "科创板", "实控人变更"}
# 是否开启API交易
API_TRADE_ENABLE = True
servers/data_server.py
@@ -382,7 +382,11 @@
            response_data = json.dumps(
                {"code": 0, "data": indexes})
        elif url.path == "/kpl/get_limit_up_statistic_infos":
            response_data = self.__get_limit_up_statistic_infos()
            try:
                # 统计最近的涨停板块
                response_data = self.__get_limit_up_statistic_infos()
            except Exception as e:
                logger_debug.exception(e)
        elif url.path == "/kpl/get_plate_info":
            ps_dict = dict([(k, v[0]) for k, v in parse_qs(url.query).items()])
trade/buy_radical/radical_buy_data_manager.py
@@ -342,6 +342,10 @@
        limit_up_timestamp = cls.__get_limit_up_timestamp(code)
        if tool.get_now_time_as_int() > 100000:
            return False, "超过生效时间"
        # 开始买的身位 2:从老三开始买  1: 从老二开始买
        START_BUY_RANK = 2
        # 根据板块聚合数据
        open_limit_up_block_codes_dict = {}
        for c in kpl_data_constant.open_limit_up_code_dict_for_radical_buy:
@@ -489,6 +493,8 @@
        @param yesterday_limit_up_codes:
        @return:
        """
        # 开始买的身位 2:从老三开始买  1: 从老二开始买
        START_BUY_RANK = 1
        # 获取当前代码的涨停时间
        limit_up_timestamp = cls.__get_limit_up_timestamp(code)
@@ -499,16 +505,18 @@
                                                                           ignore_open_limit_up=False)
        current_before_codes = [x[0] for x in current_before_codes_info]
        if len(current_before_codes_info) < 2:
            return False, f"前排代码小于2个:{current_before_codes_info}"
        if len(current_before_codes_info) < START_BUY_RANK:
            return False, f"前排代码小于{START_BUY_RANK}个:{current_before_codes_info}"
        # 当前代码开1不能买
        if limit_up_timestamp < kpl_block_util.open_limit_up_time_range[1]:
            return False, f"当前代码开1"
        THRESHOLD_MINUTES = 30
        if tool.trade_time_sub(tool.timestamp_format(limit_up_timestamp, '%H:%M:%S'),
                               tool.timestamp_format(current_before_codes_info[-1][1], '%H:%M:%S')) >= 10 * 60:
            return False, f"距离上个代码涨停已过去10分钟({current_before_codes_info[-1]})"
                               tool.timestamp_format(current_before_codes_info[-1][1],
                                                     '%H:%M:%S')) >= THRESHOLD_MINUTES * 60:
            return False, f"距离上个代码涨停已过去{THRESHOLD_MINUTES}分钟({current_before_codes_info[-1]})"
        # 包含高位板的整体排序
        all_history_index, all_history_before_codes_info = cls.__get_history_index(code, block, set(),
@@ -532,9 +540,9 @@
        open_count = len(exclude_codes)
        if open_count > 0 and open_count + 1 <= len(current_before_codes):
            # 前排有开1
            exclude_codes |= set(current_before_codes[open_count:open_count + 1])
            exclude_codes |= set(current_before_codes[open_count:open_count + START_BUY_RANK - 1])
        else:
            exclude_codes |= set(current_before_codes[:2])
            exclude_codes |= set(current_before_codes[:START_BUY_RANK])
        open_limit_up_code_dict = kpl_data_constant.open_limit_up_code_dict_for_radical_buy
        if open_limit_up_code_dict:
@@ -551,7 +559,7 @@
        # 获取本板块买入代码的最大数量
        max_count = RadicalBuyBlockCodeCountManager().get_block_code_count(block)
        if history_index > max_count:
            return False, f"排除前2,目标代码位于历史身位-{history_index + 1},前排代码:{history_before_codes_info}, 板块最多可买{max_count}"
            return False, f"排除前{START_BUY_RANK},目标代码位于历史身位-{history_index + 1},前排代码:{history_before_codes_info}, 板块最多可买{max_count}"
        if max_count == 1:
            if history_index == 1:
@@ -568,12 +576,13 @@
                # 前面一个代码不能买,前一个代码必须与前前个代码涨停时间相差15分钟内
                for i in range(len(all_history_before_codes_info) - 1, -1, -1):
                    if all_history_before_codes_info[i][0] == pre_code:
                        if tool.trade_time_sub(tool.timestamp_format(all_history_before_codes_info[i][1], '%H:%M:%S'),
                                               tool.timestamp_format(all_history_before_codes_info[i - 1][1],
                                                                     '%H:%M:%S')) >= 15 * 60:
                            return False, f"被顺位代码({pre_code}) 与上个代码涨停时间>=15分钟 ({all_history_before_codes_info[i]}##{all_history_before_codes_info[i - 1]})"
                        if i > 0 and tool.trade_time_sub(
                                tool.timestamp_format(all_history_before_codes_info[i][1], '%H:%M:%S'),
                                tool.timestamp_format(all_history_before_codes_info[i - 1][1],
                                                      '%H:%M:%S')) >= THRESHOLD_MINUTES * 60:
                            return False, f"被顺位代码({pre_code}) 与上个代码涨停时间>={THRESHOLD_MINUTES}分钟 ({all_history_before_codes_info[i]}##{all_history_before_codes_info[i - 1]})"
                        else:
                            return True, f"被顺位代码({pre_code}) 与上个代码涨停时间<15分钟 ({all_history_before_codes_info[i]}##{all_history_before_codes_info[i - 1]})"
                            return True, f"被顺位代码({pre_code}) 与上个代码涨停时间<{THRESHOLD_MINUTES}分钟 ({all_history_before_codes_info[i]})"
                return False, f"没找到顺位代码({pre_code})的前排代码"
            else:
                # 代码为目标代码