Skip to content

Risk profile filter

The crypto trade simulator's recent buys for the strategy you choose (conservative or aggressive), kept only where sentiment leans positive.

Trade signals Crypto 2 tools 78 tokens / run Python · Node.js

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.

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
# 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)

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.

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.