Skip to main content

Why This Matters

Building a traditional investing product on-chain means integrating with perp DEXes, handling EIP-712 signing flows, managing deposits and withdrawals across bridges, and tracking positions with funding rates. We’ve done that - you get one API that covers everything to get your trading product live in days.

What It Does

Let users trade stocks (AAPL, TSLA, NVDA, etc.), commodities (GOLD, OIL, NATGAS), and forex pairs (EUR, GBP, JPY) as perpetual futures. Build products that offer leveraged exposure to traditional markets, portfolio diversification beyond crypto, or automated trading strategies - all through a single API. You call our API, we return EIP-712 typed data. Your users sign off-chain (no gas needed for trades). Users trade traditional assets on-chain, you capture fees. How it works: Tokenised Stocks runs on Hyperliquid’s builder-deployed perpetual futures DEX. Users deposit USDC on Arbitrum, which bridges to Hyperliquid where they can trade perps tracking real-world asset prices.

Supported Assets

Assets are organised into three categories:
CategoryExamples
StocksAAPL, TSLA, NVDA, AMZN, GOOGL, META, MSFT, and more
CommoditiesGOLD, SILVER, OIL, NATGAS, COPPER, URANIUM, CORN
ForexEUR, GBP, JPY, AUD, CAD, CHF, CNH
Use the /v2/traditional_investing/opportunities endpoint to get the full live list with open interest, 24h volume, funding rates, and max leverage for each market.

Getting Started

1. Deposit USDC

Users deposit USDC from Arbitrum into their Hyperliquid trading account. The deposit uses an EIP-2612 permit (gasless for the user) and is bridged by a gas sponsor. Request:
  • sender - The user’s wallet address on Arbitrum
  • amount - Amount of USDC to deposit (e.g. “100”)
Response:
  • typed_data - EIP-712 typed data for the user to sign (a USDC permit)
  • After signing, call /deposit/execute with the signature to trigger the sponsored bridge deposit

2. One-Time Setup

Before placing the first trade, two one-time actions are needed: Enable Unified Account - Call /v2/traditional_investing/enable_unified_account to check and enable unified margin mode. If already enabled, returns null typed data (no action needed). Approve Builder Fee - Call /v2/traditional_investing/approve_builder_fee to authorise the 1 basis point builder fee. Sign the returned EIP-712 data and submit via /execute.

3. Place Orders

Market Order:
import httpx

# Prepare a market order to buy 1 AAPL perp
response = httpx.post(
    "https://api.compasslabs.ai/v2/traditional_investing/market_order",
    json={
        "sender": "0xYourWalletAddress",
        "asset": "AAPL",
        "is_buy": True,
        "size": "1",
    },
    headers={"x-api-key": "YOUR_API_KEY"},
)
order = response.json()

# order["typed_data"] contains EIP-712 data for the user to sign
# After signing, submit via /execute endpoint
Limit Order: Call /v2/traditional_investing/limit_order with a price parameter and optional time_in_force (GTC or ALO). Same sign-and-execute flow. Cancel Order: Call /v2/traditional_investing/cancel_order with the order ID to cancel an open limit order.

4. Execute Signed Actions

All prepare endpoints (market_order, limit_order, cancel_order, withdraw, approve_builder_fee) return EIP-712 typed data. After the user signs, submit the signature to the execute endpoint:
response = httpx.post(
    "https://api.compasslabs.ai/v2/traditional_investing/execute",
    json={
        "sender": "0xYourWalletAddress",
        "typed_data": order["typed_data"],
        "signature": "0xUserSignature...",
    },
    headers={"x-api-key": "YOUR_API_KEY"},
)
result = response.json()

5. Track Positions

Call /v2/traditional_investing/positions to get open positions with size, entry price, mark price, PnL, liquidation price, leverage, and cumulative funding.
response = httpx.get(
    "https://api.compasslabs.ai/v2/traditional_investing/positions",
    params={"sender": "0xYourWalletAddress"},
    headers={"x-api-key": "YOUR_API_KEY"},
)
positions = response.json()

for pos in positions["positions"]:
    print(f"{pos['asset']}: {pos['size']} @ {pos['entry_price']} (PnL: {pos['pnl']})")

Key Concepts

Perpetual Futures - These are not spot tokens. Users trade perps that track real-world asset prices. Positions accrue funding rates and can be leveraged. EIP-712 Signing - Unlike Earn or Credit which return unsigned Ethereum transactions, Tokenised Stocks returns EIP-712 typed data for Hyperliquid’s off-chain order system. Users sign off-chain and submit signatures - no gas is needed for trades. Prepare + Execute Flow - Every action follows a two-step flow: (1) call a prepare endpoint to get EIP-712 typed data, (2) user signs, (3) call /execute with the signature. USDC on Arbitrum - Deposits and withdrawals use USDC on Arbitrum, bridged to/from Hyperliquid.

Use Cases

Brokerage App: Build a stock trading app where users buy and sell tokenised stocks with crypto. Show familiar stock tickers, price charts, and portfolio views while executing trades on-chain. Example: User deposits 1,000 USDC, buys 2 AAPL perps at 200 each. AAPL rises 5%, user’s position is worth 1,020. Close position for 20 profit. Diversification Tool: Let crypto-native users diversify into traditional assets without leaving the on-chain ecosystem. Offer one-click allocation across stocks, gold, and forex. Example: User allocates 10,000 USDC — 40% NVDA, 30% GOLD, 30% EUR — all as perps with a single deposit from their existing Arbitrum wallet. Automated Trading: Build bots that execute strategies across traditional markets on-chain. Arbitrage between crypto and traditional asset perps, or run momentum strategies on stock perps.

Next Steps

Variable Earn

Earn yield on idle USDC while not trading.

Credit

Borrow against crypto holdings for more trading capital.

Bridging

Move assets across chains to fund your trading account.