Skip to main content
Pro Feature. Requires a Pro or Ultra subscription. Get started at api.mathematicalcompany.com

Robustness Testing

Three statistical tests designed specifically for prediction markets. They answer a question every trader must ask: “Is my edge real, or did I just get lucky?”

Event Permutation

Shuffle which outcomes map to which markets. Tests whether your market selection was skillful.

Outcome Randomization

Keep trades fixed, re-draw binary outcomes from Bernoulli(p). Tests whether you got lucky on resolutions.

Path Simulation

Shuffle trade ordering to test if your drawdown and loss streaks were unusually good or bad.

Quick Start

Output:

Event Permutation Test

Tests whether your strategy’s market selection was genuinely skillful. Since prediction market events are independent, the order in which outcomes resolve shouldn’t matter if your edge is real. This test shuffles which outcomes map to which markets and recomputes PnL. If your observed PnL is in the upper tail of the permuted distribution, your selection was skillful (not lucky).

Signature

Example

PermutationTestResult

Let Π\Pi be the set of all permutations of outcome assignments. For each permutation σΠ\sigma \in \Pi:PnLσ=mPnL(m,σ(om))\text{PnL}_\sigma = \sum_m \text{PnL}(m, \sigma(o_m))The p-value is computed conservatively:p=#{σ:PnLσPnLobserved}+1N+1p = \frac{\#\{\sigma : \text{PnL}_\sigma \geq \text{PnL}_{\text{observed}}\} + 1}{N + 1}Under H0H_0 (no selection skill), the observed PnL should be typical of the permuted distribution. A small p-value rejects H0H_0.

Outcome Randomization

Tests whether your realized outcomes were luckier than expected given market pricing. Keeps every trade exactly as-is (same prices, sizes, timing). For each simulation, re-draws each market’s binary outcome from Bernoulli(p) where p is the market’s implied probability (average buy price). If your strategy has genuinely better calibration than the market, your real PnL will sit in the upper tail.

Signature

Example

OutcomeRandomizationResult

For closed round-trips (buy then sell before expiry), the PnL is fixed regardless of the final outcome. Only open positions held to resolution contribute to variance across simulations.For each simulation ii:
  1. For each market mm, draw om(i)Bernoulli(pm)o_m^{(i)} \sim \text{Bernoulli}(p_m) where pmp_m is the implied probability
  2. Compute resolution PnL from open positions using om(i)o_m^{(i)}
  3. Total PnL = (fixed round-trip PnL) + (random resolution PnL)
This decomposition makes the simulation very fast: only open positions contribute to the variance across simulations.
If all your positions are closed before resolution, every simulation produces the same PnL. In that case, outcome randomization is uninformative — use the permutation test instead.

PnL Path Simulation

Tests whether your drawdown and loss streaks were unusually good or bad. Total PnL is invariant to ordering (same sum), but path-dependent statistics like max drawdown and consecutive losses depend heavily on which order trades occurred. This test shuffles the order of round-trip PnLs and computes a distribution of these path statistics.

Signature

Example

PathSimulationResult

Consider two sequences of trade PnLs: [+10, +10, -5, -5] and [-5, -5, +10, +10].Both have the same total PnL (+10), but:
  • Sequence 1: max drawdown = 10 (peak at +20, trough at +10)
  • Sequence 2: max drawdown = 10 (peak at 0, trough at -10)
With real trade sequences containing dozens or hundreds of trades, the variance in max drawdown across orderings can be substantial. Path simulation tells you where your actual sequence falls in this distribution.

Convenience Wrapper

Run all three tests with a single call:
Or call it directly on the result:
The wrapper automatically skips tests that require unavailable data:
  • permutation and outcome require outcomes with >= 2 markets
  • path requires at least 1 trade

RobustnessReport


Interpreting Results

p-values

Which test tells you what

  1. Run all three tests with >= 1000 simulations
  2. If permutation test fails: your market selection may be random
  3. If outcome test fails: your calibration edge may not be real
  4. If path test shows unfavorable drawdown: size down — your worst drawdown is likely ahead
A passing robustness test does not guarantee future profitability. It only confirms that your backtest results are unlikely to be explained by luck alone. Out-of-sample validation via walk-forward optimization remains essential.