bet 1.0.1 → 1.0.2

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: fb93dabb53df5ca72be4e860b158e4b4426f7a54
4
- data.tar.gz: 8118c8c5c2aa862a042d733674cb09e7fcb8d84e
3
+ metadata.gz: 40fb381a2f77c50d267fad65a1c3c7aa16d11dfe
4
+ data.tar.gz: 3fced4831128fcc5c2f466e12687e038a5a21dfa
5
5
  SHA512:
6
- metadata.gz: 744b5a87d467ddbdb846a94945deb33b73fa0f90c2fc8c14ac0f9ed5d9d71f5aedfea7464c299917ce9157ccc6c9c96c9f452699afd25f76906f828eb90701bc
7
- data.tar.gz: acc75c8bd2230b9fdcf53ed9a43862be57b535acfad047d1c913db2b4f97f514917f16fab1de063c493fe7802a3d2cbd5a718eff56ef551fea95aecc8cd7215d
6
+ metadata.gz: b68b22435cd0f6c19e94ffca6a1daaae03def60b1e2582dd5295f0f45c2ebdcbeebc1f4997d6a6c8464916ab990a6f7f47bc06926141f08cdcf98f2d9245940d
7
+ data.tar.gz: d452e0f70f36776005deea01d785e9c8df768132e0f2917c1c7e69c2534449e8ea3933c094b9510edf7b3bf59f72b1643acac579449a794006d72e47441c9801
data/README.md CHANGED
@@ -41,8 +41,8 @@ Bet::Calc.full_cover(prices, min_size: 1) # 1 is default, option can be omitted
41
41
  Some examples of bet calculations for you good folks:
42
42
 
43
43
  ```ruby
44
- # you can provide an array of winning prices, or a results hash of
45
- # price and win/price/loss representation, here's array format:
44
+ # you can provide an array of winning prices, or a results array of
45
+ # price and win/price/loss representation, here's the former:
46
46
  Bet::Calc.single(1.2) # or .single([1.2])
47
47
  # => {:returns=>1.2, :profit=>0.19999999999999996, :outlay=>1}
48
48
  # you'll notice the float imprecision, if you want accurate floating
@@ -54,17 +54,17 @@ Bet::Calc.single(BigDecimal.new('1.2'))[:profit].to_f
54
54
  Bet::Calc.double([1.2, 5.3])
55
55
  # => {:returns=>6.359999999999999, :profit=>5.359999999999999, :outlay=>1}
56
56
 
57
- # etc! here's the results hash format. you can use numerical or the
57
+ # etc! here's the results array format. you can use numerical or the
58
58
  # symbolic format for the win/place/loss result
59
59
  { -1 => :loss, 0 => :place, 1 => :win }
60
60
 
61
61
  # format is price => result
62
- Bet::Calc.yankee({ 2.3 => :win, 1.2 => :place, 4.5 => :loss, 11.0 => :win })
62
+ Bet::Calc.yankee([[2.3, :win], [1.2, :place], [4.5, :loss], [11.0, :win]])
63
63
  # => {:returns=>25.299999999999997, :profit=>14.299999999999997, :outlay=>11}
64
64
 
65
65
  # the default stake per bet is 1, you can change this with the
66
66
  # `stake` option.
67
- Bet::Calc.yankee({ 2.3 => :win, 1.2 => :place, 4.5 => :loss, 11.0 => :win }, stake: 0.45)
67
+ Bet::Calc.yankee([[2.3, :win], [1.2, :place], [4.5, :loss], [11.0, :win]], stake: 0.45)
68
68
  # => {:returns=>11.385, :profit=>6.435, :outlay=>4.95}
69
69
  ```
70
70
 
@@ -2,7 +2,7 @@ module Bet
2
2
  module Staking
3
3
  class << self
4
4
  def dutch(prices, risk = 1)
5
- denom = prices.combination(2).map{ |c| c[0] * c[1] }.reduce(:+)
5
+ denom = prices.combination(prices.size - 1).reduce(0){ |m,c| m + c.reduce(:*) }
6
6
 
7
7
  stakes = prices.map.with_index do |p, i|
8
8
  (prices.dup.tap{ |a| a.delete_at(i) }.reduce(:*) * risk)
@@ -10,7 +10,7 @@ module Bet
10
10
  .round(2)
11
11
  end
12
12
 
13
- profits = prices.zip(stakes).map{ |c| c.reduce(:*) }
13
+ profits = prices.zip(stakes).map{ |c| c[0] * c[1] }
14
14
  total_stake = stakes.reduce(:+)
15
15
  min_profit = profits.min - total_stake
16
16
 
@@ -1,3 +1,3 @@
1
1
  module Bet
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Campbell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-27 00:00:00.000000000 Z
11
+ date: 2015-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler