| Crates.io | financial-calc |
| lib.rs | financial-calc |
| version | 0.1.0-alpha.2 |
| created_at | 2026-01-24 12:14:06.521862+00 |
| updated_at | 2026-01-25 18:00:51.096014+00 |
| description | Financial calculation functions built on precision-core |
| homepage | |
| repository | https://github.com/dijkstra-keystone/keystone |
| max_upload_size | |
| id | 2066587 |
| size | 65,636 |
Financial calculation functions built on precision-core.
no_std compatible[dependencies]
financial-calc = "0.1"
use financial_calc::{compound_interest, future_value, Decimal};
let principal = Decimal::from(10000i64);
let rate = Decimal::new(5, 2); // 5%
// Compound interest: monthly for 5 years
let interest = compound_interest(principal, rate, 12, 5)?;
// Future value
let fv = future_value(principal, rate, 10)?;
use financial_calc::options::{OptionParams, OptionType, black_scholes_price, calculate_greeks};
use precision_core::Decimal;
let params = OptionParams {
spot: Decimal::from(100i64),
strike: Decimal::from(100i64),
rate: Decimal::new(5, 2), // 5% risk-free rate
volatility: Decimal::new(20, 2), // 20% volatility
time: Decimal::new(25, 2), // 0.25 years (3 months)
};
// Calculate option price
let call_price = black_scholes_price(¶ms, OptionType::Call)?;
let put_price = black_scholes_price(¶ms, OptionType::Put)?;
// Calculate Greeks
let greeks = calculate_greeks(¶ms, OptionType::Call)?;
println!("Delta: {}", greeks.delta);
println!("Gamma: {}", greeks.gamma);
println!("Theta: {}", greeks.theta);
println!("Vega: {}", greeks.vega);
simple_interest(principal, rate, time)compound_interest(principal, rate, periods_per_year, years)effective_annual_rate(nominal_rate, periods)future_value(present_value, rate, periods)present_value(future_value, rate, periods)net_present_value(rate, cash_flows)black_scholes_price(params, option_type) - Call/Put pricecalculate_greeks(params, option_type) - Delta, Gamma, Theta, Vega, Rhoimplied_volatility(params, market_price, option_type) - Newton-Raphson IV solverpercentage_of(value, percent)percentage_change(old, new)basis_points_to_decimal(bps)Licensed under either of Apache License, Version 2.0 or MIT license at your option.