| | |
| | | elif url.startswith("/kpl/get_market_data"): |
| | | return cls.__get_market_data(url) |
| | | |
| | | elif url.startswith("/kpl/get_plate_codes"): |
| | | return cls.__get_plate_codes(url) |
| | | |
| | | elif url.startswith("/get_last_trade_day_reasons"): |
| | | return cls.__get_last_trade_day_reasons(url) |
| | | |
| | |
| | | |
| | | @classmethod |
| | | def __get_limit_up_list(cls, url): |
| | | ps_dict = dict([(k, v[0]) for k, v in parse_qs(urlparse(url).query).items()]) |
| | | day = ps_dict.get("day") |
| | | if day is None: |
| | | day = tool.get_now_date_str() |
| | | # (代码, 名称, 首次涨停时间, 最近涨停时间, 几板, 涨停原因, 板块, 实际流通, 主力净额, 涨停原因代码, 涨停原因代码数量) |
| | | records = KPLLimitUpDataManager().get_limit_up_history_datas() |
| | | currents = KPLLimitUpDataManager().get_limit_up_current_datas() |
| | | records = KPLLimitUpDataManager().get_limit_up_history_datas(day) |
| | | currents = KPLLimitUpDataManager().get_limit_up_current_datas(day) |
| | | current_codes = [d[0] for d in currents] |
| | | fresult = [] |
| | | # 计算涨停时间排序 |
| | |
| | | d.append(1 if d[1] in forbidden_plates else 0) |
| | | fresult.append(d) |
| | | response_data = json.dumps({"code": 0, "data": fresult}) |
| | | return response_data, True |
| | | |
| | | @classmethod |
| | | def __get_plate_codes(cls, url): |
| | | ps_dict = dict([(k, v[0]) for k, v in parse_qs(urlparse(url).query).items()]) |
| | | day = ps_dict.get("day") |
| | | plate = ps_dict.get("plate") |
| | | if not day: |
| | | return None, False |
| | | records = KPLLimitUpDataManager().get_limit_up_history_datas(day) |
| | | currents = KPLLimitUpDataManager().get_limit_up_current_datas(day) |
| | | rs = [] |
| | | for r in records: |
| | | if r[5] != plate and plate not in r[6].split('、'): |
| | | continue |
| | | rs.append(r) |
| | | current_codes = set() |
| | | for r in currents: |
| | | current_codes.add(r[0]) |
| | | rs.sort(key=lambda x: x[2]) |
| | | |
| | | # 代码,名称,涨停时间,是否炸板,是否想买,是否已经下过单 |
| | | results = [( |
| | | x[0], x[1], time.strftime("%H:%M:%S", time.localtime(x[2])), 0 if x[0] in current_codes else 1, 0, 0, |
| | | x[4], f" {round(x[7] / 100000000, 1)}亿", 1 if x[5] == plate else 0) for x in rs] |
| | | response_data = json.dumps({"code": 0, "data": results}) |
| | | return response_data, True |
| | | |
| | | @classmethod |
| | |
| | | "SZJS": market_feelings['SZJS'], "XDJS": market_feelings['XDJS'], "sign": market_feelings['sign']} |
| | | # 获取市场情绪 |
| | | return json.dumps( |
| | | {"code": 0, "data": fdata}), True |
| | | {"code": 0, "data": fdata}), True |
| | | |
| | | |
| | | if __name__ == "__main__": |