| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Bet
Description
Data types and functions to work with odds and stakes.
- data BetType
- oppositeBetType :: BetType -> BetType
- betBool :: Iso' BetType Bool
- data Bet odds money = Bet !BetType odds money
- newtype BetFlipped money odds = BetFlipped {
- getFlipped :: Bet odds money
- betType :: Lens' (Bet odds money) BetType
- odds :: Lens (Bet odds1 money) (Bet odds2 money) odds1 odds2
- stake :: Lens (Bet odds money1) (Bet odds money2) money1 money2
- liability :: (Fractional odds, odds ~ money) => Lens' (Bet odds money) money
- winningPotential :: (Fractional odds, odds ~ money) => Lens' (Bet odds money) money
- pattern BetType BetType :: Bet t t
- pattern BetLiability BetType t money :: Num money => Bet t (Bet money money)
- pattern BetWinningPotential BetType t money :: Num money => Bet t (Bet money money)
- bestTradingStake :: (Fractional odds, odds ~ money) => Bet odds money -> odds -> money
- bestTradingStake2 :: (Fractional odds, odds ~ money) => Bet odds money -> odds -> Bet odds money
Bets
A bet type. In a betting exchange, you usually can choose if you want to make a back or lay bet. With traditional bookmakers, you usually only back.
Instances
oppositeBetType :: BetType -> BetType Source
Returns the opposite bet type.
Describes a bet in terms of its (European) odds and the stake size.
Bet odds money = Bet BetType odds money
^ ^
| |
| +--- Data type of the money to use.
|
+-- Describes the data type used as odds.
Some betting environments don't allow just any odds so
it may be useful to use this type variable to restrict
available odds.
Instances
| Bitraversable Bet | |
| Bifunctor Bet | |
| Bifoldable1 Bet | |
| Bifoldable Bet | |
| Functor (Bet odds) | |
| Foldable (Bet odds) | |
| Traversable (Bet odds) | |
| Foldable1 (Bet odds) | |
| (Eq odds, Eq money) => Eq (Bet odds money) | |
| (Ord odds, Ord money) => Ord (Bet odds money) | |
| (Read odds, Read money) => Read (Bet odds money) | |
| (Show odds, Show money) => Show (Bet odds money) | |
| (Semigroup odds, Semigroup money) => Semigroup (Bet odds money) | |
| Typeable (* -> * -> *) Bet |
newtype BetFlipped money odds Source
A wrapper to use odds as last type argument.
Constructors
| BetFlipped | |
Fields
| |
Instances
| Bitraversable BetFlipped | |
| Bifunctor BetFlipped | |
| Bifoldable1 BetFlipped | |
| Bifoldable BetFlipped | |
| Functor (BetFlipped money) | |
| Foldable (BetFlipped money) | |
| Traversable (BetFlipped money) | |
| Foldable1 (BetFlipped money) | |
| (Eq money, Eq odds) => Eq (BetFlipped money odds) | |
| (Ord money, Ord odds) => Ord (BetFlipped money odds) | |
| (Read money, Read odds) => Read (BetFlipped money odds) | |
| (Show money, Show odds) => Show (BetFlipped money odds) | |
| (Semigroup odds, Semigroup money) => Semigroup (BetFlipped money odds) | |
| Typeable (* -> * -> *) BetFlipped |
Derived lenses
The values these lenses manipulate are calculated on the fly and not stored directly. These may not necessarily follow lens laws with 100% accuracy but only because there are inaccuracies in floating point numerical values.
liability :: (Fractional odds, odds ~ money) => Lens' (Bet odds money) money Source
Liability is the amount of money you stand to lose for a bet if you lose it.
For back bets, liability equals stake. For lay bets, liability is stake multiplied by (odds-1).
An unfortunate flaw of this function: odds and money data types need to be the same.
winningPotential :: (Fractional odds, odds ~ money) => Lens' (Bet odds money) money Source
Winning potential tells you how much you could win if this bet pays.
This is profit value. If you back bet 5 dollars at odds 2.0 then your winning potential is 5 dollars. (You will have 10 dollars if you started with 5 dollars).
Pattern synonyms
pattern BetLiability BetType t money :: Num money => Bet t (Bet money money) Source
Match with liability.
pattern BetWinningPotential BetType t money :: Num money => Bet t (Bet money money) Source
Match with winning potential.
Choosing stakes
bestTradingStake :: (Fractional odds, odds ~ money) => Bet odds money -> odds -> money Source
Given a bet and opposing bet odds, calculates the ideal stake size to minimize potential loss.
This is useful in bet trading, which gives this function its name.
bestTradingStake2 :: (Fractional odds, odds ~ money) => Bet odds money -> odds -> Bet odds money Source
Same as bestTradingStake but wraps the result in a new bet.