Large-cap sentiment flip
Lists any stock Guavy covers whose sentiment polarity flipped (positive ↔ negative dominant) since the prior reading.
// The Problem
What this recipe solves
Coverage of a large cap can turn between earnings reports, and nobody watches thirty-odd tickers by hand. This script checks every stock Guavy covers in one pass and only speaks up on a flip.
// The Script
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.
# large_cap_flip.py
import os, requests
API = "https://guavy.com/api/v2/stocks"
H = {"Authorization": f"Bearer {os.environ['GUAVY_KEY']}"}
TICKERS = "AAPL AMGN AMZN AXP BA CAT CRM CSCO CVX DIS DOW GS HD HON IBM JNJ JPM KO MCD MMM MRK MSFT NKE NVDA PG SHW TRV UNH V WMT GOOG GOOGL".split()
def dominant(row):
return max(("positive", "negative", "neutral"), key=lambda k: row.get(k, 0))
for sym in TICKERS:
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 len(rows) < 2:
continue
now, prev = rows[0], rows[1]
if dominant(now) != dominant(prev):
print(f"{sym} flipped {dominant(prev)} → {dominant(now)} "
f"(pos:{now['positive']} / neg:{now['negative']} / neu:{now['neutral']})")
// Guavy Tools in Play
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.
// Keep Exploring
Related recipes
Same API key, a different job.
// Get started
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.