Risk Profile Filter
Returns current buy signals filtered to match a chosen risk profile (conservative vs aggressive).
// The Problem
What this recipe solves
Not every buy signal fits your risk tolerance. This script filters Guavy's recent buys by strategy and cross-checks each against sentiment so you only see signals that match your profile.
// 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.
# risk_filter.py
import os, json, sys, requests
API = "https://guavy.com/api/v1"
H = {"Authorization": f"Bearer {os.environ['GUAVY_KEY']}"}
PROFILE = "conservative" # or "aggressive"
buys = requests.get(
f"{API}/trades/get-recent-buys",
headers=H,
params={"strategy": PROFILE, "limit": 25}
).json()["trades"]
# Keep only names with net-positive sentiment
out = []
for b in buys:
s = requests.get(
f"{API}/sentiment/get-sentiment-history/{b['symbol']}",
headers=H,
params={"limit": 1}
).json()["sentiment"][0]
if s["positive"] > s["negative"]:
out.append(b)
json.dump(out, sys.stdout, indent=2)
// Guavy Tools in Play
2 tools, one script
This script calls 2 endpoints from the Guavy REST API. Every data point maps back to the endpoint it came from.
// Keep Exploring
Related recipes
Same API key, different job-to-be-done.
// Get started
Run this recipe in under 2 minutes
Grab a free API key, set it as an env var, and run the script. Free sandbox forever.