Research

Commodity Trading with Weather Data

Weather-integrated algorithmic trading strategy for coffee markets — backtested Sep 2023 – Aug 2024

Personal

5 technologies
2 key decisions
4 results

Problem

Problem

Commodity prices for agricultural goods like coffee are significantly affected by weather events in key growing regions. Standard technical analysis ignores this signal entirely. The hypothesis: integrating weather anomaly indicators from Brazil (the world's largest coffee producer) with traditional technical signals produces better-timed trade entries and exits than technical analysis alone.

Approach

Approach

Weather data from Visual Crossing (hourly, aggregated to daily) was aligned with historical coffee price data. Feature engineering produced frost event indicators (< 0°C), drought conditions (rainfall < 10mm/7d), extreme rainfall (> 20mm), and 7-day rolling averages for temperature, humidity, and wind speed. These were combined with technical indicators (Bollinger Bands, MACD, RSI, ATR, VWAP, Keltner Channels, CCI). Three strategies were backtested and compared: pure technical, weather-integrated signal selection, and weather-based position sizing.

Architecture

Architecture

Commodity Trading with Weather Data — system diagram

Visual Crossing (B…Coffee Price DataFeature EngineeringTechnical Indicato…Weather Indicators…Backtesting EngineReturn / Sharpe / …

Key Technical Decisions

Key Technical Decisions

Assembly Instructions — 2 Steps
01

Focus on Brazil weather specifically

Brazil produces ~35% of world coffee supply. Frost events in Minas Gerais historically cause supply shocks that spike futures prices within days. Limiting weather signals to the primary production region produced more signal-to-noise than aggregating global weather.

02

Three distinct strategy variants

Testing a pure technical baseline against weather-integrated signal selection and weather-based position sizing allows isolation of the weather signal's contribution. The comparison showed weather integration improved timing precision rather than return magnitude.

Results

Results

  • Weather-integrated strategies outperformed pure technical analysis on timing precision
  • Frost and drought indicators provided leading signals ahead of supply-shock price moves
  • Backtested across Sep 2023 – Aug 2024 with leverage, stop-loss, and take-profit mechanics
  • Seasonal trend analysis confirmed cyclical patterns in Brazilian growing regions

Tech Stack

Tech Stack

PythonPandasScikit-learnJupyterVisual Crossing API

Links