Crates.io | rfinancial |
lib.rs | rfinancial |
version | 0.1.11 |
source | src |
created_at | 2024-09-17 21:59:14.263658 |
updated_at | 2024-09-29 23:58:23.503332 |
description | A financial crate mimicking `numpy_financial` in Python |
homepage | https://github.com/seanzian2093/rust-numpy-financial |
repository | https://github.com/seanzian2093/rust-numpy-financial |
max_upload_size | |
id | 1378384 |
size | 78,096 |
A financial crate mimicking numpy_financial
in Python.
<T>
is changed to Result<T>
numpy_financial
's result with some exceptionsnumpy_financial
has some its own issuesuse rfinancial::*;
// fv
let fv = FutureValue::from_tuple((0.075, 30, -2000.0, 0.0, WhenType::End));
println!("\n{:#?}'s fv is {:?}", fv, fv.get());
// pmt
let pmt = Payment::from_tuple((0.08 / 12.0, 60, 15000.0, 0.0, WhenType::End));
println!("\n{:#?}'s pmt is {:?}", pmt, pmt.get());
// nper
let nper = NumberPeriod::from_tuple((0.075, -2000.0, 0.0, 100000.0, WhenType::End));
println!("\n{:#?}'s nper is {:?}", nper, nper.get());
// ipmt
let ipmt = InterestPayment::from_tuple((0.1 / 12.0, 1, 24, 2000.0, 0.0, WhenType::End));
println!("\n{:#?}'s ipmt is {:?}", ipmt, ipmt.get());
// ppmt
let ppmt = PrincipalPayment::from_tuple((0.1 / 12.0, 1, 24, 2000.0, 0.0, WhenType::End));
println!("\n{:#?}'s ppmt is {:?}", ppmt, ppmt.get());
// pv
let pv = PresentValue::from_tuple((0.075, 20, -2000.0, 0.0, WhenType::End));
println!("\n{:#?}'s pv is {}:?", pv, pv.get());
// rate
let rate = Rate::from_tuple((10, 0.0, -3500.0, 10000.0, WhenType::End, 0.1, 1e-6, 100));
println!("\n{:#?}'s rate is {:?}", rate, rate.get());
// irr
let values: Vec<f64> = vec![-150000.0, 15000.0, 25000.0, 35000.0, 45000.0, 60000.0];
let irr = InternalRateReturn::from_vec(values);
println!("\n{:#?}'s irr is {:?}", irr, irr.get());
// npv
let tup = (vec![-15000.0, 1500.0, 2500.0, 3500.0, 4500.0, 6000.0], 0.05);
let npv = NetPresentValue::from_tuple(tup);
println!("\n{:#?}'s npv is {:?}", npv, npv.get());
// mirr
let tup = (vec![100.0, 200.0, -50.0, 300.00, -200.0], 0.05, 0.06);
let mirr = ModifiedIRR::from_tuple(tup);
println!("\n{:#?}'s mirr is {:?}", mirr, mirr.get());