| | |
| | | |
| | | def __get_limit_up_list(self): |
| | | # 统计目前为止的代码涨停数量(分涨停原因) |
| | | now_limit_up_codes_info = self.__kplDataManager.get_data(KPLDataType.LIMIT_UP) |
| | | limit_up_reason_dict = {} |
| | | if now_limit_up_codes_info: |
| | | for d in now_limit_up_codes_info: |
| | | if d[5] not in limit_up_reason_dict: |
| | | limit_up_reason_dict[d[5]] = [0, 0] |
| | | limit_up_reason_dict[d[5]][0] += 1 |
| | | # 获取想买原因想买单的代码数量 |
| | | reason_map = self.__KPLCodeLimitUpReasonManager.list_all() |
| | | want_codes = gpcode_manager.WantBuyCodesManager.list_code() |
| | | # 其他想买单 |
| | | other_count = 0 |
| | | for k in reason_map: |
| | | reson = reason_map[k] |
| | | if k in want_codes and reson in limit_up_reason_dict: |
| | | limit_up_reason_dict[reson][1] += 1 |
| | | elif k in want_codes: |
| | | other_count += 1 |
| | | |
| | | limit_up_reason_statistic_info = [(k, limit_up_reason_dict[k][0], limit_up_reason_dict[k][1]) for k in |
| | | limit_up_reason_dict] |
| | | limit_up_reason_statistic_info.sort(key=lambda x: x[1]) |
| | | limit_up_reason_statistic_info.reverse() |
| | | if other_count > 0: |
| | | limit_up_reason_statistic_info.insert(0, ('其他', other_count, other_count)) |
| | | |
| | | total_datas = KPLLimitUpDataRecordManager.total_datas |
| | | if not total_datas: |
| | | KPLLimitUpDataRecordManager.load_total_datas() |
| | | total_datas = KPLLimitUpDataRecordManager.total_datas |
| | | # 通过涨停时间排序 |
| | | total_datas = list(total_datas) |
| | | |
| | | # 统计涨停原因 |
| | | limit_up_reason_dict = {} |
| | | for d in total_datas: |
| | | if d[2] not in limit_up_reason_dict: |
| | | limit_up_reason_dict[d[2]] = [] |
| | | limit_up_reason_dict[d[2]].append(d) |
| | | for k in limit_up_reason_dict: |
| | | limit_up_reason_dict[k].sort(key=lambda x: int(x[5])) |
| | | # 统计想买单数量 |
| | | want_codes = gpcode_manager.WantBuyCodesManager.list_code() |
| | | limit_up_reason_want_count_dict = {} |
| | | for d in total_datas: |
| | | if d[2] not in limit_up_reason_want_count_dict: |
| | | limit_up_reason_want_count_dict[d[2]] = 0 |
| | | limit_up_reason_want_count_dict[d[2]] += 1 |
| | | |
| | | limit_up_reason_statistic_info = [ |
| | | (k, len(limit_up_reason_dict[k]), limit_up_reason_want_count_dict.get(k), limit_up_reason_dict[k][0][5]) for |
| | | k in |
| | | limit_up_reason_dict] |
| | | limit_up_reason_statistic_info.sort(key=lambda x: int(x[3])) |
| | | |
| | | codes_set = set([d[3] for d in total_datas]) |
| | | # 判断是龙几,判断是否涨停,判断是否炸板,加载分数 |
| | |
| | | self.__blocks_dict[code] = (time.time(), data["kpl_code_info"]["plate"]) |
| | | |
| | | response_data = json.dumps({"code": 0, "data": data}) |
| | | print("get_score_info 耗时:", time.time()-start_time) |
| | | print("get_score_info 耗时:", time.time() - start_time) |
| | | |
| | | # 获取评分信息 |
| | | pass |
| | |
| | | # 获取板块下的代码 |
| | | # 统计目前为止的代码涨停数量(分涨停原因) |
| | | now_limit_up_codes_info = self.__kplDataManager.get_data(KPLDataType.LIMIT_UP) |
| | | now_limit_up_codes = set([d[0] for d in now_limit_up_codes_info]) |
| | | # 获取历史涨停 |
| | | record_limit_up_datas = KPLLimitUpDataRecordManager.total_datas |
| | | if not record_limit_up_datas: |
| | | KPLLimitUpDataRecordManager.load_total_datas() |
| | | record_limit_up_datas = KPLLimitUpDataRecordManager.total_datas |
| | | |
| | | codes_info = [] |
| | | for d in now_limit_up_codes_info: |
| | | if d[5] != plate: |
| | | for d in record_limit_up_datas: |
| | | if d[2] != plate: |
| | | continue |
| | | codes_info.append([d[0], d[1], 0]) |
| | | # 代码,名称,涨停时间,是否炸板,是否想买,是否已经下过单 |
| | | codes_info.append([d[3], d[4], tool.to_time_str(d[5]), d[3] not in now_limit_up_codes, False, False]) |
| | | codes_info.sort(key=lambda x: x[2]) |
| | | # 查询是否为想买单 |
| | | want_codes = gpcode_manager.WantBuyCodesManager.list_code() |
| | | for code_info in codes_info: |
| | | code_info[2] = 1 if code_info[0] in want_codes else 0 |
| | | code_info[4] = 1 if code_info[0] in want_codes else 0 |
| | | # 获取代码状态 |
| | | if trade_manager.get_trade_state(code_info[0]) != trade_manager.TRADE_STATE_NOT_TRADE: |
| | | code_info[5] = True |
| | | |
| | | response_data = json.dumps({"code": 0, "data": codes_info}) |
| | | elif url.path == "/get_h_cancel_data": |
| | | ps_dict = dict([(k, v[0]) for k, v in parse_qs(url.query).items()]) |