From c7b6f5be3e5850bbf66db5363e634c57ff9ca876 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期二, 28 三月 2023 15:32:24 +0800 Subject: [PATCH] 评分机制调整 --- server.py | 142 ++++++++++++++++++++++++++-------------------- 1 files changed, 80 insertions(+), 62 deletions(-) diff --git a/server.py b/server.py index 1478572..b187ce8 100644 --- a/server.py +++ b/server.py @@ -103,8 +103,12 @@ type = -1 try: type = data_process.parseType(_str) - except: - print(_str) + except Exception as e: + if str(e).find("Unterminated string starting") > -1: + _str = _str.replace("\n", "") + type = data_process.parseType(_str) + else: + print(_str) return_str = "OK" if type == 0: try: @@ -281,37 +285,44 @@ bad_codes = set() + # 鑾峰彇鏄ㄦ棩鏀剁洏浠� + for code in codes: + # 濡傛灉娑ㄥ仠浠锋槸绌哄�煎氨闇�瑕佽缃槰鏃ユ敹鐩樹环鏍� + if gpcode_manager.get_limit_up_price(code) is None: + juejin.re_set_price_pres([code], True) + + # 鑾峰彇60澶╂渶澶ц褰� + for code in codes: + need_get_volumn = False + if code not in global_util.max60_volumn or global_util.max60_volumn.get(code) is None: + need_get_volumn = True + if not need_get_volumn and code_nature_analyse.CodeNatureRecordManager.get_nature( + code) is None: + need_get_volumn = True + if need_get_volumn: + volumes_data = juejin.get_volumns_by_code(code, 150) + volumes = juejin.parse_max_volume(volumes_data[:60], code_nature_analyse.is_new_top( + gpcode_manager.get_limit_up_price(code), volumes_data[:60])) + logger_first_code_record.info("{} 鑾峰彇鍒伴鏉�60澶╂渶澶ч噺锛歿}", code, volumes) + code_volumn_manager.set_histry_volumn(code, volumes[0], volumes[1], volumes[2]) + # 鍒ゆ柇K绾垮舰鎬� + is_has_k_format, msg = code_nature_analyse.is_has_k_format( + gpcode_manager.get_limit_up_price(code), volumes_data) + if not is_has_k_format: + logger_first_code_record.info("{}棣栨澘K绾垮舰鎬佷笉濂�,{}", code, msg) + # 鑲℃�т笉濂斤紝灏变笉瑕佸姞鍏� + bad_codes.add(code) + # 鍔犲叆绂佹浜ゆ槗浠g爜 + l2_trade_util.forbidden_trade(code) + code_nature_analyse.set_record_datas(code, + gpcode_manager.get_limit_up_price(code), + volumes_data) + gpcode_manager.FirstCodeManager.add_record(codes) if new_add_codes: gpcode_manager.set_first_gp_codes_with_data(juejin.JueJinManager.get_gp_latest_info(codes)) # 鍔犲叆棣栨澘鍘嗗彶璁板綍 - gpcode_manager.FirstCodeManager.add_record(new_add_codes) + logger_first_code_record.info("鏂板棣栨澘锛歿}", new_add_codes) - # 鑾峰彇60澶╂渶澶ц褰� - for code in codes: - need_get_volumn = False - if code not in global_util.max60_volumn or global_util.max60_volumn.get(code) is None: - need_get_volumn = True - if not need_get_volumn and code_nature_analyse.CodeNatureRecordManager.get_nature( - code) is None: - need_get_volumn = True - if need_get_volumn: - volumes_data = juejin.get_volumns_by_code(code, 150) - volumes = juejin.parse_max_volume(volumes_data[:60], code_nature_analyse.is_new_top( - gpcode_manager.get_limit_up_price(code), volumes_data[:60])) - logger_first_code_record.info("{} 鑾峰彇鍒伴鏉�60澶╂渶澶ч噺锛歿}", code, volumes) - code_volumn_manager.set_histry_volumn(code, volumes[0], volumes[1], volumes[2]) - # 鍒ゆ柇K绾垮舰鎬� - is_has_k_format, msg = code_nature_analyse.is_has_k_format( - gpcode_manager.get_limit_up_price(code), volumes_data) - if not is_has_k_format: - logger_first_code_record.info("{}棣栨澘K绾垮舰鎬佷笉濂�,{}", code, msg) - # 鑲℃�т笉濂斤紝灏变笉瑕佸姞鍏� - bad_codes.add(code) - # 鍔犲叆绂佹浜ゆ槗浠g爜 - l2_trade_util.forbidden_trade(code) - code_nature_analyse.set_record_datas(code, - gpcode_manager.get_limit_up_price(code), - volumes_data) # 绉婚櫎浠g爜 listen_codes = gpcode_manager.get_listen_codes() @@ -376,7 +387,7 @@ gpcode_first_screen_manager.process_ticks(prices) except Exception as e: - pass + logging.exception(e) elif type == 3: # 浜ゆ槗鎴愬姛淇℃伅 @@ -717,16 +728,17 @@ # 鑾峰彇鏈�杩�2涓氦鏄撴棩娑ㄥ仠浠g爜 elif type == 72: day = tool.get_now_date_str() - last_day = juejin.JueJinManager.get_previous_trading_date(day) - data_list = list(hot_block_data_process.XGBHotBlockDataManager.list_all(day)) - data_list_last = list(hot_block_data_process.XGBHotBlockDataManager.list_all(last_day)) - data_list.extend(data_list_last) - codes_set = set() - if data_list: - for d in data_list: - if len(d[4]) > 6: - codes_set.add(d[3]) - return_str = json.dumps({"code": 0, "data": list(codes_set)}) + data_dict={} + for i in range(0, 2): + day = juejin.JueJinManager.get_previous_trading_date(day) + data_list = list(hot_block_data_process.XGBHotBlockDataManager.list_all(day)) + codes_set = set() + if data_list: + for d in data_list: + if len(d[4]) > 6: + codes_set.add(d[3]) + data_dict[day] = list(codes_set) + return_str = json.dumps({"code": 0, "data": data_dict}) elif type == 201: # 鍔犲叆榛戝悕鍗� data = json.loads(_str) @@ -891,29 +903,35 @@ l2_listen_pos_health_manager.init_all(client_infos) -if __name__ == "__main__": - codes = ["002153", "002253", "002351"] - for code in codes: - global_data_loader.load_zyltgb() - limit_up_price = float(gpcode_manager.get_limit_up_price(code)) - volumes_data = juejin.get_volumns_by_code(code, 150) - volumes_data = volumes_data[1:] - volumes = juejin.parse_max_volume(volumes_data[:60], - code_nature_analyse.is_new_top(gpcode_manager.get_limit_up_price(code), - volumes_data[:60])) - logger_first_code_record.info("{} 鑾峰彇鍒伴鏉�60澶╂渶澶ч噺锛歿}", code, volumes) - code_volumn_manager.set_histry_volumn(code, volumes[0], volumes[1], volumes[2]) - # 鍒ゆ柇K绾垮舰鎬� - is_has_k_format, msg = code_nature_analyse.is_has_k_format( - gpcode_manager.get_limit_up_price(code), volumes_data) - if not is_has_k_format: - logger_first_code_record.info("{}棣栨澘K绾垮舰鎬佷笉濂�,{}", code, msg) - # 鍔犲叆绂佹浜ゆ槗浠g爜 - l2_trade_util.forbidden_trade(code) +if __name__ == "__main__1": + cid, pid = gpcode_manager.get_listen_code_pos("000070") + print(cid, pid) - code_nature_analyse.set_record_datas(code, - gpcode_manager.get_limit_up_price(code), - volumes_data) +if __name__ == "__main__": + codes = ["603655"] + for code in codes: + try: + global_data_loader.load_zyltgb() + limit_up_price = float(gpcode_manager.get_limit_up_price(code)) + volumes_data = juejin.get_volumns_by_code(code, 150) + volumes = juejin.parse_max_volume(volumes_data[:60], + code_nature_analyse.is_new_top(gpcode_manager.get_limit_up_price(code), + volumes_data[:60])) + logger_first_code_record.info("{} 鑾峰彇鍒伴鏉�60澶╂渶澶ч噺锛歿}", code, volumes) + code_volumn_manager.set_histry_volumn(code, volumes[0], volumes[1], volumes[2]) + # 鍒ゆ柇K绾垮舰鎬� + is_has_k_format, msg = code_nature_analyse.is_has_k_format( + gpcode_manager.get_limit_up_price(code), volumes_data) + if not is_has_k_format: + logger_first_code_record.info("{}棣栨澘K绾垮舰鎬佷笉濂�,{}", code, msg) + # 鍔犲叆绂佹浜ゆ槗浠g爜 + l2_trade_util.forbidden_trade(code) + + code_nature_analyse.set_record_datas(code, + gpcode_manager.get_limit_up_price(code), + volumes_data) + except: + pass # code_nature_analyse.set_record_datas(code, # limit_up_price, -- Gitblit v1.8.0