From a00da3062c6c825b585f82275823ac45cdeb6502 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期五, 19 一月 2024 19:16:20 +0800 Subject: [PATCH] L后成交太快撤单 --- third_data/kpl_util.py | 87 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 86 insertions(+), 1 deletions(-) diff --git a/third_data/kpl_util.py b/third_data/kpl_util.py index eec6a68..4276c11 100644 --- a/third_data/kpl_util.py +++ b/third_data/kpl_util.py @@ -1,6 +1,8 @@ import enum import json +from db import mysql_data_delegate as mysql_data + def parse_kpl_datas(results): start_y = -1 @@ -69,6 +71,7 @@ if type == DABAN_TYPE_BIDDING: return data[0], data[1], data[18], data[11], data[22], data[15] elif type == DABAN_TYPE_LIMIT_UP: + # (浠g爜, 鍚嶇О, 棣栨娑ㄥ仠鏃堕棿, 鏈�杩戞定鍋滄椂闂�, 鍑犳澘, 娑ㄥ仠鍘熷洜, 鏉垮潡, 瀹為檯娴侀��, 涓诲姏鍑�棰�, 娑ㄥ仠鍘熷洜浠g爜, 娑ㄥ仠鍘熷洜浠g爜鏁伴噺) return data[0], data[1], data[6], data[25], data[9], data[16], data[11], data[15], data[12], data[26], data[27] elif type == DABAN_TYPE_OPEN_LIMIT_UP: return data[0], data[1], data[4], data[11], data[15] @@ -76,8 +79,12 @@ return data[0], data[1], data[11], data[15] elif type == DABAN_TYPE_EVER_LIMIT_DOWN: return data[0], data[1], data[4], data[11], data[15] - return None + + +def __parseLimitUpItemData(data): + # (浠g爜, 鍚嶇О, 棣栨娑ㄥ仠鏃堕棿, 鏈�杩戞定鍋滄椂闂�, 鍑犳澘, 娑ㄥ仠鍘熷洜, 鏉垮潡, 瀹為檯娴侀��, 涓诲姏鍑�棰�, 娑ㄥ仠鍘熷洜浠g爜, 娑ㄥ仠鍘熷洜浠g爜鏁伴噺) + return data[0], data[1], data[4], data[4], data[18], data[5], data[12], data[13], data[8], data[19], data[20] # 鏈�寮洪鍙� @@ -113,6 +120,20 @@ fresult_ = [] for d in list_: pdata = __parseDaBanItemData(d, type_) + if pdata: + fresult_.append(pdata) + return fresult_ + + +def parseLimitUpData(data): + if type(data) == str: + data = json.loads(data) + if int(data["errcode"]) != 0: + raise Exception(f"瑙f瀽鏁版嵁鍑洪敊锛宔rrcode锛歿data['errcode']}") + list_ = data["list"] + fresult_ = [] + for d in list_: + pdata = __parseLimitUpItemData(d) if pdata: fresult_.append(pdata) return fresult_ @@ -233,3 +254,67 @@ # (浠g爜,鍚嶇О,寮哄害,涓诲姏鍑�棰�) fresult_.append((d[0], d[1], d[2], d[6])) return fresult_ + + +class KPLPlatManager: + def save_plat(self, _id, name): + if not _id: + return + mysqldb = mysql_data.Mysqldb() + key = f"{_id}-{name}" + results = mysqldb.select_one(f"select * from kpl_plate where _name='{name}'") + if not results: + mysqldb.execute(f"insert into kpl_plate(_id,_name,_key) values({_id},'{name}','{key}')") + + def get_plat(self, name): + mysqldb = mysql_data.Mysqldb() + results = mysqldb.select_one(f"select * from kpl_plate where _name='{name}'") + if results: + return results[0] + return None + + def get_same_plat_names(self, name): + mysqldb = mysql_data.Mysqldb() + plate = self.get_plat(name) + if not plate: + return {name} + results = mysqldb.select_all(f"select _name from kpl_plate where _id='{plate}'") + return set([r[0] for r in results]) + + def get_same_plat_names_by_id(self, id_): + mysqldb = mysql_data.Mysqldb() + results = mysqldb.select_all(f"select _name from kpl_plate where _id='{id_}'") + return set([r[0] for r in results]) + + +# 鑾峰彇楂樹綅鏉跨殑鏁伴噺 +def get_high_level_count(key): + if key.find("杩炴澘") >= 0: + # 褰㈠紡濡�: 3杩炴澘 + return int(key.replace("杩炴澘", "")) + elif key.find("澶�") >= 0 and key.find("鏉�") >= 0: + # 褰㈠紡濡傦細5澶�4鏉� + return int(key.split("澶�")[1].replace("鏉�", "")) + # 褰㈠紡濡傦細棣栨澘 + return 1 + + +# 鑾峰彇瀹炴椂娑ㄥ仠鍒楄〃涓殑娑ㄥ仠鍘熷洜 +def get_current_limit_up_reasons(item) -> set: + b = {item[5]} + if item[6]: + b |= set(item[6].split("銆�")) + return b + + +def filter_block(block): + if not block: + return block + return block.replace("姒傚康", "") + + +if __name__ == "__main__": + print(get_high_level_count("棣栨澘")) + print(get_high_level_count("5澶�4鏉�")) + print(get_high_level_count("2杩炴澘")) + print(get_high_level_count("4杩炴澘")) -- Gitblit v1.8.0