Skip to content

Instantly share code, notes, and snippets.

@pricees
Created March 1, 2017 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pricees/24780f7aa6dfaed140ad33fb62545d1d to your computer and use it in GitHub Desktop.
Save pricees/24780f7aa6dfaed140ad33fb62545d1d to your computer and use it in GitHub Desktop.
Stock parser
#!/usr/bin/env ruby
cap_range =
case (ARGV[1] || '').downcase
when /small/
puts "Filtering small caps: 50MM - 2B"
0...2_000
when /mid/
puts "Filtering mid caps: 2B - 10B"
2_000...10_000
when /large/
puts "Filtering large caps: 10B+"
10_000..Float::INFINITY
else
0..Float::INFINITY
end
File.readlines(ARGV[0]).each do |line|
begin
next unless line =~ /[A-Z]{3,5}/
_, ticker, cap = line.split(/\t/)
next if cap.nil?
cap_d = cap.gsub(/,/,'').to_f
next unless cap_range.cover?(cap_d)
puts "#{ticker} -> #{cap_d}" if ENV['DEBUG']
puts ticker
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment