log
2026-07-11 1eb0e0ca2922b96cbe132f80786cd8e98c87eae1
scripts/daily_master.py
@@ -891,6 +891,12 @@
        else:
            self.ml_combiner = None
            logger.warning("⚠️ ML因子组合器不可用")
        self.ml_optimization_applied = False
        self.ml_optimization_status = (
            '未应用(模型尚未训练)'
            if self.ml_combiner is not None
            else '未应用(组件不可用)'
        )
        
        if DYNAMIC_WEIGHT_AVAILABLE:
            self.dynamic_weight_system = DynamicFactorWeightSystem()
@@ -1119,8 +1125,15 @@
    
    def optimize_with_ml(self, df: pd.DataFrame, selected_stocks: List[Dict]) -> List[Dict]:
        """使用ML因子组合优化选股结果"""
        self.ml_optimization_applied = False
        if self.ml_combiner is None:
            logger.warning("⚠️ ML组合器不可用,跳过优化")
            self.ml_optimization_status = '未应用(组件不可用)'
            return selected_stocks
        if not getattr(self.ml_combiner, 'is_fitted', False):
            logger.warning("⚠️ ML模型尚未训练,跳过二次优化并保留final_score排序")
            self.ml_optimization_status = '未应用(模型尚未训练)'
            return selected_stocks
        
        logger.info("🤖 ML因子组合优化...")
@@ -1132,6 +1145,7 @@
            
            if not factor_cols:
                logger.warning("⚠️ 未找到因子列,跳过ML优化")
                self.ml_optimization_status = '未应用(无可用因子)'
                return selected_stocks
            
            selected_codes = [s['stock_code'] for s in selected_stocks]
@@ -1146,6 +1160,7 @@
            
            if len(factor_data) == 0:
                logger.warning("⚠️ 因子数据为空,跳过ML优化")
                self.ml_optimization_status = '未应用(因子数据为空)'
                return selected_stocks
            
            factor_data = factor_data.set_index('stock_code')
@@ -1168,11 +1183,15 @@
                for i, stock in enumerate(selected_stocks):
                    stock['rank'] = i + 1
                
                self.ml_optimization_applied = True
                self.ml_optimization_status = '已应用'
                logger.info(f"✓ ML优化完成,已重新排序")
            else:
                self.ml_optimization_status = '未应用(预测结果为空)'
                logger.warning("⚠️ ML预测结果为空,使用原始排序")
            
        except Exception as e:
            self.ml_optimization_status = f'未应用({e})'
            logger.error(f"❌ ML优化失败: {e}")
        
        return selected_stocks
@@ -1395,7 +1414,7 @@
            logger.info("\n" + "="*70)
            logger.info("✅ 每日主控流程完成")
            logger.info(f"  - 选股数量: {len(filtered_stocks)}")
            logger.info(f"  - ML优化: {'已启用' if self.ml_combiner else '未启用'}")
            logger.info(f"  - ML优化: {self.ml_optimization_status}")
            logger.info(f"  - 动态权重: {'已启用' if self.dynamic_weight_system else '未启用'}")
            logger.info("="*70)