Administrator
2024-05-26 899d8485335023865f2b1055b72fe64124082961
分离LSH撤
2个文件已修改
60 ■■■■■ 已修改文件
cancel_strategy/s_l_h_cancel_strategy.py 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
third_data/code_plate_key_manager.py 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cancel_strategy/s_l_h_cancel_strategy.py
@@ -38,31 +38,33 @@
                can_buy_result = CodePlateKeyBuyManager.can_buy(code)
                if can_buy_result and can_buy_result[0]:
                    if can_buy_result[0][1] <= 1 and can_buy_result[0][2] >= 3:
                        half_must_buy = True
                        # 炸板率>60%以上就不加半红
                        if can_buy_result[0][3]<=0 or can_buy_result[0][2]/can_buy_result[0][3]>0.4:
                            half_must_buy = True
            except:
                pass
        if cancel_type == cls.TYPE_S_FAST:
            if must_buy:
                return constant.S_FAST_RATE_WITH_MUST_BUY
                return constant.S_FAST_RATE_WITH_MUST_BUY, "加红"
            elif half_must_buy:
                return round((constant.S_FAST_RATE + constant.S_FAST_RATE_WITH_MUST_BUY) / 2, 2)
                return round((constant.S_FAST_RATE + constant.S_FAST_RATE_WITH_MUST_BUY) / 2, 2),"半红"
            else:
                return constant.S_FAST_RATE
                return constant.S_FAST_RATE,"常规"
        elif cancel_type == cls.TYPE_S_FAST_BIG:
            if must_buy:
                return constant.S_FAST_BIG_RATE_WITH_MUST_BUY
                return constant.S_FAST_BIG_RATE_WITH_MUST_BUY, "加红"
            elif half_must_buy:
                return round((constant.S_FAST_RATE + constant.S_FAST_BIG_RATE_WITH_MUST_BUY) / 2, 2)
                return round((constant.S_FAST_RATE + constant.S_FAST_BIG_RATE_WITH_MUST_BUY) / 2, 2),"半红"
            else:
                return constant.S_FAST_RATE
                return constant.S_FAST_RATE,"常规"
        elif cancel_type == cls.TYPE_S_SLOW:
            if must_buy:
                return constant.S_SLOW_RATE_WITH_MUST_BUY
                return constant.S_SLOW_RATE_WITH_MUST_BUY, "加红"
            elif half_must_buy:
                return round((constant.S_SLOW_RATE + constant.S_SLOW_RATE_WITH_MUST_BUY) / 2, 2)
                return round((constant.S_SLOW_RATE + constant.S_SLOW_RATE_WITH_MUST_BUY) / 2, 2),"半红"
            else:
                return constant.S_SLOW_RATE
        return None
                return constant.S_SLOW_RATE,"常规"
        return None,""
class SCancelBigNumComputer:
@@ -290,9 +292,9 @@
        total_datas[real_place_order_info[0]]['val']['orderNo'], min_sell_money=min_sell_money)
        sell_order_num = sum([x[1] for x in sell_orders]) // 100
        rate = round(sell_order_num / total_num, 2)
        threshold_rate = SCancelRateManager.get_threshhold_rate(code, SCancelRateManager.TYPE_S_SLOW)
        threshold_rate,threshold_rate_msg = SCancelRateManager.get_threshhold_rate(code, SCancelRateManager.TYPE_S_SLOW)
        if rate > threshold_rate:
            return True, f"慢砸成交比例:{rate}/0.49  成交:{sell_order_num}/{total_num}"
            return True, f"慢砸成交比例:{rate}/0.49({threshold_rate_msg})  成交:{sell_order_num}/{total_num}"
        else:
            return False, f"尚未触发撤单比例:{rate}"
@@ -378,11 +380,11 @@
                    if total_num == 0:
                        total_num = 1
                    threshold_rate = SCancelRateManager.get_threshhold_rate(code, SCancelRateManager.TYPE_S_FAST_BIG)
                    threshold_rate,threshold_rate_msg  = SCancelRateManager.get_threshhold_rate(code, SCancelRateManager.TYPE_S_FAST_BIG)
                    if total_deal_money / (total_num * limit_up_price * 100) >= threshold_rate:
                        # 大单成交额占总剩余总囊括的30%
                        return True, f"1s内大于{threshold_big_deal}大卖单({total_deal_money})"
                        return True, f"1s内大于{threshold_big_deal}({threshold_rate_msg})大卖单({total_deal_money})"
                else:
                    return True, f"1s内大于{threshold_big_deal}大卖单({total_deal_money})"
            except Exception as e:
