Skip to content

About

Polymarket trading bot driven by Jev (TypeSafe AI) via OpenRouter

Resources

Contributing

Security policy

Stars

18 stars

Watchers

0 watching

Forks

Repository files navigation

jevymarket

CI License: MIT Python 3.12+

A Polymarket trading bot whose pricing oracle is Jev, TypeSafe AI's "System One" decision model, called through OpenRouter's Decisions API.

Jev is not a chat model. You hand it a JSON state and typed questions; it returns calibrated probabilities — no prose, no chain of thought, ~100 ms, ~$0.00003 per decision. The catch: it has no browsing and a training cutoff, so on its own it (correctly) refuses to price news-driven markets. This bot pairs it with a cheap researcher — a generative model with web search — that writes a dated, sourced evidence brief into the state. Jev then makes the calibrated call, and the bot trades where Jev's probability beats the order book by a configurable edge.

This is experimental software that places real orders with real money. Read Disclaimer and Security before running it live.

How a decision is made

 scan ──▶ research ──▶ state ──▶ Jev ──▶ evaluate ──▶ execute ──▶ log
 Gamma    DeepSeek +    compact   3 typed  edge, band,   GTC limit   SQLite
 filters  web search    JSON      answers  Kelly, gates  + hard caps
  1. Scan (markets.py) — open markets by 24h volume, filtered by liquidity, volume, days-to-resolution, spread, price band, and Yes/No outcome labels.
  2. Research (research.py) — a chat model via OpenRouter's web plugin (default deepseek/deepseek-v4-pro-0813, ≈ $0.015 per brief) returns strict JSON: dated key facts, latest development, considerations for/against YES, sources. Odds sites are excluded from search so Jev never sees market prices as "evidence". Briefs are cached in SQLite for RESEARCH_TTL_HOURS.
  3. State — question, truncated description, today, days_until_resolution (pre-computed: Jev is bad at date math), resolution_source, market_implied_probability_yes, evidence.
  4. Ask Jev (signal.py, one call, three questions):
    • resolves_yes (noul) → P(YES)
    • answerable (noul) → is there enough current, relevant information in the state to form a well-informed estimate? (information sufficiency, not certainty)
    • clarity (score 0–4) → how objective the resolution criteria are
  5. Evaluate (signal.evaluate, pure) — skip unless answerable and clear; only buy contracts priced inside [MIN_TRADE_PRICE, MAX_TRADE_PRICE]; require p − ask ≥ MIN_EDGE; size with fractional Kelly, capped.
  6. Execute (executor.py) — GTC limit order at the best ask, only if every hard cap passes: per-trade $, total open exposure $, trades per run, one position per market.
  7. Log (store.py) — every brief, decision and order in jevymarket.db, so Jev's calibration can be checked against resolutions later.

Measured on a live market (Sept 2026): without the brief Jev reported answerable=0.27; with it, 0.78. The researcher is what makes Jev usable here.

Install

git clone https://github.com/markusbug/jevymarket && cd jevymarket
uv sync
cp .env.example .env    # fill in OPENROUTER_API_KEY, POLYMARKET_PRIVATE_KEY (+ POLYMARKET_WALLET)
  • OpenRouter: one key covers Jev and the researcher. Jev has no free tier; the account needs prepaid credits.
  • Polymarket: see Funding, then uv run jevymarket setup once for the on-chain approvals.

Commands

uv run jevymarket jev-test                 # one Jev call; verifies the key + response schema
uv run jevymarket scan -n 15               # candidate markets with live best bid/ask
uv run jevymarket research <slug|url>      # researcher only: print the evidence brief (--fresh)
uv run jevymarket decide <slug|url>        # research + Jev + proposed trade, no order
uv run jevymarket run --dry-run            # full pipeline, logs intended orders only
uv run jevymarket run --max-trades 1       # LIVE: at most one real order this pass
uv run jevymarket run --loop 900           # LIVE: repeat every 15 minutes
uv run jevymarket setup                    # one-time exchange approvals
uv run jevymarket positions                # pUSD balance, positions, open orders, exposure
uv run jevymarket stats                    # decision counts, spend, calibration buckets

run is live by default; --dry-run evaluates and logs but never places orders. --no-research skips the researcher (Jev alone — expect near-zero trades).

Configuration (.env)

