Market Timing
Stochastic Dynamic Programming
Post-harvest crop price volatility costs agricultural cooperatives 8–15% of potential revenue annually through suboptimal sell timing. Every week after harvest, a sales manager must decide: sell the stored crop at today’s market price, or hold and wait for a better price—risking a decline. This is a finite-horizon optimal stopping problem solved by Stochastic Dynamic Programming, where the optimal reservation price decreases as the selling deadline approaches.
Where This Decision Fits
The agriculture sector decision chain
The Problem
When to sell under price uncertainty
You have a harvested crop in storage with a fixed selling deadline (storage capacity, spoilage, or contract expiry). Each week the market price fluctuates stochastically. The constraint is that the crop must be sold by the deadline, and once sold, the decision is final. The question is: at which week’s price should the sales manager sell to maximize expected revenue?
| Domain Concept | OR Element | |
|---|---|---|
| Harvested crop (wheat, coffee, strawberries) | Asset to be sold | |
| Weeks remaining in selling window | Time horizon T | |
| Weekly market price per tonne | Stochastic state variable | |
| “Sell now” vs. “Hold” | Action space {sell, hold} | |
| Storage cost per week | Holding cost ch | |
| Total revenue from sale | Objective: maximize E[revenue] |
where τ ∈ {1, 2, …, T} // stopping time (week to sell)
state (t, Pt) // current period and price
Bellman Vt(p) = max(p · Q − ch · t, E[Vt+1(Pt+1) | Pt=p])
boundary VT(p) = p · Q − ch · T // forced sale at deadline
The optimal policy is a threshold policy: at each period t, sell if Pt ≥ p*t, where the reservation price p*t decreases as the deadline approaches.
See full Uncertainty Modeling theory and paradigmsTry It Yourself
Find the optimal week to sell your harvest
Market Timing Optimizer
12 Weeks · 500 TonnesReady. Click “Solve & Compare All Algorithms” to run.
The Algorithms
Three approaches to optimal sell timing
The key difference
When the wheat price sits at $285/tonne in week 4 of 12—slightly above the $280 average—the Myopic Threshold sells immediately because the price exceeds the unconditional mean. The DP Backward Induction computes that with 8 weeks remaining, the expected value of continuing exceeds the immediate revenue, and holds. The Percentile Rule also holds, but for a cruder reason—$285 hasn’t crossed its fixed 75th-percentile threshold of ~$299. The DP adapts its threshold dynamically based on time remaining; the heuristics cannot.
DP Backward Induction
O(T · S) | Optimal for discretized statesWorks backwards from the deadline to compute the exact optimal reservation price at each week. At the final week, the farmer must sell at whatever price prevails. At each earlier week, the algorithm compares the immediate revenue against the expected future value—choosing to sell only when the price exceeds a computed threshold.
Myopic Threshold
O(1) per decision | No optimality guaranteeThe simplest rule: sell whenever the current price exceeds the unconditional mean of the price distribution. This ignores how much time remains and treats every week identically. It performs well when prices are symmetric and the selling window is short, but leaves money on the table when the window is long enough for large swings.
Percentile Rule (75th)
O(1) per decision | Conservative thresholdA more selective heuristic: sell only when the price reaches the 75th percentile of the historical distribution. This strategy waits for “high” prices, which can capture upside in volatile markets. However, it risks reaching the deadline without ever triggering a sale, forcing the farmer to accept whatever price prevails at expiry.
Real-World Complexity
Why agricultural market timing goes beyond the basic model
Beyond Optimal Stopping
- Partial selling — Farmers can sell portions of the crop at different times rather than all-or-nothing, transforming the problem into a multi-stage stochastic program
- Correlated commodity prices — Wheat, corn, and soybean prices move together; a comprehensive strategy must account for cross-commodity correlations and substitution effects
- Storage degradation — Grain quality degrades over time (moisture, pests); perishables like strawberries lose 3–8% of marketable weight per week, adding a non-linear cost to holding
- Forward contracts & hedging — Cooperatives can lock in prices via futures contracts, creating a hybrid strategy between spot sales and hedging that requires joint optimization
- Weather-driven supply shocks — A drought in a competing region can spike prices suddenly; the model must handle fat-tailed distributions, not just Gaussian price moves
- Transportation & logistics windows — Selling is not instantaneous—truck and rail availability constrains when grain can physically move to market, coupling the timing decision to logistics scheduling
Key References
Foundational works in stochastic inventory and optimal stopping
- (1951). “Optimal inventory policy.” Econometrica, 19(3), 250–272. DOI
- (2017). “Inventory and Production Management in Supply Chains.” 4th ed. CRC Press.
- (1963). “Analysis of Inventory Systems.” Prentice-Hall.
Need to optimize agricultural market timing?
From optimal sell timing to crop portfolio optimization and supply chain logistics, mathematical modeling can transform your agricultural operations. Let’s discuss how Operations Research can work for you.