Administrator
2024-10-29 2c707e6083d8d60b088a7f91a0020370e65c8c7f
昨日跌幅过大不扫入/添加日志记录
6个文件已修改
99 ■■■■ 已修改文件
code_attribute/code_nature_analyse.py 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code_attribute/gpcode_manager.py 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
servers/huaxin_trade_server.py 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/radical_buy_data_manager.py 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/trade_result_manager.py 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code_attribute/code_nature_analyse.py
@@ -220,8 +220,8 @@
    p11 = __is_latest_open_limit_up(code, record_datas, 5)
    # 90天内是否有涨停
    p12 = __has_limit_up(code, record_datas, 90)
    # 最近5天是否跌停
    p13 = __is_latest_limit_down(code, record_datas, 5)
    # 上个交易日是否跌幅过大
    p13 = __is_pre_day_limit_rate_too_low(code, record_datas)
    # 60个交易日是否曾涨停
    p14 = __has_limited_up(code, record_datas, 60)
    # 昨日是否涨停过
@@ -578,6 +578,26 @@
    return False
def __is_pre_day_limit_rate_too_low(code, datas):
    """
    上个交易日是否跌幅过大
    @param code:
    @param datas:
    @return:
    """
    datas = copy.deepcopy(datas)
    datas.sort(key=lambda x: x["bob"])
    items = datas[-1:]
    for item in items:
        # 是否有跌停
        # 获取当日涨幅
        rate = (item["close"] - item["pre_close"])/item["pre_close"]
        threshold_rate_ = round(0 - ((1 - tool.get_limit_down_rate(code))*0.9), 2)
        if rate < threshold_rate_:
            return True
    return False
# V字形
def __is_v_model(code, datas):
    datas = copy.deepcopy(datas)
@@ -738,6 +758,6 @@
if __name__ == "__main__":
    HighIncreaseCodeManager().add_code("000333")
    print(HighIncreaseCodeManager().is_in("000333"))
    print(HighIncreaseCodeManager().is_in("000222"))
    code = "000333"
    threshold_rate = 0 - ((1 - tool.get_limit_down_rate(code)) * 0.9)
    print(threshold_rate)
code_attribute/gpcode_manager.py
@@ -22,6 +22,17 @@
class CodesNameManager:
    __mysqldb = Mysqldb()
    __code_name_dict = {}
    __instance = None
    def __new__(cls, *args, **kwargs):
        if not cls.__instance:
            cls.__instance = super(CodesNameManager, cls).__new__(cls, *args, **kwargs)
            cls.__load_data()
        return cls.__instance
    @classmethod
    def __load_data(cls):
        cls.__code_name_dict = cls.list_code_name_dict()
    @classmethod
    def list_code_name_dict(cls):
@@ -98,6 +109,7 @@
# 想要买的代码
class WantBuyCodesManager:
    __instance = None
    __db = 0
    redisManager = redis_manager.RedisManager(0)
    __redis_key = "want_buy_codes"
@@ -126,7 +138,7 @@
    def remove_code(self, code):
        self.__want_buy_codes_cache.discard(code)
        RedisUtils.srem(self.__get_redis(), self.__redis_key, code)
        RedisUtils.srem_async(self.__db, self.__redis_key, code)
    def sync(self):
        codes = self.list_code()
@@ -397,7 +409,7 @@
    def remove_code(self, code):
        self.__codes_set.discard(code)
        RedisUtils.srem(self.__get_redis(), "green-trade-codes", code)
        RedisUtils.srem_async(self.__db, "green-trade-codes", code)
    def is_in(self, code):
        return RedisUtils.sismember(self.__get_redis(), "green-trade-codes", code)
@@ -532,7 +544,7 @@
# 获取代码的名称
def get_code_name(code):
    return CodesNameManager.get_code_name(code)
    return CodesNameManager().get_code_name(code)
def get_name_codes():
l2/l2_data_manager_new.py
@@ -724,7 +724,8 @@
            return False, True, f"14:57后不能交易", True
        if cls.__TradeTargetCodeModeManager.get_mode_cache() == TradeTargetCodeModeManager.MODE_ONLY_BUY_WANT_CODES:
            if not cls.__WantBuyCodesManager.is_in_cache(code) and not gpcode_manager.GreenListCodeManager().is_in_cache(code):
            if not cls.__WantBuyCodesManager.is_in_cache(
                    code) and not gpcode_manager.GreenListCodeManager().is_in_cache(code):
                return False, True, f"只买想买:没在想买单和绿单", True
        return True, False, f"", False
@@ -1156,10 +1157,7 @@
        k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code)
        # 是否有辨识度
        is_special = True if k_format and k_format[8][0] else False
        # 上5个交易日有炸板之后
        has_open_limit_up_in_5 = True if k_format and len(k_format) >= 11 and k_format[10] else False
        # 上5个交易日有跌停
        has_limit_down_in_5 = True if k_format and len(k_format) >= 13 and k_format[12] else False
        # 是否是强势10分钟
        is_in_strong_time = now_timestamp <= int("094000")
        # 是否是强势30分钟
@@ -1519,7 +1517,7 @@
                                                     max_num_set=set(),
                                                     buy_volume_rate=buy_volume_rate,
                                                     mode=OrderBeginPosInfo.MODE_RADICAL,
                                                     mode_desc="总抛压小扫入",
                                                     mode_desc=f"总抛压小扫入",
                                                     sell_info=sell_info,
                                                     threshold_money=threshold_money)
            order_begin_pos_info.at_limit_up = cls.__is_at_limit_up_buy(code)
