Administrator
2024-09-25 9e1ff3ffc20e681e63491364242651aa2620e4f4
扫入策略调整
3个文件已修改
70 ■■■■ 已修改文件
servers/huaxin_trade_server.py 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
third_data/kpl_api.py 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/radical_buy_strategy.py 62 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
servers/huaxin_trade_server.py
@@ -826,6 +826,7 @@
                    # -----根据成交比例判断是否可买------
                    result_by_volume = radical_buy_strategy.limit_up_active_buy_deal(code, transaction_datas)
                    async_log_util.info(logger_l2_radical_buy, f"量买入结果判断:{code}, 结果:{result_by_volume}")
                    if result_by_volume[0] != radical_buy_strategy.BUY_MODE_NONE:
                        if result_by_volume[0] == radical_buy_strategy.BUY_MODE_DIRECT:
                            refer_sell_data = L2MarketSellManager().get_refer_sell_data(code,
third_data/kpl_api.py
@@ -163,12 +163,15 @@
# 获取代码的精选板块
# 返回格式:[(板块代码,板块名称,涨幅百分比)]
def getCodeJingXuanBlocks(code):
def getCodeJingXuanBlocks(code, jx=True):
    data = f"a=GetStockIDPlate&apiv=w32&Type=2&c=StockL2Data&StockID={code}&PhoneOSNew=1&UserID=0&DeviceID=a38adabd-99ef-3116-8bb9-6d893c846e23&VerSion=5.8.0.2&Token=0&"
    result = __base_request("https://apphq.longhuvip.com/w1/api/index.php", data=data)
    result = json.loads(result)
    # print(result)
    return result.get("ListJX") if result.get("ListJX") else result.get("List")
    if jx:
        return result.get("ListJX") if result.get("ListJX") else result.get("List")
    else:
        return result.get("List")
# 获取自由流通市值
trade/radical_buy_strategy.py
@@ -93,54 +93,54 @@
    if code not in __latest_deal_active_buy_order:
        __latest_deal_active_buy_order[code] = ['', 0, 0]
    for transaction_data in transaction_datas:
        # 当遇到大单之后才需要计算累计成交
        # 统计金额
        money = transaction_data[1] * transaction_data[2]
        price = transaction_data[1]
        __deal_active_buy_total_money[code] += money
        # 统计当前的买单
        if __latest_deal_active_buy_order[code][0] == transaction_data[6]:
            __latest_deal_active_buy_order[code][1] += transaction_data[2]
            __latest_deal_active_buy_order[code][2] += money
        else:
            __latest_deal_active_buy_order[code] = [transaction_data[6], transaction_data[2], money]
        if code not in __start_time_dict:
            # 判断买单成交的金额,如果金额大于50w就作为计时起始点
            if __latest_deal_active_buy_order[code][2] >= 500000:
                # 设置计时起点
                # 设置计时起点,将当前的数据清零
                __start_time_dict[code] = l2_huaxin_util.convert_time(transaction_data[3], with_ms=True)
                __deal_active_buy_total_money[code] = __latest_deal_active_buy_order[code][2]
        else:
            __deal_active_buy_total_money[code] += money
            # 已经开始计数
            THRESHOLD_TIME = 1000 if tool.is_sh_code(code) else 500
            huaxin_timestamp = transaction_data[3]
            time_str_with_ms = __huaxin_timestamp_convert_temp[code].get(huaxin_timestamp)
            if not time_str_with_ms:
                __huaxin_timestamp_convert_temp[code].clear()
                time_str_with_ms = l2_huaxin_util.convert_time(huaxin_timestamp, with_ms=True)
                __huaxin_timestamp_convert_temp[code][huaxin_timestamp] = time_str_with_ms
    transaction_data = transaction_datas[-1]
    huaxin_timestamp = transaction_data[3]
    price = transaction_data[1]
    time_str_with_ms = __huaxin_timestamp_convert_temp[code].get(huaxin_timestamp)
    if not time_str_with_ms:
        __huaxin_timestamp_convert_temp[code].clear()
        time_str_with_ms = l2_huaxin_util.convert_time(huaxin_timestamp, with_ms=True)
        __huaxin_timestamp_convert_temp[code][huaxin_timestamp] = time_str_with_ms
    # 涨停主动买成交
    if code in __start_time_dict:
        # 判断与当前时间的差值
        THRESHOLD_TIME = 1000 if tool.is_sh_code(code) else 500
        if tool.trade_time_sub_with_ms(time_str_with_ms, __start_time_dict[code]) > THRESHOLD_TIME:
            # 距离上个较大单成交已经过去一定时间
            __start_time_dict.pop(code)
            # 清除成交金额
            __deal_active_buy_total_money[code] = 0
            return BUY_MODE_NONE, f"距离上个大单成交超过{THRESHOLD_TIME}ms"
            if tool.trade_time_sub_with_ms(time_str_with_ms, __start_time_dict[code]) > THRESHOLD_TIME:
                __start_time_dict.pop(code)
                __deal_active_buy_total_money[code] = 0
                return BUY_MODE_NONE, f"距离上个大单成交超过{THRESHOLD_TIME}ms"
        selling_num = L2LimitUpSellDataManager.get_delegating_sell_num(code)
        if selling_num:
            total_sell = __deal_active_buy_total_money[code] + selling_num * price
            rate = round(__deal_active_buy_total_money[code] / total_sell, 2)
    price = transaction_datas[-1][1]
    huaxin_timestamp = transaction_datas[-1][3]
    # 判断
    selling_num = L2LimitUpSellDataManager.get_delegating_sell_num(code)
    if selling_num:
        total_sell = __deal_active_buy_total_money[code] + selling_num * price
        rate = round(__deal_active_buy_total_money[code] / total_sell, 2)
        if rate > 0.5:
            # 成交的比例
            if total_sell > 500 * 1e4:
                if rate > 0.5:
                    return BUY_MODE_DIRECT, f"剩余涨停总卖额-{selling_num * price},原涨停总卖-{total_sell},已成交额-{__deal_active_buy_total_money[code]},成交比例-{rate} "
                else:
                    return BUY_MODE_NONE, f"被动卖成交比例未达到:剩余涨停总卖额-{selling_num * price},原涨停总卖-{total_sell},已成交额-{__deal_active_buy_total_money[code]},成交比例-{rate}"
                return BUY_MODE_DIRECT, f"剩余涨停总卖额-{selling_num * price},原涨停总卖-{total_sell},已成交额-{__deal_active_buy_total_money[code]},成交比例-{rate} "
            else:
                return BUY_MODE_BY_L2, f"剩余涨停总卖额小于500w-{selling_num * price},原涨停总卖-{total_sell},已成交额-{__deal_active_buy_total_money[code]},成交比例-{rate} "
        else:
            return __get_deal_rate_by(code, huaxin_timestamp)
            return BUY_MODE_NONE, f"被动卖成交比例未达到:剩余涨停总卖额-{selling_num * price},原涨停总卖-{total_sell},已成交额-{__deal_active_buy_total_money[code]},成交比例-{rate}"
    else:
        return BUY_MODE_NONE, "没有50w以上的买单成交"
        return __get_deal_rate_by(code, huaxin_timestamp)