| | |
| | | __latest_data = {} |
| | | __current_buy_1_price = {} |
| | | __buy1_price_info_cache = {} |
| | | # 买1的金额 |
| | | __latest_buy1_money_dict = {} |
| | | # 最近3分钟内的买1金额 |
| | | __latest_3m_buy1_money_list_dict = {} |
| | | __open_limit_up_lowest_price_cache = {} |
| | | |
| | | __instance = None |
| | |
| | | |
| | | # 处理 |
| | | |
| | | def process(self, code, buy_1_price, time_str, limit_up_price, sell_1_price, sell_1_volumn): |
| | | data_str = f"{buy_1_price},{time_str},{limit_up_price},{sell_1_price},{sell_1_volumn}" |
| | | def process(self, code, buy_1_price, buy_1_volume, time_str, limit_up_price, sell_1_price, sell_1_volumn): |
| | | data_str = f"{buy_1_price},{buy_1_volume},{time_str},{limit_up_price},{sell_1_price},{sell_1_volumn}" |
| | | if self.__latest_data.get(code) == data_str: |
| | | return |
| | | self.__latest_data[code] = data_str |
| | | # 保存买1价格 |
| | | self.__save_buy1_price(code, buy_1_price) |
| | | |
| | | # 记录日志 |
| | | logger_trade_queue_price_info.info( |
| | |
| | | # 买1价格不能小于1块 |
| | | if float(buy_1_price) < 1.0: |
| | | return |
| | | |
| | | ## 记录最近的买1金额 |
| | | if code not in self.__latest_3m_buy1_money_list_dict: |
| | | self.__latest_3m_buy1_money_list_dict[code] = [] |
| | | self.__latest_3m_buy1_money_list_dict[code].append((time_str, int(buy_1_price * buy_1_volume))) |
| | | if len(self.__latest_3m_buy1_money_list_dict[code]) > 80: |
| | | self.__latest_3m_buy1_money_list_dict[code] = self.__latest_3m_buy1_money_list_dict[code][-80:] |
| | | self.__latest_data[code] = data_str |
| | | self.__latest_buy1_money_dict[code] = int(buy_1_price * buy_1_volume) |
| | | |
| | | # 保存买1价格 |
| | | self.__save_buy1_price(code, buy_1_price) |
| | | |
| | | is_limit_up = abs(float(limit_up_price) - float(buy_1_price)) < 0.01 |
| | | old_limit_up_time, old_open_limit_up_time = self.__get_buy1_price_info_cache(code) |
| | |
| | | if limit_up_time is None: |
| | | self.__save_buy1_price_info(code, time_str, None) |
| | | |
| | | # 获取最近的买1金额 |
| | | def get_latest_buy1_money(self, code): |
| | | return self.__latest_buy1_money_dict.get(code) |
| | | |
| | | def get_latest_3m_buy1_money_list(self, code): |
| | | return self.__latest_3m_buy1_money_list_dict.get(code) |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | print(Buy1PriceManager().get_limit_up_info("002777")) |