oddityrh 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +9 -0
- package/README.md +52 -2
- package/oddity.js +169 -0
- package/package.json +11 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Oddity
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,53 @@
|
|
|
1
|
-
#
|
|
1
|
+
# oddityrh
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Read Polymarket the way [Oddity](https://oddityrh.trade) does, from your terminal or your AI agent.
|
|
4
|
+
|
|
5
|
+
Every live market priced by a real model, compared with the order book after fees, with the arbitrage, rule traps and bet sizes worked out.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npx oddityrh gaps
|
|
9
|
+
# or
|
|
10
|
+
npm i -g oddityrh
|
|
11
|
+
oddity gaps
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Commands
|
|
15
|
+
|
|
16
|
+
| Command | What you get |
|
|
17
|
+
|---|---|
|
|
18
|
+
| `oddity scan "<polymarket link or words>"` | One market: crowd price, Oddity's price, the reason, the trade if there is one |
|
|
19
|
+
| `oddity gaps [--topic crypto\|macro\|ai\|world\|politics\|other]` | Markets where Oddity's price beats the book after fees |
|
|
20
|
+
| `oddity arb` | Ladder breaks and outcome sums that lock a profit |
|
|
21
|
+
| `oddity traps` | Markets whose rules or order book can catch you out |
|
|
22
|
+
| `oddity yield [--days 31]` | Near-certain outcomes, return per year |
|
|
23
|
+
| `oddity slate [--bankroll 1000] [--ids a,b]` | Several bets sized together with quarter-Kelly |
|
|
24
|
+
| `oddity wallet 0x…` | Any Polymarket wallet: value, profit and every position scored |
|
|
25
|
+
| `oddity traders [--period week] [--category crypto]` | Leaderboard |
|
|
26
|
+
| `oddity rewards` | Markets paying liquidity rewards |
|
|
27
|
+
| `oddity --version` | Installed version |
|
|
28
|
+
|
|
29
|
+
Add `--json` to any read for raw output.
|
|
30
|
+
|
|
31
|
+
## AI agents (MCP)
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
oddity init
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Adds Oddity to Claude Code, Claude Desktop and Cursor if they are installed, and keeps a `.oddity-bak` copy of each config it changes.
|
|
38
|
+
|
|
39
|
+
Or add the server yourself:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{ "mcpServers": { "oddity": { "url": "https://oddityrh.trade/mcp" } } }
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`oddity mcp` runs a stdio bridge for clients that only speak stdio.
|
|
46
|
+
|
|
47
|
+
## Settings
|
|
48
|
+
|
|
49
|
+
`ODDITY_URL` points the CLI at another Oddity server (default `https://oddityrh.trade`).
|
|
50
|
+
|
|
51
|
+
Needs Node 18 or newer. No dependencies.
|
|
52
|
+
|
|
53
|
+
Not financial advice. Not affiliated with Polymarket.
|
package/oddity.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Oddity CLI: read Polymarket from the terminal, run a local MCP bridge, or wire your agents.
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import readline from "node:readline";
|
|
7
|
+
|
|
8
|
+
const BASE = ((process.env.ODDITY_URL || process.env.VERNIER_URL) || "https://oddityrh.trade").replace(/\/$/, "");
|
|
9
|
+
const args = process.argv.slice(2);
|
|
10
|
+
const flags = {};
|
|
11
|
+
const pos = [];
|
|
12
|
+
for (let i = 0; i < args.length; i++) {
|
|
13
|
+
if (args[i].startsWith("--")) {
|
|
14
|
+
const k = args[i].slice(2);
|
|
15
|
+
const n = args[i + 1];
|
|
16
|
+
if (!n || n.startsWith("--")) flags[k] = true;
|
|
17
|
+
else (flags[k] = n), i++;
|
|
18
|
+
} else pos.push(args[i]);
|
|
19
|
+
}
|
|
20
|
+
const VERSION = "0.1.1";
|
|
21
|
+
const cmd = flags.version || flags.v || pos[0] === "version" ? "version" : pos[0] || "help";
|
|
22
|
+
const pct = (x) => (x == null ? " – " : `${(x * 100).toFixed(1)}%`);
|
|
23
|
+
const c = (x) => (x == null ? "–" : `${(x * 100).toFixed(1)}¢`);
|
|
24
|
+
const cut = (s, n) => (s.length > n ? s.slice(0, n - 1) + "…" : s.padEnd(n));
|
|
25
|
+
|
|
26
|
+
async function get(p) {
|
|
27
|
+
const r = await fetch(BASE + p, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(30_000) });
|
|
28
|
+
const j = await r.json().catch(() => ({}));
|
|
29
|
+
if (!r.ok) throw new Error(j.error || `HTTP ${r.status}`);
|
|
30
|
+
return j;
|
|
31
|
+
}
|
|
32
|
+
const out = (j, fmt) => (flags.json ? console.log(JSON.stringify(j, null, 2)) : fmt(j));
|
|
33
|
+
|
|
34
|
+
const HELP = `oddity: Polymarket reads in your terminal (server: ${BASE}, set ODDITY_URL to change)
|
|
35
|
+
|
|
36
|
+
oddity scan "<polymarket url or words>" price one market, with the reason
|
|
37
|
+
oddity gaps [--topic crypto|macro|ai|world|politics|other]
|
|
38
|
+
oddity arb ladder breaks + outcome sums
|
|
39
|
+
oddity traps trap radar
|
|
40
|
+
oddity yield [--days 31] near-certain outcomes per year
|
|
41
|
+
oddity slate [--bankroll 1000] [--ids a,b] several bets sized together
|
|
42
|
+
oddity wallet 0x… any wallet: value, profit, positions vs Oddity
|
|
43
|
+
oddity traders [--period week] [--category crypto]
|
|
44
|
+
oddity rewards markets paying liquidity rewards
|
|
45
|
+
oddity mcp stdio MCP bridge to the server
|
|
46
|
+
oddity init add Oddity MCP to Claude Code, Claude Desktop, Cursor
|
|
47
|
+
|
|
48
|
+
oddity --version
|
|
49
|
+
|
|
50
|
+
add --json to any read for raw output`;
|
|
51
|
+
|
|
52
|
+
async function main() {
|
|
53
|
+
if (cmd === "version") return console.log(`oddityrh ${VERSION}`);
|
|
54
|
+
if (cmd === "scan") {
|
|
55
|
+
const q = pos.slice(1).join(" ").trim();
|
|
56
|
+
if (!q) throw new Error('Usage: oddity scan "<polymarket url or words>"');
|
|
57
|
+
const m = await get(`/api/market?q=${encodeURIComponent(q)}`);
|
|
58
|
+
return out(m, () => {
|
|
59
|
+
console.log(`\n${m.question}\n${m.url}\n`);
|
|
60
|
+
console.log(` Market says ${pct(m.yes)} Oddity says ${pct(m.fair)} (${m.model || "no model"})`);
|
|
61
|
+
console.log(` Bid / ask ${c(m.bid)} / ${c(m.ask)} 24h volume $${Math.round(m.volume24h).toLocaleString()} depth $${Math.round(m.liquidity).toLocaleString()}`);
|
|
62
|
+
if (m.factors) for (const f of m.factors) console.log(` ${cut(f.label, 30)} ${(f.value >= 0 ? "+" : "") + (f.value * 100).toFixed(1)} pts`);
|
|
63
|
+
console.log(m.side ? `\n → Buy ${m.side} at ${c(m.entry)}: worth +${c(m.edge)} per share. Quarter-Kelly ${(m.kelly.pct * 100).toFixed(1)}% of bankroll.` : `\n → No trade: the gap is smaller than the cost to trade.`);
|
|
64
|
+
if (m.trap?.count) console.log(` Trap score ${m.trap.score}/98: ${m.traps.map((t) => t.title).join("; ")}`);
|
|
65
|
+
console.log("");
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (cmd === "gaps") {
|
|
69
|
+
const rows = await get(`/api/board?gaps=1&limit=${flags.limit || 20}&domain=${flags.topic || "all"}`);
|
|
70
|
+
return out(rows, () => rows.forEach((r) => console.log(`${cut(r.question, 64)} ${pct(r.yes)} → ${pct(r.fair)} ${r.side || ""} +${c(r.edge)}`)));
|
|
71
|
+
}
|
|
72
|
+
if (cmd === "arb") {
|
|
73
|
+
const [l, n] = await Promise.all([get("/api/ladders"), get("/api/negrisk?limit=15")]);
|
|
74
|
+
return out({ ladders: l, outcomeSums: n }, () => {
|
|
75
|
+
console.log("\nLadder breaks");
|
|
76
|
+
l.slice(0, 10).forEach((b) => console.log(` ${cut(b.eventTitle, 54)} +${c(b.lockedProfit)} per pair`));
|
|
77
|
+
console.log("\nOutcome sums");
|
|
78
|
+
n.forEach((b) => console.log(` ${cut(b.eventTitle, 54)} ${pct(b.sumMid)} ${b.verdict}`));
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (cmd === "traps") {
|
|
82
|
+
const rows = await get("/api/traps?limit=20");
|
|
83
|
+
return out(rows, () => rows.forEach((r) => console.log(`${String(r.trap.score).padStart(2)} ${cut(r.question, 60)} ${r.traps.map((t) => t.code).join(",")}`)));
|
|
84
|
+
}
|
|
85
|
+
if (cmd === "yield") {
|
|
86
|
+
const rows = (await get("/api/yield")).filter((y) => y.daysLeft <= Number(flags.days || 31)).slice(0, 20);
|
|
87
|
+
return out(rows, () => rows.forEach((y) => console.log(`${cut(y.question, 60)} ${y.side} ${c(y.price)} ${(y.ret * 100).toFixed(2)}% in ${y.daysLeft.toFixed(1)}d`)));
|
|
88
|
+
}
|
|
89
|
+
if (cmd === "slate") {
|
|
90
|
+
const d = await get(`/api/slate?bankroll=${flags.bankroll || 1000}${flags.ids ? `&ids=${flags.ids}` : ""}`);
|
|
91
|
+
return out(d, () => {
|
|
92
|
+
d.legs.forEach((l) => console.log(`${cut(l.question, 52)} ${l.side.padEnd(3)} ${c(l.entry)} $${l.usd.toFixed(2)} (+$${l.expectedUsd.toFixed(2)})`));
|
|
93
|
+
console.log(`\nIn play $${d.total.toFixed(2)} of $${d.bankroll} · cash $${d.reserve.toFixed(2)} · expected +$${d.expectedUsd.toFixed(2)}${d.capped ? " · scaled to cap" : ""}`);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (cmd === "wallet") {
|
|
97
|
+
const d = await get(`/api/wallet?address=${encodeURIComponent(pos[1] || "")}`);
|
|
98
|
+
return out(d, () => {
|
|
99
|
+
const u = (x) => `${x < 0 ? "-" : ""}$${Math.abs(Math.round(x)).toLocaleString()}`;
|
|
100
|
+
console.log(`\n${d.name} value ${u(d.value)} all-time ${u(d.pnl.total)} (trading ${u(d.pnl.trading)}, rewards ${u(d.pnl.rewards)})${d.monthRank ? ` #${d.monthRank} this month` : ""}`);
|
|
101
|
+
if (d.redeemValue > 0.5) console.log(` ${u(d.redeemValue)} waiting to be claimed`);
|
|
102
|
+
console.log("");
|
|
103
|
+
d.positions.slice(0, 25).forEach((p) => console.log(`${cut(p.title, 52)} ${cut(p.outcome, 4)} ${c(p.avgPrice)}→${c(p.price)} ${u(p.value).padStart(8)} ${p.holdEdge == null ? "" : p.holdEdge >= 0.02 ? "HOLD" : p.holdEdge <= -0.02 ? "SELL" : "fair"}`));
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (cmd === "traders") {
|
|
107
|
+
const rows = await get(`/api/traders?period=${flags.period || "week"}&category=${flags.category || "overall"}`);
|
|
108
|
+
return out(rows, () => rows.slice(0, 25).forEach((r) => console.log(`${String(r.rank).padStart(3)} ${cut(r.name, 28)} ${r.wallet} $${Math.round(r.pnl).toLocaleString()}`)));
|
|
109
|
+
}
|
|
110
|
+
if (cmd === "rewards") {
|
|
111
|
+
const d = await get("/api/rewards");
|
|
112
|
+
return out(d, () => d.lp.slice(0, 25).forEach((r) => console.log(`${cut(r.question, 56)} $${r.daily}/day ±${r.maxSpread}¢ min ${r.minSize} book $${Math.round(r.liquidity)}`)));
|
|
113
|
+
}
|
|
114
|
+
if (cmd === "mcp") {
|
|
115
|
+
// stdio ↔ HTTP bridge: each JSON-RPC line goes to the server's /mcp.
|
|
116
|
+
const rl = readline.createInterface({ input: process.stdin });
|
|
117
|
+
for await (const line of rl) {
|
|
118
|
+
if (!line.trim()) continue;
|
|
119
|
+
try {
|
|
120
|
+
const r = await fetch(`${BASE}/mcp`, { method: "POST", headers: { "content-type": "application/json" }, body: line });
|
|
121
|
+
if (r.status === 202) continue;
|
|
122
|
+
process.stdout.write(JSON.stringify(await r.json()) + "\n");
|
|
123
|
+
} catch (e) {
|
|
124
|
+
const id = (() => { try { return JSON.parse(line).id; } catch { return null; } })();
|
|
125
|
+
if (id != null) process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id, error: { code: -32000, message: e.message } }) + "\n");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (cmd === "init") {
|
|
131
|
+
const entry = { url: `${BASE}/mcp` };
|
|
132
|
+
// Run through npx when we were started by npx (its cache can be cleared); otherwise run this very file.
|
|
133
|
+
const viaNpx = /[\\/]_npx[\\/]/.test(process.argv[1] || "");
|
|
134
|
+
const stdio = viaNpx ? { command: "npx", args: ["-y", "oddityrh", "mcp"], env: { ODDITY_URL: BASE } } : { command: process.execPath, args: [path.resolve(process.argv[1]), "mcp"], env: { ODDITY_URL: BASE } };
|
|
135
|
+
const home = os.homedir();
|
|
136
|
+
const targets = [
|
|
137
|
+
["Claude Code", path.join(home, ".claude.json"), { type: "http", ...entry }],
|
|
138
|
+
["Cursor", path.join(home, ".cursor", "mcp.json"), entry],
|
|
139
|
+
["Claude Desktop", process.platform === "darwin" ? path.join(home, "Library", "Application Support", "Claude", "claude_desktop_config.json") : process.platform === "win32" ? path.join(process.env.APPDATA || "", "Claude", "claude_desktop_config.json") : path.join(home, ".config", "Claude", "claude_desktop_config.json"), stdio],
|
|
140
|
+
];
|
|
141
|
+
for (const [name, file, cfg] of targets) {
|
|
142
|
+
if (!fs.existsSync(path.dirname(file))) {
|
|
143
|
+
console.log(` skip ${name} (not installed)`);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
let j = {};
|
|
147
|
+
if (fs.existsSync(file)) {
|
|
148
|
+
try {
|
|
149
|
+
j = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
150
|
+
} catch {
|
|
151
|
+
console.log(` skip ${name} (config is not valid JSON, left untouched)`);
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (!fs.existsSync(file + ".oddity-bak")) fs.copyFileSync(file, file + ".oddity-bak");
|
|
155
|
+
}
|
|
156
|
+
j.mcpServers = { ...(j.mcpServers || {}), oddity: cfg };
|
|
157
|
+
fs.writeFileSync(file, JSON.stringify(j, null, 2));
|
|
158
|
+
console.log(` added ${name} → ${file}`);
|
|
159
|
+
}
|
|
160
|
+
console.log("\nRestart your client, then ask it: “list the best Polymarket price gaps”.");
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
console.log(HELP);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
main().catch((e) => {
|
|
167
|
+
console.error(`oddity: ${e.message}`);
|
|
168
|
+
process.exit(1);
|
|
169
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oddityrh",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
}
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Oddity in your terminal: Polymarket markets priced by a real model, price gaps after fees, arbitrage, fine-print traps, Kelly slates, wallet checks, and an MCP bridge for AI agents.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": { "oddity": "oddity.js" },
|
|
7
|
+
"files": ["oddity.js", "README.md"],
|
|
8
|
+
"engines": { "node": ">=18" },
|
|
9
|
+
"keywords": ["polymarket", "prediction-markets", "odds", "arbitrage", "kelly", "mcp", "cli", "ai-agents", "oddity"],
|
|
10
|
+
"homepage": "https://oddityrh.trade",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"scripts": { "prepack": "cp ../bin/oddity.js ./oddity.js && chmod +x ./oddity.js" }
|
|
13
|
+
}
|