Created
March 1, 2017 03:01
-
-
Save pricees/24780f7aa6dfaed140ad33fb62545d1d to your computer and use it in GitHub Desktop.
Stock parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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