Simulating agricultural contract markets with agent-based modeling to test whether precision agriculture data changes price formation, wealth distribution, and market efficiency.
Agricultural markets have always operated under uncertainty. A farmer planting tomatoes in March doesn't know what the weather will be in July, what diseases might strike, or what the spot price will be at harvest. An investor prepaying for a share of that harvest faces the same fog β plus not knowing what other investors are doing.
Precision agriculture technologies β soil sensors, satellite imagery, drone-based crop monitoring β are generating unprecedented data about what's actually happening on farms. The question is:
We built an agent-based simulation to find out. The answer turns out to be surprising: knowing what the market thinks matters more than knowing what the crops are doing.
The simulation models a market where investors prepay for fractions of a farm's future produce β like agricultural futures, or community-supported agriculture (CSA) shares:
One simulation step equals one week. A typical run covers 2 growing seasons (65+ weeks). Weather drives crop growth, crop growth drives expected yields, yields drive contract valuations, valuations drive bidding, bidding drives prices. Everything is connected.
The central experiment varies how much information agents have:
| Tier | What the Agent Knows | Real-World Analogue |
|---|---|---|
| π Blind | Only the current ask price | Farmer's market β you see the price tag, nothing else |
| π Local | Own past trade prices | Experienced buyer who remembers what they paid before |
| π Market | Rolling-average public price index | Commodity exchange with published market data |
| π Full | Market index + competitor count | Trading floor where you can see other bidders |
| π°οΈ Precision | Full + real-time crop growth, disease, irrigation data | Precision ag: sensors, drones, satellite imagery |
Biomass follows a logistic curve driven by Growing Degree Days:
B(t) = B_max / (1 + exp(-k Γ (GDD(t) - GDD_mid)))
Where:
GDD accumulates weekly as max(0, T_avg - T_base) Γ 7
Yield = Biomass Γ Harvest_Index Γ Stress_Multiplier
Stress = (1-water_stressΓ0.6) Γ (1-temp_stressΓ0.5) Γ (1-diseaseΓ0.4)
T(week) = T_mean + T_amp Γ sin(2Ο(week - Ο)/52) + N(0, Ο)
Rain ~ Gamma(shape, scale Γ seasonal_factor)
Climate modes: normal, El NiΓ±o (+1.5Β°C, -30% rain), La NiΓ±a (-1Β°C, +30% rain)
dP = ΞΈ(ΞΌ - P)dt + ΟdW (mean-reverting commodity prices)
W(t) = W_max Γ exp(-b Γ exp(-c Γ t)) (asymptotic weight gain)
| Crop | Base Temp | GDD to Maturity | Max Yield | Price |
|---|---|---|---|---|
| π Tomato | 10Β°C | 1,200 | 36 t/ha | $800/t |
| π½ Maize | 10Β°C | 1,400 | 12.5 t/ha | $250/t |
| π« Cocoa | 15Β°C | 2,400 | 1.2 t/ha | $3,200/t |
| πΎ Wheat | 4Β°C | 1,800 | 6.8 t/ha | $300/t |
| β Coffee | 14Β°C | 2,200 | 1.25 t/ha | $4,500/t |
| Behavior | Max LTV | Approval Threshold | Rate Premium |
|---|---|---|---|
| Conservative | 50% | High (0.6) | -1% (lower rates) |
| Moderate | 70% | Medium (0.4) | 0% (baseline) |
| Aggressive | 90% | Low (0.2) | +2% (higher rates) |
Banks evaluate loans using a credit score derived from the borrower's capital, utilization rate, and repayment history. They also adjust rates based on what competing banks are offering.
We ran 50 Monte Carlo simulations per information tier, holding all other parameters constant. Here are the key findings:
Our results suggest a clear hierarchy of information value:
Market consensus (public price index)
> Competitor awareness (who else is bidding)
> Farm-level telemetry (precision ag data)
> Personal history (can be harmful!)
| Metric | Blind | Market | Full | Precision |
|---|---|---|---|---|
| Gini (holdings) | 0.81 | 0.73 | 0.75 | 0.78 |
| Contested trades | 8.4 | 19.8 | 17.4 | 12.9 |
| Price volatility ($) | 972 | 1,459 | 1,114 | 1,639 |
| Investor ROI | 0.0% | -0.0% | -1.0% | 0.0% |
The simulation features an interactive step-through mode where you can scrub through every week and observe the causal chain:
You can use the β Back and Fwd βΆ buttons, or drag the week slider, to move through time and watch how:
If the goal is market fairness and efficiency, investing in public market transparency infrastructure (real-time price indices, open contract databases) may be more impactful than subsidizing private farm-level monitoring technology. A simple published average price does more for Gini reduction than sophisticated crop sensors.
Market platforms should prominently display public price indices rather than letting participants' interfaces show only their personal transaction history. The "local" tier's poor performance shows that personal anchoring actively harms market efficiency.
More information doesn't necessarily mean more profit. The "full" information tier (market + competitors) produced the most competitive environment and the lowest individual returns. Information is an arms race β when everyone has it, the edge disappears.
When markets are more transparent (market/full tiers), contract prices are more competitive β good for farmers who receive higher bids. But it also means more investors participating, which can create auction pressure and volatile bidding patterns.
The full simulation is available as an interactive Streamlit app:
# Clone and run locally
git clone https://huggingface.co/spaces/rdjarbeng/agrimarket-abm
cd agrimarket-abm
pip install mesa networkx pandas numpy streamlit plotly scipy
streamlit run app.py
from metrics import run_monte_carlo, compute_effect_sizes
df = run_monte_carlo(
info_levels=("blind", "local", "market", "full", "precision"),
n_runs=50,
num_investors=20,
num_farmers=2,
num_banks=2,
season_length_weeks=30,
num_seasons=2,
)
effects = compute_effect_sizes(df, baseline_tier="blind")
for tier, metrics in effects.items():
sig = [m for m, d in metrics.items() if d["significant"]]
print(f"{tier}: significant effects on {sig}")
crop_models.py β CropGrowthState, LivestockGrowthState, WeatherEngine, SpotPriceEngine
agents.py β Plot, Farmer, Investor, Bank, PriceManager
model.py β AgriMarketModel (Mesa 3.5 ABM orchestrator)
metrics.py β compute_run_metrics, run_monte_carlo, compute_effect_sizes
app.py β Streamlit dashboard with step-through playback
Built with Mesa 3.5 (agent-based modeling), Streamlit (dashboard), Plotly (visualization), and Python 3.12.