Skip to content
TotalFinance

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.

$ pnpm add @insiderfinance/totalfinance
In your app
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,
});
quote
{
  "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"
    }
  }
}
In your AI agent: the same math as an MCP tool
{
  "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.
Everything for agents

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.

Build from source (Node 22.13+, pnpm)
git clone https://github.com/InsiderFinance/totalfinance.git
cd totalfinance
pnpm install --frozen-lockfile
pnpm build
node distribution/mcp/dist/bin.js doctor
Run in your terminal
claude mcp add totalfinance -- node /absolute/path/to/totalfinance/distribution/mcp/dist/bin.js

Try 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.

Local
$100.00

USD / share

$105.00

USD / share

0.25 years

years

20%

decimal · 0.20 = 20%

4%

decimal · 0.04 = 4%

0%

decimal · continuous

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 across underlying pricesToday's Black–Scholes value against the value at expiry (intrinsic). The gap between them is time value.
  • Call value today
  • Value at expiry (intrinsic)
Spot 100Strike 105
Show data (81 rows)
Underlying price · USDCall value todayValue at expiry (intrinsic)
$60.00$0.00$0.00
$61.00$0.00$0.00
$62.00$0.00$0.00
$63.00$0.00$0.00
$64.00$0.00$0.00
$65.00$0.00$0.00
$66.00$0.00$0.00
$67.00$0.00$0.00
$68.00$0.00$0.00
$69.00$0.00$0.00
$70.00$0.00$0.00
$71.00$0.00$0.00
$72.00$0.00$0.00
$73.00$0.00$0.00
$74.00$0.00$0.00
$75.00$0.00$0.00
$76.00$0.00$0.00
$77.00$0.00$0.00
$78.00$0.01$0.00
$79.00$0.01$0.00
$80.00$0.01$0.00
$81.00$0.02$0.00
$82.00$0.03$0.00
$83.00$0.04$0.00
$84.00$0.06$0.00
$85.00$0.08$0.00
$86.00$0.11$0.00
$87.00$0.14$0.00
$88.00$0.19$0.00
$89.00$0.25$0.00
$90.00$0.32$0.00
$91.00$0.41$0.00
$92.00$0.52$0.00
$93.00$0.66$0.00
$94.00$0.81$0.00
$95.00$1.00$0.00
$96.00$1.21$0.00
$97.00$1.45$0.00
$98.00$1.73$0.00
$99.00$2.04$0.00
$100.00$2.39$0.00
$101.00$2.78$0.00
$102.00$3.20$0.00
$103.00$3.67$0.00
$104.00$4.17$0.00
$105.00$4.71$0.00
$106.00$5.29$1.00
$107.00$5.90$2.00
$108.00$6.55$3.00
$109.00$7.24$4.00
$110.00$7.95$5.00
$111.00$8.70$6.00
$112.00$9.47$7.00
$113.00$10.27$8.00
$114.00$11.09$9.00
$115.00$11.94$10.00
$116.00$12.80$11.00
$117.00$13.69$12.00
$118.00$14.58$13.00
$119.00$15.50$14.00
$120.00$16.42$15.00
$121.00$17.36$16.00
$122.00$18.31$17.00
$123.00$19.26$18.00
$124.00$20.22$19.00
$125.00$21.19$20.00
$126.00$22.16$21.00
$127.00$23.14$22.00
$128.00$24.12$23.00
$129.00$25.11$24.00
$130.00$26.10$25.00
$131.00$27.09$26.00
$132.00$28.08$27.00
$133.00$29.07$28.00
$134.00$30.07$29.00
$135.00$31.06$30.00
$136.00$32.06$31.00
$137.00$33.06$32.00
$138.00$34.05$33.00
$139.00$35.05$34.00
$140.00$36.05$35.00
Delta
Spot 100Strike 105
Show data (81 rows)
Underlying price · USDDelta
$60.002.573E-8
$61.006.429E-8
$62.001.542E-7
$63.003.556E-7
$64.007.903E-7
$65.001.694E-6
$66.003.51E-6
$67.007.038E-6
$68.001.367E-5
$69.002.577E-5
$70.004.718E-5
$71.008.401E-5
$72.000.000145635
$73.000.00024606
$74.000.000405588
$75.000.000652854
$76.000.00102714
$77.000.00158092
$78.000.00238243
$79.000.00351811
$80.000.00509466
$81.000.00724036
$82.000.0101054
$83.000.013861
$84.000.018697
$85.000.0248178
$86.000.0324366
$87.000.0417685
$88.000.0530217
$89.000.0663886
$90.000.0820359
$91.000.100095
$92.000.120655
$93.000.143753
$94.000.169371
$95.000.197431
$96.000.227797
$97.000.260276
$98.000.294623
$99.000.330546
$100.000.367719
$101.000.405786
$102.000.444379
$103.000.483124
$104.000.521654
$105.000.559618
$106.000.596689
$107.000.632576
$108.000.667023
$109.000.699817
$110.000.730789
$111.000.759812
$112.000.786805
$113.000.811726
$114.000.834569
$115.000.855363
$116.000.874164
$117.000.891051
$118.000.906121
$119.000.919487
$120.000.93127
$121.000.941595
$122.000.950591
$123.000.958385
$124.000.9651
$125.000.970857
$126.000.975764
$127.000.979928
$128.000.983443
$129.000.986396
$130.000.988865
$131.000.990921
$132.000.992624
$133.000.99403
$134.000.995184
$135.000.996129
$136.000.996899
$137.000.997525
$138.000.99803
$139.000.998437
$140.000.998764
Gamma
Spot 100Strike 105
Show data (81 rows)
Underlying price · USDGamma
$60.002.41E-8
$61.005.753E-8
$62.001.318E-7
$63.002.905E-7
$64.006.167E-7
$65.001.263E-6
$66.002.499E-6
$67.004.783E-6
$68.008.87E-6
$69.001.595E-5
$70.002.787E-5
$71.004.733E-5
$72.007.823E-5
$73.000.000125971
$74.000.000197819
$75.000.000303217
$76.000.00045406
$77.000.000664829
$78.000.000952559
$79.000.00133657
$80.000.00183791
$81.000.00247853
$82.000.00328014
$83.000.0042628
$84.000.00544337
$85.000.00683385
$86.000.00843977
$87.000.0102588
$88.000.0122798
$89.000.0144819
$90.000.0168348
$91.000.019299
$92.000.0218271
$93.000.0243656
$94.000.0268566
$95.000.0292408
$96.000.0314596
$97.000.033458
$98.000.0351869
$99.000.0366049
$100.000.0376805
$101.000.0383926
$102.000.0387312
$103.000.0386976
$104.000.0383033
$105.000.0375695
$106.000.0365252
$107.000.0352061
$108.000.0336524
$109.000.0319072
$110.000.0300147
$111.000.0280185
$112.000.0259607
$113.000.02388
$114.000.0218116
$115.000.0197859
$116.000.0178287
$117.000.015961
$118.000.0141987
$119.000.0125534
$120.000.0110323
$121.000.00963908
$122.000.00837398
$123.000.00723471
$124.000.00621677
$125.000.00531404
$126.000.00451918
$127.000.00382407
$128.000.00322016
$129.000.0026988
$130.000.00225142
$131.000.00186976
$132.000.00154599
$133.000.00127282
$134.000.00104356
$135.000.000852108
$136.000.000693026
$137.000.000561464
$138.000.000453163
$139.000.000364406
$140.000.000291982
Vega
Spot 100Strike 105
Show data (81 rows)
Underlying price · USDVega
$60.004.338E-8
$61.001.07E-7
$62.002.534E-7
$63.005.765E-7
$64.001.263E-6
$65.002.668E-6
$66.005.442E-6
$67.001.074E-5
$68.002.051E-5
$69.003.798E-5
$70.006.828E-5
$71.000.000119293
$72.000.000202769
$73.000.00033565
$74.000.000541627
$75.000.000852798
$76.000.00131133
$77.000.00197089
$78.000.00289768
$79.000.00417076
$80.000.00588131
$81.000.00813082
$82.000.0110278
$83.000.0146832
$84.000.0192042
$85.000.0246873
$86.000.0312103
$87.000.0388246
$88.000.0475474
$89.000.0573556
$90.000.0681808
$91.000.0799073
$92.000.0923723
$93.000.105369
$94.000.118653
$95.000.131949
$96.000.144966
$97.000.157403
$98.000.168967
$99.000.179382
$100.000.188403
$101.000.195821
$102.000.20148
$103.000.205271
$104.000.207144
$105.000.207102
$106.000.205199
$107.000.201537
$108.000.196261
$109.000.189545
$110.000.181589
$111.000.172608
$112.000.162826
$113.000.152462
$114.000.141732
$115.000.130834
$116.000.119952
$117.000.109245
$118.000.0988516
$119.000.0888845
$120.000.0794329
$121.000.0705629
$122.000.0623192
$123.000.0547269
$124.000.0477946
$125.000.041516
$126.000.0358732
$127.000.0308392
$128.000.0263796
$129.000.0224554
$130.000.0190245
$131.000.0160435
$132.000.0134687
$133.000.0112575
$134.000.00936904
$135.000.00776484
$136.000.0064091
$137.000.00526906
$138.000.00431501
$139.000.00352035
$140.000.00286143
Theta
Spot 100Strike 105
Show data (81 rows)
Underlying price · USDTheta
$60.00-4.92E-9
$61.00-1.215E-8
$62.00-2.88E-8
$63.00-6.559E-8
$64.00-1.438E-7
$65.00-3.042E-7
$66.00-6.213E-7
$67.00-1.227E-6
$68.00-2.347E-6
$69.00-4.353E-6
$70.00-7.836E-6
$71.00-1.371E-5
$72.00-2.334E-5
$73.00-3.87E-5
$74.00-6.256E-5
$75.00-9.868E-5
$76.00-0.00015203
$77.00-0.000228956
$78.00-0.000337333
$79.00-0.000486621
$80.00-0.000687819
$81.00-0.000953276
$82.00-0.00129635
$83.00-0.00173091
$84.00-0.00227062
$85.00-0.0029282
$86.00-0.00371445
$87.00-0.00463737
$88.00-0.00570123
$89.00-0.00690576
$90.00-0.00824558
$91.00-0.0097098
$92.00-0.011282
$93.00-0.0129405
$94.00-0.0146587
$95.00-0.0164065
$96.00-0.0181508
$97.00-0.0198573
$98.00-0.0214916
$99.00-0.0230208
$100.00-0.0244146
$101.00-0.0256469
$102.00-0.0266963
$103.00-0.0275471
$104.00-0.0281893
$105.00-0.0286194
$106.00-0.0288394
$107.00-0.028857
$108.00-0.0286846
$109.00-0.0283385
$110.00-0.0278382
$111.00-0.0272055
$112.00-0.0264633
$113.00-0.0256348
$114.00-0.024743
$115.00-0.0238096
$116.00-0.022855
$117.00-0.0218972
$118.00-0.0209522
$119.00-0.0200335
$120.00-0.019152
$121.00-0.0183163
$122.00-0.0175326
$123.00-0.0168052
$124.00-0.0161364
$125.00-0.0155269
$126.00-0.014976
$127.00-0.014482
$128.00-0.0140424
$129.00-0.0136539
$130.00-0.013313
$131.00-0.0130157
$132.00-0.0127581
$133.00-0.0125361
$134.00-0.0123461
$135.00-0.0121842
$136.00-0.0120471
$137.00-0.0119315
$138.00-0.0118345
$139.00-0.0117536
$140.00-0.0116864

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.

First call
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);
Output of this example
2.3908769595711306
Reproduce 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.

