The Claude Quant PlaybookDownload ebookDownload ebook

Bayes' theorem

intermediateProbability2 of 12

Bayes' theorem turns the chance of the evidence given the hypothesis into the chance of the hypothesis given the evidence. It weighs how well the evidence fits against how rare the hypothesis was to begin with.

Build a trading system with Claude.Download ebook

01The formula

the hypothesis, here: the strategy has a real edge
the evidence, here: the strategy passed the backtest
the prior: how common real edges are before you look at any test
the sensitivity: the chance a real edge passes the test
the false-positive rate: the chance a strategy with no edge passes anyway
the posterior: the chance of a real edge once you know it passed

02See it move

03Where it is used

04Why traders use it

Most new strategy ideas have no edge, so even a good test produces many false alarms. Bayes tells you how many of the strategies that pass are really any good, which is usually far fewer than the test's accuracy suggests.

05Worked example

Suppose 10% of the strategies you test have a real edge, the backtest passes 80% of those, and it also passes 10% of the ones with no edge. Then a strategy that passes has a real edge only 47.1% of the time. Out of 1,000 tested, 90 pass with no edge at all.

06How it is built

  1. Write the joint chance two ways: .
  2. Divide by : .
  3. Expand with the law of total probability: the evidence comes either from or from not-.
  4. In counts: of 1,000 strategies, true positives are , false positives , and the posterior is true positives over all positives.

07The common mistake

Ignoring the prior (base-rate neglect). A test that is right 80% or 90% of the time does not make a passing strategy 80% or 90% likely to be real. When real edges are rare, false positives outnumber true ones.

08In Python and LaTeX

prior, sens, fpr = 0.10, 0.80, 0.10
tp = prior * sens
fp = (1 - prior) * fpr
print('P(edge | passed) =', round(tp / (tp + fp), 4))  # 0.4706
P(H \mid E) = \frac{P(E \mid H)\,P(H)}{P(E \mid H)\,P(H) + P(E \mid \neg H)\,P(\neg H)}

09Where it fits

Rather not code the maths yourself? Describe your trading idea and let AI build the bot.

Build a bot with AgenKit

The worked example and the model run the same code, so every number matches. Models simplify markets on purpose. This is education, not financial advice.