1.整理删除不必要的todo
2.将主要使用的策略分支弃用elif
3.修改有概念分支中瞬时量幅比的特别门槛(大市值票不看瞬时量幅比)
4.打印行情-精选-板块的具体数据
8个文件已修改
239 ■■■■ 已修改文件
data_server.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/l2_client.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
log_module/log.py 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.py 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/buying_strategy.py 195 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/order_methods.py 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
strategy/plate_strength_analysis.py 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin_trade_api.py 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data_server.py
@@ -388,7 +388,7 @@
                    if code not in data_cache.big_order_deal_dict:
                        data_cache.big_order_deal_dict[code] = []
                    data_cache.big_order_deal_dict[code].append(d)
                    # TODO 获取买大单数量
                    # 获取买大单数量
                    len(data_cache.big_order_deal_dict.get(code, []))
                hx_logger_l2_transaction.info(_str)
                # 记录日志
huaxin_client/l2_client.py
@@ -439,7 +439,7 @@
        __init_l2(l2_data_upload_manager, codes)
        threading.Thread(target=huaxin_l2_log.run_sync, daemon=True).start()
        # TODO 测试
        # 测试
        # threading.Thread(target=lambda: test_add_codes(queue_r), daemon=True).start()
        global l2CommandManager
        l2CommandManager = command_manager.L2CommandManager()
log_module/log.py
@@ -307,6 +307,10 @@
                   filter=lambda record: record["extra"].get("name") == "common",
                   rotation="00:00", compression="zip", enqueue=True)
        logger.add(self.get_path("kpl", "market_sift_plate"),
                   filter=lambda record: record["extra"].get("name") == "kpl_market_sift_plate",
                   rotation="00:00", compression="zip", enqueue=True)
        logger.add(self.get_path("kpl", "jingxuan_in"),
                   filter=lambda record: record["extra"].get("name") == "kpl_jingxuan_in",
                   rotation="00:00", compression="zip", enqueue=True)
@@ -444,6 +448,7 @@
# -------------------------------开盘啦日志---------------------------------
logger_kpl_jingxuan_in = __mylogger.get_logger("kpl_jingxuan_in")
logger_kpl_market_sift_plate = __mylogger.get_logger("kpl_market_sift_plate")
logger_Overall_market_strength_score = __mylogger.get_logger("Overall_market_strength_score")
logger_stock_of_markets_plate = __mylogger.get_logger("stock_of_markets_plate")
main.py
@@ -71,18 +71,6 @@
    # 初始化拉取当日买入代码
    TodayBuyCodeManager()
    # todo 2025-03-25 测试无误即可删除下部注释
    # # 先使用json.load()直接从文件中读取【已经存储在本地的K线指标属性字典】并解析JSON数据
    # if os.path.exists(constant.K_BARS_PATH):
    #     with open(constant.K_BARS_PATH, 'r', encoding='utf-8') as f:
    #         data_cache.all_stocks_all_K_line_property_dict = json.load(f)
    #         print(
    #             f"data_cache.all_stocks_all_K_line_property_dict的个数==={len(data_cache.all_stocks_all_K_line_property_dict)}")
    # # 获取目标标的K线---初始化
    # all_K_line.main_index_k_line_history.init(data_cache.DataCache().today_date, data_cache.DataCache().next_trading_day, data_cache.DataCache().main_index_stocks)
    # # 直接调用主要指数K线写入本地文件
    # all_K_line.main_index_k_line_dict_write()
# 第一步:初始化context函数,并开启获取实时数据的线程
@@ -180,7 +168,7 @@
                limit_up_price = tool.get_limit_up_price(code, self.__pre_close_price_dict[code])
                if code in self.__last_price_dict:
                    if abs(limit_up_price - self.__last_price_dict[code]) < 0.0001 < abs(limit_up_price - price):
                        # TODO 处理炸板逻辑
                        # 处理炸板逻辑
                        # 监听了炸板了要做的函数
                        try:
                            selling_strategy.explosion_strategy(code)
