> ## 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.

> ## Agent Instructions
> The Markdown of an API reference page leaves out the OpenAPI schema.
> Every object an endpoint returns or a webhook carries, with each field's type, presence and meaning, is on https://docs.0xinsider.com/api-reference/objects.md.
> The full OpenAPI 3.1 spec names each operation's and each webhook's exact parameters, request body and response schema: https://docs.0xinsider.com/api-reference/openapi.json.

# Build your own Pick of the Day algorithm

> Write a rule that picks one side of a game from 0xinsider data, run it on today's games, and backtest it on settled markets.

Write a rule that picks one side of a game from 0xinsider data, run it on today's games, and backtest it on settled markets.

The rule on this page is yours to change. It is not the rule behind 0xinsider's [Pick of the Day](https://0xinsider.com/pick-of-the-day), which stays private. Every number in it is a made-up round number to start from.

The API provides analytics. Your own Polymarket client places any order, and a past record does not guarantee a future result.

You need a Pro or Max [API key](https://docs.0xinsider.com/authentication.md) and Node.js 22 or later. The scripts use the [TypeScript client](https://docs.0xinsider.com/integrations/typescript-client.md) and run with `tsx`:

```bash theme={null}
npm install @0xinsider/sdk
export OXINSIDER_API_KEY=...
```

## What you will build

| File | What it does |
| - | - |
| `rule.ts` | Your rule: given the money on each side and the price, pick a side or pass. |
| `today.ts` | Runs the rule on the games that start in the next 24 hours. |
| `backtest.ts` | Runs the same rule on settled games, with your entry price, the fee, and the result. |
| `benchmark.ts` | Reads the published Pick of the Day record for the same days, to compare. |

## 1. The data

| Data | Endpoint | What the rule uses |
| - | - | - |
| Today's games, both sides | [List games](https://docs.0xinsider.com/api-reference/endpoint/list-games.md) | `event_slug`, `scheduled_at` (the kickoff), and the moneyline's `condition_id`, `outcome_yes`, and `outcome_no`. |
| The graded wallets on each side, and their money | [Market holders](https://docs.0xinsider.com/api-reference/endpoint/get-market-holders.md) | Each S-, A-, or B-grade wallet with open shares: its `side`, `grade`, and `current_value_usd`. |
| Each wallet's record in the league | [Market holders](https://docs.0xinsider.com/api-reference/endpoint/get-market-holders.md) | `category_win_record`: `wins` and `decided` in the game's league, which `category_win_rate_game` names. Without that field, the record covers the whole sport. |
| A wallet's record in every league | [Trader category records](https://docs.0xinsider.com/api-reference/endpoint/get-trader-category-records.md) | `records[].scopes`, one row per league or esports title. |
| Large trades | [Large trades history](https://docs.0xinsider.com/api-reference/endpoint/get-large-trades-history.md) | Trades of \$10,000 or more, with `trader.grade_at_trade`, the grade the wallet held when it traded. |
| Every fill | [List market trades](https://docs.0xinsider.com/api-reference/endpoint/list-market-trades.md) | Taker fills of \$100 or more, with `side`, `outcome_index`, and `price`. |
| Price, fee, and settlement | [List game markets](https://docs.0xinsider.com/api-reference/endpoint/list-game-markets.md) | `quote.best_ask` with `expand=quotes`, `fee_schedule` with `expand=trading_terms`, and `settlement.payouts`. |
| Closing line | [Batch market closing lines](https://docs.0xinsider.com/api-reference/endpoint/batch-get-market-close.md) | `close_price` of each outcome: the market's price at kickoff. |
| The published record | [Pick of the Day archive](https://docs.0xinsider.com/api-reference/endpoint/get-pick-of-the-day-archive.md) | Each pick's `pick_date`, `outcome`, and `unit_score`. |

A wallet's league record counts every settled market it traded in that league, at any size. A win is a market where its realized P\&L closed positive, not a market where it backed the winner.

## 2. Write the rule

The rule takes 2 sides and returns 1 of them, or `null` to pass. It knows nothing about where the money figures come from, so the live run and the backtest share it.

```typescript rule.ts theme={null}
// Your rule. Every number here is a made-up round number to start from, not a recommendation.
export const RULE = {
  minDecided: 100, // settled markets a wallet needs in the game's league to count
  minWinRate: 0.6, // the share of those markets it won
  minMoneyUsd: 20_000, // money from wallets that count, both sides together
  minShare: 0.65, // the share of that money one side must hold
  maxPrice: 0.6, // the most you pay for one share
};

export interface Side {
  index: 0 | 1; // the outcome's index in the market
  label: string; // the team or player
  money: number; // USD from wallets that count
  price: number; // what one share costs you, 0 to 1
}

// Returns the side to pick, or null to pass on the game.
export function pickSide(sides: [Side, Side]): Side | null {
  const total = sides[0].money + sides[1].money;
  if (total < RULE.minMoneyUsd) return null;
  const top = sides[0].money >= sides[1].money ? sides[0] : sides[1];
  if (top.money / total < RULE.minShare) return null;
  if (top.price > RULE.maxPrice) return null;
  return top;
}
```

Change anything here: the thresholds, a weight per grade, a limit per wallet, or a second condition. Keep it a function of what you could see before the game.

## 3. Run it on today's games

`today.ts` reads the games that start in the next 24 hours. For each moneyline, it adds up the money of S- and A-grade holders whose league record passes the rule, reads the ask, and asks the rule.

```typescript today.ts theme={null}
import { OxinsiderApiClient, paginate } from "@0xinsider/sdk";
import { RULE, pickSide, type Side } from "./rule.ts";

const apiKey = process.env["OXINSIDER_API_KEY"];
if (!apiKey) throw new Error("Set OXINSIDER_API_KEY");
const client = new OxinsiderApiClient({ apiKey });
const LEAGUE = process.env["LEAGUE"] ?? "nba";

// Games that start in the next 24 hours.
const now = Date.now();
const games = await client.listGames({
  league: LEAGUE,
  starts_after: new Date(now).toISOString(),
  starts_before: new Date(now + 24 * 3_600_000).toISOString(),
  limit: 100,
});

for (const game of games.data) {
  const moneyline = game.markets.find((m) => m.sports_market_type === "moneyline");
  if (!moneyline) continue;

  // Count the money of S- and A-grade holders whose record in this league passes the rule.
  const money = [0, 0];
  for await (const holder of paginate(client, "getMarketHolders", {
    path: { condition_id: moneyline.condition_id },
    query: { min_grade: "A", limit: 100 },
  })) {
    const record = holder.category_win_record;
    if (!record || record.decided < RULE.minDecided) continue;
    if (record.wins / record.decided < RULE.minWinRate) continue;
    money[holder.side === "YES" ? 0 : 1] += holder.current_value_usd ?? 0;
  }

  // The ask is what one share costs you now.
  const markets = await client.listGameMarkets(game.event_slug, {
    sports_market_type: "moneyline",
    expand: ["quotes"],
  });
  const row = markets.data.find((m) => m.condition_id === moneyline.condition_id);
  const asks = [0, 1].map((i) => row?.outcomes[i]?.quote?.best_ask ?? null);
  if (asks[0] === null || asks[1] === null) {
    console.log(game.event_slug, "pass: no ask to price the entry");
    continue;
  }

  const sides: [Side, Side] = [
    { index: 0, label: moneyline.outcome_yes ?? "outcome 0", money: money[0], price: asks[0] },
    { index: 1, label: moneyline.outcome_no ?? "outcome 1", money: money[1], price: asks[1] },
  ];
  const pick = pickSide(sides);
  const counted = sides.map((s) => `${s.label} $${Math.round(s.money).toLocaleString("en-US")}`).join(", ");
  console.log(game.event_slug, pick ? `pick ${pick.label} at ${pick.price}` : "pass", `(${counted})`);
}
```

```bash theme={null}
LEAGUE=nba npx tsx today.ts
```

A run at 00:24 UTC on November 11, 2026 printed 9 games, including:

```text theme={null}
nba-mil-nyk-2026-11-10 pass (Bucks $0, Knicks $71,323)
nba-mia-uta-2026-11-10 pick Jazz at 0.31 (Heat $10,827, Jazz $86,546)
nba-okc-por-2026-11-10 pass (Thunder $969, Trail Blazers $2,069)
```

The Knicks held most of the money, but their ask was above `maxPrice`, so the rule passed on that game.

`min_grade: "A"` keeps S- and A-grade holders. `paginate` follows `next_cursor`, so a market with more than 100 holders is read in full.

The holder list is rebuilt at most once a minute per market. A market nobody has asked for recently can answer `429` with `cold_read_limited`. The client waits for `Retry-After` and tries again, up to 2 times.

To read one wallet's record in every league, call [Trader category records](https://docs.0xinsider.com/api-reference/endpoint/get-trader-category-records.md):

```bash theme={null}
curl -H "Authorization: Bearer $OXINSIDER_API_KEY" \
  "https://api.0xinsider.com/api/v1/trader/0xc660ae71765d0d9eaf5fa8328c1c959841d2bd28/categories?category=basketball"
```

## 4. Backtest it on settled games

The holder list shows positions as they are now, not as they were before a past game. A backtest of `today.ts` on old games would read today's holders, so it would use information from after each game.

`as_of=kickoff` on [Market holders](https://docs.0xinsider.com/api-reference/endpoint/get-market-holders.md) and [Game holders](https://docs.0xinsider.com/api-reference/endpoint/get-game-holders.md) returns a game moneyline's holders as they were stored before kickoff: each wallet's `side`, `grade`, and `category_win_record` as they stood then. `as_of.population_fetched_at` says when those positions were read. If that is after your decision time, the roster holds positions your rule could not have seen, so compare the two before you use it.

Rosters exist only for games that kicked off after this shipped on November 16, 2026. An older game, or one nobody read before kickoff, answers `404` with `kickoff_roster_not_captured`. A game that has not started, or started less than 30 seconds ago, answers `kickoff_roster_pending`, with `Retry-After` set to 30 seconds after kickoff. Neither answer falls back to today's holders.

`backtest.ts` gives the same rule the input it can replay on every settled game: large trades placed before your decision time, by wallets that held an A grade or better when they traded. It cannot apply the league record filter, because those records are also counted as they stand now. On a game with a kickoff roster, read the record from the roster instead.

For each settled game, the script:

1. Adds up the large-trade money on each side before the decision time, 90 minutes before kickoff.
2. Takes the price of the first taker buy of the leading side after the decision time as your entry.
3. Asks the rule, with that entry as the price.
4. Reads the settlement and the fee curve from the game's moneyline.
5. Reads the closing line of every pick.

```typescript backtest.ts theme={null}
import { OxinsiderApiClient, paginate } from "@0xinsider/sdk";
import { pickSide, type Side } from "./rule.ts";

const apiKey = process.env["OXINSIDER_API_KEY"];
if (!apiKey) throw new Error("Set OXINSIDER_API_KEY");
const client = new OxinsiderApiClient({ apiKey });
const LEAGUE = process.env["LEAGUE"] ?? "nba";
const FROM = process.env["FROM"] ?? "2026-11-01T18:00:00Z";
const TO = process.env["TO"] ?? new Date(Date.now() - 6 * 3_600_000).toISOString();
const DECIDE_MINUTES = 90; // decide 90 minutes before kickoff (made up)

const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));

// The moneyline's settlement and fee curve. A first read can answer "unavailable", so read twice.
async function moneylineRow(eventSlug: string, conditionId: string) {
  for (let attempt = 1; attempt <= 2; attempt++) {
    const page = await client.listGameMarkets(eventSlug, {
      sports_market_type: "moneyline",
      status: "all",
      expand: ["trading_terms"],
    });
    const row = page.data.find((m) => m.condition_id === conditionId);
    if (row && row.settlement.status !== "unavailable" && row.trading_terms?.status === "observed") return row;
    if (attempt === 1) await sleep(5_000);
  }
  return null;
}

interface Pick {
  day: string; // UTC day of kickoff
  slug: string;
  conditionId: string;
  label: string;
  index: 0 | 1;
  entry: number; // the price you paid for one share
  fee: number; // the taker fee on one share
  paid: number; // what one share paid at settlement: 1, 0, or 0.5 on a split
}
const picks: Pick[] = [];
const skipped: Record<string, number> = {};
const skip = (why: string) => { skipped[why] = (skipped[why] ?? 0) + 1; };

for await (const game of paginate(client, "listGames", {
  query: { league: LEAGUE, status: "ended", starts_after: FROM, starts_before: TO, limit: 100 },
})) {
  const moneyline = game.markets.find((m) => m.sports_market_type === "moneyline");
  if (!moneyline || !game.scheduled_at) { skip("no moneyline or kickoff"); continue; }
  const decideAt = new Date(Date.parse(game.scheduled_at) - DECIDE_MINUTES * 60_000).toISOString();
  const labels = [moneyline.outcome_yes, moneyline.outcome_no];

  // What you could have seen at decision time: large trades by wallets that held
  // an A grade or better when they traded. Buys add to a side, sells subtract.
  const money = [0, 0];
  for await (const trade of paginate(client, "listLargeTradeHistory", {
    query: { condition_id: moneyline.condition_id, to: decideAt, min_grade_at_trade: "A", min_size: 10000, limit: 100 },
  })) {
    const i = labels.indexOf(trade.outcome ?? "");
    if (i < 0) continue;
    money[i] += trade.side === "BUY" ? trade.size_usd : -trade.size_usd;
  }
  const leader = money[0] >= money[1] ? 0 : 1;

  // Your entry: the first taker buy of the leading side after decision time and before kickoff.
  let entry: number | null = null;
  for await (const fill of paginate(client, "listMarketTrades", {
    path: { condition_id: moneyline.condition_id },
    query: { from: decideAt, to: game.scheduled_at, limit: 500 },
  })) {
    // Fills arrive newest first, so the last match is the first buy.
    if (fill.side === "BUY" && fill.outcome_index === leader) entry = fill.price;
  }
  if (entry === null) { skip("no fill to price the entry"); continue; }

  // Only the side you would buy needs a price; the other side's 1 never passes the rule.
  const sides: [Side, Side] = [
    { index: 0, label: labels[0] ?? "outcome 0", money: Math.max(money[0], 0), price: leader === 0 ? entry : 1 },
    { index: 1, label: labels[1] ?? "outcome 1", money: Math.max(money[1], 0), price: leader === 1 ? entry : 1 },
  ];
  const pick = pickSide(sides);
  if (!pick) { skip("rule passed on the game"); continue; }

  const row = await moneylineRow(game.event_slug, moneyline.condition_id);
  const payouts = row?.settlement.payouts;
  if (!row || !payouts) { skip("settlement not readable yet"); continue; }
  const terms = row.trading_terms;
  const rate = terms?.fees_enabled ? terms.fee_schedule?.rate ?? null : 0;
  const exponent = terms?.fee_schedule?.exponent ?? 1;
  if (rate === null) { skip("fee curve not published"); continue; }
  // Polymarket's taker fee on one share: rate * (p * (1 - p)) ^ exponent.
  const fee = rate * (pick.price * (1 - pick.price)) ** exponent;
  picks.push({
    day: game.scheduled_at.slice(0, 10),
    slug: game.event_slug,
    conditionId: moneyline.condition_id,
    label: pick.label,
    index: pick.index,
    entry: pick.price,
    fee,
    paid: (payouts[pick.index] ?? 0) / 1_000_000,
  });
}

// The closing line: each market's price at kickoff.
const close = new Map<string, number>();
for (let i = 0; i < picks.length; i += 25) {
  const batch = await client.batchGetMarketClose({ condition_ids: picks.slice(i, i + 25).map((p) => p.conditionId) });
  (batch.data ?? []).forEach((item, j) => {
    const p = picks[i + j];
    if (item.status === "ok" && item.data?.status === "measured") {
      const leg = item.data.outcomes.find((o) => o.outcome_index === p.index);
      if (leg) close.set(p.conditionId, leg.close_price);
    }
  });
}

// $1 on every pick. With the fee, one share costs entry + fee.
let profit = 0, profitAtClose = 0, priced = 0, clvCents = 0;
for (const p of picks) {
  profit += p.paid / (p.entry + p.fee) - 1;
  const c = close.get(p.conditionId);
  if (c !== undefined) { profitAtClose += p.paid / c - 1; clvCents += (c - p.entry) * 100; priced++; }
  const result = p.paid === 1 ? "won" : p.paid === 0 ? "lost" : "split";
  console.log(p.day, p.slug, p.label, "entry", p.entry.toFixed(3), "close", c ?? "n/a", result);
}
const perDay = new Map<string, number>();
for (const p of picks) perDay.set(p.day, (perDay.get(p.day) ?? 0) + 1);

console.log("\npicks", picks.length, "won", picks.filter((p) => p.paid === 1).length, "skipped", skipped);
if (picks.length > 0) {
  console.log("return per $1 at your entry, after fees:", (profit / picks.length).toFixed(3));
  if (priced > 0) {
    console.log("return per $1 at the close, no fee:", (profitAtClose / priced).toFixed(3));
    console.log("average close minus entry, cents:", (clvCents / priced).toFixed(2));
  }
  console.log("days with a pick:", perDay.size, "most picks in one day:", Math.max(...perDay.values()));
}
```

```bash theme={null}
LEAGUE=nba FROM=2026-11-01T18:00:00Z npx tsx backtest.ts
```

A run at 00:26 UTC on November 11, 2026 printed:

```text theme={null}
2026-11-02 nba-tor-lal-2026-11-01 Lakers entry 0.590 close 0.595 won
2026-11-03 nba-mia-lal-2026-11-02 Lakers entry 0.560 close 0.545 won
2026-11-03 nba-phx-gsw-2026-11-02 Warriors entry 0.570 close 0.555 won
2026-11-03 nba-tor-lac-2026-11-02 Clippers entry 0.360 close 0.315 lost
2026-11-06 nba-orl-phx-2026-11-05 Magic entry 0.490 close 0.475 lost
2026-11-10 nba-mem-tor-2026-11-09 Grizzlies entry 0.550 close 0.525 won

picks 6 won 4 skipped { 'rule passed on the game': 60 }
return per $1 at your entry, after fees: 0.151
return per $1 at the close, no fee: 0.204
average close minus entry, cents: -1.83
days with a pick: 4 most picks in one day: 3
```

### The fee and the entry price

Polymarket charges the taker a fee on each share: `rate * (p * (1 - p)) ^ exponent`, where `p` is the price. See Polymarket's [fee page](https://docs.polymarket.com/trading/fees).

`expand=trading_terms` returns `rate` and `exponent` in `fee_schedule`. On NBA moneylines on November 11, 2026, they were `0.05` and `1`, so a share at 0.59 paid about 1.2 cents.

The entry is a recorded taker fill, so it already paid whatever the order book asked at the time. Your own order could fill at a different price, and a large order moves the price. The closing line is Polymarket's price series at kickoff, not a fill.

[List market trades](https://docs.0xinsider.com/api-reference/endpoint/list-market-trades.md) serves fills from `coverage.recorded_from`, which was 2026-11-01T18:00:00Z on November 11, 2026. Read it from the response and set `FROM` no earlier. `trader.grade_at_trade` exists from 2026-09-19T23:00Z; an older trade never matches `min_grade_at_trade`.

The first read of an old game's moneyline can answer `settlement.status: "unavailable"` while 0xinsider fetches it. `moneylineRow` reads once more after 5 seconds. A game it still cannot read is skipped and counted, not scored as a loss.

## 5. Compare it with the published record

`benchmark.ts` reads the [Pick of the Day archive](https://docs.0xinsider.com/api-reference/endpoint/get-pick-of-the-day-archive.md) for the same days and league. `unit_score` is a pick's return on 1 unit: a win at a price of 0.40 is `1.5`, and a loss is `-1`.

```typescript benchmark.ts theme={null}
import { OxinsiderApiClient } from "@0xinsider/sdk";

const apiKey = process.env["OXINSIDER_API_KEY"];
if (!apiKey) throw new Error("Set OXINSIDER_API_KEY");
const client = new OxinsiderApiClient({ apiKey });
const CATEGORY = process.env["CATEGORY"] ?? "NBA"; // display_category, as the archive prints it
const FROM_DAY = (process.env["FROM"] ?? "2026-11-01T18:00:00Z").slice(0, 10);

// The archive pages newest first. Stop at the first page that reaches past FROM_DAY.
let cursor: string | undefined;
let decided = 0, wins = 0, units = 0;
for (;;) {
  const page = await client.call("getPickOfTheDayArchive", {
    query: { view: "summary", limit: 200, ...(cursor ? { cursor } : {}) },
  });
  if (!page.data) break;
  const rows = page.data.picks ?? [];
  for (const row of rows) {
    if (row.pick_date < FROM_DAY || row.display_category !== CATEGORY) continue;
    if (row.outcome !== "win" && row.outcome !== "loss") continue; // pending and void are not counted
    decided++;
    if (row.outcome === "win") wins++;
    units += row.unit_score ?? 0;
  }
  const next = page.data.page?.next_cursor;
  if (!next || rows.some((row) => row.pick_date < FROM_DAY)) break;
  cursor = next;
}
console.log(`Pick of the Day, ${CATEGORY}, since ${FROM_DAY}: ${wins} of ${decided} won, ${units.toFixed(2)} units`);
```

```bash theme={null}
CATEGORY=NBA FROM=2026-11-01T18:00:00Z npx tsx benchmark.ts
```

The record prices each pick at the order book midpoint when it was released, with no fee. Compare it with your figure at the close with no fee, not with your figure after fees. [Pick of the Day stats](https://docs.0xinsider.com/api-reference/endpoint/get-pick-of-the-day-stats.md) breaks the whole record down by sport, league, month, and entry price.

## 6. Before you trust a result

* **Sample size.** 6 picks is not evidence. If every pick were a coin flip at even money, 4 or more wins in 6 would still happen about 1 time in 3. Widen `FROM` and run more leagues before you believe a return.
* **Days, not picks.** In the run above, 3 of the 6 picks were on one day. Games on the same day share news, injuries, and market mood, so count the days with a pick as well as the picks.
* **Entry against close.** "Average close minus entry" was -1.83 cents, so the run paid more than the closing price on average. Its return came from 4 wins in 6, not from buying cheaper than the market's final price. A positive figure over many picks is harder to get by luck.
* **The fee.** Compare the 2 return lines. A rule that is profitable only before the fee loses money in practice.
* **Lookahead.** Use only data that existed at decision time: `min_grade_at_trade`, not `min_grade`, and a decision time before kickoff. `trader.grade` on a past trade is the wallet's grade today. Past holders come from `as_of=kickoff` only, and only when `as_of.population_fetched_at` is before your decision time.
* **Skipped games.** Read the `skipped` counts. A rule that skips most games has a small sample, even across a long window.

## Next steps

* Run the rule when trades happen instead of on a schedule, with the [`large_trade_inserted_v2`](https://docs.0xinsider.com/api-reference/webhooks/large-trade-inserted-v2) and [`market_settled`](https://docs.0xinsider.com/api-reference/webhooks/market-settled) webhooks. See [Webhooks](https://docs.0xinsider.com/guides/webhooks.md).
* See how an order is placed and capped on a Polymarket account in [Auto-buy the Pick of the Day](https://docs.0xinsider.com/guides/auto-buy-the-pick.md). That tool buys the published picks, not your rule's.
* Read a wallet's grade at a past decision time with [Trader grade at a past time](https://docs.0xinsider.com/api-reference/endpoint/get-trader-grade-at.md).
* Build a list of wallets to follow with [Copy-trade signals](https://docs.0xinsider.com/recipes/copy-trade.md).

## Limits

* A past record does not guarantee a future result.
* The backtest replays large trades, not the holder list, so it tests a thinner version of the live input.
* Large trades history is a best-effort record: `meta.completeness.status` is `best_effort`, and a gap does not prove that nobody traded.
* The API does not place, cancel, or read orders.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.