> ## Documentation Index
> Fetch the complete documentation index at: https://docs.0xinsider.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Auto-buy the Pick of the Day

> Run potd-trader on your own machine: it reads each pick and places one small Polymarket order for it. Your keys never leave your computer.

[potd-trader](https://github.com/0xinsider/potd-trader) is a small open-source program that reads the [Pick of the Day](/api-reference/endpoint/get-pick-of-the-day) and buys each pick on your Polymarket account, once, with a stake you set. You run it. 0xinsider never sees your wallet.

It is 6 short Python files. Read them before you run them with real money.

## What leaves your machine

| Goes to                       | What                                                                          | Why                                             |
| ----------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------- |
| `api.0xinsider.com`           | your 0xinsider API key                                                        | to read today's picks                           |
| `clob.polymarket.com`         | a signed order and the API credentials Polymarket's SDK derives from your key | to place the buy                                |
| `gamma-api.polymarket.com`    | the pick's token id                                                           | to read the market's kickoff and status         |
| `polymarket.com/api/geoblock` | nothing beyond your IP                                                        | Polymarket's own "may this region trade?" check |

Your Polymarket private key is read from the `.env` in the folder `init` created and used by the official [`polymarket-client`](https://pypi.org/project/polymarket-client/) SDK to sign orders inside the process. There is no 0xinsider endpoint that accepts a wallet key, and the program never sends one anywhere.

<Warning>
  Anyone who can read the folder's `.env` can trade from your account. `init` writes it at mode 600 inside a mode 700 folder with a `.gitignore` for it; keep it on a machine you control.
</Warning>

## What you need

* Python 3.12 or newer and [uv](https://docs.astral.sh/uv/).
* A 0xinsider Pro API key from [0xinsider.com/developers](https://0xinsider.com/developers). The pick endpoint answers a free key with `402`.
* A Polymarket account holding some pUSD. `potd-trader status` reports whether its trading approvals are set. An account that has traded on polymarket.com usually has them; a fresh wallet does not, and `potd-trader setup` sets them with a Relayer API key.

## One command

```bash theme={null}
uv tool install git+https://github.com/0xinsider/potd-trader && potd-trader init
```

`init` creates a new `potd-trader/` folder where you are (`potd-trader init <name>` picks another name; an existing folder is never touched) and asks 4 questions in your terminal: the 0xinsider key and the Polymarket key are typed with echo off, then the wallet address and the stake. It writes the folder's `.env` at mode 600, runs `status` and a dry run, and ends in dry-run mode unless you type the phrase it asks for. About 2 seconds to install; the questions take as long as finding the values.

No `uv` yet? `curl -LsSf https://astral.sh/uv/install.sh | sh`, or `brew install uv`.

Then, from inside the folder, when the dry run shows what you expect:

```bash theme={null}
cd potd-trader
potd-trader live on    # type "spend real money" to confirm; `live off` reverts
potd-trader watch      # keep it running: wake at each release, buy, sleep
```

## Set it up with an AI agent

Rather have an agent walk you through it? Paste this into Claude Code, Codex, Cursor, or any agent that reads `AGENTS.md`. It installs the tool, creates `.env`, tells you the 3 values to fill in, runs the checks, and stops before anything spends money. It cannot run `init` for you: the key prompts need your terminal.

```text theme={null}
Set up https://github.com/0xinsider/potd-trader for me. Read its AGENTS.md and the guide at
https://docs.0xinsider.com/guides/auto-buy-the-pick, then follow the "Setting it up for a
person" steps in order. Install it, create .env from .env.example, then tell me which 3
values to fill in and where each comes from. Never ask me to paste a key into this chat and
never print one. When I say the file is filled in, run `potd-trader status` and a dry
`potd-trader run`, and explain what it would buy. Leave LIVE=no; I will change it myself.
```

The repository's [`AGENTS.md`](https://github.com/0xinsider/potd-trader/blob/main/AGENTS.md) holds the rules the agent works under: it never prints or asks for a key, never sets `LIVE=yes`, and never edits the ledger. Prefer to do it yourself? The steps below are the same ones.

## Install by hand

The repository-checkout layout: the `.env` sits beside the code, which is the directory you run the commands from.

```bash theme={null}
git clone https://github.com/0xinsider/potd-trader && cd potd-trader
uv sync
cp .env.example .env && chmod 600 .env
```

Fill in 3 values in `.env`:

| Variable                    | Where it comes from                                                                                                                                                                                                                    |
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `OXINSIDER_API_KEY`         | [0xinsider.com/developers](https://0xinsider.com/developers), a live key (`oxi_sk_live_...`)                                                                                                                                           |
| `POLYMARKET_PRIVATE_KEY`    | Email or Google login: polymarket.com, Settings, **Export private key** ([Polymarket's help article](https://help.polymarket.com/en/articles/13364258-how-do-i-export-my-key)). MetaMask or Rabby login: the key from that wallet app. |
| `POLYMARKET_WALLET_ADDRESS` | The address in your polymarket.com profile menu. It holds the pUSD. It is not the signer address.                                                                                                                                      |

## Dry run first

```bash theme={null}
uv run potd-trader status
uv run potd-trader run
```

`status` reports the region check, your wallet, its trading approvals, and its pUSD balance. `run` reads today's picks and prints what it would buy, with the live book price against the price the pick was published at. Nothing is bought until `.env` says `LIVE=yes`. Every other value counts as no.

A dry run on a day with a released pick looks like this:

```
DRY RUN (LIVE is not "yes"): nothing is bought. Plans are printed only.
Product day 2026-09-21: 2 released pick(s), 1 scheduled
BUY  #1 Portugal (Portugal vs. Uzbekistan) | pick price 62.0c | book 0.63 | stake 5 pUSD | max 0.63
SKIP #2 Belgium (-2.5) (Belgium vs. Wales) | pick price 55.0c | book price 0.60 is 9.1% above the pick's price 0.55 (MAX_SLIPPAGE_PCT 3)
2 pick(s) would be bought. Set LIVE=yes to buy for real.
Next scheduled release: 2026-09-21 18:00:00Z
```

## Go live

`potd-trader live on` (or `LIVE=yes` in the file by hand) and a small `STAKE_USD`, then pick one of two modes.

```bash theme={null}
uv run potd-trader run     # once: buy the released picks, then exit
uv run potd-trader watch   # keep running: wake at each release, buy, sleep
```

`watch` follows the schedule the API returns. On a `404` it sleeps until `error.retry_at`; on a slate with `scheduled_picks` it sleeps until the earliest `release_at`; otherwise it re-reads every 30 minutes with `If-None-Match`. It never polls faster than that. Leave it in a terminal, a `tmux` window, or the Docker image the repository ships.

## What it checks before each order

In order, in [`trader.py`](https://github.com/0xinsider/potd-trader/blob/main/src/potd_trader/trader.py):

1. The pick is `pending`, has a `token_id`, and `game_started` is false.
2. The local ledger holds no order for this pick.
3. `DAILY_CAP_USD` still has room.
4. The Polymarket market is open and kickoff is more than `KICKOFF_BUFFER_MINUTES` away.
5. The live book fills `STAKE_USD` at or below `MAX_PRICE`, and no more than `MAX_SLIPPAGE_PCT` above the pick's published price.

Then it writes a ledger entry, places one Fill-and-Kill market BUY with that book price as the ceiling, and records the exchange's answer. Before the first live order of a run it also checks Polymarket's geoblock, the wallet's trading approvals, and that the balance covers the stakes.

| Variable                  | Default   | Meaning                                                               |
| ------------------------- | --------- | --------------------------------------------------------------------- |
| `STAKE_USD`               | `5`       | pUSD per pick                                                         |
| `MAX_PRICE`               | `0.925`   | never buy above this probability; the cap 0xinsider's own trader uses |
| `MAX_SLIPPAGE_PCT`        | `3`       | skip when the book is this far above the pick's price                 |
| `DAILY_CAP_USD`           | `25`      | per product day, across picks; `0` disables                           |
| `KICKOFF_BUFFER_MINUTES`  | `5`       | no buys this close to kickoff                                         |
| `MIN_RANKS` / `MAX_RANKS` | `1` / `6` | which ranked slots to buy                                             |

## The ledger

`ledger.json`, beside `.env`, records every live order: the pick's date, rank, token, stake, and the exchange's answer. A pick with an entry in `submitting`, `accepted`, or `unknown` is never bought twice. `unknown` means the post raised before an answer arrived: check Activity on polymarket.com, then delete the entry by hand if no order exists.

```bash theme={null}
uv run potd-trader ledger
```

## What it does not do

* It does not sell, hedge, or redeem. Winning positions pay out through Polymarket as usual.
* It does not chase. A pick whose book has moved past the slippage band is skipped; `watch` rechecks it 5 minutes later, until kickoff.
* It does not buy a prior day's pick. The endpoint never returns one.
* It does not run in a region Polymarket blocks. The geoblock check refuses.
* It does not promise a return. The [track record](https://0xinsider.com/pick-of-the-day/verify) is computed on a \$100 stake at the published price; your fills differ.

## Related

* [Get Pick of the Day](/api-reference/endpoint/get-pick-of-the-day): the endpoint, its `404` schedule, and the pick fields.
* [Get Pick of the Day track record](/api-reference/endpoint/get-pick-of-the-day-archive): every past pick and the hit rate.
* [github.com/0xinsider/potd-trader](https://github.com/0xinsider/potd-trader): the source. Issues and pull requests welcome.