strategy/buying_strategy.py
@@ -317,13 +317,11 @@
                                        f"【有概念】(涨停列表中包含自身概念 且 不是唯一包含概念不可用) !最新价: {current_price},,当日当时涨幅:{today_growth}%。")
                                    # 有概念有强度视界
                                    if strength_list_have_it is True:
                                        logger_info(
                                            f"【有概念 有强度】出现在板块强度大于2的列表中 瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,当日当时涨幅:{today_growth}%。")
                                        logger_info(f"【有概念 有强度】出现在板块强度大于2的列表中 瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,当日当时涨幅:{today_growth}%。")
                                        # if tick_growth >= 0.8:
                                        #     logger_info(
                                        #         f"【有概念 有强度 有强拉】瞬时涨幅 > 0.8% !瞬时涨幅:{round(tick_growth, 2)}%")
                                        if last_volume_to_growth_ratio > 0.8 and (
                                                free_market_value < 40 and current_price < 20):
                                        if last_volume_to_growth_ratio > 0.8 and (free_market_value <= 100 and current_price <= 10):
                                            logger_info(
                                                f"【不利】瞬时量幅比> 0.8 且 (小自由市值<40亿 或 最新价小于20元 )!,瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,自由市值:{free_market_value} 亿。")
                                            return
@@ -353,8 +351,7 @@
                                            return
                                        # elif k_line_data[0]['attribute'] == 'up_down' and k_line_data[0]['today_volume_shape'] == 'increases_down':
                                        #     logger_info(f"【不利】昨日高开低走 且 放量下跌,不买!!")
                                        if k_line_data[0]['attribute'] == 'down_down' and k_line_data[0][
                                            'today_volume_shape'] == 'increases_down':
                                        if k_line_data[0]['attribute'] == 'down_down' and k_line_data[0]['today_volume_shape'] == 'increases_down':
                                            logger_info(f"【不利】昨日低开低走 且 放量下跌,不买!!")
                                            return
                                        if throwing_pressure_position[0] is True:
@@ -401,7 +398,7 @@
                                        logger_info(
                                            f"************************************************【有概念有强度指标下单】************************************************")
                                        logger_info(
                                            f"最新价: {current_price}, 当日最高价:{current_high},瞬时涨幅: {tick_growth:.2f}%,当日当时涨幅:{today_growth}%,公司名称:{k_line_data[0]['sec_name']},当前时间:{current_created_at},低于水位线:{deep_low:.2f},交易量今日与昨日的比例{round(current_volume / k_line_data[0]['volume'], 2)}")
                                            f"最新价: {current_price}, 当日最高价:{current_high},瞬时涨幅: {tick_growth:.2f}%,瞬时量幅比:{last_volume_to_growth_ratio:.2f}%,当日当时涨幅:{today_growth}%,公司名称:{k_line_data[0]['sec_name']},当前时间:{current_created_at},低于水位线:{deep_low:.2f},交易量今日与昨日的比例{round(current_volume / k_line_data[0]['volume'], 2)}")
                                        logger_info(
                                            f"大盘综合强度分数:{data_cache.real_time_market_strong},理想交易行情分数==={data_cache.ideal_trading_market_score}分,设想的下单金额:{get_order_money()}")
                                        # 调用下单方法下单
