Perpetuals

Perpetual Futures Trading API
for AI Agents

275 markets. Up to 50x leverage. No expiry dates. 0.02% maker fee. Perpetual futures are the most powerful instrument for AI agents โ€” and Purple Flea gives you full programmatic access to everything Hyperliquid has to offer.

Get API Key โ†’ Start Trading

What Are Perpetual Futures?

Perpetual futures are derivative contracts that track the price of an underlying asset โ€” similar to traditional futures โ€” but with a critical difference: they never expire. You can hold a position indefinitely, which makes them ideal for algorithmic strategies that don't want to worry about contract rollovers.

The mechanism that keeps perpetual prices anchored to spot is the funding rate. Every 8 hours, longs pay shorts (or vice versa) depending on whether the perpetual is trading above or below the spot price. When funding is positive, longs pay shorts; when negative, shorts pay longs. This incentive keeps the perpetual price close to spot.

For AI agents, perpetuals are the preferred instrument because they support both long and short positions with equal ease, offer leverage to amplify returns without requiring spot holdings, and trade 24/7 without market close complications. Purple Flea's API routes orders through Hyperliquid, one of the deepest on-chain perpetuals venues with consistently tight spreads.

With 275 available markets spanning everything from BTC and ETH to emerging DeFi tokens and Layer 2 assets, there is always something for your agent to trade โ€” regardless of broader market conditions.

Complete Python Example

Everything your agent needs to check market conditions, open a leveraged position, and monitor it in real time:

import purpleflea
trader = purpleflea.TradingClient(api_key="YOUR_KEY")

# Get market info
info = trader.get_market_info("BTC-PERP")
print(f"Mark price: ${info['mark_price']:,.2f}")
print(f"Funding rate: {info['funding_rate_pct']:.4f}%/8h")
print(f"Open interest: ${info['open_interest_usd']:,.0f}")

# Open leveraged long
order = trader.place_order(
    market="BTC-PERP",
    side="buy",
    size=0.01, # 0.01 BTC
    order_type="market",
    leverage=5 # 5x leverage
)

# Get position details
pos = trader.get_position("BTC-PERP")
print(f"Entry: ${pos['entry_price']:,.2f}")
print(f"Liquidation price: ${pos['liquidation_price']:,.2f}")
print(f"Unrealized PnL: ${pos['unrealized_pnl']:+,.2f}")

275 Markets Across All Categories

Trade anything from Bitcoin to niche DeFi tokens โ€” all through the same unified API.

๐Ÿฅ‡
Major Cryptocurrencies
  • BTC-PERP โ€” Bitcoin
  • ETH-PERP โ€” Ethereum
  • SOL-PERP โ€” Solana
  • BNB-PERP โ€” BNB
  • XRP-PERP โ€” Ripple
10 markets
๐Ÿช™
Altcoins
  • AVAX, DOGE, MATIC
  • DOT, LINK, ADA
  • ATOM, NEAR, ICP
  • FIL, GRT, SAND
  • 200+ more markets
200+ markets
๐Ÿ›๏ธ
DeFi Tokens
  • UNI-PERP โ€” Uniswap
  • AAVE-PERP โ€” Aave
  • CRV-PERP โ€” Curve
  • MKR-PERP โ€” Maker
  • COMP, SNX, BAL
35 markets
โšก
Layer 2 Tokens
  • ARB-PERP โ€” Arbitrum
  • OP-PERP โ€” Optimism
  • MATIC-PERP โ€” Polygon
  • STRK-PERP โ€” Starknet
  • ZK, IMX, LRC
20 markets

Fee Structure

Fees compound over thousands of trades. The difference between 0.02% and 0.05% maker fee is massive at scale. Purple Flea routes through Hyperliquid, which offers industry-leading fee rates:

Order Type Fee Notes
Maker (limit orders) 0.02% Use post_only=True to guarantee maker fills
Taker (market orders) 0.05% Use for fast execution when needed
Funding rate Variable Every 8h, based on perp vs spot premium
API key Free No monthly fee, pay only on trades
Referral (incoming) 20% You earn 20% of fees from agents you refer

Fee impact at scale: An agent trading $10,000/day with 100% maker orders pays $2/day in fees at 0.02%. The same agent using taker orders (0.05%) pays $5/day. Over a year, that's $730 in additional costs โ€” without any change to the strategy. Default to limit orders wherever possible.

Why Perpetuals Are Ideal for AI Agents

No Expiry Complications

Traditional futures require rolling positions before expiry โ€” managing the rollover timing, spread costs, and position continuity. Perpetuals eliminate all of this. Your agent can hold positions indefinitely without any maintenance logic for expiry.

Long and Short with Equal Ease

Spot trading forces you to hold assets to go long, and requires borrowing to short. Perpetuals let your agent go long or short with identical API calls โ€” just change "buy" to "sell". This is critical for market-neutral and mean reversion strategies.

Leverage Without Capital Lock-up

With 5โ€“10x leverage, your agent can control $5,000โ€“$10,000 in notional exposure with $1,000 in margin. This capital efficiency allows smaller agents to participate in markets they otherwise couldn't access meaningfully.

Funding Rate as Signal

The funding rate provides a real-time, crowd-sourced signal about market positioning. Extreme positive funding signals overcrowded longs (bearish contrarian signal). Extreme negative funding signals overcrowded shorts (bullish contrarian signal). No other market offers this data so cleanly.

275
Perpetual markets available
50x
Maximum leverage on major markets
0.02%
Maker fee โ€” best in class
$5B+
Daily volume on Hyperliquid
24/7
No market close, ever
20%
Referral commission on all fees
Ready to Build

Start Trading Perpetuals
with Your AI Agent

Get your API key, access 275 markets, and deploy your first agent strategy. New agents receive $1 USDC free from the faucet.

Get API Key โ†’ Backtest Strategy โ†’

Related Pages

Trading API โ†’ Hyperliquid API โ†’ Momentum Strategy โ†’ Grid Trading โ†’ Backtesting API โ†’ Perps Explained โ†’