Set Up Finlet

Everything you need to connect your AI agent to Finlet and run your first simulated trade.

Prefer your terminal? Run finlet manual quickstart for the binary-portable, agent-readable version of these six steps. The CLI manual is the source of truth — this page mirrors it.

What is Finlet?

Finlet is an agentic trading evaluation harness for testing AI trading strategies in simulated markets with real historical data. Your agent replays any historical market period, seeing only data available at that point in time — prices, news, and fundamentals. No look-ahead bias, no real money at risk.

Connect via the finlet CLI, MCP (Model Context Protocol), or the REST API directly. Every call and decision is logged in a full reasoning trace for post-hoc analysis.

Paper trading only Real historical data No credit card required Free tier available

Getting Started with Finlet

Follow these six steps to go from zero to your first simulated trade. The main flow uses the finlet CLI — the fastest path from install to trade. Each step has an optional Raw REST API section you can expand if you prefer curl or are building your own HTTP client.

Install the Finlet CLI

Open your terminal and install Finlet using pip (Python's package manager). You need Python 3.12 or newer. The default install ships everything the CLI and MCP client need to talk to the hosted Finlet service at https://finlet.dev.

Terminal
pip install finlet
Don't have Python? Download it from python.org. On macOS you can also use brew install python.
Prefer no install? Use the REST API directly

Finlet's REST API works with any HTTP client — no Python install required. Start by verifying the API is reachable:

cURL
curl https://finlet.dev/v1/health

Expected response: {"status": "ok"}

Self-host (optional)

Most users don't need this — the cloud at finlet.dev hosts everything. Self-hosted operators who want to run their own API server can install the server extra, which pulls the additional FastAPI / database stack:

Terminal
pip install 'finlet[server]'

Create your account

Register a free account — no credit card required. The fastest way is to sign up through the website. Once signed in, create an API key from the dashboard or use the REST API below to register and receive your key in one step.

Register via the REST API instead

If you'd rather register programmatically, POST to the auth endpoint:

cURL
curl -X POST https://finlet.dev/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com", "password": "your-password"}'

Response includes your API key: {"api_key": "your_api_key_here"}.

Save your API key (or sign in with OAuth)

Recommended (interactive — OAuth Bearer): run finlet auth login once. The CLI opens your browser, walks you through the OAuth approval flow, and writes the Bearer JWT to ~/.finlet/credentials (mode 0600). Every subsequent CLI command and MCP dispatch picks it up automatically — no env-var management required.

Terminal
finlet auth login
Why OAuth first? The MCP-over-HTTP transport at https://finlet.dev/mcp requires Authorization: Bearer <jwt> — the api_key form is not accepted on that surface. OAuth is the canonical credential path; api_key remains supported on REST and on the finlet mcp serve stdio bridge as a CI / headless fallback.
CI / headless fallback — export FINLET_API_KEY instead

If you can't run finlet auth login (CI workers, eval rigs, anything without a browser), export your api_key as an environment variable. The REST API accepts it on every route, and the finlet mcp serve stdio bridge translates it to OAuth Bearer internally before dispatching to the hosted service.

Terminal
export FINLET_API_KEY=your_api_key_here

Treat your api_key like a password. Add the export line to your shell profile (~/.zshrc, ~/.bashrc) so it persists across sessions. See finlet manual auth-model for the full credential reference.

Create a simulation session

A session is a simulation environment. You pick a start date, starting capital, and which stocks to trade. The simulation replays that market period so your agent can make decisions based on real historical data.

Terminal
finlet session create --name "my-first-sim" --start 2024-01-01 --capital 100000 --universe "AAPL,GOOGL,MSFT"
What this means: Start with $100,000 virtual dollars on January 1, 2024, trading Apple (AAPL), Google (GOOGL), and Microsoft (MSFT). The response includes the session_id you'll use for all subsequent calls.
Create a session via the REST API instead
cURL
curl -X POST https://finlet.dev/v1/sessions \
  -H "Authorization: Bearer $FINLET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "my-first-sim", "start_time": "2024-01-01", "initial_capital": 100000, "universe": ["AAPL", "GOOGL", "MSFT"]}'

Returns the same session_id as the CLI command.

Submit a trade via the REST API

Once you have a session_id (exported as $SESSION_ID), submit a market buy order:

cURL
# Submit a market buy order against a session
curl -X POST https://finlet.dev/v1/sessions/$SESSION_ID/trade/order \
    -H "Authorization: Bearer $API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"ticker":"AAPL","side":"BUY","quantity":1,"order_type":"MARKET"}'

From the CLI: finlet order --session $SID --ticker AAPL --side BUY --quantity 1.

Connect your AI agent

Hosted MCP-over-HTTP (recommended). Point your agent at https://finlet.dev/mcp with the OAuth Bearer from Step 3. No local process to run, no install beyond your agent itself.

JSON
{
  "mcpServers": {
    "finlet": {
      "url": "https://finlet.dev/mcp",
      "transport": "http",
      "headers": {
        "Authorization": "Bearer $FINLET_OAUTH_BEARER"
      }
    }
  }
}

Local stdio bridge (fallback). If your client doesn't speak HTTP transports yet, use finlet mcp serve over stdio. FINLET_OAUTH_BEARER is primary; FINLET_API_KEY is the CI / headless fallback.

JSON
{
  "mcpServers": {
    "finlet": {
      "command": "finlet",
      "args": ["mcp", "serve"],
      "env": {
        "FINLET_OAUTH_BEARER": "your_jwt_here"
      }
    }
  }
}
Per-client configs: The Connect Your AI Agent page covers Claude Desktop, Claude Code, Cursor, Codex, Windsurf, VS Code, generic MCP clients, and REST — including the api_key (CI / headless) fallback per tab. See also finlet manual client-matrix for the same matrix in your terminal.
CI / headless variant — FINLET_API_KEY in stdio env

Use this when the host can't run finlet auth login (CI workers, eval rigs). The stdio bridge translates the api_key to OAuth internally; the agent still sees the same tools and the same data. The MCP HTTP surface at /mcp does not accept the api_key form — stdio is the only path that does.

JSON
{
  "mcpServers": {
    "finlet": {
      "command": "finlet",
      "args": ["mcp", "serve"],
      "env": {
        "FINLET_API_KEY": "your_api_key_here"
      }
    }
  }
}
Available MCP tools

Once connected, your agent can call any of these MCP tools:

  • create_session Create a new simulation session
  • get_price_data Historical OHLCV price data
  • submit_order Submit buy/sell orders
  • advance_time Advance the simulation clock
  • get_portfolio Current portfolio state
  • get_trace Full reasoning trace
  • search_news Search news articles
  • get_fundamentals Company fundamentals

Run your first trade

Your agent can now get market data, submit orders, and check portfolio state. Here's an example trading flow using the REST API — replace {session_id} with the ID returned in Step 4.

cURL
# Get current price for AAPL
curl "https://finlet.dev/v1/sessions/{session_id}/market/price?ticker=AAPL" \
  -H "Authorization: Bearer $FINLET_API_KEY"

# Buy 10 shares of AAPL
curl -X POST "https://finlet.dev/v1/sessions/{session_id}/trade/order" \
  -H "Authorization: Bearer $FINLET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ticker": "AAPL", "side": "buy", "quantity": 10}'

# Check your portfolio
curl "https://finlet.dev/v1/sessions/{session_id}/portfolio" \
  -H "Authorization: Bearer $FINLET_API_KEY"
You're set up! Your agent can now trade in simulated markets using real historical data. Explore the MCP tools in Step 5 to build your strategy with news search, fundamentals, and time-advance controls.
Expected responses and error handling

Price endpoint returns OHLCV data filtered to the session's current simulation time — no future data leaks through the date ceiling enforcer.

Order endpoint returns the filled order with execution price and timestamp. Orders submitted outside market hours queue as PENDING until the next trading session. Insufficient cash returns 400 with a specific actionable message (e.g., "Insufficient cash: need $18,450.00, have $12,000.00").

Portfolio endpoint returns cash, positions (with average entry price and current market value), and aggregate P&L.

Rate limits are reported in response headers. If you exceed them, you'll get a 429 with exact reset time — for example: "Finnhub rate limit exceeded: 0/60 calls remaining, resets in 42 seconds".