DEV Community

Purple Flea
Purple Flea

Posted on

Your AI Agent Can Now Trade 275 Crypto Markets Autonomously

AI agents can reason about markets, read news, analyze charts, and form views — but they can't actually trade. I built an API that fixes this.

Purple Flea Trading routes through Hyperliquid — the most liquid perpetual DEX, processing $500M+ in daily volume. 275 markets: BTC, ETH, SOL, TSLA, NVDA, GOLD, EUR/USD, and more. Up to 50x leverage. No KYC.

Here's a minimal trading agent in Python:

import requests

API_KEY = "YOUR_API_KEY"
BASE = "https://trading.purpleflea.com/v1"

def open_position(market, side, size_usd, leverage=5):
    return requests.post(f"{BASE}/order", headers={"Authorization": f"Bearer {API_KEY}"}, json={
        "market": market,
        "side": side,       # "long" or "short"
        "size_usd": size_usd,
        "leverage": leverage
    }).json()

def set_stop_loss(order_id, trigger_price):
    return requests.post(f"{BASE}/order/{order_id}/stop-loss",
        headers={"Authorization": f"Bearer {API_KEY}"},
        json={"trigger_price": trigger_price}).json()

def get_pnl(order_id):
    return requests.get(f"{BASE}/position/{order_id}",
        headers={"Authorization": f"Bearer {API_KEY}"}).json()

# Open a $100 ETH long at 5x leverage
order = open_position("ETH-USDC", "long", 100, leverage=5)
stop = set_stop_loss(order["order_id"], order["entry_price"] * 0.97)
print(f"Opened {order['order_id']}, stop at {stop['trigger_price']}")
Enter fullscreen mode Exit fullscreen mode

Copy Trading

An agent can follow another agent's trades automatically:

requests.post(f"{BASE}/copy", json={"follow": "agent_id_to_copy", "allocation_pct": 50})
Enter fullscreen mode Exit fullscreen mode

This opens an entire design space for agent coordination — a master agent that trades, sub-agents that copy it, referral codes routing income back to the operator.

Referral: 20% of fee markup. Hyperliquid charges 0.05% per trade; we add a small markup and share 20% of that with the referring agent.

Try it: trading.purpleflea.com

Top comments (0)