Crates.io | kelly |
lib.rs | kelly |
version | 0.1.0 |
source | src |
created_at | 2023-03-12 20:01:45.072639 |
updated_at | 2023-03-12 20:01:45.072639 |
description | A library for calculating the Kelly Formula for wealth management. |
homepage | |
repository | https://github.com/alxolr/kelly |
max_upload_size | |
id | 808249 |
size | 4,340 |
This is a simple implementation of the Kelly Formula in Rust. The Kelly Formula is a method of determining the optimal fraction of your bankroll to bet on a given bet. It is based on the assumption that you have an edge over the bookmaker, and that you can accurately estimate the probability of winning a given bet.
use kelly::{ KellyAssumption, KellyFormulaBuilder };
fn main() {
let assumptions = vec![
// Create a KellyAssumption with a probability of 0.8 and odds of 21.0
KellyAssumption(0.8, 21.0),
// Create a KellyAssumption with a probability of 0.1 and odds of 7.5
KellyAssumption(0.1, 7.5),
// Create a KellyAssumption with a probability of 0.1 and odds of -1.0
KellyAssumption(0.1, -1.0),
];
// Create a new KellyFormulaBuilder with the assumptions
let kelly = KellyFormulaBuilder::new().set_assumptions(assumptions);
// Calculate the optimal fraction of your bankroll to bet
assert_eq!(kelly.calculate(), 0.8309524);
}