| | |
| | | from third_data.third_blocks_manager import BlockMapManager, CodeThirdBlocksManager |
| | | from trade.buy_money_count_setting import RadicalBuyBlockCodeCountManager |
| | | from trade.order_statistic import DealAndDelegateWithBuyModeDataManager |
| | | from trade.radical_buy_data_manager import RadicalBuyDataManager |
| | | from trade.radical_buy_data_manager import RadicalBuyDataManager, BlockPlaceOrderRecordManager |
| | | from trade.trade_data_manager import RadicalBuyDealCodesManager |
| | | from utils import global_util, tool, buy_condition_util |
| | | from log_module import log, async_log_util |
| | | from db import redis_manager_delegate as redis_manager |
| | |
| | | kpl_data_constant.open_limit_up_code_dict_for_radical_buy = temp_dict |
| | | |
| | | @classmethod |
| | | def __get_current_index(cls, code, block, yesterday_limit_up_codes, exclude_codes=None, limit_up_time=None): |
| | | def __get_current_index(cls, code, block, yesterday_limit_up_codes, exclude_codes=None, limit_up_time=None, |
| | | ignore_open_limit_up=True): |
| | | """ |
| | | 获取当前涨停身位 |
| | | @param code: |
| | | @param block: |
| | | @param yesterday_limit_up_codes: |
| | | @param exclude_codes: |
| | | @param limit_up_time: |
| | | @param ignore_open_limit_up: 是否忽略开1的代码 |
| | | @return: 索引,前排代码信息([(代码, 涨停时间)]) |
| | | """ |
| | | if exclude_codes is None: |
| | |
| | | limit_up_time = time.time() |
| | | for k in LimitUpDataConstant.current_limit_up_datas: |
| | | _code = k[0] |
| | | # 剔除4板以上的板 |
| | | if kpl_util.get_high_level_count(k[4]) >= 4: |
| | | continue |
| | | |
| | | if _code in exclude_codes: |
| | | continue |
| | | blocks = LimitUpDataConstant.get_blocks_with_history(_code) |
| | | if not blocks: |
| | | blocks = set() |
| | | blocks = BlockMapManager().filter_blocks(blocks) |
| | | if _code == code: |
| | | # 获取当前代码涨停时间 |
| | | limit_up_time = int(k[2]) |
| | |
| | | # 不是这个板块 |
| | | if block not in blocks: |
| | | continue |
| | | |
| | | # 剔除4板以上的板 |
| | | if kpl_util.get_high_level_count(k[4]) >= 4 and len(blocks) > 1: |
| | | continue |
| | | |
| | | if not tool.is_can_buy_code(_code): |
| | | continue |
| | | # 剔除开1的数据 |
| | | if timestamp_start <= int(k[2]) < timestamp_end: |
| | | if ignore_open_limit_up and timestamp_start <= int(k[2]) < timestamp_end: |
| | | continue |
| | | # 剔除高位板 |
| | | if _code in yesterday_limit_up_codes: |
| | |
| | | return current_index, before_codes_info |
| | | |
| | | @classmethod |
| | | def __get_history_index(cls, code, block, yesterday_limit_up_codes, exclude_codes=None): |
| | | def __get_history_index(cls, code, block, yesterday_limit_up_codes, exclude_codes=None, ignore_open_limit_up=True): |
| | | """ |
| | | 获取历史涨停身位 |
| | | @param code: |
| | | @param block: |
| | | @param current_limit_up_datas: 昨日涨停代码 |
| | | @param current_limit_up_codes: 目前的涨停代码 |
| | | @param yesterday_limit_up_codes: |
| | | @param exclude_codes: |
| | | @param ignore_open_limit_up: 是否忽略开1代码 |
| | | @return: |
| | | """ |
| | | if exclude_codes is None: |
| | |
| | | limit_up_space_ge_60s_codes = set() |
| | | for k in LimitUpDataConstant.history_limit_up_datas: |
| | | _code = k[3] |
| | | |
| | | # 剔除4板以上的板 |
| | | if kpl_util.get_high_level_count(k[12]) >= 4: |
| | | continue |
| | | |
| | | if _code in exclude_codes: |
| | | continue |
| | | blocks = LimitUpDataConstant.get_blocks_with_history(_code) |
| | | if _code == code: |
| | | # 获取当前代码涨停时间 |
| | | limit_up_time = int(k[5]) |
| | | continue |
| | | |
| | | blocks = LimitUpDataConstant.get_blocks_with_history(_code) |
| | | # 不是这个板块 |
| | | if block not in blocks: |
| | | continue |
| | | # 剔除4板以上且板块数量大于1个 |
| | | if kpl_util.get_high_level_count(k[12]) >= 4 and len(blocks) > 1: |
| | | continue |
| | | |
| | | if not tool.is_can_buy_code(_code): |
| | | continue |
| | | # 剔除开1的数据 |
| | | if timestamp_start <= int(k[5]) < timestamp_end: |
| | | if ignore_open_limit_up and timestamp_start <= int(k[5]) < timestamp_end: |
| | | continue |
| | | # 剔除高位板 |
| | | if _code in yesterday_limit_up_codes: |
| | |
| | | if history_index == 1: |
| | | # 当前代码为老2,要判断老大是否可买 |
| | | if RadicalBuyDataManager.is_code_can_buy(history_before_codes_info[0][0], |
| | | DealAndDelegateWithBuyModeDataManager().get_deal_codes(), is_refered=True)[0]: |
| | | DealAndDelegateWithBuyModeDataManager().get_deal_codes(), |
| | | is_refered=True)[0]: |
| | | return False, f"开1数量:{count},前排代码可买:{history_before_codes_info[0]}" |
| | | return True, f"开1数量:{count},前排代码不可买:{history_before_codes_info[0]},历史前排-{history_before_codes_info},开1代码-{open_limit_up_block_codes}" |
| | | return True, f"开1数量:{count},历史-{history_index + 1} 实时-{current_index + 1}, 前排代码-{current_before_codes_info}, 开1代码-{open_limit_up_block_codes}" |
| | |
| | | return index, before_codes_info |
| | | temp_index = index |
| | | temp_before_codes_info = [] |
| | | deal_codes = RadicalBuyDealCodesManager().get_deal_codes() |
| | | for b in before_codes_info: |
| | | # 当作目标票获取扫入板块 |
| | | code_ = b[0] |
| | |
| | | if not need_delete: |
| | | if radical_buy_data_manager.ExcludeIndexComputeCodesManager.is_in_cache(code_): |
| | | need_delete = True |
| | | # 判断是不是扫了没有扫进入 |
| | | if not need_delete: |
| | | if code_ in BlockPlaceOrderRecordManager().get_codes() and code_ not in deal_codes: |
| | | need_delete = True |
| | | |
| | | if need_delete: |
| | | temp_index -= 1 |
| | | else: |
| | |
| | | |
| | | 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]})" |
| | | return False, f"距离上个代码涨停已过去10分钟({current_before_codes_info[-1]})" |
| | | |
| | | # 包含高位板的整体排序 |
| | | all_history_index, all_history_before_codes_info = cls.__get_history_index(code, block, set()) |
| | |
| | | # 前两个代码是否有炸板 |
| | | dif_codes = set(all_history_before_codes[:2]) - set(current_before_codes[:2]) |
| | | if dif_codes: |
| | | return False, f"前2代码有炸板:{dif_codes}" |
| | | return False, f"前2代码有炸板:{dif_codes}, 前排代码:{all_history_before_codes}" |
| | | # 前排代码炸板不能>=2个 |
| | | dif_codes = set(all_history_before_codes) - set(current_before_codes) |
| | | if len(dif_codes) >= 2: |
| | |
| | | pre_code = history_before_codes_info[0][0] |
| | | # pre_code不能买,才能买 |
| | | if RadicalBuyDataManager.is_code_can_buy(pre_code, |
| | | DealAndDelegateWithBuyModeDataManager().get_deal_codes(), is_refered=True)[0]: |
| | | DealAndDelegateWithBuyModeDataManager().get_deal_codes(), |
| | | is_refered=True)[0]: |
| | | return False, f"前排代码可买:{pre_code}" |
| | | # 前面一个代码不能买,前一个代码必须与前前个代码涨停时间相差15分钟内 |
| | | for i in range(len(all_history_before_codes_info) - 1, -1, -1): |