Python tool that analyzes WTI Crude Oil and Henry Hub Natural Gas prices to tell procurement teams whether to lock in prices now or wait — powered by real FRED economic data.
Energy costs are one of the biggest variables in procurement budgets for manufacturers, airlines, logistics firms, and utilities. Buying too early locks in high prices. Waiting too long means prices spike before you act.
This engine answers one question: should you lock in today or wait?
It pulls 25 years of real oil and gas price data, computes where today's price sits historically, analyzes momentum, and outputs a BUY / WAIT / WATCH recommendation with a confidence score and plain-English reasoning.
Key outputs:
- 🟢 BUY — price is historically low and/or rising fast. Lock in now.
- 🔴 WAIT — price is historically high and/or trending down. Hold off.
- 🟡 WATCH — mixed signals. Monitor closely before committing.
============================================================
ENERGY PROCUREMENT DECISION ENGINE
April 28, 2026
============================================================
WTI CRUDE OIL
Current Price : $72.14
1yr Percentile : 38.2th
30d Momentum : +4.1%
Decision : BUY
Confidence : 70%
Reason : 🟢 LOCK IN — price is in the 38th percentile vs
last year (historically cheap); 30-day momentum
+4.1% (rising fast — lock in before higher);
also cheap vs 3-year history (29th pct).
HENRY HUB NATURAL GAS
Current Price : $2.43
1yr Percentile : 91.8th
30d Momentum : -0.4%
Decision : WAIT
Confidence : 85%
Reason : 🔴 HOLD OFF — price is in the 92nd percentile vs
last year (historically expensive); momentum flat.
============================================================
Pulls daily price data from the FRED API (Federal Reserve Economic Data):
DCOILWTICO— WTI Crude Oil spot price ($/barrel)DHHNGSP— Henry Hub Natural Gas spot price ($/MMBtu)
For each commodity, computes:
- 30, 90, and 365-day moving averages
- 30 and 90-day rolling volatility
- 30 and 90-day price momentum
- 1-year and 3-year historical percentile — where does today's price rank vs history?
Each factor contributes to a score:
| Signal | Score |
|---|---|
| Price in bottom 25th percentile (1yr) | +3 |
| Price in bottom 25th percentile (3yr) | +2 |
| Strong upward momentum (>5%) | +2 |
| Price in top 75th percentile (1yr) | -3 |
| Price in top 75th percentile (3yr) | -2 |
| High volatility (reduces risk of waiting) | +1 |
Score ≥ 3 → BUY | Score ≤ -2 → WAIT | Otherwise → WATCH
Generates a visual showing:
- 5-year price history with 90-day moving average
- 1-year percentile chart with buy/wait zones highlighted
- Recommendation box with price, decision, confidence, and reasoning
1. Install dependencies
pip install -r requirements.txt2. Get a free FRED API key
- Go to fred.stlouisfed.org
- Create a free account → My Account → API Keys → Request API Key
3. Add your API key
# In energy_procurement_engine.py
FRED_API_KEY = 'your_key_here'
USE_LIVE_API = True4. Run it
python energy_procurement_engine.pyenergy-procurement-engine/
│
├── README.md
├── requirements.txt
├── energy_procurement_engine.py # Main engine
└── energy_dashboard.png # Sample output dashboard
| Tool | Purpose |
|---|---|
| Python | Core language |
| pandas + numpy | Data manipulation and feature engineering |
| FRED API | Real economic price data |
| matplotlib | Dashboard visualization |
| scipy.stats | Percentile calculations |
Concepts demonstrated:
- Time series feature engineering (rolling stats, momentum, percentiles)
- Rule-based scoring model for procurement decisions
- Real API data integration (FRED)
- Multi-panel data visualization with custom dark theme
- Manufacturers — lock in steel, aluminum, or fuel costs at optimal times
- Airlines — jet fuel procurement timing
- Logistics firms — diesel cost hedging decisions
- Energy utilities — natural gas supply contract timing
Built as part of a data science portfolio focused on finance and procurement analytics. Uses FRED public data — no proprietary data involved.
