Documentation
¶
Overview ¶
Package betting provides functions to compute bet types and sizes in order to achieve a free bet or greenbook.
Example (A) ¶
This example computes the bet type and size to be placed on the market in order to perform a "Green Book" operation.
package main import ( "fmt" "github.com/gustavooferreira/bfutils/betting" ) func main() { selection := betting.Selection{ Bets: []betting.Bet{ {Type: betting.BetType_Back, Odd: 4, Amount: 5}, {Type: betting.BetType_Lay, Odd: 3, Amount: 5}, {Type: betting.BetType_Back, Odd: 3.5, Amount: 10}, {Type: betting.BetType_Lay, Odd: 3.2, Amount: 10}, }, CurrentBackOdd: 2.4, CurrentLayOdd: 2.42, } bet, err := betting.GreenBookSelection(selection) if err != nil { panic(err) } fmt.Printf("In order to green book this selection, put a {%s} bet at {%.2f} for £%.2f.\n", bet.Type, bet.Odd, bet.Amount) fmt.Printf("P&L\n") fmt.Printf("---\n") fmt.Printf("If this selection wins: £%.2f\n", bet.WinPL) fmt.Printf("If this selection loses: £%.2f\n", bet.LosePL) }
Output: In order to green book this selection, put a {Lay} bet at {2.42} for £3.31. P&L --- If this selection wins: £3.31 If this selection loses: £3.31
Index ¶
- Constants
- func FreeBetDecimal(oddBack float64, oddLay float64) float64
- func FreeBetPL(oddBack float64, oddLay float64, stake float64) float64
- func GreenBookOpenBackAmount(oddBack float64, stakeBack float64, oddLay float64) (float64, error)
- func GreenBookOpenBackAmountByPerc(oddBack float64, perc float64) (float64, error)
- func GreenBookOpenBackDecimal(oddBack float64, oddLay float64) (float64, error)
- func GreenBookOpenLayAmount(oddLay float64, stakeLay float64, oddBack float64) (float64, error)
- func GreenBookOpenLayAmountByPerc(oddLay float64, perc float64) (float64, error)
- func GreenBookOpenLayDecimal(oddLay float64, oddBack float64) (float64, error)
- func SelectionIsEdged(bets []Bet) (bool, error)
- type AlreadyEdgedError
- type Bet
- type BetType
- type LadderStep
- type Selection
Examples ¶
Constants ¶
const ( // BetType_Back represents a back bet. BetType_Back = iota + 1 // BetType_Lay represents a lay bet. BetType_Lay )
Variables ¶
This section is empty.
Functions ¶
func FreeBetDecimal ¶
FreeBetDecimal returns the P&L multiplier factor. Example: back:4 lay:2 the multiplier factor is 2, which means if you back at odd 4 with £10 and lay at odd 2 with £10 you secure a free bet of 2 * £10 = £20
func FreeBetPL ¶
FreeBetPL returns the profit in case selection wins. Note that 'stake' is the backer's stake not the layer's liability
func GreenBookOpenBackAmount ¶
GreenBookOpenBackAmount returns lay stake to greenbook.
func GreenBookOpenBackAmountByPerc ¶
GreenBookOpenBackAmountByPerc returns oddLay for a given perc P&L. Note that when Backing, you cannot lose more than 100% of your stake therefore feeding perc with a number less or equal to -1 is an error! perc is a representation in decimal, meaning if you want to know at what LAY odd you should place a bet at in order to get 100% profit, then perc is == 1
func GreenBookOpenBackDecimal ¶
GreenBookOpenBackDecimal returns percentage of P&L.
func GreenBookOpenLayAmount ¶
GreenBookOpenLayAmount returns back stake to greenbook.
func GreenBookOpenLayAmountByPerc ¶
GreenBookOpenLayAmountByPerc returns oddBack for a given perc P&L. Note that when Laying, you cannot win more than 100% of your stake therefore feeding perc with a number greater or equal to 1 is an error!
func GreenBookOpenLayDecimal ¶
GreenBookOpenLayDecimal returns percentage of P&L.
func SelectionIsEdged ¶
SelectionIsEdged returns true if selection is already been edged or if there are no bets in this selection. This might not give an accurate result in the sense that the selection might not be edged perfectly, because it might not be possible to edge it "even" across all outcomes at the current odds.
Types ¶
type AlreadyEdgedError ¶
type AlreadyEdgedError struct { }
AlreadyEdgedError is the error used in case a selection is already edged.
func (*AlreadyEdgedError) Error ¶
func (e *AlreadyEdgedError) Error() string
type Bet ¶
type Bet struct { // Bet type: Back or Lay. Type BetType // Odd in the market. Odd float64 // Amount represents how much to bet or how much has been matched (backer's stake, or layer's payout) Amount float64 // WinPL represents how much is the profit or loss in case this selection wins. // This value is meant to be treated as read-only. WinPL float64 // LosePL represents how much is the profit or loss in case this selection loses. // This value is meant to be treated as read-only. LosePL float64 }
Bet represents a bet in the market.
func GreenBookSelection ¶
GreenBookSelection computes what bet to make in order to greenbook a selection.
type LadderStep ¶
type LadderStep struct { // Odd in the market. Odd float64 // Potential profit or loss in this selection in case of a greenbook operation. GreenBookPL float64 // Volume matched by bets placed. VolMatched float64 }
LadderStep represents a trading ladder.
func GreenBookAtAllOdds ¶
func GreenBookAtAllOdds(bets []Bet) ([]LadderStep, error)
GreenBookAtAllOdds returns the ladder with P&L and volumed matched by bets.