Skip to content

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.

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.

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_stake
let roll_after_win = BankRoll.record_win roll payout

stake 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.

import Whale.BankRoll exposing (DrawdownPolicy)
let policy = DrawdownPolicy.max_drawdown 0.20
let 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.

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.