@@ -1933,14 +1931,10 @@
        @param end_index:
        @return: (是否获取到信号, 信号位置, 消息)
        """
        # 激进买信号的时间
        radical_data = RadicalBuyDealCodesManager.buy_by_l2_delegate_expire_time_dict.get(code)
        if not radical_data:
            return False, None, "不满足激进买的条件"
        if t.time() > radical_data[0]:
            return False, None, "超过生效时间"
        def __can_order():
        # 判断是否是板上放量
        if cls.__is_at_limit_up_buy(code, start_index):
            return False, None, "板上放量"
@@ -1971,6 +1965,15 @@
            return True, single_index, "有大单"
        return False, None, "无大单"
        radical_data = RadicalBuyDealCodesManager.buy_by_l2_delegate_expire_time_dict.get(code)
        if not radical_data:
            return False, None, "不满足激进买的条件"
        if t.time() > radical_data[0]:
            return False, None, "超过生效时间"
        result = __can_order()
        l2_log.debug(code, f"L2扫入判断:{result}")
        return result
    @classmethod
    def test__compute_active_order_begin_pos(cls, code, continue_count, start_index, end_index):
        return cls.__compute_active_order_begin_pos(code, continue_count, start_index, end_index)
servers/huaxin_trade_server.py
@@ -18,7 +18,7 @@
from cancel_strategy.s_l_h_cancel_strategy import SCancelBigNumComputer
from code_attribute import gpcode_manager, code_volumn_manager, global_data_loader, zyltgb_util, code_nature_analyse
from code_attribute.code_l1_data_manager import L1DataManager
from code_attribute.gpcode_manager import CodePrePriceManager
from code_attribute.gpcode_manager import CodePrePriceManager, CodesNameManager
from huaxin_client import l2_data_transform_protocol
from huaxin_client.trade_transform_protocol import TradeResponse
from l2 import l2_data_manager_new, l2_log, code_price_manager, l2_data_util, transaction_progress, \
@@ -232,6 +232,7 @@
                        # 获取level1的代码
                        list_ = JueJinApi.get_exchanges_codes(["SHSE", "SZSE"])
                        fdatas = []
                        code_name_map = {}
                        for d in list_:
                            if not tool.is_target_code(d["sec_id"]):
                                continue
@@ -244,6 +245,11 @@
                                    days=100)).timestamp() > datetime.datetime.now().timestamp():
                                continue
                            fdatas.append(d["sec_id"])
                            code_name_map[d["sec_id"]] = d["sec_name"]
                        # 保存代码名称
                        for k in code_name_map:
                            CodesNameManager.add_code_name(k, code_name_map[k])
                        sk.sendall(
                            socket_util.load_header(json.dumps({"code": 0, "data": fdatas}).encode(encoding='utf-8')))
trade/radical_buy_data_manager.py
@@ -52,6 +52,11 @@
                return False, "自由流通市值过大"
            elif  zyltgb_as_yi < constant.MIN_CODE_RADICAL_BUY_ZYLTGB_AS_YI:
                return False, "自由流通市值过小"
        # 判断昨日是否跌幅过大
        k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code)
        if k_format and len(k_format) > 12 and k_format[12]:
            return False, "上个交易日跌幅过大"
        if gpcode_manager.BlackListCodeManager().is_in_cache(code):
            if deal_codes is not None and code in deal_codes:
                pass
trade/trade_result_manager.py
@@ -4,7 +4,7 @@
from cancel_strategy.s_l_h_cancel_strategy import HourCancelBigNumComputer
from cancel_strategy.s_l_h_cancel_strategy import LCancelBigNumComputer
from cancel_strategy.s_l_h_cancel_strategy import SCancelBigNumComputer
from code_attribute.gpcode_manager import MustBuyCodesManager, GreenListCodeManager
from code_attribute.gpcode_manager import MustBuyCodesManager, GreenListCodeManager, WantBuyCodesManager
from l2 import l2_data_manager, place_order_single_data_manager
from l2.cancel_buy_strategy import FCancelBigNumComputer, \
    NewGCancelBigNumComputer, JCancelBigNumComputer, NBCancelBigNumComputer
@@ -142,7 +142,11 @@
        __latest_cancel_l2_data_dict[code] = total_datas[-1]
    # 撤单成功需要移除红名单
    if not GreenListCodeManager().is_in_cache(code):
    if GreenListCodeManager().is_in_cache(code):
        GreenListCodeManager().remove_code(code)
        if WantBuyCodesManager().is_in_cache(code):
            WantBuyCodesManager().remove_code(code)
    if MustBuyCodesManager().is_in_cache(code):
        MustBuyCodesManager().remove_code(code)
@@ -151,7 +155,8 @@
    if code not in __latest_cancel_l2_data_dict:
        return True
    threshold_time_space = buy_condition_util.get_cancel_and_buy_space_time(code)
    if L2DataUtil.time_sub_as_ms(buy_exec_data["val"], __latest_cancel_l2_data_dict[code]["val"]) >= threshold_time_space:
    if L2DataUtil.time_sub_as_ms(buy_exec_data["val"],
                                 __latest_cancel_l2_data_dict[code]["val"]) >= threshold_time_space:
        return True
    return False