Open source · by InsiderFinance
The complete finance library for TypeScript and AI agents.
Most quant work still means a Python service or an npm package nobody maintains. TotalFinance puts options, volatility, technical analysis, risk, valuation, fixed income and backtesting in one fully typed package with no runtime dependencies. It runs in Node, browsers and edge workers, and your AI agent can call it as tools.
import { blackScholes } from '@insiderfinance/totalfinance/options';
const quote = blackScholes.greeks.explain({
type: 'call',
spot: 100,
strike: 105,
timeToExpiryYears: 0.25,
volatility: 0.2,
riskFreeRate: 0.04,
});{
"value": {
"delta": 0.367719,
"gamma": 0.037681,
"theta": -0.024415,
"vega": 0.188403,
"rho": 0.085952
},
"assumptions": {
"dayCount": "ACT/365F",
"compounding": "continuous",
"units": {
"theta": "perDay",
"vega": "per1Percent",
"rho": "per1Percent"
}
}
}{
"tool": "totalfinance_option_greeks",
"arguments": {
"type": "call",
"spot": 100,
"strike": 105,
"timeToExpiryYears": 0.25,
"volatility": 0.2,
"riskFreeRate": 0.04
},
"result": {
"summary": "delta=0.3677 gamma=0.037681 theta=-0.0244 vega=0.1884 rho=0.0860",
"assumptions": {
"dayCount": "ACT/365F"
}
}
}- Complete
- 25 modules
- 7,144 documented exports, from Black–Scholes to backtests
- Fast
- 86 ms
- to price 1,000,000 options with all five Greeks, on one thread*
- TypeScript-native
- 0 dependencies
- Fully typed, explicit units, typed errors; Node, browsers and edge
- Agent-ready
- 48 MCP tools
- plus these docs as an MCP server, llms.txt and Markdown pages
* blackScholesPriceMany with Greeks, median of seven runs on an Apple M4 with Node 26. Prices alone take about 50 ms.
Sound familiar?
Finance code fails quietly. TotalFinance makes it speak up.
Python has QuantLib. TypeScript has scattered packages.
So you port formulas from blog posts or run a Python service next to your app. TotalFinance covers options, volatility surfaces, technical analysis, risk, valuation, fixed income and backtesting in one package with no runtime dependencies.
Wrong inputs don’t throw.
A percent where a decimal belongs, days where years belong: the answer still looks plausible. TotalFinance flags suspicious inputs with the likely fix, and impossible ones throw a typed error that names the field.
You can’t defend a number you can’t trace.
Every explained result lists its assumptions (day count, compounding, conventions) and its diagnostics, so you can show your users, your team or an auditor where a number came from.
Your AI agent makes up the math.
Connect TotalFinance over MCP and your agent calls tested calculations instead of guessing, and reads these docs to write code against the real API.
Built for AI agents
Give your agent a calculator it can trust.
Language models guess at arithmetic and at APIs. Connect TotalFinance over MCP and your agent calls tested calculations that report their assumptions, and writes code against the real API.
- Calculations on your machine. 23 read-only tools by default, 48 with profiles: pricing, Greeks, strategies, volatility, indicators, risk, bonds and backtests. Your data never leaves your computer.
- These docs as tools. A hosted docs MCP lets the agent search, read pages and fetch any export's exact contract. Nothing to install.
- Context-ready docs. llms.txt, per-domain bundles and a Markdown version of every page.
- A prompt on every calculator. Each one shows the tool your agent calls and a prompt built from your inputs.
The TotalFinance MCP server runs the library on your machine: pricing, Greeks, strategies, volatility, technical analysis, risk, bonds and more, read-only by default.
Not on npm yet. Build the server once from a source checkout, then point your client at distribution/mcp/dist/bin.js as below. When the package is published, this becomes a one-line npx command.
git clone https://github.com/InsiderFinance/totalfinance.git
cd totalfinance
pnpm install --frozen-lockfile
pnpm build
node distribution/mcp/dist/bin.js doctorclaude mcp add totalfinance -- node /absolute/path/to/totalfinance/distribution/mcp/dist/bin.jsTry it live
Drag a slider. Watch the library answer.
This calculator runs the real package in your browser. Results, charts and the copyable TypeScript all follow your inputs.
Run it
Live, in your browser. Nothing leaves this page.
Change any input; everything updates.
- Call price
- $2.39
- USD / share
- Delta
- 0.367719
- per 1 USD of underlying
- Gamma
- 0.0376805
- delta per 1 USD
- Vega
- 0.188403
- USD per 1% volatility
- Theta
- -0.0244146
- USD per calendar day
- Rho
- 0.0859525
- USD per 1% rate
- Call value today
- Value at expiry (intrinsic)
Show data (81 rows)
Show data (81 rows)
Show data (81 rows)
Show data (81 rows)
Show data (81 rows)
Assumptions & conventions
What the calculation assumed, echoed by the library rather than hidden.
- price.conventionsVersion
- 0.0.1
- price.dayCount
- ACT/365F
- price.compounding
- continuous
- price.timeToExpiryYears
- 0.25
- price.dividendModel
- none
- price.units.theta
- perDay
- price.units.vega
- per1Percent
- price.units.rho
- per1Percent
- price.model
- black-scholes-merton
- price.engine
- black-scholes-merton
- greeks.conventionsVersion
- 0.0.1
- greeks.dayCount
- ACT/365F
- greeks.compounding
- continuous
- greeks.timeToExpiryYears
- 0.25
- greeks.dividendModel
- none
- greeks.units.theta
- perDay
- greeks.units.vega
- per1Percent
- greeks.units.rho
- per1Percent
- greeks.model
- black-scholes-merton
- greeks.engine
- black-scholes-merton
Diagnostics & warnings
No warnings. Engine, method and convergence details:
- price.engine
- black-scholes-merton
- price.method
- closed-form
- price.converged
- true
- greeks.engine
- black-scholes-merton
- greeks.method
- closed-form
- greeks.converged
- true
Use it in your project
Returns a number: the call price in USD per share. No array conversion or chart setup is needed. Use blackScholes.greeks(input) for a named Greeks object, or .explain(input) for assumptions and diagnostics.
import { blackScholes } from '@insiderfinance/totalfinance/options';
const input = {
"type": "call",
"spot": 100,
"strike": 105,
"timeToExpiryYears": 0.25,
"volatility": 0.2,
"riskFreeRate": 0.04,
"dividendYield": 0
} as const;
const result = blackScholes.price(input);
console.log(result);2.3908769595711306Reproduce this entire calculator
Full result object
Both examples use the inputs of the last successful calculation. Displayed metrics are rounded; copied programs keep exact values. Every copy on this page is type-checked and executed against the packed package in CI.
Ask your AI agent
With the TotalFinance MCP server connected, your agent runs this calculation with the totalfinance_option_price tool (on by default). The prompt below uses your current inputs.
Use the TotalFinance MCP tool totalfinance_option_price to price a European call: spot 100, strike 105, 0.25 years to expiry, volatility 20%, risk-free rate 4%, dividend yield 0%. Then get the Greeks with totalfinance_option_greeks and list the assumptions the tools report.
Ten calculators
Bring your own data. Keep the code.
Paste or upload your own prices into the backtest, indicator and risk calculators. Every result comes with the exact TypeScript that reproduces it, tested in CI.
Everything in one package
The finance library, tree-shakeable.
Open source
Help TypeScript developers find TotalFinance.
TotalFinance is new and built in the open. If it saves you a Python service or a week of porting formulas, a star on GitHub helps the next developer find it.
From InsiderFinance
TotalFinance computes. InsiderFinance brings the data.
Options flow, dark pool prints and market data from InsiderFinance, ready to feed straight into the calculations on this site.