From aacc6148dd43a9cffbff9a23a273a55b64bf3d8c Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期六, 12 十月 2024 17:21:42 +0800 Subject: [PATCH] bug修复 --- code_attribute/code_volumn_manager.py | 40 +++++++++++++++++++++++++++++++++++++--- 1 files changed, 37 insertions(+), 3 deletions(-) diff --git a/code_attribute/code_volumn_manager.py b/code_attribute/code_volumn_manager.py index 45d9510..d0b4cec 100644 --- a/code_attribute/code_volumn_manager.py +++ b/code_attribute/code_volumn_manager.py @@ -7,6 +7,7 @@ # yesterday 鏄ㄥぉ鐨勯噺 import json +from code_attribute import gpcode_manager from db.redis_manager_delegate import RedisUtils from log_module import async_log_util from utils import global_util, tool @@ -20,7 +21,7 @@ # 璁剧疆鍘嗗彶閲� def set_histry_volumn(code, max60, yesterday, max60_day, max60_day_count): redis = __redis_manager.getRedis() - global_util.max60_volumn[code] = (max60, max60_day,max60_day_count) + global_util.max60_volumn[code] = (max60, max60_day, max60_day_count) global_util.yesterday_volumn[code] = yesterday try: RedisUtils.setex_async(0, "volumn_max60-{}".format(code), tool.get_expire(), @@ -85,13 +86,23 @@ return _volumn +# 鑾峰彇浠婃棩閲� +def get_today_volumn_cache(code): + return global_util.today_volumn.get(code) + + # 鑾峰彇閲忔瘮锛堜粖鏃ラ噺/max(60澶╂渶澶ч噺,鏄ㄦ棩閲�)锛� # 灏嗘�诲崠閲忚绠楀湪鍐� def get_volume_rate(code, total_sell_volume=0, with_info=False): today = get_today_volumn(code) max60, yesterday = get_histry_volumn(code) - if today is None or max60 is None or yesterday is None: - raise Exception("鑾峰彇閲忓け璐�") + if today is None: + today = 0 + if max60 is None or yesterday is None: + max60 = [today, ''] + yesterday = today + if max60[0] < 1: + max60[0] = 1 rate = round((int(today) + total_sell_volume) / max(int(max60[0]), int(yesterday)), 2) if not with_info: return rate @@ -153,5 +164,28 @@ RedisUtils.realse(redis) +__reference_volume_as_money_y_dict = {} + + +def get_reference_volume_as_money_y(code): + """ + 杩斿洖鍙傝�冮噺浠婃棩瀵瑰簲鐨勯噾棰濓紙鍗曚綅涓轰嚎锛� + @param code: + @return: + """ + if code in __reference_volume_as_money_y_dict: + return __reference_volume_as_money_y_dict.get(code) + max60, yesterday = get_histry_volumn(code) + if max60: + num = max60[0] + limit_up_price = gpcode_manager.get_limit_up_price(code) + if limit_up_price: + money_y = round((num * float(limit_up_price)) / 1e8, 1) + __reference_volume_as_money_y_dict[code] = money_y + return money_y + # 榛樿涓�5浜� + return 5 + + if __name__ == "__main__": print(get_volume_rate("000059")) -- Gitblit v1.8.0