@@ -439,10 +441,10 @@
            # 防止分母为0
            total_fast_money = 1
        rate = round(total_deal_money / total_fast_money, 2)
        threshold_rate = SCancelRateManager.get_threshhold_rate(code, SCancelRateManager.TYPE_S_FAST)
        threshold_rate,threshold_rate_msg = SCancelRateManager.get_threshhold_rate(code, SCancelRateManager.TYPE_S_FAST)
        if total_deal_money >= threash_money_w * 10000 and rate >= threshold_rate:
            return True, f"近1s有大卖单({round(total_deal_money / 10000, 1)}万/{threash_money_w}万,成交占比:{total_deal_money}/{total_fast_money})"
            return True, f"近1s有大卖单({round(total_deal_money / 10000, 1)}万/{threash_money_w}万({threshold_rate_msg}),成交占比:{total_deal_money}/{total_fast_money})"
        else:
            l2_log.s_cancel_debug(code,
                                  f"S快撤没达到撤单比例:成交金额({total_deal_money})/囊括金额({total_fast_money}),比例:{rate} 大单阈值:{threash_money_w}w")
third_data/code_plate_key_manager.py
@@ -695,14 +695,20 @@
        block_codes = current_limit_up_block_codes_dict.get(block)
        if block_codes is None:
            block_codes = set()
        # 历史涨停代码
        block_codes_records = set()
        if limit_up_record_datas:
            for k in limit_up_record_datas:
                if code_limit_up_reasons_dict.get(k[3]) == block:
                    block_codes_records.add(k[3])
        if not block_codes:
            # 高位板泛化板块中无板块
            if not high_level_block_codes.get(block):
                return False, True, f"{block}:板块无涨停", False, False, 0, 0
                return False, True, f"{block}:板块无涨停", False, False, 0, 0, 0
        elif len(block_codes) == 1 and code in block_codes:
            if not high_level_block_codes.get(block):
                return False, True, f"{block}:板块只有当前代码涨停", False, False, 0, 0
                return False, True, f"{block}:板块只有当前代码涨停", False, False, 0, 0, 0
        # 可以买的最大排名
        # open_limit_up_codes = kpl_block_util.get_shsz_open_limit_up_codes(code, block, limit_up_record_datas,
        #                                                                   code_limit_up_reason_dict)
@@ -753,10 +759,10 @@
        if current_shsz_rank < len(current_open_limit_up_codes) + max_rank:
            return True, False, f"【{block}】前排代码:{current_shsz_rank}", is_strong_block, is_active_buy, current_shsz_rank, len(
                block_codes)
                block_codes),len(block_codes_records)
        else:
            return False, False, f"【{block}】前排代码:{front_current_shsz_rank_codes} 超过{len(current_open_limit_up_codes) + max_rank}个", is_strong_block, is_active_buy, current_shsz_rank, len(
                block_codes)
                block_codes), len(block_codes_records)
    # 获取可以买的板块
    # current_limit_up_datas: 今日实时涨停
@@ -799,7 +805,7 @@
        code_limit_up_reasons_dict = {}
        load_code_block()
        for block in keys:
            can_buy, unique, msg, is_strong, is_active_buy, current_rank, block_limit_up_count = cls.__is_block_can_buy_new(
            can_buy, unique, msg, is_strong, is_active_buy, current_rank, block_limit_up_count, block_limit_up_record_count = cls.__is_block_can_buy_new(
                code, block,
                current_limit_up_datas,
                code_limit_up_reasons_dict,
@@ -808,7 +814,7 @@
                current_limit_up_block_codes_dict,
                high_level_code_blocks=high_level_general_code_blocks,
                high_level_block_codes=high_level_general_block_codes)
            fresults.append((block, can_buy, unique, msg, is_strong, is_active_buy, current_rank, block_limit_up_count))
            fresults.append((block, can_buy, unique, msg, is_strong, is_active_buy, current_rank, block_limit_up_count, block_limit_up_record_count))
        return fresults, keys
    # 是否可以下单
@@ -900,11 +906,11 @@
                # if r[0] in trade_delegate_blocks_count and len(trade_delegate_blocks_count[r[0]]) >= MAX_DELEGATE_COUNT:
                #     msg_list.append(f"【{r[0]}】已挂单:{trade_delegate_blocks_count[r[0]]}")
                #     continue
                if len(r) > 7:
                    can_buy_blocks.append((r[0], r[6], r[7]))
                if len(r) > 8:
                    can_buy_blocks.append((r[0], r[6], r[7], r[8]))
                else:
                    # (板块名称,身位,板块涨停数量)
                    can_buy_blocks.append((r[0], 0, 1))
                    can_buy_blocks.append((r[0], 0, 1, 1))
                if r[4]:
                    can_buy_strong_blocks.append(r[0])
                if r[3]: