| | |
| | | __industry_cache_dict = {} |
| | | __latest_limit_up_codes_set = set() |
| | | __data_process_thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=10) |
| | | # 新题材请求 |
| | | __new_blocks_codes_request_thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=5) |
| | | # 代码的涨幅 |
| | | __code_limit_rate_dict = {} |
| | | |
| | |
| | | self.__send_response(result_str) |
| | | |
| | | def __process_kpl_data(self, data_origin): |
| | | |
| | | def do_limit_up(result_list_): |
| | | |
| | | def request_new_blocks_codes(blocks_info): |
| | | """ |
| | | 请求新板块的代码 |
| | | @param blocks_info:[(板块名称,板块代码)] |
| | | @return: |
| | | """ |
| | | yesterday_codes = kpl_data_manager.get_yesterday_limit_up_codes() |
| | | for bi in blocks_info: |
| | | result = kpl_api.getCodesByPlate(bi[1]) |
| | | result = json.loads(result) |
| | | code_info_list = [] |
| | | for d in result["list"]: |
| | | if d[0] in yesterday_codes: |
| | | continue |
| | | # 涨幅要大于5% |
| | | rate = d[6] / int(round((tool.get_limit_up_rate(d[0]) - 1) * 10)) |
| | | if rate < 5: |
| | | continue |
| | | # 格式:(代码,涨幅) |
| | | code_info_list.append((d[0], d[6])) |
| | | if code_info_list: |
| | | # 将代码加入新题材 |
| | | for x in code_info_list: |
| | | add_result = LimitUpCodesBlockRecordManager().add_new_blocks(x[0], bi[0]) |
| | | if add_result: |
| | | # 增加新题材是否成功, 临时将票加入辨识度 |
| | | BlockSpecialCodesManager().add_code_block_for_temp(x[0], bi[0]) |
| | | |
| | | try: |
| | | if result_list_: |
| | | # 保存涨停时间 |
| | |
| | | records = KPLLimitUpDataRecordManager.total_datas |
| | | # 计算今日新增的题材概念 |
| | | block_codes = {} |
| | | # 统计板块的代码 |
| | | block_plate_code_dict = {} |
| | | for x in records: |
| | | bs = {kpl_util.filter_block(x[2])} |
| | | block_plate_code_dict[kpl_util.filter_block(x[2])] = x[15] |
| | | if x[6]: |
| | | bs |= set(x[6].split("、")) |
| | | for b in bs: |
| | |
| | | reasons -= constant.KPL_INVALID_BLOCKS |
| | | reasons -= LimitUpCodesBlockRecordManager().get_total_before_blocks() |
| | | if reasons: |
| | | # 新板块 |
| | | update_new_block_plates = [] |
| | | for r in reasons: |
| | | for c in block_codes[r]: |
| | | add_result = LimitUpCodesBlockRecordManager().add_new_blocks(c, r) |
| | |
| | | # 增加新题材是否成功, 临时将票加入辨识度 |
| | | BlockSpecialCodesManager().add_code_block_for_temp(c, r) |
| | | |
| | | for r in reasons: |
| | | if r in block_plate_code_dict: |
| | | update_new_block_plates.append((r, block_plate_code_dict[r])) |
| | | if update_new_block_plates: |
| | | # 需要获取板块下的代码 |
| | | self.__new_blocks_codes_request_thread_pool.submit( |
| | | lambda: request_new_blocks_codes(update_new_block_plates)) |
| | | except: |
| | | pass |
| | | self.__kplDataManager.save_data(type_, result_list_) |