| | |
| | | from code_attribute.gpcode_manager import BlackListCodeManager |
| | | 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.third_blocks_manager import BlockMapManager |
| | |
| | | params = self.__parse_request() |
| | | result_str = self.__process_kpl_data(params) |
| | | self.__send_response(result_str) |
| | | if url.path == "/upload_codes_in_money": |
| | | # 接收代码净流入金额 |
| | | params = self.__parse_request() |
| | | d = params["data"] |
| | | d = json.loads(d) |
| | | try: |
| | | for code in d: |
| | | CodeInMoneyManager().set_money(code, d[code]) |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | result_str =json.dumps({"code": 0}) |
| | | self.__send_response(result_str) |
| | | |
| | | def __process_kpl_data(self, data_origin): |
| | | def do_limit_up(result_list_): |
| | |
| | | self.__kplDataManager.save_data(type_, result_list) |
| | | RealTimeKplMarketData.set_top_5_industry(result_list) |
| | | elif type_ == KPLDataType.JINGXUAN_RANK.value: |
| | | result_list = kpl_util.parseMarketJingXuan(data["data"]) |
| | | # result_list = kpl_util.parseMarketJingXuan(data["data"]) |
| | | result_list = json.loads(data["data"]) |
| | | # 保存精选数据 |
| | | if result_list: |
| | | self.__kplDataManager.save_data(type_, result_list) |
| | | RealTimeKplMarketData.set_market_jingxuan_blocks(result_list) |
| | | elif type_ == KPLDataType.JINGXUAN_RANK_OUT.value: |
| | | result_list = kpl_util.parseMarketJingXuan(data["data"]) |
| | | # result_list = kpl_util.parseMarketJingXuan(data["data"]) |
| | | result_list = json.loads(data["data"]) |
| | | # 保存精选数据 |
| | | if result_list: |
| | | self.__kplDataManager.save_data(type_, result_list) |
| | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | # 统计目前为止的代码涨停数量(分涨停原因) |
| | | currents = LimitUpDataConstant.current_limit_up_datas |
| | | records = LimitUpDataConstant.history_limit_up_datas |
| | | if not currents: |
| | | currents = KPLDataManager.get_data(KPLDataType.LIMIT_UP) |
| | | # 获取历史涨停 |
| | | if not records: |
| | | KPLLimitUpDataRecordManager.load_total_datas() |
| | | records = KPLLimitUpDataRecordManager.total_datas |
| | | |
| | | records_map = {x[3]: x for x in records} |
| | | current_codes = [d[0] for d in currents] |
| | | record_codes = [d[3] for d in records] |
| | | # 计算涨停时间排序 |
| | | record_reason_dict = {} |
| | | current_reason_dict = {} |
| | | for _code in record_codes: |
| | | blocks = LimitUpCodesBlockRecordManager().get_radical_buy_blocks(_code) |
| | | if not blocks: |
| | | blocks = set() |
| | | for b in blocks: |
| | | if b not in record_reason_dict: |
| | | record_reason_dict[b] = [] |
| | | record_reason_dict[b].append(_code) |
| | | for _code in current_codes: |
| | | blocks = LimitUpCodesBlockRecordManager().get_radical_buy_blocks(_code) |
| | | if not blocks: |
| | | blocks = set() |
| | | for b in blocks: |
| | | if b not in current_reason_dict: |
| | | current_reason_dict[b] = [] |
| | | current_reason_dict[b].append(_code) |
| | | # (板块名称,涨停代码数量,炸板数量,涨停时间) |
| | | limit_up_reason_statistic_info = [(k, len(record_reason_dict[k]), len(record_reason_dict[k]) - len( |
| | | current_reason_dict.get(k) if k in current_reason_dict else []), |
| | | 0) for k in record_reason_dict] |
| | | limit_up_reason_statistic_info.sort(key=lambda x: x[1] - x[2]) |
| | | limit_up_reason_statistic_info.reverse() |
| | | |
| | | response_data = json.dumps({"code": 0, "data": {"limit_up_count": len(current_codes), |
| | | "open_limit_up_count": len(record_codes) - len(current_codes), |
| | | "limit_up_reason_statistic": limit_up_reason_statistic_info}}) |
| | | |
| | | # data = code_info_output.get_output_params(code, self.__jingxuan_cache_dict, self.__industry_cache_dict, |
| | | # trade_record_date=date) |
| | | run("", 9004) |