@@ -432,83 +429,102 @@
                                                    free_market_value < 40 and current_price < 20):
                                                logger_info(
                                                    f"【不利】瞬时量幅比> 0.8 且 (小自由市值<40亿 或 最新价小于20元 )!,瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,自由市值:{free_market_value} 亿。")
                                            elif now_time <= datetime.time(9, 30, 5).strftime("%H:%M:%S"):
                                                return
                                            if now_time <= datetime.time(9, 30, 5).strftime("%H:%M:%S"):
                                                logger_info(
                                                    f"【不利】早盘第一个tick,瞬时涨幅计算恐有误,不买!瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,瞬时涨幅: {tick_growth:.2f}%,当日当时涨幅:{today_growth}%。")
                                            elif now_time <= datetime.time(9, 35, 00).strftime("%H:%M:%S"):
                                                return
                                            if now_time <= datetime.time(9, 35, 00).strftime("%H:%M:%S"):
                                                logger_info(
                                                    f"【不利】早盘前5分钟,不做有概念无强度试验,不买!瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,瞬时涨幅: {tick_growth:.2f}%,当日当时涨幅:{today_growth}%。")
                                            elif today_growth < 3:
                                                return
                                            if today_growth < 3:
                                                logger_info(
                                                    f"【不利】当日当时涨幅小于3%,信心不足,不太可能有强度,不买!瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,瞬时涨幅: {tick_growth:.2f}%,当日当时涨幅:{today_growth}%。")
                                            elif limit_up_day < 1 and tick_growth < 1:
                                                return
                                            if limit_up_day < 1 and tick_growth < 1:
                                                logger_info(
                                                    f"【不利】冷票 且 瞬时涨幅小于 1 !不买!!,瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,90天内涨停天数:{limit_up_day}")
                                                return
                                            # for d in k_line_data[1:3] 只检查k_line_data中的第二个和第三个元素
                                            elif limit_up_day > 6 and any(
                                            if limit_up_day > 6 and any(
                                                    'attribute' in d and d['attribute'] in data_cache.limit_up_type
                                                    for d in k_line_data[1:3]) and current_volume <= k_line_data[0][
                                                'volume'] * 1.5:
                                                logger_info(
                                                    f"【不利】过于显著票 且 上日或上上涨停板 当日量还不足昨日量的1.5倍!不买!! 今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,最新价: {current_price},,90天内涨停天数:{limit_up_day}")
                                            elif k_line_data[0]['attribute'] in data_cache.frying_plate_type:
                                                return
                                            if k_line_data[0]['attribute'] in data_cache.frying_plate_type:
                                                logger_info(f"【不利】昨日炸板!不买!!")
                                            elif k_line_data[0]['attribute'] in data_cache.limit_up_type:
                                                return
                                            if k_line_data[0]['attribute'] in data_cache.limit_up_type:
                                                logger_info(f"【不利】昨日涨停!不买!!")
                                            elif k_line_data[0]['attribute'] in data_cache.limit_down_type:
                                                return
                                            if k_line_data[0]['attribute'] in data_cache.limit_down_type:
                                                logger_info(f"【不利】昨日跌停!不买!!")
                                            # elif k_line_data[0]['attribute'] == 'up_down' and k_line_data[0]['today_volume_shape'] == 'increases_down':
                                            #     logger_info(f"【不利】昨日高开低走 且 放量下跌,不买!!")
                                            elif k_line_data[0]['attribute'] == 'down_down' and k_line_data[0][
                                                return
                                            if k_line_data[0]['attribute'] == 'up_down' and k_line_data[0]['today_volume_shape'] == 'increases_down':
                                                logger_info(f"【不利】昨日高开低走 且 放量下跌,不买!!")
                                                return
                                            if k_line_data[0]['attribute'] == 'down_down' and k_line_data[0][
                                                'today_volume_shape'] == 'increases_down':
                                                logger_info(f"【不利】昨日低开低走 且 放量下跌,不买!!")
                                            elif throwing_pressure_position[0] is True:
                                                return
                                            if throwing_pressure_position[0] is True:
                                                # 最近涨停日期:{k_line_data[limit_up_day_min_index]['bob']} ,
                                                logger_info(
                                                    f"【不利】接近涨停大抛压价位 近7日涨停过票 且 当前价和今日涨停价  且 当日量还不足涨停次日量的1.5倍!且 次日最高价小于涨停最高价的1.02倍 不买!! 今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,90天内涨停天数:{limit_up_day}")
                                            elif throwing_pressure_position[1] is True:
                                                return
                                            if throwing_pressure_position[1] is True:
                                                # 最近涨停日期:{k_line_data[frying_plate_day_min_index]['bob']} ,炸板次日量{round(k_line_data[frying_plate_day_min_index - 1]['volume'], 2)},
                                                logger_info(
                                                    f"【不利】接近炸板大抛压价位 近7日炸板过票 且 当前价和今日涨停价  且 当日量还不足涨停次日量的1.5倍!且 次日最高价小于炸板最高价的1.02倍 不买!! ,90天内涨停天数:{limit_up_day}")
                                            elif throwing_pressure_position[2] is True:
                                                return
                                            if throwing_pressure_position[2] is True:
                                                # 最近涨停日期:{k_line_data[limit_down_day_min_index]['bob']} ,
                                                logger_info(
                                                    f"【不利】接近跌停大抛压价位[跌停日的最高价或最低价] 近7日跌停过票 且 当前价和今日涨停价  且当日量还不足昨日量的1.5倍!不买!!今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,90天内涨停天数:{limit_up_day}")
                                            elif (
                                                return
                                            if (
                                                    free_market_value == 0 or free_market_value == 0.0) and free_market_value < 6:
                                                logger_info(
                                                    f"【不利】自由市值小于6亿!不买!! 公司名称:{k_line_data[0]['sec_name']},最新价: {current_price}")
                                            elif (
                                                return
                                            if (
                                                    free_market_value == 0 or free_market_value == 0.0) and free_market_value > 100 and L2_found_big_order is False:
                                                logger_info(
                                                    f"【不利】自由市值大于100亿,且未发现大单!不买!! 公司名称:{k_line_data[0]['sec_name']},最新价: {current_price}")
                                            elif len(intersection_plate) > 0:
                                                return
                                            if len(intersection_plate) > 0:
                                                logger_info(
                                                    f"【不利】同概念只买一次,不买了,公司名称:{k_line_data[0]['sec_name']},重复相交概念==={intersection_plate}")
                                            elif data_cache.have_plate_buy_times >= 1:
                                                return
                                            if data_cache.have_plate_buy_times >= 1:
                                                logger_info(
                                                    f"【不利】有概念无强度买入已经1次了!不买了!!公司名称:{k_line_data[0]['sec_name']},")
                                            elif len(data_cache.addition_position_symbols_set) >= 4:
                                                return
                                            if len(data_cache.addition_position_symbols_set) >= 4:
                                                logger_info(
                                                    f"【不利】当日已经买了3只票!不买了!!公司名称:{k_line_data[0]['sec_name']},")
                                            elif now_time < data_cache.OPENING_TIME or now_time > data_cache.NOON_MARKET_TIME:
                                                return
                                            if now_time < data_cache.OPENING_TIME or now_time > data_cache.NOON_MARKET_TIME:
                                                logger_info(f"【不利】不在9:30-13:05时间内!不买!!")
                                                return
                                            logger_info(
                                                f"************************************************【有概念无强度指标下单】************************************************")
                                            logger_info(
                                                f"最新价: {current_price}, 当日最高价:{current_high},瞬时涨幅: {tick_growth:.2f}%,瞬时量幅比:{last_volume_to_growth_ratio:.2f}%,当日当时涨幅:{today_growth}%,公司名称:{k_line_data[0]['sec_name']},当前时间:{current_created_at},低于水位线:{deep_low:.2f},交易量今日与昨日的比例{round(current_volume / k_line_data[0]['volume'], 2)}")
                                            # 检测持仓代码集合中有无下单个股,才认为交易成功
                                            if symbol_code not in data_cache.position_symbols_set:
                                                logger_info(
                                                    f"【{k_line_data[0]['sec_name']}】交易失败~持仓集合:{data_cache.position_symbols_set}")
                                            else:
                                                # 将有概念买入次数自加1
                                                data_cache.have_plate_buy_times += 1
                                                # 将买入个股的当时概念添加到全局变量中存储
                                                data_cache.bought_plate.extend(limit_up_plate_included_list)
                                                logger_info(
                                                    f"************************************************【有概念无强度指标下单】************************************************")
                                                logger_info(
                                                    f"最新价: {current_price}, 当日最高价:{current_high},瞬时涨幅: {tick_growth:.2f}%,当日当时涨幅:{today_growth}%,公司名称:{k_line_data[0]['sec_name']},当前时间:{current_created_at},低于水位线:{deep_low:.2f},交易量今日与昨日的比例{round(current_volume / k_line_data[0]['volume'], 2)}")
                                                # 检测持仓代码集合中有无下单个股,才认为交易成功
                                                if symbol_code not in data_cache.position_symbols_set:
                                                    logger_info(
                                                        f"【{k_line_data[0]['sec_name']}】交易失败~持仓集合:{data_cache.position_symbols_set}")
                                                else:
                                                    # 将有概念买入次数自加1
                                                    data_cache.have_plate_buy_times += 1
                                                    # 将买入个股的当时概念添加到全局变量中存储
                                                    data_cache.bought_plate.extend(limit_up_plate_included_list)
                                                    logger_info(
                                                        f"【{k_line_data[0]['sec_name']}】交易成功!持仓集合:{data_cache.position_symbols_set}")
                                                    f"【{k_line_data[0]['sec_name']}】交易成功!持仓集合:{data_cache.position_symbols_set}")
                                '''
                                无概念 有强度视界
                                '''
@@ -535,80 +551,90 @@
                                                if limit_up_day < 1:
                                                    logger_info(
                                                        f"【不利】冷票 !不买!!,瞬时量幅比:{round(last_volume_to_growth_ratio, 2)}%,90天内涨停天数:{limit_up_day}")
                                                    return
                                                # for d in k_line_data[1:3] 只检查k_line_data中的第二个和第三个元素
                                                elif limit_up_day > 6 and any(
                                                if limit_up_day > 6 and any(
                                                        'attribute' in d and d['attribute'] in data_cache.limit_up_type
                                                        for d in k_line_data[1:3]) and current_volume <= k_line_data[0][
                                                    'volume'] * 1.5:
                                                        for d in k_line_data[1:3]) and current_volume <= k_line_data[0]['volume'] * 1.5:
                                                    logger_info(
                                                        f"【不利】过于显著票 且 上日或上上涨停板 当日量还不足昨日量的1.5倍!不买!! 今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,90天内涨停天数:{limit_up_day}")
                                                elif k_line_data[0]['attribute'] in data_cache.frying_plate_type:
                                                    return
                                                if k_line_data[0]['attribute'] in data_cache.frying_plate_type:
                                                    logger_info(f"【不利】昨日炸板!不买!!")
                                                elif k_line_data[0]['attribute'] in data_cache.limit_up_type:
                                                    return
                                                if k_line_data[0]['attribute'] in data_cache.limit_up_type:
                                                    logger_info(f"【不利】昨日涨停!不买!!")
                                                elif k_line_data[0]['attribute'] in data_cache.limit_down_type:
                                                    return
                                                if k_line_data[0]['attribute'] in data_cache.limit_down_type:
                                                    logger_info(f"【不利】昨日跌停!不买!!")
                                                # elif k_line_data[0]['attribute'] == 'up_down' and k_line_data[0]['today_volume_shape'] == 'increases_down':
                                                    return
                                                # if k_line_data[0]['attribute'] == 'up_down' and k_line_data[0]['today_volume_shape'] == 'increases_down':
                                                #     logger_info(
                                                #         f"【不利】昨日高开低走 且 放量下跌,不买!!")
                                                elif k_line_data[0]['attribute'] == 'down_down' and k_line_data[0][
                                                    'today_volume_shape'] == 'increases_down':
                                                    logger_info(
                                                        f"【不利】昨日低开低走 且 放量下跌,不买!!")
                                                elif throwing_pressure_position[0] is True:
                                                #     return
                                                if k_line_data[0]['attribute'] == 'down_down' and k_line_data[0]['today_volume_shape'] == 'increases_down':
                                                    logger_info(f"【不利】昨日低开低走 且 放量下跌,不买!!")
                                                    return
                                                if throwing_pressure_position[0] is True:
                                                    # 最近涨停日期:{k_line_data[limit_up_day_min_index]['bob']} ,
                                                    logger_info(
                                                        f"【不利】接近涨停大抛压价位 近7日涨停过票 且 当前价和今日涨停价 且 当日量还不足涨停次日量的1.5倍!且 次日最高价小于涨停最高价的1.02倍 不买!! 今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,90天内涨停天数:{limit_up_day}")
                                                elif throwing_pressure_position[1] is True:
                                                    return
                                                if throwing_pressure_position[1] is True:
                                                    # 最近涨停日期:{k_line_data[frying_plate_day_min_index]['bob']} ,炸板次日量{round(k_line_data[frying_plate_day_min_index - 1]['volume'], 2)},
                                                    logger_info(
                                                        f"【不利】接近炸板大抛压价位 近7日炸板过票 且 当前价和今日涨停价 且 当日量还不足涨停次日量的1.5倍!且 次日最高价小于炸板最高价的1.02倍 不买!!90天内涨停天数:{limit_up_day}")
                                                elif throwing_pressure_position[2] is True:
                                                    return
                                                if throwing_pressure_position[2] is True:
                                                    # 最近涨停日期:{k_line_data[limit_down_day_min_index]['bob']} ,
                                                    logger_info(
                                                        f"【不利】接近跌停大抛压价位[跌停日的最高价或最低价] 近7日跌停过票 且 当前价和今日涨停价 且当日量还不足昨日量的1.5倍!不买!!今日当时成交量为昨日等比量的{round(current_volume / k_line_data[0]['volume'], 2)}倍,,90天内涨停天数:{limit_up_day}")
                                                elif (
                                                        free_market_value == 0 or free_market_value == 0.0) and free_market_value < 6:
                                                    return
                                                if (free_market_value == 0 or free_market_value == 0.0) and free_market_value < 6:
                                                    logger_info(
                                                        f"【不利】自由市值小于6亿!不买!! 公司名称:{k_line_data[0]['sec_name']},最新价: {current_price}")
                                                elif have_leading_increase is False:
                                                    return
                                                if have_leading_increase is False:
                                                    logger_info(
                                                        f"【不利】有强度的板块中没有发现领涨次数!不买!! 公司名称:{k_line_data[0]['sec_name']},最新价: {current_price}")
                                                elif (
                                                        free_market_value == 0 or free_market_value == 0.0) and free_market_value > 100 and L2_found_big_order is False:
                                                    return
                                                if (free_market_value == 0 or free_market_value == 0.0) and free_market_value > 100 and L2_found_big_order is False:
                                                    logger_info(
                                                        f"【不利】自由市值大于100亿,且未发现大单!不买!! 公司名称:{k_line_data[0]['sec_name']},最新价: {current_price}")
                                                elif data_cache.have_strength_buy_times >= 1:
                                                    return
                                                if data_cache.have_strength_buy_times >= 1:
                                                    logger_info(
                                                        f"【不利】有强度买入 1 次了!不买了!!公司名称:{k_line_data[0]['sec_name']},")
                                                elif len(TodayBuyCodeManager().get_buy_codes()) >= 3:
                                                    return
                                                if len(TodayBuyCodeManager().get_buy_codes()) >= 3:
                                                    logger_info(
                                                        f"【不利】当日已经买了3只票!不买了!!公司名称:{k_line_data[0]['sec_name']},")
                                                elif now_time < data_cache.OPENING_TIME or now_time > data_cache.NOON_MARKET_TIME:
                                                    return
                                                if now_time < data_cache.OPENING_TIME or now_time > data_cache.NOON_MARKET_TIME:
                                                    logger_info(f"【不利】不在9:30-13:05时间内!不买!!")
                                                    return
                                                logger_info(
                                                    f"************************************************【有强度有强拉指标下单】************************************************")
                                                logger_info(
                                                    f"最新价: {current_price}, 当日最高价:{current_high},瞬时涨幅: {tick_growth:.2f}%,瞬时量幅比:{last_volume_to_growth_ratio:.2f}%,当日当时涨幅:{today_growth}%,公司名称:{k_line_data[0]['sec_name']},当前时间:{current_created_at},低于水位线:{deep_low:.2f},交易量今日与昨日的比例{round(current_volume / k_line_data[0]['volume'], 2)}")  # 输出当前价格和3秒涨幅信息
                                                logger_info(
                                                    f"大盘综合强度分数:{data_cache.real_time_market_strong},理想交易行情分数==={data_cache.ideal_trading_market_score}分,设想的下单金额:{get_order_money()}")
                                                # 调用下单方法下单
                                                order_methods.buy_order_by_value(symbol,
                                                                                 get_order_money(),
                                                                                 k_line_data[0]['sec_name'],
                                                                                 current_price)
                                                # 检测持仓代码集合中有无下单个股,才认为交易成功
                                                if symbol_code not in data_cache.position_symbols_set:
                                                    logger_info(
                                                        f"【{k_line_data[0]['sec_name']}】交易失败~持仓集合:{data_cache.position_symbols_set}")
                                                else:
                                                    # 将有概念买入次数自加1
                                                    data_cache.have_strength_buy_times += 1
                                                    # 将买入个股的当时概念添加到全局变量中存储
                                                    data_cache.bought_plate.extend(strength_plate)
                                                    logger_info(
                                                        f"************************************************【有强度有强拉指标下单】************************************************")
                                                    logger_info(
                                                        f"最新价: {current_price}, 当日最高价:{current_high},瞬时涨幅: {tick_growth:.2f}%,当日当时涨幅:{today_growth}%,公司名称:{k_line_data[0]['sec_name']},当前时间:{current_created_at},低于水位线:{deep_low:.2f},交易量今日与昨日的比例{round(current_volume / k_line_data[0]['volume'], 2)}")  # 输出当前价格和3秒涨幅信息
                                                    logger_info(
                                                        f"大盘综合强度分数:{data_cache.real_time_market_strong},理想交易行情分数==={data_cache.ideal_trading_market_score}分,设想的下单金额:{get_order_money()}")
                                                    # 调用下单方法下单
                                                    order_methods.buy_order_by_value(symbol,
                                                                                     get_order_money(),
                                                                                     k_line_data[0]['sec_name'],
                                                                                     current_price)
                                                    # 检测持仓代码集合中有无下单个股,才认为交易成功
                                                    if symbol_code not in data_cache.position_symbols_set:
                                                        logger_info(
                                                            f"【{k_line_data[0]['sec_name']}】交易失败~持仓集合:{data_cache.position_symbols_set}")
                                                    else:
                                                        # 将有概念买入次数自加1
                                                        data_cache.have_strength_buy_times += 1
                                                        # 将买入个股的当时概念添加到全局变量中存储
                                                        data_cache.bought_plate.extend(strength_plate)
                                                        logger_info(
                                                            f"【{k_line_data[0]['sec_name']}】交易成功!持仓集合:{data_cache.position_symbols_set}")
                                                        f"【{k_line_data[0]['sec_name']}】交易成功!持仓集合:{data_cache.position_symbols_set}")
                                '''
                                无概念无强度 有小量换大涨幅度视界
                                '''
@@ -709,7 +735,6 @@
                                                        data_cache.bought_plate.extend(k_line_data[0]['sec_name'])
                                                        logger_info(
                                                            f"【{k_line_data[0]['sec_name']}】交易成功!持仓集合:{data_cache.position_symbols_set}")
                                '''
                                昨日涨停视界,今日连板预期盯视界
                                '''
strategy/order_methods.py
@@ -65,7 +65,6 @@
            logger.info(f"该股已经持仓==》{sec_name}")
            pass
        # todo 当前为测试阶段的冗余打印
        # 检测持仓信息中有无下单个股且有该个股的当前持仓,只有当前持仓数量不为0时,才认为交易成功
        for i in data_cache.account_positions_dict:
            # print(i)
@@ -157,8 +156,6 @@
        if position_volume_yesterday >= sell_order_volume:
            sell_order_by_volume(symbol, sell_order_volume, sec_name, current_price)
            logger.info(f"【十分之 {round(part_of_volume * 10)} 仓】委卖完毕")
            # todo  data_cache.account_positions 数据内容已经变化需重新写,似乎不用计算剩余持仓量,直接请求就行了
            # 计算并更新剩余可用持仓数量
            # data_cache.account_positions[index]['volume'] = position_volume_yesterday - sell_order_volume
            if data_cache.account_positions_dict[index]['currentPosition'] <= 0:
strategy/plate_strength_analysis.py
@@ -5,7 +5,7 @@
import dask
import constant
from log_module.log import logger_common, logger_kpl_jingxuan_in, logger_debug
from log_module.log import logger_common, logger_kpl_jingxuan_in, logger_debug, logger_kpl_market_sift_plate
from strategy import kpl_api, data_cache, basic_methods
from utils import tool, hx_qc_value_util
@@ -75,16 +75,19 @@
    data = (kpl_api.getMarketJingXuanRealRankingInfo())
    market_sift_plate = json.loads(data)
    # logger_kpl_jingxuan_in 打印的日志专用于开盘了数据的存储分析,不能轻易删除
    # print(f"market_sift_plate 数 ======{len(market_sift_plate['list'])}")
    # 行情》精选板块》排名前20中》对应个股》符合条件的个股
    # logger.info(f"market_sift_plate['list']======{market_sift_plate['list']}")
    # 精选板块【前20】 market_sift_plate['list'] ======
    logger_kpl_market_sift_plate.info(f"{market_sift_plate['list']}")
    # market_sift_plate['list'][0] = ['801062', '军工', 3520, -0.49, 0.666, 139133934669, 383864272, 9077352839, -8693488567, 1.183, 6129448037490,-0.12, 168245858, 7088854452019, -290614763, 50.2408, 30.3672, 3520, 0]
    # 行情精选板块列表 前20 中的 第一个板块列表数据 = 【代码,板块名称,强度,涨幅?,0.666?,成交额?,现额?,主买,主卖,1.183?,流通值?,-0.12?,300W大单净额?,总市值?,上季度机构增仓,今年平均PE,次年平均PE,强度,未知0值】
    # logger.info(f"market_sift_plate['list'][0]  ======{market_sift_plate['list'][0]}")
    # 初始化精选板块对应个股字典
    market_sift_plate_stock_dict = {}
    if 'list' in market_sift_plate:
        ds = []
        for d in market_sift_plate['list']:
            # todo 获取板块名称和板块代码 主要是板块的强度和主力净额这些
            ds.append(request_plate_codes(d))
        dask_result = batch_get_plate_codes(ds)
        compute_results = dask_result.compute()
@@ -98,7 +101,7 @@
        # logger.info(f"精选板块股票强度数据更新 == {market_sift_plate_stock_dict}")
        # 只在盘中时间获取
        kpl_api.KPLStockOfMarketsPlateLogManager().add_log(market_sift_plate['list'], log_datas)
    # 行情》精选板块》排名前20中》对应个股》符合条件的个股
    return market_sift_plate_stock_dict
@@ -116,6 +119,7 @@
                its_stock_power = get_market_sift_plate_its_stock_power()
                time_str = datetime.datetime.now().strftime("%H%M%S")
                if 92900 < int(time_str) < 95000:
                    # logger_kpl_jingxuan_in 打印的日志专用于开盘了数据的存储分析,不能轻易删除
                    logger_kpl_jingxuan_in.info(f"耗时:{time.time() - start_time}  数据:{its_stock_power}")
                callback(its_stock_power)
                # print(f"精选板块拉升个股更新===={its_stock_power}")
trade/huaxin_trade_api.py
@@ -509,7 +509,7 @@
    return res
# todo 获取华鑫持仓列表 后续即可实现仓位管理
# 获取华鑫持仓列表 后续即可实现仓位管理
# 获取持仓列表
def get_position_list(blocking=True):
    """
@@ -524,7 +524,7 @@
    return res
# todo 获取华鑫账户资金 后续即可实现账户管理
# 获取华鑫账户资金 后续即可实现账户管理
# 获取账户资金状况
def get_money(blocking=True):
    """