| | |
| | | from l2.l2_transaction_data_manager import HuaXinBuyOrderManager |
| | | from log_module.log import logger_system, logger_debug, logger_kpl_limit_up, logger_request_api |
| | | from third_data.custom_block_in_money_manager import CodeInMoneyManager |
| | | from third_data.kpl_data_constant import LimitUpCodesBlockRecordManager, LimitUpDataConstant |
| | | from third_data.kpl_limit_up_data_manager import LatestLimitUpBlockManager, CodeLimitUpSequenceManager, \ |
| | | from third_data.kpl_data_constant import LimitUpCodesBlockRecordManager, LimitUpDataConstant, \ |
| | | ContainsLimitupCodesBlocksManager |
| | | from third_data.kpl_limit_up_data_manager import LatestLimitUpBlockManager, CodeLimitUpSequenceManager |
| | | from third_data.third_blocks_manager import BlockMapManager |
| | | from trade.buy_radical.block_special_codes_manager import BlockSpecialCodesManager |
| | | from trade.buy_strategy import OpenLimitUpGoodBlocksBuyStrategy |
| | |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from third_data import kpl_block_util, kpl_api, kpl_util |
| | | from settings.trade_setting import MarketSituationManager |
| | | from third_data.kpl_data_constant import LimitUpCodesBlockRecordManager |
| | | from third_data.kpl_limit_up_data_manager import ContainsLimitupCodesBlocksManager |
| | | from third_data.kpl_data_constant import LimitUpCodesBlockRecordManager, ContainsLimitupCodesBlocksManager |
| | | from third_data.third_blocks_manager import BlockMapManager |
| | | from utils import global_util, tool, buy_condition_util |
| | | from log_module import async_log_util |
| | |
| | | open_limit_up_code_dict_for_radical_buy = None |
| | | |
| | | |
| | | @tool.singleton |
| | | class ContainsLimitupCodesBlocksManager: |
| | | """ |
| | | 包含涨停代码的板块 |
| | | """ |
| | | __block_codes_dict = {} |
| | | |
| | | def __init__(self): |
| | | self.__load_data() |
| | | |
| | | def __load_data(self): |
| | | records = KPLLimitUpDataUtil.get_latest_block_infos_by_day() |
| | | if records: |
| | | codes = set([r[3] for r in records]) |
| | | for code in codes: |
| | | self.__add_code(code) |
| | | |
| | | def get_block_codes(self, block): |
| | | return self.__block_codes_dict.get(block) |
| | | |
| | | def __add_code(self, code): |
| | | blocks = LimitUpCodesBlockRecordManager().get_radical_buy_blocks(code) |
| | | if blocks: |
| | | for b in blocks: |
| | | if b not in self.__block_codes_dict: |
| | | self.__block_codes_dict[b] = set() |
| | | self.__block_codes_dict[b].add(code) |
| | | |
| | | def set_current_limit_up_datas(self, datas): |
| | | """ |
| | | 设置当前涨停数据 |
| | | @param datas: |
| | | @return: |
| | | """ |
| | | if datas: |
| | | codes = [x[0] for x in datas] |
| | | for code in codes: |
| | | self.__add_code(code) |
| | | |
| | | |
| | | @singleton |
| | | class LimitUpCodesBlockRecordManager: |
| | | """ |
| | |
| | | if code in cls.__history_code_data_dict: |
| | | return int(cls.__history_code_data_dict[code][5]) |
| | | return None |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | ContainsLimitupCodesBlocksManager() |
| | |
| | | return kpl_data_manager.KPLLimitUpDataRecordManager.total_datas |
| | | |
| | | |
| | | @tool.singleton |
| | | class ContainsLimitupCodesBlocksManager: |
| | | """ |
| | | 包含涨停代码的板块 |
| | | """ |
| | | __block_codes_dict = {} |
| | | |
| | | def __init__(self): |
| | | self.__load_data() |
| | | |
| | | def __load_data(self): |
| | | records = get_history_limit_up_datas(tool.get_now_date_str()) |
| | | if records: |
| | | codes = set([r[3] for r in records]) |
| | | for code in codes: |
| | | self.__add_code(code) |
| | | |
| | | def get_block_codes(self, block): |
| | | return self.__block_codes_dict.get(block) |
| | | |
| | | def __add_code(self, code): |
| | | blocks = LimitUpCodesBlockRecordManager().get_radical_buy_blocks(code) |
| | | for b in blocks: |
| | | if b not in self.__block_codes_dict: |
| | | self.__block_codes_dict[b] = set() |
| | | self.__block_codes_dict[b].add(code) |
| | | |
| | | def set_current_limit_up_datas(self, datas): |
| | | """ |
| | | 设置当前涨停数据 |
| | | @param datas: |
| | | @return: |
| | | """ |
| | | if datas: |
| | | codes = [x[0] for x in datas] |
| | | for code in codes: |
| | | self.__add_code(code) |
| | | |
| | | |
| | | class CodeLimitUpSequenceManager: |
| | |
| | | cls.__k_max_rate[code] = rate |
| | | return cls.__k_datas.get(code) |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | ContainsLimitupCodesBlocksManager() |
| | |
| | | @param code: 代码 |
| | | @return: 最近的涨停板块信息 |
| | | """ |
| | | sql = f"SELECT r.`_code`, r.`_day`, r.`_hot_block_name`, r.`_blocks` FROM `kpl_limit_up_record` r WHERE r.`_day`>'{min_day}' and r.`_day` <'{max_day}'" |
| | | sql = f"SELECT r.`_code`, r.`_day`, r.`_hot_block_name`, r.`_blocks` FROM `kpl_limit_up_record` r WHERE r.`_day`>='{min_day}' and r.`_day` <'{max_day}'" |
| | | |
| | | if code: |
| | | sql += f" AND _code='{code}'" |
| | |
| | | results = mysqldb.select_all(sql) |
| | | return results |
| | | |
| | | @classmethod |
| | | def get_latest_block_infos_by_day(cls, day=tool.get_now_date_str()): |
| | | sql = f"SELECT * FROM `kpl_limit_up_record` r WHERE r.`_day`='{day}'" |
| | | mysqldb = Mysqldb() |
| | | results = mysqldb.select_all(sql) |
| | | return results |
| | | |
| | | |
| | | |
| | | if __name__ == '__main__': |
| | | # 删除不是交易日期的数据 |