From 5ae8b19fdc000fc719f3ad45fa5f7462fdbffbdf Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期二, 20 九月 2022 18:46:10 +0800 Subject: [PATCH] l2数据计算优化 --- juejin.py | 30 +++++++++++++++++++----------- 1 files changed, 19 insertions(+), 11 deletions(-) diff --git a/juejin.py b/juejin.py index 331756e..d133d38 100644 --- a/juejin.py +++ b/juejin.py @@ -41,14 +41,20 @@ return account_id, strategy_id, token -# 姣忔棩鍒濆鍖� -def everyday_init(): - codes = gpcode_manager.get_gp_list() - logger_system.info("姣忔棩鍒濆鍖�") +def init_data(): # 杞藉叆琛屼笟鑲$エ浠g爜 global_util.load_industry() # 杞藉叆浠g爜鑷敱娴侀�氬競鍊� global_util.load_zyltgb() + # 杞藉叆閲� + global_util.load_volumn() + + +# 姣忔棩鍒濆鍖� +def everyday_init(): + codes = gpcode_manager.get_gp_list() + logger_system.info("姣忔棩鍒濆鍖�") + # 浠婃棩瀹炴椂娑ㄥ仠 global_util.add_limit_up_codes([], True) # 涓昏鑾峰彇鏀剁洏浠� @@ -68,6 +74,8 @@ big_money_num_manager.expire(code) # 娓呴櫎娑ㄥ仠鏃堕棿 global_util.limit_up_time.clear() + init_data() + def __run_schedule(): while True: @@ -80,8 +88,10 @@ # 璁㈤槄娴﹀彂閾惰, bar棰戠巼涓轰竴澶╁拰涓�鍒嗛挓 # 璁㈤槄璁㈤槄澶氫釜棰戠巼鐨勬暟鎹紝鍙娆¤皟鐢╯ubscribe # 鑾峰彇闇�瑕佺洃鍚殑鑲$エ + init_data() logger_system.info("鎺橀噾鍒濆鍖�") schedule.every().day.at("09:00:00").do(everyday_init) + schedule.every().day.at("14:37:00").do(everyday_init) t1 = threading.Thread(target=lambda: __run_schedule()) # 鍚庡彴杩愯 t1.setDaemon(True) @@ -163,8 +173,7 @@ start2 = 60 * 60 * 12 + 50 * 60; end2 = 60 * 60 * 15 + 5 * 60; # TODO 娴嬭瘯 - test = False - if (start1 < relative_timestamp < end1 or start2 < relative_timestamp < end2) or test: + if (start1 < relative_timestamp < end1 or start2 < relative_timestamp < end2) or global_util.TEST: symbol = tick['symbol'] price = tick['price'] # print(symbol,price) @@ -299,22 +308,21 @@ start_time="{:%Y-%m-%d}".format(start), fields="symbol,volume,eob", end_time="{:%Y-%m-%d}".format(end)) - print(len(results)) _fresult = {} for result in results: code = result["symbol"].split(".")[1] volumn = int(result["volume"]) day = "{:%Y-%m-%d}".format(result["eob"]) + if _fresult.get(code) is None: _fresult[code] = (volumn, volumn) if volumn > _fresult[code][0]: - _fresult[code][0] = volumn; - _fresult[code][1] = volumn; + _fresult[code] = (volumn, _fresult[code][1]) + _fresult[code] = (_fresult[code][0], volumn) return _fresult if __name__ == '__main__': - _fresult = get_volumns(["000333", "002531"]) - print(_fresult) + everyday_init() -- Gitblit v1.8.0