deal-win-rate-report 1.0.0
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 +7 -0
- data/LICENSE +22 -0
- data/README.md +35 -0
- data/bin/deal-win-rate-report +11 -0
- data/lib/deal_win_rate_report.rb +55 -0
- metadata +50 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9b34b0c5ed882c659a6f8747816d248433ea64f3186ed7c47088645c722fc940
|
|
4
|
+
data.tar.gz: 61d14aab615dbed7832b4429adf86249e02030d601a4a9fc029ef0211121ebd8
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a7ccac10d3daf95eb25afd1bb68d2034a9af27983cfb7ca8d94736b58a8b622bdf201bf7b2e29dce6bb49e60a952ab9a9c930d644332387f55ffc9ce6f7ffa5a
|
|
7
|
+
data.tar.gz: 92136e4fdd915ab22f138220f470d6b1eb25926ad0bee955658e263e6d77eaa523ce547121ad99fb5ab4ff38a2dac693cebd81e92ef9ff0222da57a090dac42f
|
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OneGTMLab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
data/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# deal-win-rate-report
|
|
2
|
+
|
|
3
|
+
A small Ruby library and command-line tool for [win rate](https://www.onegtmlab.dev/glossary/sales-win-rate): won / (won + lost) over
|
|
4
|
+
your closed deals, overall and by segment, with a 95 percent Wilson range beside each rate so a handful of deals is not read as a trend.
|
|
5
|
+
Open deals are ignored. Offline, no dependencies. Built by [OneGTMLab](https://www.onegtmlab.dev/glossary/sales-win-rate) (GTM engineering for B2B teams).
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
gem install deal-win-rate-report
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```csv
|
|
12
|
+
segment,stage
|
|
13
|
+
smb,won
|
|
14
|
+
smb,lost
|
|
15
|
+
mid,won
|
|
16
|
+
mid,won
|
|
17
|
+
mid,lost
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
deal-win-rate-report deals.csv
|
|
22
|
+
# segment won lost rate 95% range
|
|
23
|
+
# ALL 3 2 60.0% 23.1% to 88.2%
|
|
24
|
+
# mid 2 1 66.7% 20.8% to 93.9%
|
|
25
|
+
# smb 1 1 50.0% 9.5% to 90.5%
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The range is the point: three wins out of five deals could really be anywhere from about 23 to 88 percent. See the
|
|
29
|
+
[win rate glossary entry](https://www.onegtmlab.dev/glossary/sales-win-rate).
|
|
30
|
+
|
|
31
|
+
## Test
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
ruby test/run.rb
|
|
35
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative '../lib/deal_win_rate_report'
|
|
5
|
+
|
|
6
|
+
if ARGV.include?('-h') || ARGV.include?('--help')
|
|
7
|
+
warn "usage: deal-win-rate-report deals.csv (columns: stage [won|lost], segment optional; open stages are ignored)\nMore: https://www.onegtmlab.dev/glossary/sales-win-rate"
|
|
8
|
+
exit 2
|
|
9
|
+
end
|
|
10
|
+
text = ARGV[0] ? File.read(ARGV[0]) : $stdin.read
|
|
11
|
+
print DealWinRateReport.render(DealWinRateReport.from_csv(text))
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'csv'
|
|
4
|
+
|
|
5
|
+
# Win rate from closed deals, overall and by segment, with a 95 percent Wilson interval so a
|
|
6
|
+
# small sample is not read as a trend. Win rate = won / (won + lost).
|
|
7
|
+
module DealWinRateReport
|
|
8
|
+
VERSION = '1.0.0'
|
|
9
|
+
Row = Struct.new(:segment, :won, :lost, :rate, :low, :high, keyword_init: true)
|
|
10
|
+
|
|
11
|
+
module_function
|
|
12
|
+
|
|
13
|
+
# Wilson score interval for wins out of n at 95 percent confidence; returns [low, high] as fractions.
|
|
14
|
+
def wilson(wins, n, z = 1.959964)
|
|
15
|
+
return [0.0, 0.0] if n.zero?
|
|
16
|
+
p = wins.to_f / n
|
|
17
|
+
denom = 1 + z * z / n
|
|
18
|
+
centre = (p + z * z / (2 * n)) / denom
|
|
19
|
+
half = z * Math.sqrt((p * (1 - p) + z * z / (4 * n)) / n) / denom
|
|
20
|
+
[[centre - half, 0.0].max, [centre + half, 1.0].min]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# deals: array of hashes with 'segment' (optional) and 'stage' ('won' or 'lost'); other stages are open and ignored.
|
|
24
|
+
def from_deals(deals)
|
|
25
|
+
groups = Hash.new { |h, k| h[k] = [0, 0] }
|
|
26
|
+
deals.each do |d|
|
|
27
|
+
stage = d['stage'].to_s.strip.downcase
|
|
28
|
+
next unless %w[won lost closed-won closed-lost].include?(stage)
|
|
29
|
+
seg = d['segment'].to_s.strip
|
|
30
|
+
seg = 'all' if seg.empty?
|
|
31
|
+
i = stage.end_with?('won') ? 0 : 1
|
|
32
|
+
groups[seg][i] += 1
|
|
33
|
+
groups['ALL'][i] += 1 unless seg == 'ALL'
|
|
34
|
+
end
|
|
35
|
+
groups.map { |seg, (w, l)| build(seg, w, l) }.sort_by { |r| [r.segment == 'ALL' ? 0 : 1, -(r.won + r.lost)] }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def build(seg, won, lost)
|
|
39
|
+
n = won + lost
|
|
40
|
+
lo, hi = wilson(won, n)
|
|
41
|
+
Row.new(segment: seg, won: won, lost: lost, rate: n.zero? ? 0.0 : won.to_f / n, low: lo, high: hi)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def from_csv(text)
|
|
45
|
+
from_deals(CSV.parse(text, headers: true).map(&:to_h))
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def render(rows)
|
|
49
|
+
out = format("%-16s %5s %5s %8s %s\n", 'segment', 'won', 'lost', 'rate', '95% range')
|
|
50
|
+
rows.each do |r|
|
|
51
|
+
out << format("%-16s %5d %5d %7.1f%% %.1f%% to %.1f%%\n", r.segment, r.won, r.lost, r.rate * 100, r.low * 100, r.high * 100)
|
|
52
|
+
end
|
|
53
|
+
out
|
|
54
|
+
end
|
|
55
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: deal-win-rate-report
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- OneGTMLab
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: "Ruby CLI and library: win rate (won / won + lost) overall and by segment from a deals CSV, with a 95 percent Wilson interval so small samples are not read as trends."
|
|
13
|
+
email:
|
|
14
|
+
- account@onegtmlab.dev
|
|
15
|
+
executables:
|
|
16
|
+
- deal-win-rate-report
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- LICENSE
|
|
21
|
+
- README.md
|
|
22
|
+
- bin/deal-win-rate-report
|
|
23
|
+
- lib/deal_win_rate_report.rb
|
|
24
|
+
homepage: "https://www.onegtmlab.dev/glossary/sales-win-rate"
|
|
25
|
+
licenses:
|
|
26
|
+
- MIT
|
|
27
|
+
metadata:
|
|
28
|
+
homepage_uri: "https://www.onegtmlab.dev/glossary/sales-win-rate"
|
|
29
|
+
source_code_uri: "https://github.com/jaizendra-netizen/deal-win-rate-report"
|
|
30
|
+
documentation_uri: "https://www.onegtmlab.dev/glossary/sales-win-rate"
|
|
31
|
+
rdoc_options: []
|
|
32
|
+
require_paths:
|
|
33
|
+
- lib
|
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
-
|
|
37
|
+
- ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: "2.7"
|
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
|
+
requirements:
|
|
42
|
+
-
|
|
43
|
+
- ">="
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: "0"
|
|
46
|
+
requirements: []
|
|
47
|
+
rubygems_version: 4.1.0
|
|
48
|
+
specification_version: 4
|
|
49
|
+
summary: "Win rate by segment from closed deals, with a 95 percent range"
|
|
50
|
+
test_files: []
|