Prompt

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.

Connect Claude, Cursor, VS Code, Codex or ChatGPT

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.

All calculators →
Analyze an option strategyEdit the legs or start from a preset. The chart is net profit or loss at expiration, not option value before expiry. Premiums are per share; the option contract multiplier is 100.Track profit, not depositsA sample ledger holds one equity position. Change the closing mark or add a deposit: new cash changes account value, but it is not investment profit. USD throughout.Value a company’s cash flowsA five-year sample FCFF forecast produces enterprise value. A discount rate is a stated assumption—not a market fact. No debt/cash bridge or share count is silently invented.Backtest a moving-average ruleHold the asset while a moving-average rule is on. Signals execute on the next bar, commissions are charged on every fill, and every input is yours to change, including the price data. A research demonstration, not evidence of an investable edge.Explore price and volatility scenariosRevalue a sample 100/110 bull call spread before expiry across underlying prices and volatility shocks. This is mark-to-market P&L, not an expiration payoff or a forecast.Chart technical indicatorsOverlay a moving average or Bollinger Bands on your own price bars and add an RSI or MACD pane. Warmup values stay NaN: an indicator never invents a value before it has enough history.Measure value at riskEstimate one-period value at risk and expected shortfall from a return series, then see where those losses sit in the distribution and how deep the drawdowns ran. Paste daily returns, or closing prices and they become simple returns.Price a fixed-rate bondPrice a newly issued fixed-rate bond from its yield, read its duration, convexity and DV01, and see how price responds as yields move. Prices are per 100 of face value; day count is 30/360.Fit a volatility smileEnter implied volatilities by strike for one expiry and fit a smooth smile with SVI, SABR or monotone interpolation. Read off the at-the-money level and wings, and check the fit for butterfly arbitrage.

Everything in one package

The finance library, tree-shakeable.

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

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.

Explore InsiderFinance