fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Kelly Allocation

Install and import#

bash
npm install fintech-algorithms
ts
import { kellyAllocation } from "fintech-algorithms/portfolio-construction/bayesian-and-robust-allocation/kelly-allocation";

Signature#

kellyAllocation(returns, probabilities, maxIterations, tolerance)

Maximizes expected logarithmic growth over a discrete scenario set, separating the long-run growth criterion from the single-coin-toss intuition.

Parameters#

NameTypeNotes
returns`S x n` matrixdecimal simple return/scenario
probabilitieslength `S` vectorprobability
optional
maxIterationsunknown
toleranceunknown

Worked example#

executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

Input#

returns
[
  [0.1, -0.05],
  [-0.05, 0.1],
  [0.02, 0.02]
]
probabilities
[0.3333333333333333, 0.3333333333333333, 0.3333333333333333]

Call#

kellyAllocation(returns, probabilities, maxIterations, tolerance)

Returns#

object with 8 fields: weights, expectedLogGrowth, wealthFactors, minimumWealthFactor, arithmeticExpectedReturn, iterations, projectedGradientNorm, status

{
  "weights": [0.5, 0.5],
  "expectedLogGrowth": 0.023062617492307515,
  "wealthFactors": [1.025, 1.025, 1.02],
  "minimumWealthFactor": 1.02,
  "arithmeticExpectedReturn": 0.02333333333333333,
  "iterations": 1,
  "projectedGradientNorm": 0,
  "status": "optimal"
}

Other exports#

This module also exports logGrowth, fractionalKelly. Every module additionally exports run as an alias of its primary function, and a meta object carrying its catalog id, domain, family, shape and article URL.

Diagrams#

Kelly Allocation — article hero

Calculation flow#

Diagram
flowchart TB
    N0[Read scenario model] --> N1
    N1[Check positive wealth] --> N2
    N2[Maximize expected log] --> N3
    N3[Check residual and factors] --> N4
    N4[Scale risky mix into cash]

How it works#

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References#

  • A New Interpretation of Information Rate — J. L. Kelly Jr.
  • Risk-Constrained Kelly Gambling — Enzo Busseti, Ernest K. Ryu, and Stephen Boyd.
  • Distributional Robust Kelly Gambling — Qingyun Sun and Stephen Boyd.

The rest of the Bayesian and Robust Allocation family#