Bet Sizes

Calculate López de Prado’s bet size for meta-labelled bets: how much of the budget to put on each date, from -1 (fully short) to 1 (fully long).

It follows from the sides of the bets a primary model takes and, for the probability bet size, how often its bets have paid off. A model that only says which side to take does not say how much to bet; sizing the bets keeps a strategy from betting the same on a weak signal as on a strong one.

  • Budget bet size: the open long bets as a share of the most long bets ever open, minus the same share of the short bets, a size that spreads the budget over the bets the strategy usually has open.
  • Reserve bet size: the net number of open bets (long minus short) against how many the strategy usually has open, through a mixture of two normal distributions fitted to it with the EF3M algorithm (López de Prado and Foreman, 2014). An unusually large net count gives a bet close to 1 and a usual one a small bet, keeping a reserve for stronger signals.
  • Probability bet size: every bet sized by the probability that it pays off, taken as the hit rate of the bets closed before it was placed (the share whose meta-label is 1), and the sizes averaged over the bets still open. A hit rate of 50% or less gives no bet.

The formula is as follows, per method:

  • Long Bets_t and Short Bets_t, the bets open on t: placed on or before t and closing after t, Holding Period periods after they were placed
\[\text{Budget bet size:}\;\; m_{t} = \frac{\text{Long Bets}_{t}}{\max(\text{Long Bets})} - \frac{\text{Short Bets}_{t}}{\max(\text{Short Bets})}\] \[\text{Reserve bet size:}\;\; c_{t} = \text{Long Bets}_{t} - \text{Short Bets}_{t},\;\; F \text{ the mixture of two normal distributions that matches the first five moments of } c_{t} \text{ on the dates bets are placed},\;\; \text{and}\;\; m_{t} = \frac{F(c_{t}) - F(0)}{1 - F(0)} \;\text{when}\; c_{t} \geq 0,\;\; \frac{F(c_{t}) - F(0)}{F(0)} \;\text{otherwise}\] \[\text{Probability bet size:}\;\; p = \text{the hit rate known when bet}\; i \;\text{is placed},\;\; z_{i} = \frac{p - 0.5}{\sqrt{p \cdot (1 - p)}}\;\;\text{and}\;\; m_{i} = \text{side}_{i} \cdot (2 \cdot N(z_{i}) - 1) \;\text{when}\; p > 0.5,\;\; \text{else 0};\;\; m_{t} = \text{the average of}\; m_{i} \;\text{over the bets open on}\; t \;(0 \;\text{without an open bet})\] \[\text{with a step\_size:}\;\; m^{*}_{t} = \operatorname{round}\left(\frac{m_{t}}{\text{step\_size}}\right) x \text{step\_size},\;\; \text{capped at -1 and 1}\]

Where N is the standard normal distribution function. The bets come from the meta-labels: the Side is the side of a bet, the Holding Period the periods until it closes at a barrier and the Label (1 or 0) whether it made money.

Also known as: bet sizing, position sizing from meta-labels, budget bet size, reserve bet size, EF3M, bet size from predicted probabilities.

Example · AAPL, MSFT · 2024 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_bet_sizes:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["AAPL", "MSFT"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2024-01-01",
    end_date="2025-12-31",
)

bet_sizes = toolkit.technicals.get_bet_sizes(method="reserve")

bet_sizes.xs("AAPL", level=1, axis="columns")

Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:

How large a position did the reserve method of bet sizing take in Apple on each day of 2025?

Which returns:

Parameters

get_bet_sizes accepts the following parameters.

ParameterTypeDescriptionExample
methodstrThe bet size. Options are: “budget” (the budget bet size), “reserve” (the reserve bet size), “probability” (the probability bet size). Defaults to “budget”."budget"
labelspd.DataFrame | NoneMeta-labels with a Side, Holding Period and Label per date and ticker, such as the result of get_triple_barrier_labels with a side. Defaults to None, which uses the triple-barrier meta-labels of the CUSUM filter’s events with the direction of each event as the side (a trend-following primary model) and the other defaults.None, which uses the triple-barrier meta-labels of the CUSUM filter's events with the direction of each event as the side (a trend-following primary model) and the other defaults
step_sizefloat | NoneThe step the bet sizes are rounded to, between 0 and 1, so small changes of the size do not trade. Defaults to None, which keeps them unrounded.None, which keeps them unrounded
minimum_labelsintThe number of closed bets the hit rate of “probability” needs before it sizes a bet; earlier bets are left out. Defaults to 20.20
runsintThe number of random starting points of the EF3M fit of “reserve”. Defaults to 100.100
seedintThe seed of the starting points of the EF3M fit. Defaults to 0.42
periodstrThe time period of the labels. Options are: “intraday” (intraday prices), “daily” (daily prices), “weekly” (weekly prices), “monthly” (monthly prices), “quarterly” (quarterly prices), “yearly” (yearly prices). Defaults to “daily”."weekly"
close_columnstrThe column name for closing prices in the historical data. Defaults to “Adj Close”."Close"
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise).2
show_columnsstr | list[str] | NoneThe columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column.None, which keeps every column

References

  • Paper López de Prado, M. (2018). “Advances in Financial Machine Learning.” Wiley, chapter 10 (Snippets 10.1 to 10.3).
  • Paper López de Prado, M. and Foreman, M. (2014). “A mixture of two Gaussians approach to mathematical portfolio oversight: the EF3M algorithm.” Quantitative Finance, 14(5), 913-930.
  • Library Referenced against RiskLabAI’s probability_bet_size
  • Library Referenced against RiskLabAI’s avg_active_signals
Share