var default meaning
JEV_MODEL typesafe/jev-1.13 pin a Jev version; typesafe/jev-latest also works
RESEARCH_MODEL deepseek/deepseek-v4-pro-0813 any OpenRouter chat model; see below
RESEARCH_TTL_HOURS 6 reuse a cached brief for this long
MAX_RESEARCH_PER_RUN 20 hard cap on researcher calls per pass
MIN_EDGE 0.08 required P_jev − best ask
MIN_ANSWERABLE 0.70 Jev's belief the state has enough information
MIN_CLARITY 2 0–4 rubric score of resolution criteria
MIN_TRADE_PRICE / MAX_TRADE_PRICE 0.10 / 0.90 only buy contracts priced in this band
MAX_USD_PER_TRADE 5 per-order notional cap
MAX_OPEN_EXPOSURE_USD 50 positions + open buy orders may not exceed this
MAX_TRADES_PER_RUN 3 orders per run pass
KELLY_FRACTION 0.25 fraction of full Kelly used for sizing

Researcher models. Any OpenRouter chat model works. Models without native search get OpenRouter's Exa fallback ($0.007/search), which supports the odds-site exclusion list. Tested: deepseek/deepseek-v4-pro-0813 (default), z-ai/glm-5.3, qwen/qwen3.8-max-0902, moonshotai/kimi-k3; anthropic/claude-sonnet-5 for native search at ~2× the cost.

Costs (Sept 2026): Jev ≈ $0.00006 per decision with evidence; brief ≈ $0.010–0.020; a 20-market pass ≈ $0.20–0.40 before caching.

Funding

Since the April 2026 exchange upgrade Polymarket settles in pUSD (0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB, Polygon), a 1:1 USDC-backed wrapper — not USDC.e and not native USDC.

  1. Via polymarket.com (easiest). Deposit on the site; it lands as pUSD in your Polymarket wallet. Put the private key of the wallet you log in with in POLYMARKET_PRIVATE_KEY and your Polymarket wallet address in POLYMARKET_WALLET. The SDK detects the wallet type.
  2. Raw EOA. Hold USDC.e (0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174), approve the CollateralOnramp (0x93070a847efEf7F70739046A929D47a521F5B8ee) and call wrap(USDC_E, you, amount). Keep a little POL for gas.

jevymarket positions shows the pUSD balance the exchange sees.

Known limitations

  • Longshot bias. Jev tends to be less confident than the market at the extremes, which shows up as "edge" on 5-cent contracts. The trade band (MIN_TRADE_PRICE) is the guard; widen it only with data from stats.
  • Edge ≠ profit. Limit orders at the ask are taker orders; adverse selection and stale briefs eat into an 8 % threshold. Start with --dry-run, watch stats, then trade small.
  • No exits. Positions are held to resolution. No stop-loss, no re-pricing on new evidence.
  • Beta endpoint. OpenRouter's decisions API is in beta; jev.Answer is tolerant to field naming, but re-run jev-test after a Jev version bump.
  • Jev interprets literally and degrades with irrelevant context — keep the state small.

Disclaimer

This software is provided for educational and research purposes. It is not financial advice. Prediction markets involve risk of total loss; you are solely responsible for your trades, for complying with Polymarket's terms of service and with the laws of your jurisdiction. The authors accept no liability for losses. See LICENSE.

Security

See SECURITY.md. Short version: dedicated low-balance wallet, never commit .env, the exposure caps are the only brake.

Layout

src/jevymarket/
  config.py     settings (.env)          signal.py    Jev questions, gates, edge + sizing (pure)
  jev.py        OpenRouter Decisions     research.py  researcher (web search → Brief)
  markets.py    scan / filter / state    executor.py  caps + order placement
  store.py      SQLite log + cache       cli.py       typer commands
tests/          mocked Jev + researcher, signal math, store

Troubleshooting

  • uv sync hangs with pyenv installed: uv probes the pyenv python shim, which can block. Use UV_PYTHON=/usr/bin/python3.12 uv sync.
  • Unknown block during setup: the public Polygon RPC hiccuped; setup retries and skips approvals already granted.
  • Invalid private_key … 20 bytes: you pasted an address. The key is 32 bytes (64 hex chars).

Contributing

See CONTRIBUTING.md. Roadmap: exit logic, calibration report, alternative researchers behind the same Brief interface.

License

MIT © 2026 Markus Haas

About

Polymarket trading bot driven by Jev (TypeSafe AI) via OpenRouter

Resources

Contributing

Security policy

Stars

18 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages