l2/l2_data_manager_new.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
l2/l2_transaction_data_manager.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
l2/transaction_progress.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
third_data/code_plate_key_manager.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
third_data/data_server.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
trade/huaxin/huaxin_trade_api.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
trade/huaxin/huaxin_trade_server.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
utils/buy_condition_util.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
utils/middle_api_protocol.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
l2/l2_data_manager_new.py
@@ -1021,54 +1021,53 @@ if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.29: return False, True, f"上5个交易日跌停,量未达到{0.29}({cls.volume_rate_info[code][0]})" is_special = True if k_format and k_format[8][0] else False # 获取市场行情 situation = cls.__MarketSituationManager.get_situation_cache() zylt_threshold = buy_condition_util.get_zyltgb_threshold(situation) zyltgb = global_util.zyltgb_map.get(code) if k_format and k_format[8][0]: if is_special: # 具有辨识度 zyltgb = zylt_threshold[1] + 1 zyltgb = zylt_threshold[2] + 1 if zyltgb >= zylt_threshold[0]: return False, True, f"{zylt_threshold[0] // 100000000}亿以上的都不买({zyltgb})" if zyltgb >= zylt_threshold[1]: return False, True, f"{zylt_threshold[1] // 100000000}亿以上的都不买({zyltgb})" if zyltgb < zylt_threshold[0]: return False, True, f"{zylt_threshold[0] // 100000000}亿以下的都不买({zyltgb})" if HighIncreaseCodeManager().is_in(code): if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < 0.8: return False, True, f"5天内3次涨停,量未达到80%({cls.volume_rate_info[code][0]})" msg_list = [] if now_timestamp <= int("094000"): msg_list.append("强势10分钟") # 独苗 if not can_buy_result[0] and can_buy_result[1]: msg_list.append("独苗") if zyltgb < zylt_threshold[1] or zyltgb > zylt_threshold[2]: if zyltgb < zylt_threshold[2] or zyltgb > zylt_threshold[3]: # 如果没有辨识度才不买 if k_format and k_format[8][0]: # 有辨识度 pass else: return False, True, f"强势10分钟,独苗({can_buy_result[4]})不下单({can_buy_result[4]})自由流通市值({zyltgb})不满足条件" if not is_special: return False, True, f"强势10分钟,无辨识度, 独苗({can_buy_result[4]})不下单({can_buy_result[4]})自由流通市值({zyltgb})不满足条件" if k_format and (k_format[1][0] or k_format[3][0]): msg_list.append("股价创新高或者逼近前高") # 股价创新高或者逼近前高 if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[1]: return False, True, f"强势10分钟,独苗({can_buy_result[4]}),股价创新高或者逼近前高,当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[1]}" else: if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[0]: return False, True, f"强势10分钟,独苗({can_buy_result[4]}),当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[0]}" if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[0] and not is_special: return False, True, f"强势10分钟,无辨识度,独苗({can_buy_result[4]}),当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[0]}" else: msg_list.append("非独苗") if zyltgb < zylt_threshold[1] or zyltgb > zylt_threshold[2]: if zyltgb < zylt_threshold[2] or zyltgb > zylt_threshold[3]: msg_list.append("不满足自由流通") if k_format and (k_format[1][0] or k_format[3][0]): # 股价创新高或者逼近前高 if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[1]: return False, True, f"强势10分钟,后排,不满足自由市值,股价创新高或者逼近前高,当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[1]}" else: if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[0]: return False, True, f"强势10分钟,后排,不满足自由市值,当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[0]}" if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[0] and not is_special: return False, True, f"强势10分钟,后排,无辨识度,不满足自由市值,当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[0]}" else: msg_list.append("满足自由流通") # 后排,满足自由流通市值需要下单 @@ -1079,39 +1078,40 @@ if code in global_util.max60_volumn: day = global_util.max60_volumn[code][1] if day in HistoryKDatasUtils.get_latest_trading_date_cache(5): if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[1]: return False, True, f"参考量在最近5天,量未达到{volume_rate_thresholds[1]}({cls.volume_rate_info[code][0]})" if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[1] and not is_special: return False, True, f"参考量在最近5天,无辨识度,量未达到{volume_rate_thresholds[1]}({cls.volume_rate_info[code][0]})" # 非强势10分钟只买主线 if not can_buy_result[0] and can_buy_result[1]: return False, True, f"非强势10分钟,独苗({can_buy_result[4]})不下单" if not is_special: return False, True, f"非强势10分钟,无辨识度,独苗({can_buy_result[4]})不下单" if can_buy_result[3]: # 强势主线 if zyltgb < zylt_threshold[1] or zyltgb > zylt_threshold[2]: if zyltgb < zylt_threshold[2] or zyltgb > zylt_threshold[3]: if k_format and (k_format[1][0] or k_format[3][0]): # 股价创新高或者逼近前高 if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[1]: return False, True, f"非强势10分钟,强势主线后排,不满足自由市值,股价创新高或者逼近前高,当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[1]}" else: if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[0]: return False, True, f"非强势10分钟,强势主线后排,不满足自由市值,当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[0]}" if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[0] and not is_special: return False, True, f"非强势10分钟,强势主线后排,不满足自由市值,无辨识度,当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[0]}" else: if k_format and (k_format[1][0] or k_format[3][0]): if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[0]: return False, True, f"非强势10分钟,强势主线后排,满足自由市值,股价创新高或者逼近前高, 当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[0]}" else: # 非强势主线 if zyltgb < zylt_threshold[1] or zyltgb > zylt_threshold[2]: if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[1]: return False, True, f"非强势10分钟,非强势主线后排【主线后排】,不满足自由市值, 当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[1]}" if zyltgb < zylt_threshold[2] or zyltgb > zylt_threshold[3]: if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[1] and not is_special: return False, True, f"非强势10分钟,非强势主线后排【主线后排】,不满足自由市值,无辨识度, 当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[1]}" else: if k_format and (k_format[1][0] or k_format[3][0]): # 股价创新高或者逼近前高 if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[1]: return False, True, f"非强势10分钟,非强势主线后排【主线后排】,满足自由市值,股价创新高或者逼近前高, 当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[1]}" else: if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[0]: return False, True, f"非强势10分钟,非强势主线后排【主线后排】, 满足自由市值,当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[0]}" if code in cls.volume_rate_info and cls.volume_rate_info[code][0] < volume_rate_thresholds[0] and not is_special: return False, True, f"非强势10分钟,非强势主线后排【主线后排】, 满足自由市值,无辨识度,当日量比({cls.volume_rate_info[code][0]})小于{volume_rate_thresholds[0]}" return True, False, can_buy_result[2] @classmethod @@ -1247,7 +1247,7 @@ 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 * 3 // (float(gpcode_manager.get_limit_up_price(code)) * 100) 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): @@ -1264,7 +1264,7 @@ total_num += left_count * val["num"] if total_num > thresh_hold_num: break if total_num > thresh_hold_num and False: 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})") @@ -1759,7 +1759,7 @@ l2_log.buy_debug(code, "位置-{},总手数:{},目标手数:{}", i, buy_nums, threshold_num) # 纯买额足够,且笔数大于5笔 if buy_nums >= threshold_num and trigger_buy and buy_count>=5: if buy_nums >= threshold_num and trigger_buy and buy_count >= 5: try: info = cls.__trade_log_placr_order_info_dict[code] info.set_trade_factor(threshold_money, 0, []) l2/l2_transaction_data_manager.py
@@ -8,14 +8,15 @@ from code_attribute import gpcode_manager from db import redis_manager from db.redis_manager_delegate import RedisUtils from l2 import l2_data_util, l2_data_manager, transaction_progress from l2 import l2_data_util, l2_data_manager, transaction_progress, l2_data_source_util from l2.cancel_buy_strategy import LCancelRateManager, LCancelBigNumComputer, \ SecondCancelBigNumComputer, HourCancelBigNumComputer, FastCancelBigNumComputer, UCancelBigNumComputer from l2.l2_data_manager_new import L2TradeDataProcessor from l2.l2_data_util import L2DataUtil from l2.l2_data_util import L2DataUtil, local_today_canceled_buyno_map from log_module import async_log_util from log_module.log import logger_l2_trade_buy_queue, hx_logger_l2_upload, hx_logger_l2_debug, \ hx_logger_l2_transaction_desc, logger_debug from msg import push_msg_manager from third_data import kpl_data_manager from trade import current_price_process_manager, trade_manager, l2_trade_factor from trade.deal_big_money_manager import DealOrderNoManager @@ -135,12 +136,14 @@ LCancelRateManager.compute_big_num_deal_rate(code) buy_progress_index = self.__compute_latest_trade_progress(code, buyno_map, datas) if buy_progress_index is not None: self.__TradeBuyQueue.set_traded_index(code, buy_progress_index, total_datas) buy_progress_index_changed = self.__TradeBuyQueue.set_traded_index(code, buy_progress_index, total_datas) async_log_util.info(logger_l2_trade_buy_queue, "获取成交位置成功: code-{} index-{}", code, buy_progress_index) if buy_progress_index is not None: LCancelBigNumComputer().set_trade_progress(code, order_begin_pos.buy_single_index, buy_progress_index, total_datas) FastCancelBigNumComputer().set_trade_progress(code, buy_progress_index) @@ -165,6 +168,28 @@ # L2TradeDataProcessor.cancel_buy(code, msg) except Exception as e: logger_debug.exception(e) if buy_progress_index_changed: # 交易进度变化,判断到真实下单位置的距离 real_order_index = SecondCancelBigNumComputer().get_real_place_order_index_cache(code) if real_order_index and real_order_index >= buy_progress_index: left_count = 0 for i in range(buy_progress_index + 1, real_order_index): val = total_datas[i]["val"] if not L2DataUtil.is_limit_up_price_buy(val): continue if val["num"] * float(val["price"]) < 5000: continue left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2( code, i, total_datas, local_today_canceled_buyno_map.get( code)) if left_count > 0: left_count += 1 if left_count <= 3: # 当成交进度距离真实下单位置不足3笔时推送即将成交的消息 push_msg_manager.push_order_almost_deal(code, gpcode_manager.get_code_name(code)) else: pass if order_begin_pos and order_begin_pos.buy_exec_index and order_begin_pos.buy_exec_index > -1: l2/transaction_progress.py
@@ -188,6 +188,8 @@ # 设置交易进度 def set_traded_index(self, code, index, total_datas = None): last_info = self.latest_buy_progress_index_cache.get(code) # 交易进度是否改变 traded_index_changed = False if not last_info or last_info[0] != index: if last_info and total_datas: val = total_datas[last_info[0]]['val'] @@ -196,7 +198,9 @@ # 成交速率 self.trade_speed_cache[code] = rate self.latest_buy_progress_index_cache[code] = (index, time.time()) traded_index_changed = True self.__save_buy_progress_index(code, index, False) return traded_index_changed # 获取成交速率 def get_trade_speed(self, code): third_data/code_plate_key_manager.py
@@ -590,8 +590,8 @@ zyltgb = global_util.zyltgb_map.get(code) situation = MarketSituationManager().get_situation_cache() zylt_threshold = buy_condition_util.get_zyltgb_threshold(situation) if zyltgb and zylt_threshold[1] <= zyltgb <= zylt_threshold[2]: return True, False, f"【{block}】强势板块 自由流通市值({zyltgb})大于{zylt_threshold[1]//100000000}亿 小于{zylt_threshold[2]//100000000}亿", is_strong_block if zyltgb and zylt_threshold[2] <= zyltgb <= zylt_threshold[3]: return True, False, f"【{block}】强势板块 自由流通市值({zyltgb})大于{zylt_threshold[2]//100000000}亿 小于{zylt_threshold[3]//100000000}亿", is_strong_block return False, False, f"【{block}】前排代码:{front_current_shsz_rank_codes} 超过{len(current_open_limit_up_codes) + max_rank}个", is_strong_block # 过时的代码 third_data/data_server.py
@@ -528,6 +528,7 @@ response_data = json.dumps({"code": 1, "msg": "请上传code"}) elif url.path == "/get_last_trade_day_reasons": # 计算平均涨幅 def get_limit_rate_list(codes): if not codes: @@ -549,6 +550,7 @@ return [(c_, self.__code_limit_rate_dict[c_][0]) for c_ in codes] try: raise Exception("接口暂停使用") # 获取上个交易日的相同涨停原因的代码信息 ps_dict = dict([(k, v[0]) for k, v in parse_qs(url.query).items()]) code = ps_dict["code"] trade/huaxin/huaxin_trade_api.py
@@ -16,6 +16,7 @@ from log_module import async_log_util from log_module.log import hx_logger_trade_debug, hx_logger_trade_loop, hx_logger_trade_callback, logger_trade, \ logger_system from msg import push_msg_manager from trade.huaxin import huaxin_trade_data_update, huaxin_trade_record_manager from trade.huaxin.huaxin_trade_record_manager import TradeOrderIdManager from trade.huaxin.huaxin_trade_order_processor import CancelOrderManager, HuaxinOrderEntity, TradeResultProcessor @@ -39,6 +40,8 @@ def __run_recv_queue_trade(queue: multiprocessing.Queue): def __process_order(data): # 更新委托队列 push_msg_manager.push_delegate_queue_update() code = data["securityID"] accountID = data["accountID"] orderStatus = data["orderStatus"] trade/huaxin/huaxin_trade_server.py
@@ -1149,7 +1149,6 @@ except Exception as e: self.send_response({"code": 1, "msg": str(e)}, client_id, request_id) elif ctype == "get_delegated_buy_code_infos": raise Exception("接口暂停使用") # 获取委托中的代码 current_delegates = huaxin_trade_record_manager.DelegateRecordManager().list_current_delegates() fdatas = [] utils/buy_condition_util.py
@@ -9,8 +9,8 @@ # 获取自由流通市值的阈值范围 def get_zyltgb_threshold(market_sitation: int): if market_sitation == MarketSituationManager.SITUATION_GOOD: return 100 * 100000000, 10 * 100000000, 50 * 100000000 return 50 * 100000000, 10 * 100000000, 25 * 100000000 return 8.9 * 100000000, 100 * 100000000, 10 * 100000000, 50 * 100000000 return 8.9 * 100000000, 31 * 100000000, 10 * 100000000, 25 * 100000000 # 获取量比的等级获取量 utils/middle_api_protocol.py
@@ -34,6 +34,7 @@ fdata = {"type": "redis", "data": {"ctype": "cmd", "data": data}} return fdata def load_redis_cmds(datas): fdata = {"type": "redis", "data": {"ctype": "cmds", "data": datas}} return fdata @@ -68,3 +69,9 @@ def load_l2_subscript_codes(datas): fdata = {"type": "l2_subscript_codes", "data": {"ctype": "l2_subscript_codes", "data": datas}} return fdata # ------------------------------消息推送------------------------------------ def load_push_msg(data): fdata = {"type": "push_msg", "data": {"ctype": "push_msg", "data": data}} return fdata