From cd830d988be0dfacd4fd5fac30630ae509fdb71b Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期三, 05 六月 2024 16:14:51 +0800 Subject: [PATCH] 上证买入修改 --- l2/l2_data_manager_new.py | 105 ++++++++++++++++++++++++---------------------------- 1 files changed, 48 insertions(+), 57 deletions(-) diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py index e88d6c4..16c0adf 100644 --- a/l2/l2_data_manager_new.py +++ b/l2/l2_data_manager_new.py @@ -11,7 +11,7 @@ from db.redis_manager_delegate import RedisUtils from l2.huaxin import l2_huaxin_util, huaxin_delegate_postion_manager from l2.l2_sell_manager import L2MarketSellManager, L2LimitUpSellManager -from l2.l2_transaction_data_manager import HuaXinSellOrderStatisticManager +from l2.l2_transaction_data_manager import HuaXinSellOrderStatisticManager, BigOrderDealManager from l2.place_order_single_data_manager import L2TradeSingleDataProcessor from log_module import async_log_util, log_export from third_data import kpl_data_manager, block_info @@ -497,7 +497,8 @@ cls.__process_order(code, start_index, end_index, capture_timestamp, is_first_code) else: # 鏈寕鍗�,鏃堕棿鐩稿樊涓嶅ぇ鎵嶈兘鎸傚崟 - if tool.trade_time_sub(latest_time, "09:32:00") < 0 or l2.l2_data_util.L2DataUtil.is_same_time( + # tool.trade_time_sub(latest_time, "09:32:00") < 0 + if l2.l2_data_util.L2DataUtil.is_same_time( now_time_str, latest_time): cls.__process_not_order(code, start_index, end_index, capture_timestamp, is_first_code) l2_log.info(code, logger_l2_process, "code:{} 澶勭悊鏁版嵁鑼冨洿: {}-{} 澶勭悊鏃堕棿:{} 绾跨▼ID锛歿}", code, @@ -964,7 +965,7 @@ now_time_int = int(tool.get_now_time_str().replace(":", "")) if now_time_int >= 145700: return False, True, f"14:57鍚庝笉鑳戒氦鏄�" - if 130100 >= now_time_int >= 112900 or now_time_int<93100: + if 130100 >= now_time_int >= 112900 or now_time_int < 93100: return False, True, f"09:31:00涔嬪墠锛�11:29:00-13:01:00涓嶈兘浜ゆ槗" # place_order_count = cls.__PlaceOrderCountManager.get_place_order_count(code) @@ -1054,41 +1055,26 @@ not_cancel_money = not_cancel_num * 100 * float(gpcode_manager.get_limit_up_price(code)) if m_base_val > not_cancel_money: return False, False, f"鎴愪氦浣嶇疆璺濈褰撳墠浣嶇疆绾拱棰�({not_cancel_money})灏忎簬m鍊�({m_base_val})" - else: - # 鍒ゆ柇涔�1浠锋牸妗d綅 - zyltgb = global_util.zyltgb_map.get(code) - if zyltgb is None: - global_data_loader.load_zyltgb() - zyltgb = global_util.zyltgb_map.get(code) - if zyltgb >= 200 * 100000000: - buy1_price = cls.__Buy1PriceManager.get_buy1_price(code) - if buy1_price is None: - return False, True, f"灏氭湭鑾峰彇鍒颁拱1浠�" - dif = float(limit_up_price) - float(buy1_price) - # 澶т簬10妗� - if dif > 0.10001: - return False, True, f"鑷敱娴侀��200浜夸互涓婏紝涔�1鍓╀綑妗f暟澶т簬10妗o紝涔颁竴锛坽buy1_price}锛夋定鍋滐紙{limit_up_price}锛�" + # 涓婅瘉涓嬪崟闇�瑕佹湁鎴愪氦澶у崟锛堝寘鍚富鍔ㄤ拱涓庤鍔ㄤ拱锛夋垨鑰呮寕涔扮殑澶у崟 + if code.find("60") == 0: + deal_big_order_count = BigOrderDealManager().get_total_buy_count(code) + if deal_big_order_count < 1: + # 缁熻鎸備拱澶у崟 + trade_index, is_default = cls.__TradeBuyQueue.get_traded_index(code) + if trade_index is None: + trade_index = 0 + limit_up_price = round(float(gpcode_manager.get_limit_up_price(code)), 2) + # 浠庢垚浜よ繘搴︿綅鍒版埅鑷充綅缃绠楀ぇ鍗� + min_money = l2_data_util.get_big_money_val(limit_up_price) + left_count, left_money = cancel_buy_strategy.L2DataComputeUtil.compute_left_buy_order(code, trade_index, total_data[-1]["index"], + limit_up_price, + min_money=min_money) + if left_count < 1: + return False, False, f"娌℃湁宸叉寕鎴栬�呮垚浜ょ殑澶у崟" - open_limit_up_lowest_price = cls.__Buy1PriceManager.get_open_limit_up_lowest_price(code) - # price_pre_close = gpcode_manager.CodePrePriceManager.get_price_pre_cache(code) - # if open_limit_up_lowest_price and ( - # float(open_limit_up_lowest_price) - price_pre_close) / price_pre_close < 0.05: - # return False, True, f"鐐告澘鍚庢渶浣庝环璺岃嚦5%浠ヤ笅" - # 鍥炲皝鐨勭エ锛屼笅13:15涔板叆闇�瑕佸垽鏂澘鍧楁槸鍚︿负鐙嫍 - # if open_limit_up_lowest_price and int(total_data[-1]["val"]["time"].replace(":", "")) > 131500: - # # 鑾峰彇褰撳墠绁ㄧ殑娑ㄥ仠鍘熷洜 - # if code in LimitUpCodesPlateKeyManager.today_total_limit_up_reason_dict: - # limit_up_reason = kpl_data_manager.KPLLimitUpDataRecordManager.get_current_block(code) - # if limit_up_reason and limit_up_reason not in constant.KPL_INVALID_BLOCKS: - # # 鍒ゆ柇鏄惁鏄嫭鑻� - # codes = kpl_data_manager.KPLLimitUpDataRecordManager.get_current_codes_by_block(limit_up_reason) - # if codes: - # codes = copy.deepcopy(codes) - # codes.discard(code) - # if not codes: - # return False, True, f"13:15浠ュ悗鐐告澘涔嬪悗涓嬪崟锛岋紙{limit_up_reason}锛� 涓虹嫭鑻�" + # 鏆傛椂娉ㄩ噴鎯充拱鍗曞姛鑳� if not cls.__WantBuyCodesManager.is_in_cache(code): # if cls.__TradeTargetCodeModeManager.get_mode_cache() == TradeTargetCodeModeManager.MODE_ONLY_BUY_WANT_CODES: @@ -1302,8 +1288,6 @@ @classmethod def can_buy_first_new(cls, code, limit_up_price): - if 1>0: - return True, False, "涔版墍鏈�" now_timestamp = int(tool.get_now_time_str().replace(":", "")) # 鍒ゆ柇鏉垮潡 @@ -1320,11 +1304,14 @@ zylt_threshold_as_yi = buy_condition_util.get_zyltgb_threshold(situation) zyltgb_as_yi = round(global_util.zyltgb_map.get(code) / 100000000, 2) - if zyltgb_as_yi >= zylt_threshold_as_yi[1]: - return False, True, f"{zylt_threshold_as_yi[1]}浜夸互涓婄殑閮戒笉涔帮紙{zyltgb_as_yi}锛�" - if zyltgb_as_yi < zylt_threshold_as_yi[0]: return False, True, f"{zylt_threshold_as_yi[0]}浜夸互涓嬬殑閮戒笉涔帮紙{zyltgb_as_yi}锛�" + + if 1 > 0: + return True, False, "涔版墍鏈�" + + if zyltgb_as_yi >= zylt_threshold_as_yi[1]: + return False, True, f"{zylt_threshold_as_yi[1]}浜夸互涓婄殑閮戒笉涔帮紙{zyltgb_as_yi}锛�" msg_list = [] if is_in_strong_time_30: @@ -1514,7 +1501,7 @@ # _start_time = l2_data_log.l2_time(code, tool.get_now_timestamp() - _start_time, "m鍊奸槇鍊艰绠�") # 璁剧疆涓烘�诲崠棰� - new_buy_exec_index, buy_nums, buy_count, rebegin_buy_pos, threshold_money_new, max_num_set_new, not_buy_msg = cls.__sum_buy_num_for_order_active( + new_buy_exec_index, buy_nums, buy_count, rebegin_buy_pos, threshold_money_new, max_num_set_new, not_buy_msg, clear_buy_single = cls.__sum_buy_num_for_order_active( code, start_process_index, compute_end_index, @@ -1525,8 +1512,9 @@ threshold_money = threshold_money_new order_begin_pos.threshold_money = threshold_money - l2_log.debug(code, "m鍊�-{} 閲忔瘮:{} rebegin_buy_pos:{}", threshold_money, cls.volume_rate_info[code][0], - rebegin_buy_pos) + l2_log.debug(code, "鑼冨洿锛歿}-{} m鍊�-{} 閲忔瘮:{} rebegin_buy_pos:{} clear_buy_single:{}", compute_start_index, compute_end_index, + threshold_money, cls.volume_rate_info[code][0], + rebegin_buy_pos, clear_buy_single) # 涔板叆淇″彿浣嶄笌璁$畻浣嶇疆闂撮殧2s鍙婁互涓婁簡 if rebegin_buy_pos is not None: @@ -1568,16 +1556,18 @@ else: # 鏈揪鍒颁笅鍗曟潯浠讹紝淇濆瓨绾拱棰濓紝璁剧疆绾拱棰� # 璁板綍涔板叆淇″彿浣嶇疆 - cls.__save_order_begin_data(code, OrderBeginPosInfo(buy_single_index=buy_single_index, buy_exec_index=-1, - buy_compute_index=compute_end_index, num=buy_nums, - count=buy_count, - mode_desc=order_begin_pos.mode_desc, - max_num_set=max_num_set_new, mode=order_begin_pos.mode, - sell_info=order_begin_pos.sell_info, - threshold_money=threshold_money)) - # 璁板綍娌′笅鍗曞師鍥� - async_log_util.info(logger_l2_not_buy_reasons, f"{code}#{not_buy_msg}") - _start_time = t.time() + if not clear_buy_single: + # 娌℃湁娓呴櫎淇″彿浣嶇疆灏变繚瀛樹笅鍗曚綅缃俊鎭� + cls.__save_order_begin_data(code, OrderBeginPosInfo(buy_single_index=buy_single_index, buy_exec_index=-1, + buy_compute_index=compute_end_index, num=buy_nums, + count=buy_count, + mode_desc=order_begin_pos.mode_desc, + max_num_set=max_num_set_new, mode=order_begin_pos.mode, + sell_info=order_begin_pos.sell_info, + threshold_money=threshold_money)) + # 璁板綍娌′笅鍗曞師鍥� + async_log_util.info(logger_l2_not_buy_reasons, f"{code}#{not_buy_msg}") + _start_time = t.time() # 鑾峰彇涓嬪崟璧峰淇″彿 @classmethod @@ -2245,15 +2235,16 @@ trigger_buy = False # 蹇呴』涓鸿繛缁�2绉掑唴鐨勬暟鎹� if L2DataUtil.time_sub_as_ms(_val, total_datas[buy_single_index]["val"]) > max_space_time_ms: + # 娓呴櫎涔扮偣鏁版嵁 cls.__TradePointManager.delete_buy_point(code) if i == compute_end_index: # 鏁版嵁澶勭悊瀹屾瘯 - return None, buy_nums, buy_count, None, threshold_money, max_buy_num_set, f"銆恵i}銆戜俊鍙蜂笉杩炵画锛屽泭鎷椂闂�-{max_space_time_ms}ms" + return None, buy_nums, buy_count, None, threshold_money, max_buy_num_set, f"銆恵i}銆戜俊鍙蜂笉杩炵画锛屽泭鎷椂闂�-{max_space_time_ms}ms", True else: # 璁$畻涔板叆淇″彿锛屼笉鑳藉悓涓�鏃堕棿寮�濮嬭绠� for ii in range(buy_single_index + 1, compute_end_index + 1): if total_datas[buy_single_index]["val"]["time"] != total_datas[ii]["val"]["time"]: - return None, buy_nums, buy_count, ii, threshold_money, max_buy_num_set, f"銆恵i}銆戜俊鍙蜂笉杩炵画锛屽泭鎷椂闂�-{max_space_time_ms}ms" + return None, buy_nums, buy_count, ii, threshold_money, max_buy_num_set, f"銆恵i}銆戜俊鍙蜂笉杩炵画锛屽泭鎷椂闂�-{max_space_time_ms}ms", True # if L2DataUtil.is_sell(_val): # threshold_money += _val["num"] * int(float(_val["price"]) * 100) # threshold_num = round(threshold_money / (limit_up_price * 100)) @@ -2357,14 +2348,14 @@ async_log_util.error(logger_l2_error, f"璁板綍浜ゆ槗鍥犲瓙鍑洪敊锛歿str(e)}") l2_log.buy_debug(code, f"婵�杩涗拱涓诲姩鍗栨墜鏁帮細{sell_order_num}") - return i, buy_nums, buy_count, None, threshold_money, max_buy_num_set, "鍙互涓嬪崟" + return i, buy_nums, buy_count, None, threshold_money, max_buy_num_set, "鍙互涓嬪崟", False l2_log.buy_debug(code, "灏氭湭鑾峰彇鍒颁拱鍏ユ墽琛岀偣(婵�杩涗拱鍏�)锛岃捣濮嬭绠椾綅缃細{} 缁熻绾拱鎵嬫暟锛歿} 鐩爣绾拱鎵嬫暟锛歿} 缁熻绾拱鍗曟暟锛歿} ", compute_start_index, buy_nums, threshold_num, buy_count) - return None, buy_nums, buy_count, None, threshold_money, max_buy_num_set, not_buy_msg + return None, buy_nums, buy_count, None, threshold_money, max_buy_num_set, not_buy_msg, False def test_trade_record(): -- Gitblit v1.8.0