Class Ucb1Selector
java.lang.Object
com.quantfinlib.execution.Ucb1Selector
UCB1 multi-armed bandit — principled selection among venues, LPs or
algo variants when the scorecards are still THIN. The exploration
problem is real: always using the best-so-far venue means never
learning whether another improved; rotating uniformly wastes flow on
known-bad ones. UCB1 (Auer et al. 2002) picks the arm maximizing
mean reward + √(2·ln N / nᵢ)— the optimism bonus shrinks as an arm is tried, so exploration decays exactly as fast as the evidence accumulates, with logarithmic regret guaranteed. Rewards must be in [0, 1] (the theory's scale — map fill quality, negated cost bps, or markout onto it; the gate enforces it because a mis-scaled reward silently breaks the exploration balance).
Where this sits vs the scorecards: VenueScorecard and
fx.LpScorecard are the RIGHT tool once hundreds of fills per
venue exist — they model fill rate, latency and markout separately.
UCB1 is for the cold start and for A/B-ing ALGO variants (is the
new schedule actually better?), where a single scalar reward and a
regret guarantee beat a half-warmed-up model. Deterministic
(ties break to the lowest index), O(arms) per selection,
allocation-free after construction. Research/warm lane.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublemeanReward(int arm) The arm's observed mean reward (NaN before its first pull).longpulls(int arm) Times an arm has been used.voidrecord(int arm, double reward) Records the observed reward for an arm.intselect()The arm to use next: each arm once first (in index order), then highest upper confidence bound, ties to the lowest index.long
-
Constructor Details
-
Ucb1Selector
public Ucb1Selector(int arms) - Parameters:
arms- number of venues/variants, ≥ 2
-
-
Method Details
-
select
public int select()The arm to use next: each arm once first (in index order), then highest upper confidence bound, ties to the lowest index. -
record
public void record(int arm, double reward) Records the observed reward for an arm.- Parameters:
arm- the arm that was usedreward- in [0, 1] — the UCB1 theory's scale; rescale upstream, never here
-
pulls
public long pulls(int arm) Times an arm has been used. -
meanReward
public double meanReward(int arm) The arm's observed mean reward (NaN before its first pull). -
totalPulls
public long totalPulls()
-