npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bet-brew

v2.1.5

Published

A betting tools package for various odds and probability calculations.

Downloads

93

Readme

Bet-Brew

Bet-Brew is an npm package that provides a suite of utilities designed to aid bettors in various betting and trading strategies.

Table of Contents

Installation

npm install bet-brew

Usage

Import the main class and use its methods. Below are example usages for a few methods:

import { betBrew } from 'bet-brew';

const brew = betBrew();

// Example usage of calculateEV
const evResult = brew.calculateEV({
    stakedAmount: 100,
    oddsTaken: 2.0,
    startingPrice: 1.9,
});

console.log('Expected Value:', evResult);

// Example usage of calculateROI
const roiResult = brew.calculateROI({
    stakedAmount: 100,
    oddsTaken: 2.0,
    startingPrice: 1.9,
});

console.log('Return on Investment:', roiResult);

// Example usage of calculateBookmakerMargin
const marginResult = brew.calculateBookmakerMargin({
    allOdds: [1.9, 2.1, 3.0],
});

console.log('Bookmaker Margin:', marginResult);

// Example usage of calculateAdjustedProbability
const adjustedProbResult = brew.calculateAdjustedProbability({
    startingPrice: 1.9,
    allOdds: [1.9, 2.1, 3.0],
});

console.log('Adjusted Probability:', adjustedProbResult);

// Example usage of calculateAdjustedEV
const adjustedEVResult = brew.calculateAdjustedEV({
    stakedAmount: 100,
    oddsTaken: 2.0,
    startingPrice: 1.9,
    allOdds: [1.9, 2.1, 3.0],
});

console.log('Adjusted Expected Value:', adjustedEVResult);

// Example usage of calculateAdjustedROI
const adjustedROIResult = brew.calculateAdjustedROI({
    stakedAmount: 100,
    oddsTaken: 2.0,
    startingPrice: 1.9,
    allOdds: [1.9, 2.1, 3.0],
});

console.log('Adjusted Return on Investment:', adjustedROIResult);

API Documentation

BetBrewClass

Core class containing methods for various betting utilities.

Methods

  • calculateEV(input: EVInput): Calculates the Expected Value (EV) of a bet.
  • calculateROI(input: ROIInput): Calculates the Return on Investment (ROI) of a bet.
  • calculateBookmakerMargin(input: BookmakerMarginInput): Calculates the margin of a bookmaker based on provided odds.
  • calculateAdjustedProbability(input: AdjustedProbabilityInput): Calculates the adjusted probability accounting for the bookmaker's margin.
  • calculateAdjustedEV(input: AdjustedEVInput): Calculates the adjusted Expected Value (EV) of a bet.
  • calculateAdjustedROI(input: AdjustedROIInput): Calculates the adjusted Return on Investment (ROI) of a bet.
  • calculatePnL(input: PnlInput): Calculates profit and total return of a bet.
  • calculateKellyBet(input: KellyBetInput): Calculates the optimal bet amount using the Kelly criterion, returns the suggested bet amount and the Kelly fraction.
  • decimalToFractional(decimalOdds: number): Converts decimal odds to fractional format.
  • fractionalToDecimal(fraction: string): Converts fractional odds to decimal format.
  • decimalToMoneyline(decimalOdds: number): Converts decimal odds to moneyline format.
  • moneylineToDecimal(moneyline: number): Converts moneyline odds to decimal format.

Input Types

EVInput

Used for calculating the Expected Value (EV) of a bet.

  • stakedAmount: The amount of money staked on the bet. (Type: number)
  • oddsTaken: The odds that were taken when the bet was placed. (Type: number)
  • startingPrice: The starting price or odds of the bet. (Type: number)

ROIInput

Used for calculating the Return on Investment (ROI) of a bet. Extends from EVInput.

BookmakerMarginInput

Used for calculating the margin of a bookmaker based on provided odds.

  • allOdds: An array of all odds that are being considered. (Type: number[])

AdjustedProbabilityInput

Used for calculating the adjusted probability, accounting for the bookmaker's margin.

  • startingPrice: The starting price or odds of the bet. (Type: number)
  • allOdds: An array of all odds that are being considered. (Type: number[])

AdjustedEVInput

Used for calculating the adjusted Expected Value (EV) of a bet.

  • Inherits fields from both EVInput and BookmakerMarginInput.

AdjustedROIInput

Used for calculating the adjusted Return on Investment (ROI) of a bet.

  • Inherits all fields from AdjustedEVInput.

PnlInput

Used for calculating the profit and total return of a bet.

  • oddsTaken: The odds that were taken when the bet was placed. (Type: number)
  • stakedAmount: The amount of money staked on the bet. (Type: number)

KellyBetInput

Used for calculating the profit and total return of a bet.

  • oddsTaken: The odds that were taken when the bet was placed. (Type: number)
  • bankroll: The total amount of money available for betting. (Type: number)
  • probability: The bettor's estimated probability that the bet will win, expressed as a value between 0 and 1. (Type: number)

BrewResult

Interface outlining the results of calculations:

  • margin: Bookmaker's margin in percentage. (Type: number)
  • rawEV: Raw Expected Value of a bet. (Type: number)
  • rawROI: Raw Return on Investment of a bet in percentage. (Type: number)
  • adjustedEV: Adjusted Expected Value of a bet. (Type: number)
  • adjustedROI: Adjusted Return on Investment of a bet in percentage. (Type: number)