Skip to content
TotalFinance

TotalFinance

Open-source TypeScript finance with explicit units, honest assumptions and diagnostics you can read. Built by InsiderFinance.

TotalFinance is a TypeScript library for financial computation: options and strategies, volatility, technical analysis, portfolios and performance, risk, valuation, fixed income, FX, commodities, crypto and backtesting. It runs in Node.js and in the browser, has no runtime dependencies, and never fetches market data on its own. You supply the data; it computes, and tells you exactly how.

import { blackScholes } from '@insiderfinance/totalfinance/options';

const price = blackScholes.price({
  type: 'call',
  spot: 100,
  strike: 105,
  timeToExpiryYears: 0.25,
  volatility: 0.2,
  riskFreeRate: 0.04,
});
console.log(price.toFixed(4)); // 2.3909

What makes it different

  • Units are explicit. Rates and volatilities are decimals, times are year fractions or epoch milliseconds, and field names say which. No percent-or-decimal guessing.
  • Answers explain themselves. Add .explain() to a facade and the result carries its assumptions (day count, compounding, model) and diagnostics (method, convergence, warnings).
  • Errors teach. Invalid input throws a typed error that names the field and the fix, never a stray TypeError or a silent NaN.
  • Nothing is invented. No hidden market data, no silent financial defaults, no lookahead in backtests, no warmup values pretending to be signals.
  • Built for agents too. Every operation in the registry is available to AI agents through an MCP server, the CLI and a local HTTP API, and every page of these docs has a Markdown twin.

Where to go next

Library

Research dataProvider-neutral research queries, immutable source views, bounded windows and explicit resume/quality decisions; external packages own acquisition.1 entry point · 55 exportsOptionsBlack–Scholes, Black-76, Bachelier, American, Heston, SABR and exotic pricing; Greeks; implied volatility; chain health.15 entry points · 444 exportsStrategiesMulti-leg option positions: payoff, break-evens, scenarios and a named strategy catalogue.4 entry points · 195 exportsVolatilityRealized and implied volatility, smiles and surfaces (SVI, SSVI, SABR, Heston), GARCH.28 entry points · 460 exportsTechnical analysisHundreds of registered indicators with explicit warmup, streaming state, snapshots and a TA-Lib compatibility matrix.32 entry points · 1,577 exportsPortfolioEvent-sourced ledgers, positions, lots, cash, P&L attribution and timelines.9 entry points · 556 exportsPerformanceReturns, risk-adjusted ratios, drawdowns, benchmarks and sector performance.12 entry points · 214 exportsRiskValue at risk, expected shortfall, covariance, drawdown risk and portfolio optimization.8 entry points · 366 exportsValuationDCF, NPV and IRR, WACC, comparables, dividend and residual-income models, loans and price-level conversion.6 entry points · 405 exportsFundamentalsStatement ratios, quality scores (Piotroski, Altman, Beneish), growth and point-in-time availability.4 entry points · 204 exportsFixed incomeBonds, yields, duration and convexity, curves, swaps, caps, swaptions and futures.15 entry points · 431 exportsForeign exchangeConversion, cross rates, forwards, swaps, non-deliverable forwards and hedging.4 entry points · 90 exportsCommoditiesForwards, carry, convenience yield, roll yield, spreads and term structure.3 entry points · 92 exportsCryptoPerpetual funding, futures basis, carry curves, inverse contracts and liquidation prices.5 entry points · 76 exportsScenariosScenario runs across priced positions and portfolio scenario targets.2 entry points · 81 exportsExposure & flowDealer Greek exposure (gamma, vanna, charm and more), option flow and unusual activity.3 entry points · 146 exportsBacktestingVectorized and event-driven backtests, costs, execution and tear sheets.12 entry points · 492 exportsResearchScreens, factors, event studies and research hygiene.5 entry points · 232 exportsMathDistributions, statistics, linear algebra, optimization, root finding and Monte Carlo.16 entry points · 343 exportsCalendarsExchange calendars (NYSE, Cboe, 24×7 crypto), holidays and option expirations.4 entry points · 19 exportsCoreShared errors, conventions, validation, dates, formatting, OCC symbols and artifacts.6 entry points · 386 exportsWorkflowsThe operation registry behind the CLI, HTTP server and MCP tools.2 entry points · 104 exportsCLIThe command-line interface over the operation registry.1 entry point · 18 exportsHTTP serverA local HTTP/OpenAPI server over the operation registry.1 entry point · 8 exportsMCP serverThe optional @insiderfinance/totalfinance-mcp package for AI agents.1 entry point · 28 exports
Edit this page on GitHub ↗Every code block on this site is executed in CI against the library.