| | |
| | | |
| | | import constant |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from third_data import kpl_block_util |
| | | from third_data import kpl_block_util, kpl_api |
| | | from utils import global_util, tool |
| | | from log_module import log |
| | | from log_module import log, async_log_util |
| | | from db import redis_manager_delegate as redis_manager |
| | | |
| | | from log_module.log import logger_kpl_limit_up, logger_kpl_block_can_buy, logger_kpl_debug |
| | | from log_module.log import logger_kpl_limit_up, logger_kpl_block_can_buy |
| | | from third_data.kpl_util import KPLPlatManager |
| | | from trade import trade_manager, l2_trade_util |
| | | |
| | |
| | | return self.__code_by_blocks.get(code) |
| | | else: |
| | | return self.__code_blocks.get(code) |
| | | |
| | | # 从网络上加载精选板块 |
| | | def load_jx_blocks(self, code, buy_1_price, limit_up_price): |
| | | if limit_up_price and buy_1_price: |
| | | # 处理买1,卖1信息 |
| | | pre_close_price = round(float(limit_up_price) / 1.1, 2) |
| | | # 如果涨幅大于7%就读取板块 |
| | | price_rate = (buy_1_price - pre_close_price) / pre_close_price |
| | | if price_rate > 0.07: |
| | | if not self.get_jx_blocks_cache(code): |
| | | blocks = kpl_api.getCodeJingXuanBlocks(code) |
| | | self.save_jx_blocks(code, blocks) |
| | | async_log_util.info(logger_kpl_block_can_buy,f"{code}:获取到精选板块-{blocks}") |
| | | elif price_rate > 0.03: |
| | | # 添加备用板块 |
| | | if not self.get_jx_blocks_cache(code, by=True): |
| | | blocks = kpl_api.getCodeJingXuanBlocks(code) |
| | | self.save_jx_blocks(code, blocks, by=True) |
| | | async_log_util.info(logger_kpl_block_can_buy, f"{code}:获取到精选板块(备用)-{blocks}") |
| | | |
| | | |
| | | |
| | | # 开盘啦禁止交易板块管理 |
| | |
| | | @classmethod |
| | | def is_in_top(cls, keys): |
| | | reasons = cls.get_can_buy_key_set() |
| | | log.logger_kpl_debug.debug("市场流入前5:{}", reasons) |
| | | forbidden_plates = cls.__KPLPlateForbiddenManager.list_all_cache() |
| | | reasons = reasons - forbidden_plates |
| | | temp_set = keys & reasons |
| | | log.logger_kpl_debug.debug("市场流入前5匹配结果:{}", temp_set) |
| | | if temp_set: |
| | | return True, temp_set |
| | | else: |
| | |
| | | self.__history_limit_up_reason_dict[code] = set(reasons) |
| | | RedisUtils.setex(self.__get_redis(), f"kpl_his_limit_up_reason-{code}", tool.get_expire(), |
| | | json.dumps(list(reasons))) |
| | | logger_kpl_debug.debug(f"设置历史涨停原因:{code}-{reasons}") |
| | | |
| | | # 如果返回值不为None表示已经加载过历史原因了 |
| | | def get_history_limit_up_reason(self, code): |
| | |
| | | keys |= k4 |
| | | keys = keys - constant.KPL_INVALID_BLOCKS |
| | | |
| | | log.logger_kpl_debug.info("{}最终关键词:{}", code, keys) |
| | | # log.logger_kpl_debug.info("{}最终关键词:{}", code, keys) |
| | | |
| | | # 涨停列表中匹配关键词,返回(板块:代码集合),代码集合中已经排除自身 |
| | | if not keys: |