//! NAC AI资产估值系统 //! //! 提供基于多元AI协同仲裁的资产估值服务 //! //! # 特性 //! //! - 12种资产类型分类 //! - 8个辖区支持(US, EU, China, HK, Singapore, UK, Japan, Middle East) //! - 5个国际贸易协定(WTO, SCO, RCEP, CPTPP, USMCA) //! - 多元AI模型(ChatGPT-4.1, DeepSeek-V3, 豆包AI-Pro) //! - 协同仲裁算法(加权投票 + 贝叶斯融合) //! //! # 示例 //! //! ```no_run //! use nac_ai_valuation::{ValuationEngine, ValuationEngineConfig, Asset, AssetType, Jurisdiction, InternationalAgreement}; //! use rust_decimal::Decimal; //! //! #[tokio::main] //! async fn main() { //! let engine = ValuationEngine::new( //! "chatgpt_api_key".to_string(), //! "deepseek_api_key".to_string(), //! "doubao_api_key".to_string(), //! ValuationEngineConfig::default(), //! ).expect("mainnet: handle error"); //! //! let asset = Asset::new( //! "asset_001".to_string(), //! AssetType::RealEstate, //! "GNACS-001".to_string(), //! "Manhattan Office Building".to_string(), //! Decimal::new(50_000_000, 0), //! "USD".to_string(), //! ); //! //! let result = engine.appraise( //! &asset, //! Jurisdiction::US, //! InternationalAgreement::WTO, //! ).await.expect("mainnet: handle error"); //! //! println!("估值: {} XTZH", result.valuation_xtzh); //! println!("置信度: {:.1}%", result.confidence * 100.0); //! } //! ``` pub mod asset; pub mod jurisdiction; pub mod agreement; pub mod ai_model; pub mod ai_models; pub mod arbitration; pub mod engine; pub mod realtime; pub mod history; pub mod validation; pub use asset::{Asset, AssetType}; pub use jurisdiction::{Jurisdiction, AccountingStandard}; pub use agreement::InternationalAgreement; pub use ai_model::{AIProvider, AIModelManager, AIValuationResult}; pub use ai_models::{AIModelConfig, AIModelClient}; pub use arbitration::{Arbitrator, ArbitrationConfig, DynamicWeightCalculator}; pub use engine::{ValuationEngine, ValuationEngineConfig}; pub use realtime::{RealtimeValuationEngine, RealtimeDataSource, RealtimeConfig, ValuationCache, CacheStats}; pub use history::{ValuationHistory, ValuationHistoryEntry, TrendAnalyzer, TrendAnalysis, TrendDirection, DataExporter}; pub use validation::{ValuationValidator, ValidationRule, ValidationResult, AccuracyEvaluator, AccuracyMetrics, DivergenceAnalyzer, DivergenceAnalysis, ModelOptimizer, OptimizationSuggestion}; use rust_decimal::Decimal; use serde::{Deserialize, Serialize}; use std::collections::HashMap; /// 最终估值结果 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct FinalValuationResult { /// 最终估值(XTZH) pub valuation_xtzh: Decimal, /// 综合置信度 [0.0, 1.0] pub confidence: f64, /// 各AI模型的估值结果 pub model_results: Vec, /// 各模型权重 pub weights: HashMap, /// 是否存在异常值 pub is_anomaly: bool, /// 异常值报告 pub anomaly_report: Option, /// 分歧分析报告 pub divergence_report: String, /// 是否需要人工审核 pub requires_human_review: bool, } impl FinalValuationResult { /// 生成完整的估值报告 pub fn generate_report(&self) -> String { let mut report = String::new(); report.push_str("# NAC AI资产估值报告\n\n"); report.push_str(&format!("## 最终估值\n\n")); report.push_str(&format!("**{} XTZH**\n\n", self.valuation_xtzh)); report.push_str(&format!("- 综合置信度: {:.1}%\n", self.confidence * 100.0)); report.push_str(&format!("- 需要人工审核: {}\n\n", if self.requires_human_review { "是" } else { "否" })); if let Some(ref anomaly_report) = self.anomaly_report { report.push_str("## ⚠️ 异常值警告\n\n"); report.push_str(anomaly_report); report.push_str("\n\n"); } report.push_str(&self.divergence_report); report.push_str("\n\n"); report.push_str("## AI模型详细结果\n\n"); for result in &self.model_results { report.push_str(&format!("### {:?}\n\n", result.provider)); report.push_str(&format!("- 估值: {} XTZH\n", result.valuation_xtzh)); report.push_str(&format!("- 置信度: {:.1}%\n", result.confidence * 100.0)); report.push_str(&format!("- 权重: {:.1}%\n", self.weights.get(&result.provider).unwrap_or(&0.0) * 100.0)); report.push_str(&format!("- 推理过程:\n\n{}\n\n", result.reasoning)); } report } /// 转换为JSON pub fn to_json(&self) -> serde_json::Result { serde_json::to_string_pretty(self) } } #[cfg(test)] mod tests { use super::*; #[test] fn test_final_valuation_result() { let result = FinalValuationResult { valuation_xtzh: Decimal::new(1000000, 0), confidence: 0.85, model_results: vec![], weights: HashMap::new(), is_anomaly: false, anomaly_report: None, divergence_report: "Test report".to_string(), requires_human_review: false, }; let report = result.generate_report(); assert!(report.contains("1000000 XTZH")); assert!(report.contains("85.0%")); } }