Free Black-76 and Barone-Adesi-Whaley pricing, greeks, multi-leg payoff charts and scenario grids for 14 futures markets: metals, energy, grains, softs and cattle. Futures prices and the daily US Trea
翻譯準備中
金融JavaScript · HTMLGitHub @MartinColaF上線中營運者未確認
試用過了嗎? 點一下就好,不需要登入。
尚未偵測到更新。GitHub 發布版本後會顯示在這裡。
個人 GitHub 帳號下公開儲存庫的擁有者可以登入並驗證所有權,自行管理介紹,無需管理員核准。
登入並產生驗證檔案,在 30 分鐘內將其提交至此儲存庫的預設分支。其他分支或分叉儲存庫中的檔案無效。然後在下方檢查檔案,即可無需管理員核准直接管理專案。請保留檔案以維持管理權限。
如需登入,將前往登入頁面。登入後請回到此處,再次點擊所選的驗證按鈕。
在專案資料夾中執行 /nomorevibe verify,即可驗證所有權並自行管理介紹。
一分鐘完成驗證Options calculator for commodity futures
翻譯準備中
取自儲存庫 README
正在載入完整 README。
檢視完整 README ↗Options calculator for commodity futures. Static site, no build step, no backend:
open index.html or serve the folder. In Spanish at /es/.
b = 0 → Black-76, options on futures (the market standard here).b = r - q → Black-Scholes-Merton on spot with a convenience yield.b = 0 the early-exercise premium is real on calls and puts alike.IV.
The leg keeps the exact volatility, so it is worth its premium and a position just
entered shows no P&L; the table shows it to two decimals and the message to four.
A premium with no time value — what the option is worth at zero volatility, as a
deep in-the-money option close to expiry can be — implies no volatility, and the
button says so rather than writing one in.One button fills all four inputs for the selected commodity; each field reports its own source and anything that fails is left untouched.
| Input | Source | Key needed |
|---|---|---|
| Futures price | Front-month contract (GC=F, CL=F, ZC=F…) via /api/market | no |
| Risk-free rate | US Treasury daily par yield curve, interpolated to your expiry and converted from its semi-annual bond-equivalent basis to a continuously compounded rate | no |
| Volatility | Realised volatility (close-to-close, EWMA, Parkinson) on the futures series itself | no |
| Convenience yield | Implied by the real curve from two listed contracts: y = r − ln(F2/F1)/(T2−T1) | no |
| Fallback | Alpha Vantage ETF proxies, for custom tickers or if the function is down | free key |
/api/market functionYahoo Finance sends no CORS headers, so the browser cannot read it directly. The
serverless function in api/market.js makes that request instead.
s-maxage: quotes 5 min, history and the
listed contracts 1 h) and again in the browser, so upstream sees very little traffic.commodities.js. The
months endpoint probes the next listed contracts and returns those that quote,
nearest first. The month picker, the convenience yield and the per-leg fill all read
that one answer, the last two from its first two contracts, so the page makes one
request for the whole curve.Notes and limitations, stated plainly in the UI as well:
index.html — markupstyles.css — styling, light and darkcommodities.js — the table of markets: contract specs and ticks, presets and
futures symbols. The page and the function both read it, so adding a market is one
entry.app.js — pricing engine, strategy analytics, data providers, renderingapi/market.js — serverless futures data proxy (Vercel)privacy.html — privacy policyi18n.js — t(), through which app.js writes every word, keyed by its English textes/ — the Spanish page, its words (words.js), the policy in Spanish and its
preview imageNo dependencies, nothing to install. Node 20+ is the only requirement (CI runs 20 and 22).
npm run dev # static server on http://localhost:3000 (UI only)
npx vercel dev # also runs the /api functions locally
npm test # the full test suite
CI also runs ESLint's recommended rules over the code, at versions it installs itself so
that package.json stays free of dependencies; CLAUDE.md has the command to run it
by hand.
Opening index.html directly works too, but the /api buttons need a server, and
some browsers restrict cross-origin requests from file://.
node --test, no framework:
test/pricing.test.js — put-call parity in both models, a textbook reference
value, all five greeks against finite differences, rho in each model's own
convention even when BSM's carry is zero, theta and rho with no volatility left,
equal to their limits just above it, implied-volatility round trips and none from a
premium with no time value, the volatility estimators against a series of known
volatility, curve interpolation and the carry inversion.test/strategies.test.js — closed-form limits for spreads, straddles, condors and
butterflies, financed and nominal; bounded put payoffs; the rate an unlimited maximum
grows at, a European calendar's against an American one's and a naked call's; the
verdict decided where the price has no bound, in calendars whose far call is
exercised far past the grid or never, a diagonal doing its worst past the grid, a far
call with no exercise boundary searched past it all the same, legs on their own
months and random American calendars against their own P&L; contract
multipliers including cents-quoted markets; every preset and every commodity.test/financing.test.js — the premium's interest: a debit paying it and a credit
earning it up to the date the P&L is read, a fairly priced option breaking even on
average at the risk-free rate (by quadrature, a calendar's far leg included), a rate
of your own or none, a futures leg carrying nothing, the chart's leg curves adding up
to the position, what the page says in each mode, and old scenarios restoring nominal.test/probability.test.js — the probability of profit against closed forms, on
either tail and between breakevens, a breakeven past the top of the statistics grid
included, measured at the volatility of the option nearest the money at the
horizon, and the summary naming that volatility.test/skew.test.js — the skew curve reproducing the 25-delta quotes it was built
from, the wings under a butterfly, the clamp on an extreme risk reversal, every
strike read where the curve and its delta agree, the note naming strikes a curve too
steep to read, and the scenario grid's shape, ordering and response to volatility
and time.test/curve.test.js — per-leg underlying prices: a flat curve reproducing the
shared-price behaviour exactly, the payoff kink landing on the shared axis,
contango raising a calendar spread, and the zero-price guards.test/american.test.js — an independent CRR binomial tree, and the
Barone-Adesi-Whaley pricer checked against it: the approximation envelope, the
no-arbitrage bounds, the early-exercise premium on both sides of a futures
option, the exercise boundary, greeks by finite difference, theta as the price's
rate of change, the style-aware implied-volatility solver, negative rates: European
exactly where the tree finds no early-exercise value, never below the European price
anywhere, no premium where BAW finds no exercise boundary, and with no volatility,
exercise on the best date — now, at expiry or in between — with that date's greeks.app.js has no module system on purpose, so the page still runs from a file://
path. The tests load it into a VM with a small DOM stub — see
test/helpers/load-app.js.
CI runs the suite on every push (.github/workflows/test.yml).
The repo is self-contained and dependency-free, so any cloud dev environment works
with no setup step: point it at the GitHub repo and npm test runs immediately.
This matters because the serverless function cannot be exercised without a Node
toolchain — locally that meant deploying to find out, which is what the test suite
now replaces.
test/leg-pricing.test.js — every path that prices a leg agreeing with the others:
the implied volatility of a leg's own premium is its own volatility, a position marked
today at today's price shows no P&L, value and greeks report the same price,
every net greek and greek profile is the matching derivative of the chart's P&L,
with legs on other months and theta beside the premium's interest per day, the IV
button writing nothing for a premium with no time value and the exact volatility
for one with it, and volatility fields rounding what they show, not what is used.test/restore.test.js — the trust boundary for shared links, saved state and
imported files: hostile fields rejected or retyped, ids never taken from the input,
a legitimate scenario, its financing included, round-tripping unchanged, and the legs
table escaping every value it renders.test/inputs.test.js — what a number may be: a price, strike or size above zero and
a volatility not below it, refused in the panel, the legs table and a restored
scenario, with the reason beside the field until the user's next action.test/actions.test.js — every market-data action against a fake network: the rate
read off a real Treasury response, the price switching to cents on a USX quote, a
quote below zero refused with the reason,
the Alpha Vantage fallback, realised volatility kept as measured, the curve's
convenience yield, leg prices from the slope
and from the listed strip with their undo, all three reading one request for the
curve, auto-fill carrying on past a failure, the
presets, and every source line staying true: a price, rate, volatility or yield typed
by hand is the user's own, and the month picker follows the price.test/commodities.test.js — the page and the function reading one table: the
markets the page sends to the function are exactly those with futures data, every
contract entry is in a form the function can build symbols from, and every market but
custom gives its tick.test/prices.test.js — every price shown to its market's tick: the decimals per
market and per quoting unit, the review's copper, gas, silver and gold premiums within
half a tick, and the same decimals in the breakevens, the strike marks, the scenario
grid, the month picker and every source line.test/page.test.js — the page's one third-party script: pinned by its hash, an
exact version of a file the package publishes, and a Content-Security-Policy that
allows that file and nothing broader.test/chart.test.js — what the payoff chart is given in every mode (the horizon,
today and each leg; one series per greek profile; strike marks on the shared axis),
the chart created once and updated in place, its colours read from the stylesheet
in both schemes, and the page carrying on without Chart.js.test/layers.test.js — the calculations and actions never touching the page, the
rendering never changing the state, the chart date kept within the horizon, and the
listed strip: dropped with the commodity, never saved or shared.test/storage.test.js — the local-storage cache: expired entries removed, pruning
that touches nothing but the cache, a full quota making room for the saved
scenario instead of losing it, and the Alpha Vantage key forgotten when its field
is emptied.test/deploy.test.js — .vercelignore keeping the notes, tests and tooling off the
site without ever dropping a file the page or the market function needs.test/privacy.test.js — the privacy policy promising nothing the site does not do:
no cookie banner it lacks, no "no cookies" while code sets one, ads described as
inactive for as long as none load, and every third party the page may contact
named.test/api.test.js — the serverless function with a mocked upstream: rejected
commodities, method and action validation, series parsing, the two rules of the
contract probe (skip the delivery month, skip contracts that have not traded
recently), and curve being the first two contracts of that same probe.test/loader.test.js — the test loader handing over every top-level function in
app.js without a list to keep, and the const bindings the tests read.