| | |
| | | code = k.split("-")[1] |
| | | val = RedisUtils.get(redis, k, auto_free=False) |
| | | cls.__max_volume_info_in_5days[code] = json.loads(val) |
| | | |
| | | keys = RedisUtils.keys(redis, "volumn_today-*", auto_free=False) |
| | | if keys is not None: |
| | | for k in keys: |
| | | code = k.split("-")[-1] |
| | | val = RedisUtils.get(redis, k, auto_free=False) |
| | | if val: |
| | | cls.__today_volumn_cache[code] = int(val) |
| | | global_util.today_volumn[code] = int(val) |
| | | |
| | | finally: |
| | | RedisUtils.realse(redis) |
| | | |
| | |
| | | @return: |
| | | """ |
| | | # 60个交易日未涨停取 |
| | | k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) |
| | | has_limit_up_in_60 = True |
| | | if k_format and not k_format[13]: |
| | | has_limit_up_in_60 = False |
| | | volume = self.get_max_volume_in_5days(code) |
| | | if volume * limit_up_price >= 9e8 and has_limit_up_in_60: |
| | | return volume |
| | | # k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) |
| | | # has_limit_up_in_60 = True |
| | | # if k_format and not k_format[13]: |
| | | # has_limit_up_in_60 = False |
| | | # volume = self.get_max_volume_in_5days(code) |
| | | # if volume and volume * limit_up_price >= 9e8 and has_limit_up_in_60: |
| | | # return volume |
| | | return int(self.get_reference_volume_as_money_y(code) * 1e8 / limit_up_price) |
| | | |
| | | def get_radical_buy_refer_volume_info(self, code, limit_up_price): |
| | | """ |
| | | TODO 更改正确 |
| | | 获取参考量信息 |
| | | 获取扫入的参考量: |
| | | 参考额小于3.14亿就取90天参考量 |
| | | 否则就取最近5天的参考量 |
| | |
| | | @return: |
| | | """ |
| | | # 60个交易日未涨停取 |
| | | k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) |
| | | has_limit_up_in_60 = True |
| | | if k_format and not k_format[13]: |
| | | has_limit_up_in_60 = False |
| | | volume_info = self.__max_volume_info_in_5days.get(code, None) |
| | | if volume_info and volume_info[0] * limit_up_price >= 9e8 and has_limit_up_in_60: |
| | | return volume_info |
| | | return int(self.get_reference_volume_as_money_y(code) * 1e8 / limit_up_price) |
| | | # k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) |
| | | # has_limit_up_in_60 = True |
| | | # if k_format and not k_format[13]: |
| | | # has_limit_up_in_60 = False |
| | | # (量, 日期) |
| | | # volume_info = self.__max_volume_info_in_5days.get(code, None) |
| | | # if volume_info and volume_info[0] * limit_up_price >= 9e8 and has_limit_up_in_60: |
| | | # return volume_info |
| | | return self.get_reference_volume_info(code) |
| | | |
| | | def get_volume_rate_refer_in_5days(self, code, total_sell_volume=0): |
| | | """ |
| | |
| | | max_volume = self.get_max_volume_in_5days(code) |
| | | if not max_volume: |
| | | return 0 |
| | | today_volume = self.get_today_volumn(code) |
| | | today_volume = self.get_today_volumn_cache(code) |
| | | return round((today_volume + total_sell_volume) / max_volume, 2) |
| | | |
| | | # 获取历史量 |
| | |
| | | _volumn = global_util.today_volumn.get(code) |
| | | if _volumn is None: |
| | | _volumn = RedisUtils.get(self.__redis_manager.getRedis(), "volumn_today-{}".format(code)) |
| | | if not _volumn: |
| | | _volumn = 0 |
| | | return int(_volumn) |
| | | |
| | | # 获取今日量 |
| | | def get_today_volumn_cache(self, code): |
| | | return global_util.today_volumn.get(code) |
| | | if code in global_util.today_volumn: |
| | | return global_util.today_volumn.get(code) |
| | | return 0 |
| | | |
| | | # 获取量比(今日量/max(60天最大量,昨日量)) |
| | | # 将总卖量计算在内 |
| | | def get_volume_rate(self, code, total_sell_volume=0, with_info=False): |
| | | today = self.get_today_volumn(code) |
| | | today = self.get_today_volumn_cache(code) |
| | | max60, yesterday = self.get_histry_volumn(code) |
| | | if today is None: |
| | | today = 0 |
| | |
| | | # 默认为5亿 |
| | | return 5 |
| | | |
| | | def get_reference_volume_info(self, code): |
| | | """ |
| | | 获取传统参考量信息 |
| | | @param code: |
| | | @return:(量,日期) |
| | | """ |
| | | max60 = global_util.max60_volumn.get(code) |
| | | return max60 |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | print(CodeVolumeManager().get_volume_rate("000059")) |