NAC_Blockchain/nac-ai-valuation/src/agreement.rs

252 lines
9.6 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//! 国际贸易协定和多边条约
use serde::{Deserialize, Serialize};
/// 国际贸易协定类型
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum InternationalAgreement {
/// 欧盟法案体系
EU,
/// 世界贸易组织
WTO,
/// 上海合作组织
SCO,
/// 区域全面经济伙伴关系协定
RCEP,
/// 全面与进步跨太平洋伙伴关系协定
CPTPP,
/// 美墨加协定
USMCA,
/// 非洲大陆自贸区
AfCFTA,
/// 无协定
None,
}
/// 协定详细信息
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgreementInfo {
/// 协定代码
pub code: InternationalAgreement,
/// 协定名称
pub name: String,
/// 成员国列表
pub member_countries: Vec<String>,
/// 关税调整系数 (-1 to 1, 负数表示关税减免)
pub tariff_adjustment: f64,
/// 市场准入折扣 (0-1)
pub market_access_discount: f64,
/// 投资保护系数 (0-1, 越高越好)
pub investment_protection: f64,
/// 流动性溢价 (-1 to 1)
pub liquidity_premium: f64,
/// 合规成本率 (0-1)
pub compliance_cost_rate: f64,
}
impl InternationalAgreement {
/// 获取协定详细信息
pub fn info(self) -> AgreementInfo {
match self {
InternationalAgreement::EU => AgreementInfo {
code: InternationalAgreement::EU,
name: "欧盟法案体系".to_string(),
member_countries: vec![
"德国".to_string(), "法国".to_string(), "意大利".to_string(),
"西班牙".to_string(), "荷兰".to_string(), "比利时".to_string(),
"奥地利".to_string(), "瑞典".to_string(), "丹麦".to_string(),
"芬兰".to_string(), "爱尔兰".to_string(), "葡萄牙".to_string(),
"希腊".to_string(), "波兰".to_string(), "捷克".to_string(),
],
tariff_adjustment: 0.0, // 内部零关税
market_access_discount: 0.0,
investment_protection: 0.95,
liquidity_premium: 0.10,
compliance_cost_rate: 0.03, // MiFID II, GDPR等合规成本
},
InternationalAgreement::WTO => AgreementInfo {
code: InternationalAgreement::WTO,
name: "世界贸易组织".to_string(),
member_countries: vec!["164个成员国".to_string()],
tariff_adjustment: 0.05, // 平均MFN关税
market_access_discount: 0.0,
investment_protection: 0.70,
liquidity_premium: 0.0,
compliance_cost_rate: 0.01,
},
InternationalAgreement::SCO => AgreementInfo {
code: InternationalAgreement::SCO,
name: "上海合作组织".to_string(),
member_countries: vec![
"中国".to_string(), "俄罗斯".to_string(), "印度".to_string(),
"巴基斯坦".to_string(), "哈萨克斯坦".to_string(), "吉尔吉斯斯坦".to_string(),
"塔吉克斯坦".to_string(), "乌兹别克斯坦".to_string(), "伊朗".to_string(),
"白俄罗斯".to_string(),
],
tariff_adjustment: -0.10, // 关税减免
market_access_discount: 0.10,
investment_protection: 0.75,
liquidity_premium: 0.10, // 本币结算溢价
compliance_cost_rate: 0.02,
},
InternationalAgreement::RCEP => AgreementInfo {
code: InternationalAgreement::RCEP,
name: "区域全面经济伙伴关系协定".to_string(),
member_countries: vec![
"中国".to_string(), "日本".to_string(), "韩国".to_string(),
"澳大利亚".to_string(), "新西兰".to_string(), "东盟10国".to_string(),
],
tariff_adjustment: -0.15, // 90%关税减免
market_access_discount: 0.0,
investment_protection: 0.85,
liquidity_premium: 0.08,
compliance_cost_rate: 0.015,
},
InternationalAgreement::CPTPP => AgreementInfo {
code: InternationalAgreement::CPTPP,
name: "全面与进步跨太平洋伙伴关系协定".to_string(),
member_countries: vec![
"日本".to_string(), "澳大利亚".to_string(), "加拿大".to_string(),
"新加坡".to_string(), "墨西哥".to_string(), "越南".to_string(),
"马来西亚".to_string(), "智利".to_string(), "秘鲁".to_string(),
"新西兰".to_string(), "文莱".to_string(),
],
tariff_adjustment: -0.20, // 高标准关税减免
market_access_discount: 0.0,
investment_protection: 0.90,
liquidity_premium: 0.05,
compliance_cost_rate: 0.02, // 高标准合规要求
},
InternationalAgreement::USMCA => AgreementInfo {
code: InternationalAgreement::USMCA,
name: "美墨加协定".to_string(),
member_countries: vec![
"美国".to_string(), "墨西哥".to_string(), "加拿大".to_string(),
],
tariff_adjustment: -0.18,
market_access_discount: 0.0,
investment_protection: 0.88,
liquidity_premium: 0.07,
compliance_cost_rate: 0.018,
},
InternationalAgreement::AfCFTA => AgreementInfo {
code: InternationalAgreement::AfCFTA,
name: "非洲大陆自贸区".to_string(),
member_countries: vec!["54个非洲国家".to_string()],
tariff_adjustment: -0.12,
market_access_discount: 0.15, // 市场准入仍有障碍
investment_protection: 0.60,
liquidity_premium: -0.15, // 流动性较差
compliance_cost_rate: 0.025,
},
InternationalAgreement::None => AgreementInfo {
code: InternationalAgreement::None,
name: "无协定".to_string(),
member_countries: vec![],
tariff_adjustment: 0.15, // 高关税
market_access_discount: 0.30, // 市场准入困难
investment_protection: 0.50,
liquidity_premium: -0.20,
compliance_cost_rate: 0.04,
},
}
}
/// 计算协定调整系数
pub fn adjustment_factor(self) -> f64 {
let info = self.info();
// 综合调整系数 = (1 + 关税调整) × (1 - 市场准入折扣) × (1 + 流动性溢价) × (1 - 合规成本率)
(1.0 + info.tariff_adjustment)
* (1.0 - info.market_access_discount)
* (1.0 + info.liquidity_premium)
* (1.0 - info.compliance_cost_rate)
}
/// 判断两个国家是否在同一协定下
pub fn is_member(self, country: &str) -> bool {
let info = self.info();
info.member_countries.iter().any(|c| c.contains(country))
}
}
/// 欧盟特殊法案影响
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EURegulations {
/// MiFID II合规成本 (金融资产)
pub mifid_ii_cost: f64,
/// GDPR数据保护成本
pub gdpr_cost: f64,
/// AMLD反洗钱成本
pub amld_cost: f64,
/// ESG披露成本
pub esg_disclosure_cost: f64,
/// EU Taxonomy绿色认证溢价
pub eu_taxonomy_premium: f64,
}
impl Default for EURegulations {
fn default() -> Self {
Self {
mifid_ii_cost: 0.02,
gdpr_cost: 0.01,
amld_cost: 0.015,
esg_disclosure_cost: 0.01,
eu_taxonomy_premium: 0.10, // 绿色资产溢价
}
}
}
impl EURegulations {
/// 计算欧盟法案总调整系数
pub fn total_adjustment(&self, is_green_asset: bool) -> f64 {
let cost = self.mifid_ii_cost + self.gdpr_cost + self.amld_cost + self.esg_disclosure_cost;
let premium = if is_green_asset { self.eu_taxonomy_premium } else { 0.0 };
(1.0 - cost) * (1.0 + premium)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_agreement_info() {
let eu_info = InternationalAgreement::EU.info();
assert_eq!(eu_info.tariff_adjustment, 0.0);
assert!(eu_info.investment_protection > 0.9);
let sco_info = InternationalAgreement::SCO.info();
assert!(sco_info.tariff_adjustment < 0.0); // 关税减免
}
#[test]
fn test_adjustment_factor() {
let eu_factor = InternationalAgreement::EU.adjustment_factor();
assert!(eu_factor > 1.0); // 欧盟有流动性溢价
let none_factor = InternationalAgreement::None.adjustment_factor();
assert!(none_factor < 0.7); // 无协定折扣大
}
#[test]
fn test_is_member() {
assert!(InternationalAgreement::EU.is_member("德国"));
assert!(InternationalAgreement::SCO.is_member("中国"));
assert!(!InternationalAgreement::EU.is_member("美国"));
}
#[test]
fn test_eu_regulations() {
let eu_regs = EURegulations::default();
// 非绿色资产
let adj_normal = eu_regs.total_adjustment(false);
assert!(adj_normal < 1.0);
// 绿色资产
let adj_green = eu_regs.total_adjustment(true);
assert!(adj_green > adj_normal); // 绿色资产有溢价
}
}