| | |
| | | |
| | | # 开盘啦历史涨停数据管理 |
| | | from db import mysql_data_delegate as mysql_data, redis_manager_delegate as redis_manager |
| | | from log_module.log import logger_kpl_limit_up_reason_change, logger_debug, logger_kpl_limit_up |
| | | from log_module.log import logger_kpl_limit_up_reason_change, logger_debug, logger_kpl_limit_up, \ |
| | | logger_kpl_open_limit_up |
| | | from third_data import kpl_util, kpl_api |
| | | from third_data.code_plate_key_manager import LimitUpCodesPlateKeyManager, CodesHisReasonAndBlocksManager |
| | | |
| | |
| | | __kplPlatManager = KPLPlatManager() |
| | | __LimitUpCodesPlateKeyManager = LimitUpCodesPlateKeyManager() |
| | | __CodesPlateKeysManager = CodesHisReasonAndBlocksManager() |
| | | __current_code_reason_dict = {} |
| | | __current_code_reasons_dict = {} |
| | | __current_reason_codes_dict = {} |
| | | __records_cache = {} |
| | | |
| | |
| | | |
| | | @classmethod |
| | | def save_record(cls, day, records): |
| | | # 统计炸板 |
| | | try: |
| | | last_codes = set() |
| | | if cls.latest_origin_datas: |
| | | last_codes = set([x[0] for x in cls.latest_origin_datas]) |
| | | now_codes = set() |
| | | if records: |
| | | now_codes = set([x[0] for x in records]) |
| | | open_limit_up_codes = last_codes - now_codes |
| | | if open_limit_up_codes: |
| | | logger_kpl_open_limit_up.info(f"炸板代码:{open_limit_up_codes}") |
| | | except Exception as e: |
| | | pass |
| | | |
| | | # 统计代码所属板块 |
| | | code_block_dict = {} |
| | | for data in records: |
| | |
| | | code_block_dict[code] = set() |
| | | code_block_dict[code].add(b) |
| | | # 设置涨停数据 |
| | | |
| | | if records: |
| | | cls.latest_origin_datas = records |
| | | cls.__LimitUpCodesPlateKeyManager.set_today_limit_up([(r[0], r[5]) for r in records]) |
| | | |
| | | code_reason_dict = {} |
| | | reason_code_dict = {} |
| | | code_reasons_dict = {} |
| | | reason_codes_dict = {} |
| | | for d in records: |
| | | code_reason_dict[d[0]] = d[5] |
| | | if d[5] not in reason_code_dict: |
| | | reason_code_dict[d[5]] = set() |
| | | reason_code_dict[d[5]].add(d[0]) |
| | | cls.__current_code_reason_dict = code_reason_dict |
| | | cls.__current_reason_codes_dict = reason_code_dict |
| | | # 涨停原因 + 推荐原因 |
| | | bs = {d[5]} |
| | | if d[6]: |
| | | bs |= set(d[6].split("、")) |
| | | code_reasons_dict[d[0]] = bs |
| | | for b in bs: |
| | | if b not in reason_codes_dict: |
| | | reason_codes_dict[b] = set() |
| | | reason_codes_dict[b].add(d[0]) |
| | | cls.__current_code_reasons_dict = code_reasons_dict |
| | | cls.__current_reason_codes_dict = reason_codes_dict |
| | | |
| | | # 涨停数据记录 |
| | | mysqldb = mysql_data.Mysqldb() |
| | |
| | | return bs |
| | | |
| | | @classmethod |
| | | def get_current_block(cls, code): |
| | | return cls.__current_code_reason_dict.get(code) |
| | | def get_current_blocks(cls, code): |
| | | return cls.__current_code_reasons_dict.get(code) |
| | | |
| | | @classmethod |
| | | def get_current_codes_by_block(cls, block): |
| | |
| | | |
| | | def get_limit_up(): |
| | | while True: |
| | | if tool.is_trade_time(): |
| | | if (tool.is_trade_time() and int(tool.get_now_time_str().replace(':', '')) > int("092530")): |
| | | try: |
| | | results = kpl_api.getLimitUpInfo() |
| | | results = kpl_api.getLimitUpInfoNew() |
| | | result = json.loads(results) |
| | | start_time = time.time() |
| | | __upload_data("limit_up", result) |
| | |
| | | time.sleep(3) |
| | | |
| | | threading.Thread(target=get_limit_up, daemon=True).start() |
| | | threading.Thread(target=get_bidding_money, daemon=True).start() |
| | | # threading.Thread(target=get_bidding_money, daemon=True).start() |
| | | # threading.Thread(target=get_market_industry, daemon=True).start() |
| | | # threading.Thread(target=get_market_jingxuan, daemon=True).start() |
| | | |