← All projects
PROJECT 01 / Market microstructure / Paper trading

NegRisk Arbitrage Lab

When the prices do not add up, does the trade still work?

  • Python
  • FastAPI
  • SQLite
  • WebSockets
View source ↗
N / NegRisk LabRECORDED FIXTURE
BASKET RESEARCH

One event. Three outcomes.

Mirassol FC vs. CR Flamengo

16 AUG 2026
OutcomeYES askShares
Mirassol FC$0.105.50
Draw$0.2613.00
CR Flamengo$0.53988.97
Combined YES ask$0.89
AFTER COSTS
$0.079/ share

Estimated net edge in this fixture

Fees$0.02658
Slippage buffer$0.00445
Depth cap5.5 shares
DiscoverPrice the basketRevalidatePaper execution

Historical quote illustration · estimated edge is not realized profit

01

Overview

NegRisk Arbitrage Lab asks whether inconsistent prices across mutually exclusive prediction-market outcomes remain actionable after execution constraints. It discovers Polymarket baskets, maintains their order books, and compares two routes in isolated paper accounts.

02

Problem

A basket can appear underpriced without offering a practical trade. Fees reduce the edge, the thinnest leg limits size, and a position held for settlement ties up capital. A positive closed-trade result can also hide losses in unresolved inventory.

03

Approach

Separate discovery, quote calculation, and simulation. Public Gamma metadata defines the outcome set; CLOB REST and WebSocket data supply prices. A candidate must survive a fresh REST repricing before the simulator records a fill.

04

How it works

The scanner evaluates NO-share combinations. Converting m selected NO legs returns (m − 1) shares of collateral plus YES shares for each unselected outcome. The simulator sells the resulting YES legs, starting with the thinnest bid. An alternative strategy buys every YES outcome and holds for resolution.

  1. 01Gamma event discovery
  2. 02CLOB books & updates
  3. 03Basket pricing
  4. 04REST revalidation
  5. 05Paper fills & SQLite
05

Strategy & methodology

Instant-conversion accounts use 0.5%, 1%, and 2% minimum net-edge thresholds. Buy-All-YES accounts use 0.5% and 2%. Sizing is capped by available cash, the weakest required ask or bid, and minimum-order constraints.

The model applies the configured taker-fee curve and a 0.5% slippage buffer. Incomplete or augmented hold baskets, malformed books, duplicate snapshots, and insufficient liquidity are rejected. Unsold conversion outputs remain open fallback positions.

06

Implementation

Python modules separate quote arithmetic (negrisk.py), stream updates (market_stream.py), scanning, simulation, and SQLite persistence. FastAPI serves the local API and dashboard; HTTPX and websockets handle public market feeds.

The included public fixture contains a three-outcome basket with a $0.89 raw ask cost. Fees and the slippage buffer reduce its estimated edge to $0.07897 per share, with a 5.5-share depth cap. This is a quote calculation, not realized performance.

07

Results & output

The retained 54.35-hour experiment contains 3,607 decisions and 31 paper trades. Combined mark-to-market P&L was −$24.54334 across five independent accounts. Seventeen closed trades were positive, but 14 open trades carried −$26.02317 in unrealized P&L.

The experiment_summary.json export preserves the aggregate results. Thin liquidity limited instant-conversion gains, while unresolved Buy-All-YES holdings dominated the combined loss.

Observation window54.35 hours
Recorded decisions3,607
Paper trades31
Combined MTM return−0.49%

16–18 August 2026 · five independent paper accounts · 14 trades unresolved at the end. This short sample does not establish a deployable strategy.

08

Technical challenges

Execution depends on both entry and exit depth. Fresh repricing and explicit fallback positions prevent the simulator from silently assuming that every quoted exit can fill.

Top-of-book fills still omit queue position, market impact, shared liquidity consumption, and explicit network latency. The retained decision data are not a complete raw-book replay archive.

09

Takeaways

The project demonstrates cost-aware basket pricing and careful separation of realized and unrealized outcomes. Its strongest finding is that a visible price discrepancy and a profitable executable strategy are different claims.

CONTINUE EXPLORING

PulseForge

All selected work ↑