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

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more