Administrator
2024-06-07 57a7a0dbc43b21256f877bb50f6dd4a35addf313
code_attribute/gpcode_manager.py
@@ -7,6 +7,8 @@
import constant
from db import redis_manager_delegate as redis_manager
from db.redis_manager_delegate import RedisUtils
from log_module import log_export
from log_module.log import logger_pre_close_price
from utils import tool
import decimal
@@ -696,9 +698,9 @@
        data = get_gp_list()
    list = []
    for d in data:
        if d[0:2] == '00':
        if tool.is_sz_code(d):
            list.append("SZSE.{}".format(d))
        elif d[0:2] == '60':
        elif tool.is_sh_code(d):
            list.append("SHSE.{}".format(d))
    return list
@@ -710,9 +712,9 @@
    # 获取收盘价
    @classmethod
    def get_price_pre(cls, code):
        result = RedisUtils.get(cls.__redisManager.getRedis(), "price-pre-{}".format(code))
        if result is not None:
            return float(result)
        fdatas = log_export.load_pre_close_price()
        if code in fdatas:
            return round(float(fdatas.get(code)), 2)
        return None
    # 获取缓存
@@ -731,8 +733,9 @@
        codes = get_gp_list()
        if code not in codes and not FirstCodeManager().is_in_first_record_cache(code) and not force:
            return
        RedisUtils.setex(cls.__redisManager.getRedis(), "price-pre-{}".format(code), tool.get_expire(), str(price))
        cls.__price_pre_cache[code] = float(price)
        price = round(float(price), 2)
        logger_pre_close_price.info(f"{code}-{price}")
        cls.__price_pre_cache[code] = price
__limit_up_price_dict = {}
@@ -746,7 +749,7 @@
    price = CodePrePriceManager.get_price_pre_cache(code)
    if price is None:
        return None
    limit_up_price = tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal("1.1"))
    limit_up_price = tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal(tool.get_limit_up_rate(code)))
    __limit_up_price_dict[code] = limit_up_price
    return limit_up_price
@@ -757,16 +760,16 @@
    return None
def get_limit_up_price_by_preprice(price):
def get_limit_up_price_by_preprice(code, price):
    if price is None:
        return None
    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal("1.1"))
    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal(f"{tool.get_limit_up_rate(code)}"))
def get_limit_down_price_by_preprice(price):
def get_limit_down_price_by_preprice(code, price):
    if price is None:
        return None
    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal("0.9"))
    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal(f"{tool.get_limit_down_rate(code)}"))
# 获取跌停价
@@ -774,7 +777,7 @@
    price = CodePrePriceManager.get_price_pre_cache(code)
    if price is None:
        return None
    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal("0.9"))
    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal(f"{tool.get_limit_down_rate(code)}"))
# 获取现价