Omid Golchin · Decision tools
Order Quantity Planner
You have a product whose demand you cannot predict exactly. Get the order quantity the math supports, with the checks a planner runs first.
It answers: how many units to order for the next period when demand is uncertain, so that the cost of running out and the cost of leftovers balance for your prices.
- Pick the situation closest to yours in "Start from a common situation": a real product with a known pattern, or a margin structure. Or keep the steady seller already filled in.
- Put in your own numbers: past sales in section 1 (one number per week or month, most recent last) and your prices in section 2. Fill from my notes in section 2 can read pasted notes. Everything updates as you type.
- Read the order in section 3 and the checks beside it. After the period, grade the order in section 4. Before you rely on it, check when to use this tool, and when not.
3 · The order
Verdict
…
What each order quantity earns
Forecast and backtest which method, and how much to trust it
The full numbers critical ratio, sensitivity, demand quantiles
How the verdict is decided rules, formulas, sources
The order quantity is the newsvendor solution (Arrow, Harris & Marschak 1951): order up to the demand quantile set by your economics, not to the forecast. One unit too many loses (cost − salvage); one unit too few loses (price − cost + goodwill). The balance point is the critical ratio, and the tool orders the smallest quantity whose chance of covering demand reaches it.
The forecast is chosen by backtest, not by fit. Seasonal naive, ETS and ARIMA forecast the last 8 periods one step at a time, each time using only the past (rolling origin; Hyndman & Athanasopoulos, Forecasting: Principles and Practice, 3rd ed.). The lowest error wins, and its 80% interval coverage is shown: a method can win on error and still be overconfident. (In your browser, a pasted series races seasonal naive against ETS; the built-in products were also raced against ARIMA offline, by the Python reference implementation in this repository.)
Sold-out periods hide demand. If a period sold exactly the stock on hand, demand was at least that high. With a stock column, those periods are replaced by draws from the sales seen at or above that level before anything is fit (a Kaplan–Meier style fix), which widens the top of the demand range instead of understating it.
Intermittent demand (30% or more of periods at zero) breaks ETS and ARIMA assumptions, so the tool samples past periods directly and says so (Syntetos & Boylan 2005).
Where the numbers behind this tool came from (the 30-product backtest, the classic study this replaces): see Research notes.
4 · Check last period
Grade
…
How last period is graded what counts as money left on the table
Your realized profit is computed from what actually sold. The plan's order is the recommendation from section 3 for the same product and prices. “Left on the table” compares expected profit (over the whole demand distribution) at the plan's quantity against your quantity: one period is a single draw, so a good order can still lose money and a bad one can get lucky. If you sold out, your sales are a floor on demand, not demand itself: the grade says so instead of treating the period as fully observed.
When to use it, and when not assumptions, limits, alternatives
Use it to set a one-time or once-per-period order for one product whose leftovers lose value: seasonal or fashion stock, perishables, a print run, event supplies, or a weekly order of a product whose unsold units are marked down.
It assumes the following. Each line says what happens to the answer when your case breaks the assumption.
| Assumption | If yours differs |
|---|---|
| One period: leftovers are sold off at the salvage value, not kept for the next period. | If leftovers keep most of their value and are simply sold next period, the bet is milder than the tool assumes and it orders too cautiously. Use a reorder-point or base-stock policy instead. |
| The order arrives before selling starts; there is no second chance to reorder within the period. | If you can top up mid-period, order less up front: the tool overstates the risk of running out. |
| Next period's demand looks like the history: the same level and seasonal pattern. | Before a promotion, a price change, a new competitor or a product launch, history understates or overstates demand. Adjust the history or use the forecast only as a starting point. |
| Your sales show your demand, except in periods you mark as sold out. | If you sold out without recording stock, sales understate demand and the order comes out too low. Add the stock column. |
| Costs are per unit: no fixed cost per order and no quantity discounts. | With a large fixed order cost or price breaks, use an economic-order-quantity or discount model; the newsvendor answer ignores both. |
| One product, judged on its own. | If customers switch to a similar product when this one runs out, a lost sale costs less than the tool assumes; if a shared budget or shelf space limits several products, plan them together. |
| Prices and costs are known. | The profit range covers demand only, not uncertain prices or costs. |
Do not use it for products replenished continuously from a warehouse (use a reorder-point policy), for multi-period inventory with lead times (the Ordering Policy Tester covers lead times in a supply chain), or for a product with no sales history at all (borrow the history of a similar product and say so).
Where this tool comes from the problem and data it was built on, and how it was generalised
The tool grew from an earlier forecasting and ordering experiment on the Online Retail II dataset (a UK giftware wholesaler, 2009 to 2011; UCI, CC BY 4.0). That experiment backtested a seasonal-naive forecast on the shop's 30 best-selling products over four-week horizons and simulated orders and profit at one fixed price design. It also compared language-model forecasts, which did not carry into the tool.
What the tool's own backtest adds. No forecasting method wins everywhere: in a rolling-origin race on the same 30 products, ETS won 14, ARIMA 13 and seasonal naive 3. And the forecast is not the order: on the default product the critical ratio is 43%, so the plan orders 516 units against a forecast of 736, and ordering the forecast earns about a quarter less in expectation.
How it was generalised. The tool runs the same method race on whatever series you give it (all three methods for the built-in products, computed offline; two in the browser for a pasted series), spreads the winning forecast by its own errors, and turns the experiment's fixed prices into your inputs. It adds what a buyer needs that the experiment did not have: sold-out periods treated as "at least" demand, the goodwill cost of a lost customer, and a fair grade of last period's order.