Skip to content

Commodity sentiment board

A one-line-per-commodity board: today's dominant sentiment polarity and its shift from the prior reading, across energy, metals, and ag.

Inform Commodities 1 tool 21 tokens / run Python · Node.js

What this recipe solves

Getting a single-glance read on how the whole commodity complex feels means checking each market one by one. This script prints the entire board in one pass, ready for a morning Slack post.

Copy, run, ship

Drop this script into your project and run it locally or on a cron. Set GUAVY_KEY in your environment, swap the symbols, and go.

Python
# commodity_board.py
import os, requests

API     = "https://guavy.com/api/v2/commodities"
H       = {"Authorization": f"Bearer {os.environ['GUAVY_KEY']}"}
SYMBOLS = ["Oil", "Gold", "Silver", "Copper", "NaturalGas", "Wheat", "Corn"]

def dominant(row):
    return max(("positive", "negative", "neutral"), key=lambda k: row.get(k, 0))

for sym in SYMBOLS:
    rows = requests.get(
        f"{API}/sentiment/get-sentiment-history/{sym}",
        headers=H, params={"limit": 2}
    ).json()["sentiment"]
    rows.sort(key=lambda r: r["timestamp"], reverse=True)
    if not rows:
        continue
    now = rows[0]
    shift = dominant(rows[1]) + " → " if len(rows) > 1 and dominant(rows[1]) != dominant(now) else ""
    print(f"{sym:12} {shift}{dominant(now)}  (pos:{now['positive']} / neg:{now['negative']})")

1 tool, one script

This script calls 1 endpoint from the Guavy REST API. Every data point maps back to the endpoint it came from.

What the script prints

Output from a real run of this script.

commodity-sentiment-board.out REST
Oil          negative → positive  (pos:1 / neg:1)
Gold         negative → positive  (pos:19 / neg:19)
Silver       positive → negative  (pos:2 / neg:8)
Copper       positive → negative  (pos:0 / neg:1)
NaturalGas   positive → negative  (pos:8 / neg:9)
Wheat        positive  (pos:19 / neg:18)
Corn         negative → positive  (pos:19 / neg:13)

Run this recipe on the free plan

Grab a free API key, set it as an env var, and run the script. Free sandbox forever.