Skip to content

Getting started

Whale ships as a reef package. Install it from the Chelis-Lang GitHub org:

Terminal window
chelis reef install --from-github Chelis-Lang/whale@v0.1.13

This pulls Whale and its transitive dependencies (chelis-std 0.4.0, shoals 0.21.4) into your local reef cache.

A minimal example that computes the optimal stake fraction using the Kelly criterion.

import Whale.Sizing exposing (kelly)
import Whale.Types exposing (Probability, Odds)
let win_prob : Probability = Probability.from_float 0.55
let decimal_odds : Odds = Odds.decimal 2.10
let fraction = kelly win_prob decimal_odds
-- fraction ≈ 0.0738 (stake 7.38% of bankroll)

kelly returns a StakeFraction value. The caller decides whether to apply it directly or pass it through a fractional or capped variant before sizing the actual stake in currency units.

  • Sizing covers all Kelly variants and simultaneous multi-bet sizing.
  • Bankroll shows how to track balances and enforce drawdown limits.
  • Risk and policy explains the guardrail and policy layers.
  • Backtesting walks through strategy evaluation.