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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98a33134f1f23b9347eb046690cc6f2692c6452b
4
- data.tar.gz: e8a3390c0910bca81f24b078ac295c99c12a0521
3
+ metadata.gz: b6f9b353c88cb9743b57d00e3b61b8d87aae036b
4
+ data.tar.gz: 276ace1ddd1a161bec48f166e4eb25683435ccdb
5
5
  SHA512:
6
- metadata.gz: e32a4970b3ad3570f0cc0121a5d7c316052640feb649fa8b45c49dbcc907e9d606ce4edd319544e17cd1ab417030d2803ab7eb30a06fbd18aa9c719af3d34269
7
- data.tar.gz: 87c053a6cb75605c10422fb29145c00df682d39ac263398e31de4a38c6e31cb5824531737a9ae7be482381076bb91b6bfd8aac238a221f59918b9415df3d2859
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. Make it actually work
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. Test
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 = extract_prices(opts)
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 = extract_prices(opts)
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 = extract_prices(opts)
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], prices: multis)[:returns]
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 = extract_prices(opts)
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 = extract_prices(opts)
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]
@@ -28,7 +28,7 @@ module Bet
28
28
  stake * price
29
29
  end
30
30
 
31
- def extract_prices(opts_or_prices)
31
+ def parse_prices(opts_or_prices)
32
32
  case opts_or_prices
33
33
  when Hash
34
34
  opts_or_prices[:prices] ? extract_prices(opts_or_prices[:prices]) : opts_or_prices
@@ -1,3 +1,3 @@
1
1
  module Bet
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Campbell