Skip to main content

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

Pre-Season Seed & field planning
Planting Equipment & irrigation
Growing Pest & nutrient mgmt
Harvest Scheduling & transport
Post-Harvest Storage & distribution
Market & Sales Sell timing & pricing

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]
Stochastic DP — Optimal Stopping Formulation maximize   E[Pτ · Q − ch · τ]   // expected revenue minus storage costs
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 paradigms

Try It Yourself

Find the optimal week to sell your harvest

Market Timing Optimizer

12 Weeks · 500 Tonnes
Illustrative example. A Saskatchewan cooperative holds 500 tonnes of Hard Red Spring Wheat after the September harvest. They have a 12-week selling window before storage costs erode margins. Weekly price follows a mean-reverting process around $280/tonne with moderate volatility—a textbook optimal stopping instance.

Ready. 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.

Exact

DP Backward Induction

O(T · S)  |  Optimal for discretized states

Works 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.

1
Set the value at the final week T: for every possible price level, the value equals selling revenue minus cumulative storage cost.
2
Move to week T−1. For each price level, compute the expected value of holding by averaging V(T) over all reachable prices at week T.
3
At each price level, compare immediate sell revenue against the expected continuation value. The reservation price is the threshold where these two are equal.
4
Repeat backward through all weeks. The result is a decreasing sequence of reservation prices: the farmer becomes less selective as the deadline approaches.
5
When a price path is realized, sell at the first week where the market price meets or exceeds the pre-computed threshold for that week.
Heuristic

Myopic Threshold

O(1) per decision  |  No optimality guarantee

The 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.

1
Compute the unconditional expected price from the price distribution (e.g., $280/tonne for prairie wheat).
2
Each week, observe the market price. If price is at or above the mean, sell the entire crop immediately.
3
If the deadline arrives without the price ever reaching the mean, sell at the final week’s price regardless.
Heuristic

Percentile Rule (75th)

O(1) per decision  |  Conservative threshold

A 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.

1
Compute the 75th percentile price from the distribution (e.g., ~$299/tonne for prairie wheat with 8% volatility).
2
Each week, observe the market price. If price is at or above the 75th percentile, sell the entire crop.
3
If the deadline arrives without a trigger, the farmer is forced to sell at the terminal price—which may be well below the average.

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

  • Arrow, K.J., Harris, T. & Marschak, J. (1951). “Optimal inventory policy.” Econometrica, 19(3), 250–272. DOI
  • Silver, E.A., Pyke, D.F. & Thomas, D.J. (2017). “Inventory and Production Management in Supply Chains.” 4th ed. CRC Press.
  • Hadley, G. & Whitin, T.M. (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.

Disclaimer
Data shown is illustrative. Crop names, prices, volatility parameters, and storage costs are representative scenarios for educational purposes and do not reflect any specific agricultural cooperative or commodity exchange.
Back