| | |
| | | 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: |
| | |
| | | @param yesterday_limit_up_codes: |
| | | @return: |
| | | """ |
| | | # 开始买的身位 2:从老三开始买 1: 从老二开始买 |
| | | START_BUY_RANK = 1 |
| | | |
| | | # 获取当前代码的涨停时间 |
| | | limit_up_timestamp = cls.__get_limit_up_timestamp(code) |
| | |
| | | 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(), |
| | |
| | | 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: |
| | |
| | | # 获取本板块买入代码的最大数量 |
| | | 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: |
| | |
| | | # 前面一个代码不能买,前一个代码必须与前前个代码涨停时间相差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: |
| | | # 代码为目标代码 |