bet 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +60 -2
- data/lib/bet/bet_calculations/combinatorial.rb +10 -10
- data/lib/bet/bet_calculations/core.rb +5 -5
- data/lib/bet/calc.rb +1 -1
- data/lib/bet/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6f9b353c88cb9743b57d00e3b61b8d87aae036b
|
4
|
+
data.tar.gz: 276ace1ddd1a161bec48f166e4eb25683435ccdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 711402bf09efb34329022e16e73c03e4632ef4e7ac375ad4c5f8f12cfad94b36e4865548da5524cc1a8f5f260aa50c304b97777e8cc21d8556d989f052229272
|
7
|
+
data.tar.gz: 9e94aa7d0b8e551dc44443ef9d59a8911f0314789200e03397e28d9650a50cd5452d0c28487bf26c6e1255a3aa34571a6c6cb9d185acf73076a8f7a9ead7af47
|
data/README.md
CHANGED
@@ -6,11 +6,69 @@ Want to prototype a new betting strategy? Can't be arsed to work out all the ann
|
|
6
6
|
|
7
7
|
$ gem install bet
|
8
8
|
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Possible bet types:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
# types of acca
|
15
|
+
Bet::Calc.single # 1 bet
|
16
|
+
Bet::Calc.double # 2 bet acca
|
17
|
+
Bet::Calc.treble # 3 bet acca
|
18
|
+
Bet::Calc.accumulator # any number of bets, aliased as acca, parlay
|
19
|
+
|
20
|
+
# types of full cover without single bets
|
21
|
+
Bet::Calc.trixie # 3 selections (4 bets)
|
22
|
+
Bet::Calc.yankee # 4 selections (11 bets)
|
23
|
+
Bet::Calc.canadian # 5 selections (26 bets)
|
24
|
+
Bet::Calc.heinz # 6 selections (57 bets)
|
25
|
+
Bet::Calc.super_heinz # 7 selections (120 bets)
|
26
|
+
Bet::Calc.goliath # 8 selections (247 bets)
|
27
|
+
Bet::Calc.block # 9 selections (502 bets)
|
28
|
+
Bet::Calc.full_cover(prices, min_size: 2)
|
29
|
+
|
30
|
+
# types of complete full cover (inc. singles)
|
31
|
+
Bet::Calc.patent # 3 selections (4 bets)
|
32
|
+
Bet::Calc.lucky15 # 4 selections (11 bets)
|
33
|
+
Bet::Calc.lucky31 # 5 selections (26 bets)
|
34
|
+
Bet::Calc.lucky63 # 6 selections (57 bets)
|
35
|
+
Bet::Calc.super_heinz_with_singles # 7 selections (120 bets)
|
36
|
+
Bet::Calc.goliath_with_singles # 8 selections (247 bets)
|
37
|
+
Bet::Calc.block_with_singles # 9 selections (502 bets)
|
38
|
+
Bet::Calc.full_cover(prices, min_size: 1) # 1 is default, option can be omitted
|
39
|
+
```
|
40
|
+
|
41
|
+
Some examples for the good folks of github and beyond:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
# you can provide an array of winning prices, or a results hash
|
45
|
+
# of price and win/price/loss representation, here's array format:
|
46
|
+
Bet::Calc.single(1.2) # or .single([1.2])
|
47
|
+
# => {:returns=>1.2, :profit=>0.19999999999999996, :outlay=>1}
|
48
|
+
|
49
|
+
Bet::Calc.double([1.2, 5.3])
|
50
|
+
# => {:returns=>6.359999999999999, :profit=>5.359999999999999, :outlay=>1}
|
51
|
+
|
52
|
+
# etc! here's the results hash format. you can use numerical or
|
53
|
+
# the symbolic format for the win/place/loss result
|
54
|
+
{ -1 => :loss, 0 => :place, 1 => :win }
|
55
|
+
|
56
|
+
Bet::Calc.yankee({ 2.3 => :win, 1.2 => :place, 4.5 => :loss, 11.0 => :win })
|
57
|
+
# => {:returns=>25.299999999999997, :profit=>14.299999999999997, :outlay=>11}
|
58
|
+
|
59
|
+
# the default stake per bet is 1, you can change this with the
|
60
|
+
# `stake` option.
|
61
|
+
Bet::Calc.yankee({ 2.3 => :win, 1.2 => :place, 4.5 => :loss, 11.0 => :win }, stake: 0.45)
|
62
|
+
# => {:returns=>11.385, :profit=>6.435, :outlay=>4.95}
|
63
|
+
```
|
64
|
+
|
9
65
|
## Todo
|
10
66
|
|
11
|
-
1.
|
67
|
+
1. Use big decimal instead of float 'cus float imprecision innit
|
68
|
+
1. Implement each way bets properly
|
12
69
|
2. Add dutching and shit like that
|
13
|
-
3.
|
70
|
+
3. Maybe implement support for other price formats (fractional & 'murican)
|
71
|
+
3. Write tests
|
14
72
|
|
15
73
|
## Contributing
|
16
74
|
|
@@ -10,11 +10,11 @@ module Bet
|
|
10
10
|
goliath: 8,
|
11
11
|
block: 9
|
12
12
|
}.each do |ord, n|
|
13
|
-
define_method(ord) do |opts|
|
14
|
-
results =
|
13
|
+
define_method(ord) do |results, opts = {}|
|
14
|
+
results = parse_prices(results)
|
15
15
|
raise ArgumentError, "Wrong number of results (#{results.size} for #{n})" if results.size != n
|
16
16
|
opts[:min_size] = 2
|
17
|
-
full_cover(opts)
|
17
|
+
full_cover(results, opts)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -27,15 +27,15 @@ module Bet
|
|
27
27
|
goliath_with_singles: 8,
|
28
28
|
block_with_singles: 9
|
29
29
|
}.each do |ord, n|
|
30
|
-
define_method(ord) do |opts|
|
31
|
-
results =
|
30
|
+
define_method(ord) do |results, opts = {}|
|
31
|
+
results = parse_prices(results)
|
32
32
|
raise ArgumentError, "Wrong number of results (#{results.size} for #{n})" if results.size != n
|
33
|
-
full_cover(opts)
|
33
|
+
full_cover(results, opts)
|
34
34
|
end
|
35
|
-
end
|
35
|
+
end
|
36
36
|
|
37
|
-
def full_cover(opts)
|
38
|
-
prices =
|
37
|
+
def full_cover(prices, opts = {})
|
38
|
+
prices = parse_prices(prices)
|
39
39
|
opts = parse_opts(opts)
|
40
40
|
opts = { min_size: 1 }.merge(opts)
|
41
41
|
|
@@ -51,7 +51,7 @@ module Bet
|
|
51
51
|
|
52
52
|
returns = (opts[:min_size]..winning_prices.length).to_a.map do |n|
|
53
53
|
winning_prices.combination(n).map do |multis|
|
54
|
-
acca(stake: opts[:stake]
|
54
|
+
acca(multis, stake: opts[:stake])[:returns]
|
55
55
|
end.reduce(:+)
|
56
56
|
end.reduce(:+)
|
57
57
|
|
@@ -2,15 +2,15 @@ module Bet
|
|
2
2
|
module BetCalculations
|
3
3
|
module Core
|
4
4
|
{ single: 1, double: 2, treble: 3 }.each do |ord, n|
|
5
|
-
define_method(ord) do |opts|
|
6
|
-
prices =
|
5
|
+
define_method(ord) do |prices, opts = {}|
|
6
|
+
prices = parse_prices(prices)
|
7
7
|
raise ArgumentError, "Wrong number of prices (#{prices.size} for #{n})" if prices.size != n
|
8
|
-
acca(opts)
|
8
|
+
acca(prices, opts)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
def accumulator(opts)
|
13
|
-
prices =
|
12
|
+
def accumulator(prices, opts = {})
|
13
|
+
prices = parse_prices(prices)
|
14
14
|
opts = parse_opts(opts)
|
15
15
|
|
16
16
|
return send("ew_#{__method__}") if opts[:ew]
|
data/lib/bet/calc.rb
CHANGED
data/lib/bet/version.rb
CHANGED