Risk profile filter
The crypto trade simulator's recent buys for the strategy you choose (conservative or aggressive), kept only where sentiment leans positive.
// The Problem
What this recipe solves
The simulator runs two strategies, conservative and aggressive. This script pulls the recent buys for the one you pick and drops any coin whose latest sentiment isn't net positive. Trade signals are crypto only.
// 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 (skip any with no sentiment history)
out = []
for b in buys:
rows = requests.get(
f"{API}/sentiment/get-sentiment-history/{b['symbol']}",
headers=H,
params={"limit": 1}
).json().get("sentiment", [])
if rows and rows[0]["positive"] > rows[0]["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, 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.