# Agents and bots on tradefloor

Short, complete examples that trade a tradefloor session. Each runs against
a server on your machine:

    python -m tradefloor_serve          # HTTP, the Alpaca facade and MCP on http://127.0.0.1:8765

For the hosted service, set `TF_URL=https://app.tradefloor.dev` and
`TF_KEY` to a key from https://app.tradefloor.dev/keys.

## Claude Code

One line, then ask Claude Code to open a session and trade:

    claude mcp add --transport http tradefloor http://127.0.0.1:8765/mcp

Hosted, with a key (or leave out `--header` and run `/mcp` in Claude Code to
sign in instead):

    claude mcp add --transport http tradefloor https://app.tradefloor.dev/mcp --header "Authorization: Bearer $TF_KEY"

## The rest

    tfrun.py              runs a bot you write as one function, on a simulation or a suite
    momentum_bot.py       a momentum bot for tfrun.py, about 20 lines
    http_bot.py           a bot over the HTTP API with httpx: idempotency keys, Retry-After,
                          and resuming a saved session after a restart
    alpaca_bot.py         an alpaca-py bot; only the base URL changes
    openai_agents_mcp.py  the OpenAI Agents SDK over MCP (pip install openai-agents)
    pydantic_ai_mcp.py    PydanticAI over MCP (pip install "pydantic-ai-slim[mcp]")

    TF_URL=http://127.0.0.1:8765 python tfrun.py momentum_bot.py --days 20 --every day
    python http_bot.py --days 5
    python alpaca_bot.py --days 10
    python openai_agents_mcp.py            # needs OPENAI_API_KEY
    python pydantic_ai_mcp.py              # needs a model key, e.g. ANTHROPIC_API_KEY

tfrun.py goes to the hosted service unless TF_URL says otherwise; a server
on your machine needs no key.

The two LLM examples take `--offline`, which replaces the model with a
scripted one (`_offline.py`) that makes the same tool calls a model would.
The MCP connection, the tools and the server are real, so it shows the
wiring works without an API key.
