At any moment, you have:
- Current market state (crypto, price, time remaining)
- Probability matrix with historical win rates
Your goal: Look up the historical data for this exact situation.
Inputs:
crypto_type: BTC, ETH, or SOL (from market ticker)current_price: Token1's current market price ($0.00-$1.00)time_to_close_sec: Seconds remaining until market closes
Calculate:
# Time window (based on time remaining, not market duration)
if time_to_close_sec < 3600: # Less than 1 hour
time_window = "<1hr"
elif time_to_close_sec < 21600: # 1-6 hours
time_window = "1-6hr"
elif time_to_close_sec < 86400: # 6-24 hours
time_window = "6-24hr"
else:
time_window = ">24hr"
# Price bucket (0-19, representing $0.05 ranges)
price_bucket = floor(current_price / 0.05)
# Bucket 0 = $0.00-$0.05
# Bucket 1 = $0.05-$0.10
# ...
# Bucket 19 = $0.95-$1.00Query the matrix for:
matrix[crypto_type, time_window, price_bucket]
Returns:
token1_prob: Historical win rate for Token1 (0-1)token2_prob: Historical win rate for Token2 (0-1)sample_size: Number of historical trades in this celltoken1_prob_ci_lower/upper: 95% confidence interval bounds
For Token1:
token1_price = current_price
EV_token1 = token1_prob - token1_priceFor Token2:
token2_price = 1.00 - token1_price # Binary market: prices sum to $1
EV_token2 = token2_prob - token2_priceInterpretation:
- EV > 0: Market is underpricing this token (opportunity!)
- EV < 0: Market is overpricing this token (avoid)
- EV ≥ $0.10: Strong edge (strategy threshold)
Check if each token meets BOTH criteria:
EV ≥ $0.10(minimum edge threshold)sample_size ≥ 50(minimum confidence)
IF Token1 qualifies AND Token2 qualifies:
→ Enter "Long Both" (hedge position)
ELSE IF Token1 qualifies ONLY:
→ Enter "Long Token1" (directional)
ELSE IF Token2 qualifies ONLY:
→ Enter "Long Token2" (directional)
ELSE:
→ Skip market (no edge)
Market State:
- Crypto: BTC
- Market type: 15-minute
- Time remaining: 8 minutes (480 seconds)
- Token1 ("Up") price: $0.42
- Token2 ("Down") price: $0.58
Step 3.1: Determine cell coordinates
crypto_type = "BTC"
time_window = "<1hr" # 480 sec < 3,600 sec
price_bucket = floor(0.42 / 0.05) = 8 # Bucket 8 = $0.40-$0.45
Step 3.2: Look up historical data
Query: matrix[BTC, <1hr, 8]
Returns:
token1_prob = 0.5500 (55%)
token2_prob = 0.4500 (45%)
sample_size = 35,000
Step 3.3: Calculate EV
Token1: EV = 0.55 - 0.42 = $0.13 ✓
Token2: EV = 0.45 - 0.58 = -$0.13 ✗
Step 4: Check qualification
Token1: EV=$0.13 ≥ $0.10 ✓, samples=35,000 ≥ 50 ✓ → QUALIFIES
Token2: EV=-$0.13 < $0.10 ✗ → DOES NOT QUALIFY
Decision: Enter Long Token1 only (directional bet)
Market State:
- Crypto: ETH
- Market type: 4-hour
- Time remaining: 2 hours 15 minutes (8,100 seconds)
- Token1 price: $0.45
- Token2 price: $0.55
Step 3.1: Determine cell coordinates
crypto_type = "ETH"
time_window = "1-6hr" # 8,100 sec is between 3,600 and 21,600
price_bucket = floor(0.45 / 0.05) = 9 # Bucket 9 = $0.45-$0.50
Step 3.2: Look up historical data
Query: matrix[ETH, 1-6hr, 9]
Returns:
token1_prob = 0.6000 (60%)
token2_prob = 0.4000 (40%)
sample_size = 2,000
Step 3.3: Calculate EV
Token1: EV = 0.60 - 0.45 = $0.15 ✓
Token2: EV = 0.40 - 0.55 = -$0.15 ✗
Step 4: Check qualification
Token1: EV=$0.15 ≥ $0.10 ✓, samples=2,000 ≥ 50 ✓ → QUALIFIES
Token2: EV=-$0.15 < $0.10 ✗ → DOES NOT QUALIFY
Decision: Enter Long Token1 only
Market State:
- Crypto: SOL
- Market type: 4-hour
- Time remaining: 40 minutes (2,400 seconds)
- Token1 price: $0.40
- Token2 price: $0.60
Step 3.1: Determine cell coordinates
crypto_type = "SOL"
time_window = "<1hr" # 2,400 sec < 3,600 sec
price_bucket = floor(0.40 / 0.05) = 8 # Bucket 8 = $0.40-$0.45
Step 3.2: Look up historical data
Query: matrix[SOL, <1hr, 8]
Returns:
token1_prob = 0.5200 (52%)
token2_prob = 0.4800 (48%)
sample_size = 8,000
Step 3.3: Calculate EV
Token1: EV = 0.52 - 0.40 = $0.12 ✓
Token2: EV = 0.48 - 0.60 = -$0.12 ✗
Wait, Token2 doesn't qualify! Let me recalculate Token2's price:
Actually, if Token1 = $0.40, then Token2 must be trading separately.
Let me redo this with a proper "Long Both" scenario:
Corrected Market State:
- Token1 price: $0.42
- Token2 price: $0.35
- Combined cost: $0.77
Step 3.3: Calculate EV (corrected)
Token1: EV = 0.52 - 0.42 = $0.10 ✓
Token2: EV = 0.48 - 0.35 = $0.13 ✓
Step 4: Check qualification
Token1: EV=$0.10 ≥ $0.10 ✓, samples=8,000 ≥ 50 ✓ → QUALIFIES
Token2: EV=$0.13 ≥ $0.10 ✓, samples=8,000 ≥ 50 ✓ → QUALIFIES
Decision: Enter Long Both (hedge position)
- Buy Token1 at $0.42
- Buy Token2 at $0.35
- Combined cost = $0.77 → Guaranteed profit of $0.23 (29.9% ROI)
Market State:
- Crypto: BTC
- Time remaining: 5 minutes
- Token1 price: $0.48
- Token2 price: $0.52
Step 3: Query matrix
matrix[BTC, <1hr, 9]
Returns:
token1_prob = 0.5023 (50.23%)
token2_prob = 0.4977 (49.77%)
sample_size = 39,482
Calculate EV:
Token1: EV = 0.5023 - 0.48 = $0.0223 ✗ (below threshold)
Token2: EV = 0.4977 - 0.52 = -$0.0223 ✗ (negative)
Decision: Skip market (no edge)
15-minute markets:
- Always fall in
<1hrbucket (max 15 mins remaining) - Matrix cell:
[crypto, <1hr, price_bucket]
4-hour markets:
- First 3 hours:
1-6hrbucket (240-60 mins remaining) - Final hour:
<1hrbucket (60-0 mins remaining) - Matrix cells:
[crypto, 1-6hr, bucket]OR[crypto, <1hr, bucket]
This explains why:
<1hrwindow has 47 cells (mix of 15-min + 4-hour final hour)1-6hrwindow has 50 cells (4-hour early life only)6-24hrwindow has 16 cells (if daily markets exist)
In a binary prediction market, theoretically:
token1_price + token2_price = $1.00
But in practice on Polymarket:
- Orderbook spreads create gaps
- Token1 best ask = $0.42, Token2 best ask = $0.60
- Sum = $1.02 (market maker profit = $0.02)
This is why "Long Both" opportunities exist:
- When
combined_cost < $1.00, guaranteed arbitrage - When both tokens have
EV ≥ $0.10, strong statistical edge
Step 3: Look up historical win rates for current (crypto, time_window, price_bucket)
Step 4: Check if EV ≥ $0.10 and samples ≥ 50 for each token
- Both qualify → Long Both (hedge)
- One qualifies → Directional bet
- Neither qualifies → Skip
Critical: Time windows are based on time remaining, not market type:
- 15-min markets → always
<1hr - 4-hour markets →
1-6hrearly,<1hrlate