| | |
| | | __db = 3 |
| | | __code_limit_up_info_dict = {} |
| | | __redis_manager = redis_manager.RedisManager(3) |
| | | # 记录最近60s的买1数据(炸板要清除) |
| | | # 格式:{"代码":[(时间,(价格,量)),...]} |
| | | __latest_60s_buy1_list_dict = {} |
| | | |
| | | def __init__(self): |
| | | self.__load_data() |
| | |
| | | @param sell1_info: 卖1信息 (价格,量) |
| | | @return: |
| | | """ |
| | | |
| | | if abs(buy1_info[0] - limit_up_price) < 0.0001: |
| | | # 涨停 |
| | | if code not in self.__latest_60s_buy1_list_dict: |
| | | self.__latest_60s_buy1_list_dict[code] = [] |
| | | self.__latest_60s_buy1_list_dict[code].append((time_str, buy1_info)) |
| | | # 清除60s之前的数据 |
| | | max_count = len(self.__latest_60s_buy1_list_dict[code]) |
| | | while True: |
| | | max_count -= 1 |
| | | if max_count <= 0: |
| | | break |
| | | if self.__latest_60s_buy1_list_dict[code]: |
| | | if tool.trade_time_sub(time_str, self.__latest_60s_buy1_list_dict[code][0][0]) > 60: |
| | | self.__latest_60s_buy1_list_dict[code].pop(0) |
| | | else: |
| | | break |
| | | |
| | | if buy1_info[0] * buy1_info[1] > 1e7: |
| | | # 1000w的封单才算涨停 |
| | | if code not in self.__code_limit_up_info_dict: |
| | | self.__code_limit_up_info_dict[code] = [time_str, ''] |
| | | self.__set_code_limit_up_info(code, self.__code_limit_up_info_dict[code]) |
| | | else: |
| | | if code in self.__latest_60s_buy1_list_dict: |
| | | self.__latest_60s_buy1_list_dict.pop(code) |
| | | # 尚未涨停,判断炸板 |
| | | if sell1_info and sell1_info[1] > 0: |
| | | # 出现买2 |
| | |
| | | return True |
| | | return False |
| | | |
| | | def is_almost_open_limit_up(self, code): |
| | | """ |
| | | 是否即将炸板 |
| | | @param code: |
| | | @return: |
| | | """ |
| | | buy1_list = self.__latest_60s_buy1_list_dict.get(code) |
| | | if not buy1_list: |
| | | return False |
| | | if len(buy1_list) < 2: |
| | | return False |
| | | latest_buy1 = buy1_list[-1][1] |
| | | if latest_buy1[0]*latest_buy1[1] > 500e4: |
| | | # 最近的买1要小于500万 |
| | | return False |
| | | latest_volume = latest_buy1[1] |
| | | max_volume = max([x[1][1] for x in buy1_list]) |
| | | if max_volume//10 > latest_volume: |
| | | # 当前量小于最大量的1/10 |
| | | return True |
| | | return False |
| | | |
| | | |
| | | class RadicalBuyDataManager: |
| | | @classmethod |