| | |
| | | def __is_radical_buy_with_block_up(cls, code, block, yesterday_limit_up_codes): |
| | | """ |
| | | 是否激进买(板块突然涨起来) |
| | | 1.老大和老二的涨停时间相差5分钟内 |
| | | 2.老三的涨停时间距离老大涨停在10分钟内就买 |
| | | 1.老二和老三的涨停时间相差5分钟内 |
| | | 2.老三不能买顺位到老四(老四与老三相差10分钟内) |
| | | 3.前2个票不能炸板(历史身位与现在身位一致) |
| | | 4.除开前两个代码可买老1与老2 |
| | | 5.买老2的情况:老1不满足买入条件 |
| | |
| | | if len(current_before_codes_info) < 2: |
| | | return False, f"前排代码小于2个:{current_before_codes_info}" |
| | | |
| | | |
| | | # 老大,老二必须相隔5分钟内 |
| | | # if current_before_codes_info[1][1] - current_before_codes_info[0][1] >= 5 * 60: |
| | | # return False, f"老大老二涨停时间必须间隔5分钟内" |
| | | |
| | | # 获取当前代码的涨停时间 |
| | | limit_up_timestamp = LimitUpDataConstant.get_first_limit_up_time(code) |
| | | if not limit_up_timestamp: |
| | | limit_up_timestamp = time.time() |
| | | if limit_up_timestamp - current_before_codes_info[0][1] >= 15 * 60: |
| | | return False, f"距离老大涨停已过去15分钟({current_before_codes_info[0]})" |
| | | |
| | | # 当前代码开1不能买 |
| | | if limit_up_timestamp < kpl_block_util.open_limit_up_time_range[1]: |
| | | return False, f"当前代码开1" |
| | | |
| | | 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[0]})" |
| | | |
| | | history_index, history_before_codes_info = cls.__get_history_index(code, block, set()) |
| | | history_before_codes = [x[0] for x in history_before_codes_info] |
| | | |
| | | # 判断是否是老3且与老二间隔5分钟以内 |
| | | if current_index == 2 and history_index == 2: |
| | | if limit_up_timestamp - current_before_codes_info[-1][1] <= 5 * 60: |
| | | if RedicalBuyDataManager.can_buy(code)[0]: |
| | | return True, f"老二老三间隔5分钟内:前排代码-{current_before_codes_info}" |
| | | |
| | | if current_before_codes_info[0][1] < kpl_block_util.open_limit_up_time_range[1]: |
| | | return False, f"有开1:{current_before_codes_info}" |
| | | |
| | | # 前两个代码是否有炸板 |
| | | dif_codes = set(history_before_codes[:2]) - set(current_before_codes[:2]) |
| | | if dif_codes: |
| | | return False, f"前2代码有炸板:{dif_codes}" |
| | | # 不计算前2的代码 |
| | | exclude_codes = set(current_before_codes[:2]) |
| | | |
| | | exclude_codes = set() |
| | | for x in current_before_codes: |
| | | if x[1] < kpl_block_util.open_limit_up_time_range[1]: |
| | | exclude_codes.add(x[0]) |
| | | # 除去前二代码与开1代码之后是否为首板老大:所有开1的视为1个 |
| | | 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]) |
| | | else: |
| | | exclude_codes |= set(current_before_codes[:2]) |
| | | |
| | | open_limit_up_code_dict = kpl_data_constant.open_limit_up_code_dict_for_radical_buy |
| | | if open_limit_up_code_dict: |
| | | exclude_codes |= set(open_limit_up_code_dict.keys()) |
| | | history_index, history_before_codes_info = cls.__get_history_index(code, block, yesterday_limit_up_codes, |
| | | exclude_codes) |
| | | if history_index > 1: |
| | | return False, f"排除前2,目标代码位于历史身位-{history_index + 1},前排代码:{history_before_codes_info}" |
| | | if history_index == 1: |
| | | elif history_index == 1: |
| | | # 首板老2,判断前面的老大是否是属于不能买的范畴 |
| | | pre_code = history_before_codes_info[0][0] |
| | | # pre_code不能买,才能买 |
| | | if RedicalBuyDataManager.can_buy(pre_code)[0]: |
| | | return False, f"前排代码可买:{pre_code}" |
| | | # 距离前一个是否在10分钟内 |
| | | if tool.trade_time_sub(tool.timestamp_format(limit_up_timestamp, '%H:%M:%S'), |
| | | tool.timestamp_format(history_before_codes_info[-1][1], '%H:%M:%S')) >= 10 * 60: |
| | | return False, f"距离上个不能买的代码涨停已过去10分钟({history_before_codes_info[0]})" |
| | | else: |
| | | # 距离上个代码涨停5分钟以内 |
| | | 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')) >= 5 * 60: |
| | | return False, f"距离上个代码涨停已过去5分钟({current_before_codes_info[-1]})" |
| | | |
| | | return True, f"满足买入需求: 前排代码-{current_before_codes_info}" |
| | | |
| | | @classmethod |
| | | def __is_re_limit_up(cls, code, block): |
| | | # 获取身位 |
| | | current_index, current_before_codes_info = cls.__get_current_index(code, block, set()) |
| | | history_index, history_before_codes_info = cls.__get_history_index(code, block, set()) |
| | | if current_index != history_index: |
| | | return False, f"有其他炸板" |
| | | if current_index > 1: |
| | | return False, f"不是前2的板块" |
| | | history_codes = set() |
| | | # 获取板块炸板情况 |
| | | for k in LimitUpDataConstant.history_limit_up_datas: |
| | | _code = k[3] |
| | | blocks = LimitUpDataConstant.get_blocks_with_history(_code) |
| | | blocks = BlockMapManager().filter_blocks(blocks) |
| | | # 不是这个板块 |
| | | if block in blocks: |
| | | history_codes.add(_code) |
| | | if len(history_codes) <= 4: |
| | | return False, f"板块历史涨停小于4个:{history_codes}" |
| | | # 获取当前涨停数量 |
| | | current_codes = set() |
| | | for k in LimitUpDataConstant.current_limit_up_datas: |
| | | _code = k[0] |
| | | blocks = LimitUpDataConstant.get_blocks_with_history(_code) |
| | | if not blocks: |
| | | blocks = set() |
| | | blocks = BlockMapManager().filter_blocks(blocks) |
| | | # 不是这个板块 |
| | | if block in blocks: |
| | | current_codes.add(_code) |
| | | current_codes.add(code) |
| | | diff = history_codes - current_codes |
| | | if diff: |
| | | return False, f"板块炸板不止当前票:{diff}" |
| | | return True, "" |
| | | |
| | | @classmethod |
| | | def is_radical_buy(cls, code, yesterday_limit_up_codes): |
| | |
| | | can_buy_blocks.add(b) |
| | | msges.append(f"【{b}】:{result[1]}") |
| | | fmsges.append("板块快速启动判断##" + ",".join(msges)) |
| | | |
| | | if not can_buy_blocks: |
| | | for b in keys_: |
| | | result = cls.__is_re_limit_up(code, b) |
| | | if result[0]: |
| | | can_buy_blocks.add(b) |
| | | |
| | | return can_buy_blocks, " **** ".join(fmsges) |
| | | |
| | | |