| | |
| | | from code_attribute import gpcode_manager |
| | | |
| | | # 代码股性记录管理 |
| | | from db import redis_manager |
| | | from utils import tool |
| | | from db.redis_manager_delegate import RedisManager, RedisUtils |
| | | from utils.tool import CodeDataCacheUtil |
| | | |
| | | |
| | | class CodeNatureRecordManager: |
| | |
| | | if val: |
| | | cls.__nature_cache[code] = val |
| | | return val |
| | | |
| | | |
| | | class LatestMaxVolumeManager: |
| | | __db = 0 |
| | | __instance = None |
| | | __redis_manager = redis_manager.RedisManager(0) |
| | | __max_volume_cache = {} |
| | | |
| | | def __new__(cls, *args, **kwargs): |
| | | if not cls.__instance: |
| | | cls.__instance = super(LatestMaxVolumeManager, cls).__new__(cls, *args, **kwargs) |
| | | cls.__load_datas() |
| | | return cls.__instance |
| | | |
| | | @classmethod |
| | | def __load_datas(cls): |
| | | __redis = cls.__get_redis() |
| | | try: |
| | | keys = RedisUtils.keys(__redis, "is_latest_max_volume-*") |
| | | for k in keys: |
| | | code = k.split("-")[-1] |
| | | val = RedisUtils.get(__redis, k) |
| | | CodeDataCacheUtil.set_cache(cls.__max_volume_cache, code, val) |
| | | finally: |
| | | RedisUtils.realse(__redis) |
| | | |
| | | @classmethod |
| | | def __get_redis(cls): |
| | | return cls.__redis_manager.getRedis() |
| | | |
| | | def __save_has_latest_max_volume(self, code): |
| | | RedisUtils.setex_async(self.__db, f"is_latest_max_volume-{code}", tool.get_expire(), "1") |
| | | |
| | | # 设置最近有最大量 |
| | | def set_has_latest_max_volume(self, code): |
| | | CodeDataCacheUtil.set_cache(self.__max_volume_cache, code, 1) |
| | | self.__save_has_latest_max_volume(code) |
| | | |
| | | # 最近是否有最大量 |
| | | def is_latest_max_volume(self, code): |
| | | return code in self.__max_volume_cache |
| | | |
| | | def clear(self): |
| | | self.__max_volume_cache.clear() |
| | | keys = RedisUtils.keys(self.__get_redis(), "is_latest_max_volume-*") |
| | | for k in keys: |
| | | RedisUtils.delete_async(self.__db, k) |
| | | |
| | | |
| | | # 设置历史K线 |
| | |
| | | |
| | | |
| | | # 最近几天是否有最大量 |
| | | def is_latest_max_volume(record_datas, day_count): |
| | | def is_have_latest_max_volume(record_datas, day_count): |
| | | datas = copy.deepcopy(record_datas) |
| | | datas.sort(key=lambda x: x["bob"]) |
| | | datas = datas[-120:] |
| | |
| | | # 判断是否太高 |
| | | l2_trade_util.forbidden_trade(code, "120天内股价长得太高") |
| | | |
| | | if code_nature_analyse.is_have_latest_max_volume(volumes_data, 2): |
| | | # 最近2天是否是最高量 |
| | | code_nature_analyse.LatestMaxVolumeManager().set_has_latest_max_volume(code) |
| | | |
| | | # 判断K线形态 |
| | | # is_has_k_format, msg = code_nature_analyse.is_has_k_format( |
| | | # gpcode_manager.get_limit_up_price(code), volumes_data) |
| | |
| | | # import gm.api as gmapi |
| | | |
| | | from code_attribute import big_money_num_manager, global_data_loader, gpcode_manager, gpcode_first_screen_manager |
| | | from code_attribute.code_nature_analyse import LatestMaxVolumeManager |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from ths import client_manager |
| | | import constant |
| | |
| | | DCancelBigNumComputer().clear() |
| | | # 清除大单成交数据 |
| | | DealOrderNoManager().clear() |
| | | # 最近是否有最大量 |
| | | LatestMaxVolumeManager().clear() |
| | | |
| | | |
| | | # 每日初始化 |
| | |
| | | import time as t |
| | | |
| | | from code_attribute import big_money_num_manager, code_volumn_manager, code_data_util, industry_codes_sort, \ |
| | | limit_up_time_manager, global_data_loader, gpcode_manager |
| | | limit_up_time_manager, global_data_loader, gpcode_manager, code_nature_analyse |
| | | import constant |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from l2.huaxin import l2_huaxin_util, huaxin_delegate_postion_manager |
| | |
| | | if float(limit_up_price) >= constant.MAX_CODE_PRICE: |
| | | return False, True, f"股价大于{constant.MAX_CODE_PRICE}块" |
| | | |
| | | if code_nature_analyse.LatestMaxVolumeManager().is_latest_max_volume(code): |
| | | # 最近几天有最大量,判断量比是否大于60% |
| | | if cls.volume_rate_info[code][0] < 0.6: |
| | | return False, True, f"近日出现最大量,当日量比({cls.volume_rate_info[code][0]})小于0.6" |
| | | |
| | | if constant.L2_SOURCE_TYPE == constant.L2_SOURCE_TYPE_HUAXIN: |
| | | total_data = local_today_datas.get(code) |
| | | trade_price = current_price_process_manager.get_trade_price(code) |
| | |
| | | return False, True, "尚未获取到板块信息" |
| | | |
| | | # 板块不可买,且没有挂过单的就不能买 |
| | | if not can_buy_result[0] and trade_manager.CodesTradeStateManager().get_trade_state_cache(code) == trade_manager.TRADE_STATE_NOT_TRADE: |
| | | if not can_buy_result[0] and trade_manager.CodesTradeStateManager().get_trade_state_cache( |
| | | code) == trade_manager.TRADE_STATE_NOT_TRADE: |
| | | return False, True, can_buy_result[1] |
| | | return True, False, can_buy_result[1] |
| | | |