From 250dea26eab3894551751381b1757ac2b440d09d Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期三, 24 四月 2024 10:28:54 +0800 Subject: [PATCH] 删除之前的下单方式 --- l2/l2_data_manager_new.py | 177 +++++++++++++++++++--------------------------------------- 1 files changed, 58 insertions(+), 119 deletions(-) diff --git a/l2/l2_data_manager_new.py b/l2/l2_data_manager_new.py index 023fe07..7a431e9 100644 --- a/l2/l2_data_manager_new.py +++ b/l2/l2_data_manager_new.py @@ -947,12 +947,13 @@ # 2.鎬诲崠棰濅负0 if abs(float(limit_up_price) - float(trade_price)) < 0.001: sell_data = cls.__L2MarketSellManager.get_current_total_sell_data(code) - if sell_data and sell_data[1]<=0: + if sell_data and sell_data[1] <= 0: # 鏉夸笂鏀鹃噺锛屽垽鏂槸鍚︽湁鏀鹃噺锛屾斁閲忔墠浼氫笅鍗� # 鑾峰彇鏈�杩�1s鐨勪富鍔ㄥ崠閲戦 - min_time = total_data[order_begin_pos.buy_single_index]['val']['time'] + min_time = total_data[order_begin_pos.buy_single_index]['val']['time'] min_time = tool.trade_time_add_second(min_time, -1) - sell_orders = HuaXinSellOrderStatisticManager.get_latest_transaction_datas(code, min_deal_time=min_time) + sell_orders = HuaXinSellOrderStatisticManager.get_latest_transaction_datas(code, + min_deal_time=min_time) sell_order_num = sum([x[1] for x in sell_orders]) sell_money = int(float(limit_up_price) * sell_order_num) if sell_money < 2990000: @@ -1337,37 +1338,17 @@ # if code.find('60') == 0: # 婵�杩涗拱 continue_count = 1 - has_single, _index, sell_info, single_msg = cls.__compute_active_order_begin_pos(code, continue_count, - compute_start_index, - compute_end_index) + has_single, _index, sell_info, single_msg, mode = cls.__compute_active_order_begin_pos(code, continue_count, + compute_start_index, + compute_end_index) fast_msg = None if has_single: - order_begin_pos.mode = OrderBeginPosInfo.MODE_ACTIVE + order_begin_pos.mode = mode order_begin_pos.sell_info = sell_info fast_msg = sell_info # 鐢ㄤ簡淇″彿灏卞繀椤绘竻闄ゆ帀鍘熸湁淇″彿 place_order_single_data_manager.L2TradeSingleDataManager.clear_data(code) - # if not has_single: - # # 绗簩姝ワ細璁$畻闂數涓嬪崟淇″彿 - # has_single, _index, sell_info = cls.__compute_fast_order_begin_pos(code, compute_start_index, - # compute_end_index) - # fast_msg = None - # if has_single: - # order_begin_pos.mode = OrderBeginPosInfo.MODE_FAST - # order_begin_pos.sell_info = sell_info - # elif _index is not None and _index < 0: - # fast_msg = sell_info - # # 绗笁姝�: 璁$畻甯歌涔板叆淇″彿 - # has_single, _index = cls.__compute_order_begin_pos(code, max( - # (compute_start_index - continue_count - 1) if new_add else compute_start_index, 0), - # continue_count, - # compute_end_index) - # order_begin_pos.mode = OrderBeginPosInfo.MODE_NORMAL - # # 鑾峰彇鏈�鏂扮殑涔颁俊鎭� - # sell_info = cls.__L2MarketSellManager.get_current_total_sell_data(code) - # order_begin_pos.sell_info = sell_info - # 濡傛灉涔板叆淇″彿涓庝笂娆$殑涔板叆淇″彿涓�鏍峰氨涓嶈兘绠楁柊鐨勪俊鍙� if cls.__last_buy_single_dict.get(code) == _index: has_single = None _index = None @@ -1377,32 +1358,34 @@ order_begin_pos.at_limit_up = cls.__is_at_limit_up_buy(code) # -------------璁$畻淇″彿浣嶅埌鎴愪氦浣嶇殑绾拱棰濓紙杩囪繙鍒欎负鏃犳晥浣嶇疆锛�------------------- if order_begin_pos.at_limit_up: + # 淇″彿浣嶆槸鍚︽湁鏁� + pass # 鑾峰彇鎴愪氦杩涘害浣嶇疆 - trade_index, is_default = TradeBuyQueue().get_traded_index(code) - if trade_index and not is_default: - m_base_val = l2_trade_factor.L2PlaceOrderParamsManager.get_base_m_val(code) - thresh_hold_num = m_base_val * 4 // (float(gpcode_manager.get_limit_up_price(code)) * 100) - # 鐪熷疄涓嬪崟浣嶅埌鎴愪氦浣嶇疆鐨勭函涔伴 * 3 - total_num = 0 - for i in range(trade_index + 1, buy_single_index): - data = total_datas[i] - val = data["val"] - if not L2DataUtil.is_limit_up_price_buy(val): - continue - left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2( - code, - data["index"], - total_datas, - local_today_canceled_buyno_map.get( - code)) - total_num += left_count * val["num"] - if total_num > thresh_hold_num: - break - if total_num > thresh_hold_num: - # 璺濈鎴愪氦杩涘害浣嶇疆杩囪繙 - l2_log.debug(code, - f"鑾峰彇鐨勪俊鍙蜂綅鏃犳晥锛堟澘涓婁拱锛岃寖鍥达細{trade_index + 1}-{order_begin_pos.buy_single_index} 鏈垚浜ゆ�绘墜{total_num}/闃堝�納thresh_hold_num}锛�") - return None + # trade_index, is_default = TradeBuyQueue().get_traded_index(code) + # if trade_index and not is_default: + # m_base_val = l2_trade_factor.L2PlaceOrderParamsManager.get_base_m_val(code) + # thresh_hold_num = m_base_val * 4 // (float(gpcode_manager.get_limit_up_price(code)) * 100) + # # 鐪熷疄涓嬪崟浣嶅埌鎴愪氦浣嶇疆鐨勭函涔伴 * 3 + # total_num = 0 + # for i in range(trade_index + 1, buy_single_index): + # data = total_datas[i] + # val = data["val"] + # if not L2DataUtil.is_limit_up_price_buy(val): + # continue + # left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2( + # code, + # data["index"], + # total_datas, + # local_today_canceled_buyno_map.get( + # code)) + # total_num += left_count * val["num"] + # if total_num > thresh_hold_num: + # break + # if total_num > thresh_hold_num: + # # 璺濈鎴愪氦杩涘害浣嶇疆杩囪繙 + # l2_log.debug(code, + # f"鑾峰彇鐨勪俊鍙蜂綅鏃犳晥锛堟澘涓婁拱锛岃寖鍥达細{trade_index + 1}-{order_begin_pos.buy_single_index} 鏈垚浜ゆ�绘墜{total_num}/闃堝�納thresh_hold_num}锛�") + # return None # -----------------------------涔板叆璁$畻鍒濆鍖�,璁$畻绾拱棰濋槇鍊�----------------------- cls.__last_buy_single_dict[code] = buy_single_index @@ -1411,25 +1394,8 @@ order_begin_pos.count = 0 order_begin_pos.buy_single_index = buy_single_index # 璋冩暣闂數涓嬪崟鐨勪拱鍏ラ槇鍊� - if order_begin_pos.sell_info and order_begin_pos.mode == OrderBeginPosInfo.MODE_FAST: - situation = cls.__MarketSituationManager.get_situation_cache() - if sell_info[1] > 2000 * 10000 and situation != MarketSituationManager.SITUATION_GOOD: - # 甯傚満琛屾儏濂芥椂涓嶆墦鎶� - if code.find('00') == 0: - # 娣卞湷棣栨涓嬪崟鎵撴姌 - place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count(code) - if place_order_count is not None and place_order_count == 0: - order_begin_pos.threshold_money = int(sell_info[1]) - else: - order_begin_pos.threshold_money = int(sell_info[1] * 0.6) - - else: - order_begin_pos.threshold_money = int(sell_info[1] * 0.8) - else: - order_begin_pos.threshold_money = int(sell_info[1]) - if order_begin_pos.sell_info and order_begin_pos.mode == OrderBeginPosInfo.MODE_ACTIVE: - # 鎬诲崠棰濈殑1鍊� - order_begin_pos.threshold_money = int(sell_info[1] * 1.0) + # 鎬诲崠棰濈殑1鍊� + order_begin_pos.threshold_money = int(sell_info[1] * 1.0) l2_log.debug(code, "鑾峰彇鍒颁拱鍏ヤ俊鍙疯捣濮嬬偣锛歿} ,璁$畻鑼冨洿锛歿}-{} 锛岄噺姣旓細{}锛屾槸鍚︽澘涓婁拱锛歿}锛屾暟鎹細{} 妯″紡锛歿}锛坽}锛� 淇″彿绫诲瀷锛歿}", buy_single_index, @@ -1457,42 +1423,19 @@ # 涔板叆绾拱棰濈粺璁� new_buy_exec_index, buy_nums, buy_count, rebegin_buy_pos, max_num_set_new, not_buy_msg = None, None, None, None, [], "" - if order_begin_pos.mode == OrderBeginPosInfo.MODE_ACTIVE: - # 璁剧疆涓烘�诲崠棰� - 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( - code, - start_process_index, - compute_end_index, - order_begin_pos.num, - order_begin_pos.count, - order_begin_pos.threshold_money, - order_begin_pos.buy_single_index, order_begin_pos.max_num_set, order_begin_pos.sell_info[1]) - threshold_money = threshold_money_new - order_begin_pos.threshold_money = threshold_money - elif order_begin_pos.mode == OrderBeginPosInfo.MODE_FAST: - threshold_money = order_begin_pos.threshold_money - 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_fast( - code, - start_process_index, - compute_end_index, - order_begin_pos.num, - order_begin_pos.count, - threshold_money, - order_begin_pos.buy_single_index, order_begin_pos.max_num_set) - threshold_money = threshold_money_new - order_begin_pos.threshold_money = threshold_money - else: - new_buy_exec_index, buy_nums, buy_count, rebegin_buy_pos, max_num_set_new, not_buy_msg = cls.__sum_buy_num_for_order_3( - code, - start_process_index, - compute_end_index, - order_begin_pos.num, - order_begin_pos.count, - threshold_money, - order_begin_pos.buy_single_index, - order_begin_pos.max_num_set, - order_begin_pos.at_limit_up) + # 璁剧疆涓烘�诲崠棰� + 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( + code, + start_process_index, + compute_end_index, + order_begin_pos.num, + order_begin_pos.count, + order_begin_pos.threshold_money, + order_begin_pos.buy_single_index, order_begin_pos.max_num_set, order_begin_pos.sell_info[1]) + 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) @@ -1522,11 +1465,6 @@ l2_log.debug(code, "delete_buy_cancel_point") # 鐩存帴涓嬪崟 ordered = cls.__buy(code, capture_time, total_datas[-1], total_datas[-1]["index"], is_first_code) - - # 淇濆瓨闂數涓嬪崟鐨勪拱鍏ヤ俊鎭� - if order_begin_pos.mode == OrderBeginPosInfo.MODE_FAST: - cls.__latest_fast_place_order_info_dict[code] = ( - order_begin_pos.sell_info[0], order_begin_pos.sell_info[1]) # 鏁版嵁鏄惁澶勭悊瀹屾瘯 if new_buy_exec_index < compute_end_index: @@ -1733,7 +1671,7 @@ total_datas = local_today_datas[code] start_time_str = total_datas[start_index]["val"]["time"] if end_index - start_index + 1 < continue_count: - return False, -1, "淇″彿涓嶈繛缁�", '' + return False, -1, "淇″彿涓嶈繛缁�", '', OrderBeginPosInfo.MODE_NORMAL # 鑾峰彇鏈�杩戠殑鎬诲崠淇℃伅 # (time_str, round(money), volume, sell_1_info) refer_sell_data = cls.__L2MarketSellManager.get_refer_sell_data(code, start_time_str) @@ -1752,12 +1690,12 @@ # 閲戦瑕佸ぇ浜�50涓� if _val["num"] * float(_val["price"]) < 5000: continue - return True, i, [refer_sell_data[0], 0], '涓婅瘉涔板叆' - return False, -1, "鏈幏鍙栧埌婵�杩涗拱鐨勮捣濮嬩俊鍙�", '' + return True, i, [refer_sell_data[0], 0], '涓婅瘉涔板叆', OrderBeginPosInfo.MODE_FAST + return False, -1, "鏈幏鍙栧埌婵�杩涗拱鐨勮捣濮嬩俊鍙�", '', OrderBeginPosInfo.MODE_NORMAL else: # 娣辫瘉 if refer_sell_data is None: - return False, -1, "鎬诲崠涓虹┖", '' + return False, -1, "鎬诲崠涓虹┖", '', OrderBeginPosInfo.MODE_NORMAL if refer_sell_data is None: refer_sell_data = (start_time_str, 0, 0, (round(float(total_datas[start_index]["val"]["price"]), 2), 0)) l2_log.debug(code, f"涓㈠け鎬诲崠棰濓紝璁剧疆榛樿涓�0锛岃绠楄寖鍥达細{start_index}-{end_index}") @@ -1793,22 +1731,23 @@ buy_single_index = cls.__get_active_single_start_index(code, start_index, end_index, continue_count, valid_single=False) if buy_single_index is not None: - return True, buy_single_index, [refer_sell_data[0], threshold_money], "涓婃澘鏃犳定鍋滃崠" + return True, buy_single_index, [refer_sell_data[0], + threshold_money], "涓婃澘鏃犳定鍋滃崠", OrderBeginPosInfo.MODE_NORMAL else: # 鎸夌収鎴愪氦涔板叆淇″彿璁$畻 buy_single_index = cls.__get_active_single_start_index(code, start_index, end_index, continue_count, valid_single=True) if buy_single_index is not None: - return True, buy_single_index, [refer_sell_data[0], 0], "涓婃澘鏈夋垚浜や拱鍏ヤ俊鍙�" + return True, buy_single_index, [refer_sell_data[0], 0], "涓婃澘鏈夋垚浜や拱鍏ヤ俊鍙�", OrderBeginPosInfo.MODE_FAST else: # 鏉夸笂鏀鹃噺锛氬彧闇�瑕佷竴绗旀定鍋滀拱鍙綔涓轰俊鍙� buy_single_index = cls.__get_active_single_start_index(code, start_index, end_index, continue_count, valid_single=False) if buy_single_index is not None: - return True, buy_single_index, [refer_sell_data[0], 0], "鏉夸笂鏀鹃噺" + return True, buy_single_index, [refer_sell_data[0], 0], "鏉夸笂鏀鹃噺", OrderBeginPosInfo.MODE_NORMAL - return False, -1, "鏈幏鍙栧埌婵�杩涗拱鐨勮捣濮嬩俊鍙�", '' + return False, -1, "鏈幏鍙栧埌婵�杩涗拱鐨勮捣濮嬩俊鍙�", '', OrderBeginPosInfo.MODE_NORMAL @classmethod def test__compute_active_order_begin_pos(cls, code, continue_count, start_index, end_index): -- Gitblit v1.8.0