Skip to content

Walkthrough

Nine short pages, one idea each, all built on the same small example. They cover every object in a Stockcast run and end with running the backtested policy in production.

The running example. A tea shop sells 250 g packs, about six a day. The supplier delivers 2 days after an order and the shop orders every 4 days. It opens with 30 packs on the shelf, and sales it cannot serve are lost.

Step You will learn Key objects
1. Inventory state On hand, on order, backorders, and inventory position InventoryStateDataFrame
2. Demand and time The demand table, calendars, and what one period means DemandGenerator
3. Forecast targets How a forecast becomes a stock target, and why it covers a whole window target tables
4. Policies Turning a target into an order with fit and predict OrderUpToPolicy, OrderDecision
5. The engine What happens inside one simulated day SimulationEngine
6. The event table Reading the record of every unit SimulationResult
7. Evaluate a run Service, stock, and cost metrics InventoryEvaluator
8. Compare scenarios Fair comparisons on identical demand run_comparison
9. From backtest to production Running the chosen policy every period, and why it matches the backtest plan / close with the same objects

Steps 1 to 8 build the research pipeline: simulate, evaluate, and compare. Step 9 takes the chosen policy into the production pipeline: a periodic job on live stock and fresh forecasts.

The code blocks run as they are, in order, and reproduce the numbers shown.

Prefer notebooks?

Notebook 01 and Notebook 02 cover the same ground with more plots. The examples go much further.

Start with step 1