| | |
| | | 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 |
| | | |
| | |
| | | return self.__pause_buy_codes_cache |
| | | |
| | | |
| | | # 必买单 |
| | | # 必买单/红名单 |
| | | class MustBuyCodesManager: |
| | | __instance = None |
| | | __db = 0 |
| | |
| | | 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 |
| | | |
| | |
| | | # 获取收盘价 |
| | | @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 |
| | | |
| | | # 获取缓存 |
| | |
| | | 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 = {} |
| | |
| | | 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 |
| | | |
| | |
| | | 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(code, price): |
| | | if price is None: |
| | | return None |
| | | return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal(f"{tool.get_limit_down_rate(code)}")) |
| | | |
| | | |
| | | # 获取跌停价 |
| | |
| | | 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)}")) |
| | | |
| | | |
| | | # 获取现价 |