use-quant 0.1.0

Facade crate for RustUse quantitative finance primitives
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use use_quant::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let weights = WeightSet::from_asset_weights([
        AssetWeight::new("AAPL", PortfolioWeight::new(0.40)?)?,
        AssetWeight::new("MSFT", PortfolioWeight::new(0.35)?)?,
        AssetWeight::new("CASH", PortfolioWeight::new(0.25)?)?,
    ])?;

    println!("weight sum: {:.2}", weights.sum());

    assert!((weights.sum() - 1.0).abs() < 1e-12);
    assert!(weights.is_approximately_fully_invested(1e-12)?);

    Ok(())
}