code_attribute/code_volumn_manager.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
constant.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
db/redis_manager.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
db/redis_manager_delegate.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
l2/l2_data_manager_new.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
l2/l2_transaction_data_processor.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
servers/huaxin_trade_server.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
trade/buy_radical/radical_buy_data_manager.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
trade/buy_radical/radical_buy_strategy.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
code_attribute/code_volumn_manager.py
@@ -77,6 +77,11 @@ auto_free=False) def get_max_volume_in_5days(self, code): """ 5日最大量 @param code: @return: """ return self.__max_volume_in_5days.get(code) def get_volume_rate_refer_in_5days(self, code, total_sell_volume=0): @@ -84,7 +89,7 @@ 获取今日量与5日最大量的参考值 @param total_sell_volume: 当前总卖量 @param code: @return: @return: 5日量比 """ max_volume = self.get_max_volume_in_5days(code) if not max_volume: constant.py
@@ -31,7 +31,7 @@ "db": 0, "pwd": "Yeshi2016@" } if is_windows() else { "host": "172.16.32.15", "host": "127.0.0.1", "port": 6379, "db": 0, "pwd": "Yeshi2016@" db/redis_manager.py
@@ -39,7 +39,8 @@ try: return lamada_method() finally: logger_redis_debug.info("{}({}):{}", method_name, round((time.time() - __start_time) * 1000, 3), key) # logger_redis_debug.info("{}({}):{}", method_name, round((time.time() - __start_time) * 1000, 3), key) pass @classmethod def get(cls, redis_, key, auto_free=True): db/redis_manager_delegate.py
@@ -1,6 +1,8 @@ """ redis管理器 """ import builtins import json import logging import queue import time @@ -11,6 +13,8 @@ from log_module import async_log_util from log_module.log import logger_redis_debug, logger_system from utils import tool, middle_api_protocol from db import redis_manager config = constant.REDIS_CONFIG @@ -33,6 +37,9 @@ class RedisUtils: # 本机执行redis __LOCAL_REQUEST = True __async_task_queue = queue.Queue(maxsize=4096) @classmethod @@ -46,33 +53,70 @@ @classmethod def __request(cls, db, cmd, key, args=None): data = { "db": db, "cmd": cmd, "key": key, } if args is not None: data["args"] = args fdata = middle_api_protocol.load_redis_cmd(data) result = middle_api_protocol.request(fdata) return result if cls.__LOCAL_REQUEST: redis = RedisManager(db).getRedis() method = getattr(redis_manager.RedisUtils, cmd) args_ = [redis, key] if args is not None: if builtins.type(args) == tuple or builtins.type(args) == list: args = list(args) if cmd == "setex": args_.append(args[0]) if type(args[1]) == list: args_.append(json.dumps(args[1])) else: args_.append(args[1]) else: for a in args: args_.append(a) else: args_.append(args) args_ = tuple(args_) result = method(*args_) if builtins.type(result) == set: result = list(result) return result else: data = { "db": db, "cmd": cmd, "key": key, } if args is not None: data["args"] = args fdata = middle_api_protocol.load_redis_cmd(data) result = middle_api_protocol.request(fdata) return result # [(db, cmd, key, args)] @classmethod def __batch__request(cls, odatas): _datas = [] for d in odatas: data = { "db": d[0], "cmd": d[1], "key": d[2] } if d[3] is not None: data["args"] = d[3] _datas.append(data) fdata = middle_api_protocol.load_redis_cmds(_datas) results = middle_api_protocol.request(fdata) return results if cls.__LOCAL_REQUEST: result_list = [] for d in odatas: db = d[0] cmd = d[1] key = d[2] args = None if d[3] is not None: args = d[3] result = cls.__request(db, cmd, key, args) result_list.append(result) return result_list else: _datas = [] for d in odatas: data = { "db": d[0], "cmd": d[1], "key": d[2] } if d[3] is not None: data["args"] = d[3] _datas.append(data) fdata = middle_api_protocol.load_redis_cmds(_datas) results = middle_api_protocol.request(fdata) return results @classmethod def __get_db(cls, redis_): l2/l2_data_manager_new.py
@@ -2075,45 +2075,55 @@ limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) bigger_money = l2_data_util.get_big_money_val(limit_up_price, tool.is_ge_code(code)) min_num = int(bigger_money / limit_up_price / 100) # 如果有大单成交就不需要看大单 total_deal_money = 0 if constant.CAN_RADICAL_BUY_NEED_BIG_ORDER_EVERYTIME: # 每次下单都需要大单 current_big_order_deal_money_info = EveryLimitupBigDealOrderManager.get_big_buy_deal_order_money_info( code) if current_big_order_deal_money_info: total_deal_money = current_big_order_deal_money_info[0] if current_big_order_deal_money_info and tool.trade_time_sub(tool.get_now_time_str(), current_big_order_deal_money_info[1]) > 60: # 60s以上的大单不看 total_deal_money = 0 else: # 只需要总成交的大单 total_deal_money = BigOrderDealManager().get_total_buy_money(code) refer_sell_data = L2MarketSellManager().get_refer_sell_data(code, radical_data[3]) # 参考总卖额 refer_sell_money = 0 if refer_sell_data: refer_sell_money = refer_sell_data[1] THRESHOLD_MONEY = 2990000 if refer_sell_money >= 1e7: THRESHOLD_MONEY = 2990000 * 2 else: THRESHOLD_MONEY = 2990000 if total_deal_money >= THRESHOLD_MONEY: # 大单判断结果 big_order_deal_enough_result = radical_buy_data_manager.is_big_order_deal_enough(code, code_volumn_manager.CodeVolumeManager().get_volume_rate_refer_in_5days( code), refer_sell_money) # 缺乏的大单金额 lack_money = big_order_deal_enough_result[3] # 如果有大单成交就不需要看大单 if constant.CAN_RADICAL_BUY_NEED_BIG_ORDER_EVERYTIME: # 每次下单都需要大单 current_big_order_deal_money_info = EveryLimitupBigDealOrderManager.get_big_buy_deal_order_money_info( code) if current_big_order_deal_money_info and tool.trade_time_sub(tool.get_now_time_str(), current_big_order_deal_money_info[1]) > 60: # 60s以上就不下单了 return False, None, "距离上次统计大单时间过去60s", set() if lack_money == 0: min_num = int(5000 / limit_up_price) # 需要监听的大单 watch_indexes = set() # 总委托大单金额 total_delegating_big_money = 0 single_index = None for i in range(start_index, end_index + 1): # 从成交进度位开始看 trade_index, is_default = cls.__TradeBuyQueue.get_traded_index(code) if trade_index is None: trade_index = 0 canceled_buyno_map = local_today_canceled_buyno_map.get(code) for i in range(trade_index, end_index + 1): data = total_datas[i] val = data["val"] if not L2DataUtil.is_limit_up_price_buy(val): continue if val["num"] < min_num: continue # 撤单不算 left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, i, total_datas, canceled_buyno_map) if left_count == 0: continue # 上证有可能是部分成交的大单 if i == start_index and tool.is_sh_code(code): dealing_active_order_info = HuaXinBuyOrderManager().get_dealing_active_order_info(code) @@ -2121,9 +2131,9 @@ # 判断是否为大单 order_money = dealing_active_order_info[2] + round(val["price"], 2) * val["num"] * 100 if order_money >= bigger_money: total_delegating_big_money += order_money lack_money -= order_money watch_indexes.add(i) if total_delegating_big_money + total_deal_money >= THRESHOLD_MONEY: if lack_money < 0: single_index = i break @@ -2131,8 +2141,8 @@ # 主动买单后的数据不算 continue watch_indexes.add(i) total_delegating_big_money += round(val["price"], 2) * val["num"] * 100 if total_delegating_big_money + total_deal_money >= THRESHOLD_MONEY: lack_money -= round(val["price"], 2) * val["num"] * 100 if lack_money < 0: single_index = i break if single_index is not None: l2/l2_transaction_data_processor.py
@@ -21,6 +21,7 @@ from trade import current_price_process_manager, trade_constant import concurrent.futures from trade.buy_radical import radical_buy_strategy from trade.buy_radical.radical_buy_data_manager import RadicalBuyDataManager, EveryLimitupBigDealOrderManager from utils import tool @@ -99,6 +100,7 @@ if limit_up_price > datas[-1][1]: # 没有涨停 EveryLimitupBigDealOrderManager.open_limit_up(code) radical_buy_strategy.clear_data(code) except: pass servers/huaxin_trade_server.py
@@ -52,7 +52,7 @@ from trade.huaxin.huaxin_trade_record_manager import DelegateRecordManager from trade.order_statistic import DealAndDelegateWithBuyModeDataManager from trade.buy_radical.radical_buy_data_manager import RadicalBuyDataManager, RadicalBuyBlockManager, \ EveryLimitupBigDealOrderManager EveryLimitupBigDealOrderManager, RadicalCodeMarketInfoManager from trade.sell.sell_rule_manager import TradeRuleManager from trade.trade_data_manager import RadicalBuyDealCodesManager from trade.trade_manager import CodesTradeStateManager @@ -251,7 +251,8 @@ CodesNameManager().add_code_names(code_name_map) # 更新辨识度代码 threading.Thread(target= block_special_codes_manager.update_block_special_codes, daemon=True).start() threading.Thread(target=block_special_codes_manager.update_block_special_codes, daemon=True).start() sk.sendall( socket_util.load_header(json.dumps({"code": 0, "data": fdatas}).encode(encoding='utf-8'))) @@ -474,6 +475,15 @@ L2MarketSellManager().set_current_total_sell_data(code, time_str, data["totalAskVolume"] * data["avgAskPrice"], data["totalAskVolume"], sell_1_info, data.get("sell")) # 设置扫入数据 sell_2_info = data["sell"][1] if data.get("sell") and len(data.get("sell")) > 1 else None RadicalCodeMarketInfoManager().set_market_info(code, time_str, limit_up_price, data["buy"][0], sell_2_info) # 判断是否下单 state = CodesTradeStateManager().get_trade_state_cache(code) if not trade_util.is_can_order_by_state(state): # 不处于可下单状态 RadicalBuyDataManager().market_info_change(code) @classmethod def trading_order_canceled(cls, code, order_no): @@ -788,6 +798,11 @@ f"开得太高:{code}") radical_buy_data_manager.ExcludeIndexComputeCodesManager.add_code(code) return True if not RadicalCodeMarketInfoManager().is_opened_limit_up(code): async_log_util.info(logger_l2_radical_buy, f"没有炸过板:{code}") return True radical_buy_data_manager.ExcludeIndexComputeCodesManager.remove_code(code) if result_by_volume[0] == radical_buy_strategy.BUY_MODE_DIRECT and not tool.is_sh_code(code): @@ -818,7 +833,7 @@ if buy_result: # 下单成功 radical_buy_data_manager.BlockPlaceOrderRecordManager().add_record(code, buy_blocks) radical_buy_strategy.clear_latest_deal_active_buy_order(code) radical_buy_strategy.clear_data(code) RDCancelBigNumComputer().clear_data(code) return True else: @@ -849,8 +864,6 @@ if can_clear_before_data: # 清除 EveryLimitupBigDealOrderManager.clear(code) # 回调 @@ -914,7 +927,7 @@ def __init(): def run_pending(): schedule.every().day.at("15:10:00").do(zyltgb_util.update_all_zylt_volumes) schedule.every().day.at("01:01:00").do(__test_pre_place_order) schedule.every().day.at("01:01:30").do(__test_pre_place_order) schedule.every().day.at("09:10:00").do(__subscript_fixed_codes_l2) schedule.every().day.at("08:00:01").do(history_k_data_manager.update_history_k_bars) schedule.every().day.at("08:30:01").do(history_k_data_manager.update_history_k_bars) trade/buy_radical/radical_buy_data_manager.py
@@ -29,6 +29,74 @@ from utils import tool, global_util @tool.singleton class RadicalCodeMarketInfoManager: """ 激进买的票行情数据管理 """ # 涨停情况 {"代码":[涨停时间,炸板时间]} __db = 3 __code_limit_up_info_dict = {} __redis_manager = redis_manager.RedisManager(3) def __init__(self): self.__load_data() def __load_data(self): keys = redis_manager.RedisUtils.keys(self.__get_redis(), "market_info_for_radical-*") for k in keys: code = k.split("-")[1] val = redis_manager.RedisUtils.get(self.__get_redis(), k) val = json.loads(val) self.__code_limit_up_info_dict[code] = val def __get_redis(self): return self.__redis_manager.getRedis() def __set_code_limit_up_info(self, code, info): async_log_util.info(logger_l2_radical_buy_data, f"上板/炸板数据:{code}-{info}") redis_manager.RedisUtils.setex_async(self.__db, f"market_info_for_radical-{code}", tool.get_expire(), json.dumps(info)) def set_market_info(self, code, time_str, limit_up_price, buy1_info, sell2_info): """ 设置行情信息 @param code: @param time_str: 行情时间 @param limit_up_price: 涨停价格 @param buy1_info: 买1信息 (价格,量) @param sell2_info: 卖2信息 (价格,量) @return: """ if abs(buy1_info[0] - limit_up_price) < 0.0001: # 涨停 if buy1_info[0] * buy1_info[1] > 1e7: # 1000w的封单才算涨停 if code not in self.__code_limit_up_info_dict: self.__code_limit_up_info_dict[code] = [time_str, ''] self.__set_code_limit_up_info(code, self.__code_limit_up_info_dict[code]) else: # 尚未涨停,判断炸板 if sell2_info and sell2_info[1] > 0: # 出现买2 if code in self.__code_limit_up_info_dict: if not self.__code_limit_up_info_dict[code][1]: # 有涨停时间且没有记录炸板时间 self.__code_limit_up_info_dict[code][1] = time_str self.__set_code_limit_up_info(code, self.__code_limit_up_info_dict[code]) def is_opened_limit_up(self, code): """ 是否炸过板 @param code: @return: """ data = self.__code_limit_up_info_dict.get(code) if data and data[1]: return True return False class RadicalBuyDataManager: @classmethod def is_code_can_buy(cls, code, deal_codes=None, is_refered=False): @@ -119,13 +187,19 @@ @classmethod def place_order_success(cls, code): # 如果有大单成交就加红 volume_rate = code_volumn_manager.CodeVolumeManager().get_volume_rate(code, with_info=False) if volume_rate is None: volume_rate = 0.5 big_order_deal_enough = is_big_order_deal_enough(code, volume_rate, 0) # BigOrderDealManager().get_total_buy_count(code) if big_order_deal_enough[0]: pass @classmethod def market_info_change(cls, code): """ 行情变化:当量达到69%就加红 @param code: @return: """ if gpcode_manager.MustBuyCodesManager().is_in_cache(code): return volume_rate = code_volumn_manager.CodeVolumeManager().get_volume_rate_refer_in_5days(code) if volume_rate and volume_rate >= 0.69: gpcode_manager.MustBuyCodesManager().add_code(code) @@ -428,6 +502,8 @@ if pre_code in deal_codes: return False, f"开1数量:{count},前排代码已成交:{history_before_codes_info[0]}" else: if not cls.__is_not_buy_success(pre_code): return False, f"开1数量:{count},前排代码未下过单:{pre_code}" return True, f"开1数量:{count},前排代码尚未成交:{history_before_codes_info[0]}" return True, f"开1数量:{count},前排代码不可买:{history_before_codes_info[0]},历史前排-{history_before_codes_info},开1代码-{open_limit_up_block_codes}" return True, f"开1数量:{count},历史-{history_index + 1} 实时-{current_index + 1}, 前排代码-{current_before_codes_info},开1代码-{open_limit_up_block_codes}" @@ -447,31 +523,16 @@ return index, before_codes_info temp_index = index temp_before_codes_info = [] deal_codes = RadicalBuyDealCodesManager().get_deal_codes() # 已经下单过的代码 placed_order_codes = set() max_count = RadicalBuyBlockCodeCountManager().get_block_code_count(block) for b in before_codes_info: # 当作目标票获取扫入板块 code_ = b[0] blocks = LimitUpCodesBlockRecordManager().get_radical_buy_blocks(code_) blocks = BlockMapManager().filter_blocks(blocks) need_delete = False # 判断原因不正 if block not in blocks and b[0] not in yesterday_codes: # 首板涨停原因不正 need_delete = True # 判断是否是不计算身位 if not need_delete: if ExcludeIndexComputeCodesManager.is_in_cache(code_): need_delete = True # 判断是不是扫了没有扫进入 if not need_delete: # 最多排除max_count个 if code_ in BlockPlaceOrderRecordManager().get_codes() and code_ not in deal_codes and len( placed_order_codes) < max_count: need_delete = True placed_order_codes.add(code_) if need_delete: temp_index -= 1 else: @@ -485,6 +546,18 @@ logging.exception(e) async_log_util.error(logger_debug, f"扫入板块过滤出错:{str(e)}") return index, before_codes_info @classmethod def __is_not_buy_success(cls, code_): """ 是否下单了还没买入成功 @param code: @return: """ deal_codes = RadicalBuyDealCodesManager().get_deal_codes() if code_ in BlockPlaceOrderRecordManager().get_codes() and code_ not in deal_codes: return True return False @classmethod def __is_radical_buy_with_block_up(cls, code, block, yesterday_limit_up_codes): @@ -530,7 +603,9 @@ all_history_index, all_history_before_codes_info = cls.__get_history_index(code, block, set(), ignore_open_limit_up=False) history_index_first, history_before_codes_info_first = cls.__get_history_index(code, block, yesterday_limit_up_codes, ignore_open_limit_up=False) history_index_first, history_before_codes_info_first = cls.__get_history_index(code, block, yesterday_limit_up_codes, ignore_open_limit_up=False) all_history_before_codes = [x[0] for x in history_before_codes_info_first] if not constant.TEST: # 前两个代码是否有炸板 @@ -561,7 +636,6 @@ origin_history_index, origin_history_before_codes_info = cls.__get_history_index(code, block, yesterday_limit_up_codes, exclude_codes) # 过滤不正的原因 history_index, history_before_codes_info = cls.__filter_before_codes(code, block, origin_history_index, origin_history_before_codes_info, @@ -584,6 +658,10 @@ deal_codes = RadicalBuyDealCodesManager().get_deal_codes() if pre_code in deal_codes: return False, f"前排代码已成交:{pre_code}" # pre_code不是因为买不进 if not cls.__is_not_buy_success(pre_code): return False, f"前排代码没下过单:{pre_code}" # 前面一个代码不能买,前一个代码必须与前前个代码涨停时间相差15分钟内 for i in range(len(all_history_before_codes_info) - 1, -1, -1): if all_history_before_codes_info[i][0] == pre_code: @@ -904,14 +982,13 @@ return self.__codes def is_big_order_deal_enough(code, volume_rate, refer_total_sell_money, delegating_big_order_money=0): def is_big_order_deal_enough(code, volume_rate, refer_total_sell_money): """ 大单成交是否足够 @param delegating_big_order_money: 正在委托的大单金额 @param refer_total_sell_money: 引用的总卖额 @param code: @param volume_rate: @return: 大单是否足够, 原因, 是否是短时生效 @return: 大单是否足够, 原因, 是否是短时生效, 还差的金额 """ limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) refer_volume = code_volumn_manager.CodeVolumeManager().get_max_volume_in_5days(code) @@ -923,46 +1000,44 @@ money_y = max(money_y, 5) before_time = tool.get_now_time_as_int() < 93100 # 计算大单参考数量 threshold_count = 1 # int(round(0.4 * money_y)) current_threshold_count = 1 # int(round(0.4 * money_y)) if refer_total_sell_money >= 1e7: threshold_count = 2 current_threshold_count = 2 else: threshold_count = 1 current_threshold_count = 1 if before_time: threshold_count = int(round(0.4 * money_y * 1.5)) threshold_money = threshold_count * 299 * 10000 current_threshold_count = int(round(0.4 * money_y * 1.5)) current_threshold_money = current_threshold_count * 299 * 10000 if volume_rate >= 0.5 and False: # 按量大于50%算 # 当换手量>50%时,则,不需要每次扫入时需要≥2笔大单,而是累计需要≥2笔大单即可 deal_big_order_money = BigOrderDealManager().get_total_buy_money(code) try: # 获取正在成交的订单 dealing_order_info = HuaXinBuyOrderManager().get_dealing_order_info(code) threshold_big_money = l2_data_util.get_big_money_val(limit_up_price, tool.is_ge_code(code)) if dealing_order_info and dealing_order_info[2] >= threshold_big_money: # 正在成交的订单是大单 deal_big_order_money += dealing_order_info[2] except Exception as e: async_log_util.info(logger_l2_radical_buy, f"计算正在成交大单出错:{str(e)}") if deal_big_order_money >= threshold_money: return True, f"量比-{volume_rate}, 总大单成交金额({deal_big_order_money})>={threshold_money}", before_time # ==========判断总大单成交================ TOTAL_BIG_DEAL_MONEY_THRESHOLD_COUNT = round( code_volumn_manager.CodeVolumeManager().get_max_volume_in_5days(code) * limit_up_price / 1e8, 2) TOTAL_BIG_DEAL_MONEY_THRESHOLD_MONEY = TOTAL_BIG_DEAL_MONEY_THRESHOLD_COUNT * 299 * 10000 deal_big_order_money = BigOrderDealManager().get_total_buy_money(code) try: # 获取正在成交的订单 dealing_order_info = HuaXinBuyOrderManager().get_dealing_order_info(code) threshold_big_money = l2_data_util.get_big_money_val(limit_up_price, tool.is_ge_code(code)) if dealing_order_info and dealing_order_info[2] >= threshold_big_money: # 正在成交的订单是大单 deal_big_order_money += dealing_order_info[2] except Exception as e: async_log_util.info(logger_l2_radical_buy, f"计算正在成交大单出错:{str(e)}") total_lack_money = max(0, int(TOTAL_BIG_DEAL_MONEY_THRESHOLD_MONEY - deal_big_order_money)) # ===========判断单次大单成交============== current_big_order_deal_money = 0 current_big_order_deal_money_info = EveryLimitupBigDealOrderManager.get_big_buy_deal_order_money_info(code) if current_big_order_deal_money_info: if tool.trade_time_sub(tool.get_now_time_str(), current_big_order_deal_money_info[1]) > 60: # 60s以上的大单不看 current_big_order_deal_money = 0 else: return False, f"量比-{volume_rate}, 总大单成交金额({deal_big_order_money})<{threshold_money}", before_time else: current_big_order_deal_money = 0 current_big_order_deal_money_info = EveryLimitupBigDealOrderManager.get_big_buy_deal_order_money_info(code) if current_big_order_deal_money_info: if tool.trade_time_sub(tool.get_now_time_str(), current_big_order_deal_money_info[1]) > 60: # 60s以上的大单不看 current_big_order_deal_money = 0 else: current_big_order_deal_money = current_big_order_deal_money_info[0] if current_big_order_deal_money + delegating_big_order_money >= threshold_money: return True, f"量比-{volume_rate}, 本次大单成交金额({current_big_order_deal_money})+委托大单金额({delegating_big_order_money})>={threshold_money}", before_time else: return False, f"量比-{volume_rate}, 本次大单成交金额({current_big_order_deal_money}) + 委托大单金额({delegating_big_order_money}) <{threshold_money}", before_time current_big_order_deal_money = current_big_order_deal_money_info[0] current_lack_money = max(0, int(current_threshold_money - current_big_order_deal_money)) if total_lack_money == 0 and current_lack_money == 0: return True, f"量比-{volume_rate}, 瞬时大单成交-({current_big_order_deal_money}/{current_threshold_money}),总大单成交-({deal_big_order_money}/{TOTAL_BIG_DEAL_MONEY_THRESHOLD_MONEY})", before_time, 0 return False, f"量比-{volume_rate}, 瞬时大单成交-({current_big_order_deal_money}/{current_threshold_money}),总大单成交-({deal_big_order_money}/{TOTAL_BIG_DEAL_MONEY_THRESHOLD_MONEY})", before_time, max( current_lack_money, total_lack_money) class EveryLimitupBigDealOrderManager: @@ -1074,17 +1149,18 @@ else: # 当前代码身位比成交代码身位靠前的可以多成交一个代码 is_front = False limit_up_timestamp = LimitUpDataConstant.get_first_limit_up_time(code) if not limit_up_timestamp: limit_up_timestamp = time.time() for c in deal_reason_codes[b]: # 获取涨停时间 timestamp = LimitUpDataConstant.get_first_limit_up_time(c) if timestamp and timestamp > limit_up_timestamp: # 比目标代码后涨停 is_front = True async_log_util.info(logger_l2_radical_buy, f"前排代码还可买入:{b}-{code},后排成交代码-{c}") break # 暂时注释 # limit_up_timestamp = LimitUpDataConstant.get_first_limit_up_time(code) # if not limit_up_timestamp: # limit_up_timestamp = time.time() # for c in deal_reason_codes[b]: # # 获取涨停时间 # timestamp = LimitUpDataConstant.get_first_limit_up_time(c) # if timestamp and timestamp > limit_up_timestamp: # # 比目标代码后涨停 # is_front = True # async_log_util.info(logger_l2_radical_buy, f"前排代码还可买入:{b}-{code},后排成交代码-{c}") # break if not is_front: continue f_buy_blocks.add(b) trade/buy_radical/radical_buy_strategy.py
@@ -10,6 +10,7 @@ from log_module import async_log_util from log_module.log import logger_l2_radical_buy, hx_logger_l2_transaction from trade.buy_radical import radical_buy_data_manager from trade.trade_data_manager import RadicalBuyDealCodesManager from utils import tool # 不买入 @@ -29,14 +30,19 @@ __latest_deal_active_buy_order = {} def clear_latest_deal_active_buy_order(code): def clear_data(code): """ 清除最近主动成交的订单信息 清除数据:下单过后/开板后清除数据 @param code: @return: """ if code in __deal_active_buy_total_money: __deal_active_buy_total_money.pop(code) if code in __latest_deal_active_buy_order: __latest_deal_active_buy_order.pop(code) # 清除L2下单信号 if code in RadicalBuyDealCodesManager.buy_by_l2_delegate_expire_time_dict: RadicalBuyDealCodesManager.buy_by_l2_delegate_expire_time_dict.pop(code) def process_limit_up_active_buy_deal(code, transaction_datas):