bet 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/bet/staking.rb +2 -2
- data/lib/bet/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40fb381a2f77c50d267fad65a1c3c7aa16d11dfe
|
4
|
+
data.tar.gz: 3fced4831128fcc5c2f466e12687e038a5a21dfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
45
|
-
# price and win/price/loss representation, here's
|
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
|
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(
|
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(
|
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
|
|
data/lib/bet/staking.rb
CHANGED
@@ -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(
|
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
|
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
|
|
data/lib/bet/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|