| | |
| | | |
| | | import constant |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from log_module import async_log_util |
| | | from utils import tool |
| | | |
| | | # 开盘啦历史涨停数据管理 |
| | | 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 |
| | | from log_module.log import logger_kpl_limit_up_reason_change, logger_debug, logger_kpl_limit_up |
| | | from third_data import kpl_util, kpl_api |
| | | from third_data.code_plate_key_manager import LimitUpCodesPlateKeyManager, CodesHisReasonAndBlocksManager |
| | | |
| | |
| | | def get_current_reason_codes_dict(cls): |
| | | return copy.deepcopy(cls.__current_reason_codes_dict) |
| | | |
| | | @classmethod |
| | | def get_current_reasons(cls): |
| | | if cls.__current_reason_codes_dict: |
| | | return cls.__current_reason_codes_dict.keys() |
| | | return set() |
| | | |
| | | |
| | | class KPLDataManager: |
| | | __latest_datas = {} |
| | |
| | | |
| | | |
| | | def get_yesterday_limit_up_codes(): |
| | | yesterday_limit_up_data_records = get_current_limit_up_data_records(1)[0][1] |
| | | yesterday_limit_up_data_records = get_yesterday_current_limit_up_records() |
| | | yesterday_codes = set([x[0] for x in yesterday_limit_up_data_records]) |
| | | return yesterday_codes |
| | | |
| | | |
| | | def get_yesterday_current_limit_up_records(): |
| | | yesterday_limit_up_data_records = get_current_limit_up_data_records(1)[0][1] |
| | | return yesterday_limit_up_data_records |
| | | |
| | | |
| | | # 运行拉取任务 |
| | |
| | | requests.post("http://127.0.0.1:9004/upload_kpl_data", json.dumps(root_data)) |
| | | |
| | | def get_limit_up(): |
| | | last_time = 0 |
| | | while True: |
| | | if tool.is_trade_time(): |
| | | try: |
| | |
| | | result = json.loads(results) |
| | | start_time = time.time() |
| | | __upload_data("limit_up", result) |
| | | logger_kpl_limit_up_reason_change.info("上传耗时:{}", time.time() - start_time) |
| | | if start_time - last_time >= 60: |
| | | last_time = time.time() |
| | | # 记录涨停数据 |
| | | logger_kpl_limit_up.info(result) |
| | | # logger_kpl_limit_up_reason_change.info("上传耗时:{}", time.time() - start_time) |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | time.sleep(3) |