Zero Dependencies (std-only)
สร้างขึ้นบน Rust Standard Library (std) 100% ปราศจาก external crate ใดๆ คอมไพล์ได้เร็วในระดับมิลลิวินาที ใช้งานได้ทุกระบบตั้งแต่ Microservices, WebAssembly จนถึงระบบจำกัดทรัพยากร
Zero Dependencies (std-only)
สร้างขึ้นบน Rust Standard Library (std) 100% ปราศจาก external crate ใดๆ คอมไพล์ได้เร็วในระดับมิลลิวินาที ใช้งานได้ทุกระบบตั้งแต่ Microservices, WebAssembly จนถึงระบบจำกัดทรัพยากร
QuantLib Parity
ทดสอบและเทียบเคียงกับชุดทดสอบของ QuantLib มั่นใจได้ในความถูกต้องเชิงตัวเลขของอนุสัญญา ISDA/ICMA, Actual/Actual ICMA day counts, ปฏิทินวันหยุดตลาด และรอบดอกเบี้ยไม่เต็มงวด (stubs)
Exact Decimal & Settlement
การคำนวณเงินทศนิยมแน่นอนขนาด 128-bit (DecimalAmount) ละเอียด 38 ตำแหน่ง พร้อมโหมดการปัดเศษมาตรฐาน 7 รูปแบบ มีระบบป้องกันข้อผิดพลาดการชำระราคาและตัดปัญหาเศษสตางค์คลาดเคลื่อน
Deep Analytical Risk
คำนวณตัวชี้วัดความเสี่ยงลำดับที่ 1 และ 2 แบบ Analytical: Modified Duration, Macaulay Duration, Convexity, และ แม่นยำตรงตามสูตรคณิตศาสตร์โดยไม่มีสัญญาณรบกวนจากการประมาณค่า
คำนวณราคา Clean, ราคา Dirty, ดอกเบี้ยค้างรับ (Accrued Interest), และวิเคราะห์ความเสี่ยงด้วย SabiQuant:
use sabiquant::bonds::{BondPricingPlan, BondPricingResult};use sabiquant::core::{Date, Frequency};use sabiquant::core::calendars::TargetCalendar;use sabiquant::core::daycount::ActualActualICMA;
fn main() -> Result<(), Box<dyn std::error::Error>> { // 1. กำหนดวันชำระราคาและวันครบกำหนดไถ่ถอน let settlement = Date::from_ymd(2025, 3, 15)?; let maturity = Date::from_ymd(2035, 3, 15)?;
// 2. สร้างแบบแผนการคำนวณราคาพันธบัตร (อายุ 10 ปี, คูปอง 4.5% ต่อปี) let plan = BondPricingPlan::builder() .settlement(settlement) .maturity(maturity) .coupon_rate(0.045) .frequency(Frequency::Annual) .calendar(TargetCalendar::default()) .day_counter(ActualActualICMA::default()) .face_value(100.0) .build()?;
// 3. คำนวณราคาที่อัตราผลตอบแทนตลาด 4.20% let market_yield = 0.042; let pricing: BondPricingResult = plan.price_from_yield(market_yield)?;
println!("Dirty Price: {:.4}", pricing.dirty_price); println!("Clean Price: {:.4}", pricing.clean_price); println!("Accrued Interest: {:.4}", pricing.accrued_interest); println!("Modified Duration: {:.4}", pricing.modified_duration); println!("Convexity: {:.4}", pricing.convexity);
// 4. Invert หาอัตราผลตอบแทนจากราคา Clean ในตลาด let target_clean_price = 102.435; let implied_yield = plan.yield_from_clean_price(target_clean_price)?; println!("Implied Yield: {:.4}%", implied_yield * 100.0);
Ok(())}เพิ่ม SabiQuant ลงใน Cargo.toml:
[dependencies]sabiquant = "0.1.0"หรือใช้คำสั่งผ่าน Command Line:
cargo add sabiquant