# Run or Build a Headline-Reading Trading Agent

Use this skill when a user wants to run, adapt, or build an automated agent that places paper-trading bets on Investment Bets.

## The demo agent

- Human-readable guide: `https://investment-bets.com/agent`
- Complete runnable source: `https://investment-bets.com/agent.py` (single file, Python 3.9+, needs `requests` and `anthropic`)

The demo reads today's market headlines, asks an LLM for at most one conviction call via a schema-forced tool call, and opens it with `POST /bet/open`. The server records entry and exit prices itself, so the resulting track record is verified, not self-reported.

## Required guards for any derived agent

Keep these as code-level checks, never as prompt instructions. The demo implements all five:

1. Dry-run by default; irreversible writes require an explicit flag (`--yes` in the demo).
2. At most one bet per run, enforced structurally.
3. Refuse a ticker the account already has an open bet on.
4. Refuse a malformed or past `target_date`.
5. The ticker must resolve on `GET /price/{ticker}` before any write.

## Operational notes

- Secrets (`IB_EMAIL`, `IB_PASSWORD`, `ANTHROPIC_API_KEY`) come from the environment; never print or commit them.
- `POST /bet/open` returns 403 when the account's bet slots are full and 503 while the price feed is stale. Both are clean stop conditions — do not retry in a loop.
- Only place a bet when the human user has asked for the agent to run; opening a bet is a user action.
- Use a recognizable bot-ish username or profile note, so the leaderboard stays legible about who is human.

## API mechanics

Defer to the `investment-bets` skill in this same index, plus `https://investment-bets.com/openapi.json` and `https://investment-bets.com/auth.md`. This skill does not restate authentication or endpoint details.
