Bankroll
The Whale.BankRoll module tracks bankroll state and enforces drawdown
constraints. Balances are represented as Shoals.Money values, so
denomination and rounding are handled by the Shoals currency layer.
Core types
Section titled “Core types”import Whale.BankRoll exposing (BankRoll, Allocation)
let roll = BankRoll.init (Money.usd 10_000.00)A BankRoll carries the current balance, the high-water mark, and a
history of deposits and withdrawals.
Applying bets
Section titled “Applying bets”let sized_stake = BankRoll.stake roll fraction-- sized_stake : Money (the currency amount for this bet)
let roll_after_loss = BankRoll.record_loss roll sized_stakelet roll_after_win = BankRoll.record_win roll payoutstake multiplies the current balance by a StakeFraction and returns a
concrete Money amount. record_loss and record_win update the balance
and the internal ledger.
Drawdown limits
Section titled “Drawdown limits”import Whale.BankRoll exposing (DrawdownPolicy)
let policy = DrawdownPolicy.max_drawdown 0.20let allowed = DrawdownPolicy.check policy roll-- allowed : Bool (false if current drawdown exceeds 20% from high-water)When check returns false, the caller should halt bet placement or
reduce sizing until the bankroll recovers.
Allocation splits
Section titled “Allocation splits”For strategies that partition capital across independent sub-bankrolls:
let splits = BankRoll.allocate roll [0.6, 0.25, 0.15]-- splits : List BankRoll (three sub-bankrolls summing to the original)Each sub-bankroll tracks its own high-water mark and drawdown independently.