Published
Edited
Nov 4, 2019
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
grainDemand = BUYER_BUDGET / ANCHOR_PRICE
Insert cell
clearingPrice = (grainDemand / GRAIN_OFFERED) * ANCHOR_PRICE
Insert cell
clampWithin = (val, min, max) => Math.max(Math.min(max, val), min)
Insert cell
minPrice = ANCHOR_PRICE / (1 + VOLATILITY)
Insert cell
maxPrice = ANCHOR_PRICE * (1 + VOLATILITY)
Insert cell
salePrice = clampWithin(clearingPrice, minPrice, maxPrice)
Insert cell
clearingAmount = {
// Too much Grain; buyer buys as much as they can afford at salePrice
if (salePrice === minPrice) return BUYER_BUDGET / salePrice
// Otherwise, all the Grain gets sold
return GRAIN_OFFERED
}
Insert cell
supplySatisfaction = clearingAmount / GRAIN_OFFERED
Insert cell
demandSatisfaction = clearingAmount * salePrice / BUYER_BUDGET
Insert cell
import {slider} from "@jashkenas/inputs"
Insert cell
d3 = require("https://d3js.org/d3.v5.min.js")
Insert cell
percentFormat = d3.format(".1%")
Insert cell
dollarFormat = d3.format("$,.2f")
Insert cell
grainFormat = (x) => d3.format(",.0f")(x) + "`¤`"
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more