financial-calc
Financial calculation functions built on precision-core.
Features
- Interest calculations (simple, compound, effective annual rate)
- Time value of money (future value, present value, NPV)
- Black-Scholes options pricing with Greeks
- Percentage operations
no_stdcompatible- Deterministic results
Installation
[]
= "0.1"
Quick Start
use ;
let principal = from;
let rate = new; // 5%
// Compound interest: monthly for 5 years
let interest = compound_interest?;
// Future value
let fv = future_value?;
Options Pricing
use ;
use Decimal;
let params = OptionParams ;
// Calculate option price
let call_price = black_scholes_price?;
let put_price = black_scholes_price?;
// Calculate Greeks
let greeks = calculate_greeks?;
println!;
println!;
println!;
println!;
Functions
Interest
simple_interest(principal, rate, time)compound_interest(principal, rate, periods_per_year, years)effective_annual_rate(nominal_rate, periods)
Time Value
future_value(present_value, rate, periods)present_value(future_value, rate, periods)net_present_value(rate, cash_flows)
Options (Black-Scholes)
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 solver
Percentages
percentage_of(value, percent)percentage_change(old, new)basis_points_to_decimal(bps)
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.