kelly-criterion
v0.0.0
Published
A Kelly Criterion calculator written in TypeScript
Downloads
4
Readme
kelly-criterion
A Kelly Criterion calculator written in TypeScript
Kelly Criterion Calculator
Introduction
The Kelly Criterion Calculator is a TypeScript class designed for calculating the Kelly Criterion, a formula used in probability theory and investing to determine the optimal size of a series of bets. This class provides methods to compute both the Kelly Criterion fraction and the optimal fraction to bet based on a given win probability and payoff ratio.
Installation
Install the package using pnpm:
npm install kelly-criterion
Example
import { KellyCriterion } from 'kelly-criterion';
// Create an instance of the KellyCriterion class
const kellyCalculator = new KellyCriterion();
// Set the win probability and payoff ratio
const winProbability = 0.6; // 60% chance of winning
const payoffRatio = 2; // 2:1 payoff ratio
// Calculate the Kelly Criterion fraction
const kellyFraction = kellyCalculator.calKellyCriterion(winProbability, payoffRatio);
console.log(`Kelly Criterion Fraction: ${kellyFraction}`);
// Calculate the optimal fraction to bet
const optimalFraction = kellyCalculator.calOptimalFraction(winProbability, payoffRatio);
console.log(`Optimal Fraction to Bet: ${optimalFraction}`);
Methods
calKellyCriterion(winProbability: number, payoffRatio: number): number
Calculates the Kelly Criterion fraction based on the given win probability and payoff ratio.
winProbability
: The probability of winning (a value between 0 and 1).payoffRatio
: The ratio of the payoff (e.g., 2 for 2:1 odds).- Returns: The calculated Kelly Criterion fraction.
calOptimalFraction(winProbability: number, payoffRatio: number): number
Calculates the optimal fraction to bet based on the Kelly Criterion.
winProbability
: The probability of winning (a value between 0 and 1).payoffRatio
: The ratio of the payoff (e.g., 2 for 2:1 odds).- Returns: The calculated optimal fraction to bet.