stock_info 0.1.3 → 0.1.4
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/Gemfile.lock +1 -1
- data/bin/stock_info +0 -1
- data/lib/stock_info/cli.rb +2 -2
- data/lib/stock_info/stock.rb +24 -4
- data/lib/stock_info/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: 011e27a1f7a2a47b605c8c724c01daa80aed357d
|
|
4
|
+
data.tar.gz: 02ac7c7e2973528f4c7ca87d994ee0b6cde5efd7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6eaccafdd840dee4a66e390777ff08c8d6720e4cdcbe118ee9575c170c91e019104425a44b9b8feaf475839020ea5a0ddddb70c4cfc2fee63fe4e31648fe8eb7
|
|
7
|
+
data.tar.gz: cf818c0d918575b96cb020cf6b72ff92db81b60ce8989ddeeb757bc30f539ed6637fb5117c7f2aa133006638fc5235059d0e1a76de68f04cd58abff6d69ce047
|
data/Gemfile.lock
CHANGED
data/bin/stock_info
CHANGED
data/lib/stock_info/cli.rb
CHANGED
|
@@ -15,12 +15,12 @@ class StockInfo::CLI
|
|
|
15
15
|
input = nil
|
|
16
16
|
while input != 'exit'
|
|
17
17
|
puts 'Enter the ticker symbol of a stock you would like more info on.'
|
|
18
|
-
puts "Other commands: 'exit' - exits stock-info, 'trending' -
|
|
18
|
+
puts "Other commands: 'exit' - exits stock-info, 'trending' - refresh trending stocks."
|
|
19
19
|
input = gets.strip.downcase
|
|
20
20
|
if input == 'trending'
|
|
21
21
|
trending_tickers
|
|
22
22
|
elsif StockInfo::Stock.check_symbol(input.upcase) == true
|
|
23
|
-
stock = StockInfo::Stock.
|
|
23
|
+
stock = StockInfo::Stock.create_or_return(input.upcase)
|
|
24
24
|
stock.print_info
|
|
25
25
|
puts 'View recent news articles related to this stock? (yes/no)'
|
|
26
26
|
news_bool = gets.strip[0].downcase
|
data/lib/stock_info/stock.rb
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
class StockInfo::Stock
|
|
2
2
|
attr_accessor :company, :symbol, :daily_change, :price, :news, :earnings, :rvol, :optionable, :short_ratio
|
|
3
3
|
@@trending = []
|
|
4
|
+
@@all = []
|
|
4
5
|
def initialize(symbol)
|
|
5
6
|
@symbol = symbol
|
|
6
7
|
@news = []
|
|
7
8
|
get_info(symbol)
|
|
9
|
+
@@all << self
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.create_or_return(symbol)
|
|
13
|
+
if self.market_open || @@all.any? {|stock| stock.symbol == symbol}
|
|
14
|
+
if self.market_open
|
|
15
|
+
stock = @@all.select {|stock| stock.symbol == symbol }[0]
|
|
16
|
+
stock.get_info(symbol)
|
|
17
|
+
stock
|
|
18
|
+
else
|
|
19
|
+
stock = @@all.select {|stock| stock.symbol == symbol}[0]
|
|
20
|
+
end
|
|
21
|
+
else
|
|
22
|
+
self.new(symbol)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.market_open
|
|
27
|
+
time = Time.now.localtime('-05:00')
|
|
28
|
+
(time.saturday? || time.sunday? || time.hour > 20 || time.hour < 4) ? false : true
|
|
8
29
|
end
|
|
9
30
|
|
|
10
31
|
def self.check_symbol(symbol)
|
|
@@ -38,20 +59,19 @@ class StockInfo::Stock
|
|
|
38
59
|
end
|
|
39
60
|
|
|
40
61
|
def self.print_trending
|
|
41
|
-
trending.each do |stock|
|
|
62
|
+
self.trending.each do |stock|
|
|
42
63
|
puts "#{stock.symbol} - Price: #{stock.price} - Change: #{stock.daily_change} - Relative Volume: #{stock.rvol}"
|
|
43
64
|
end
|
|
44
65
|
end
|
|
45
66
|
|
|
46
67
|
def self.trending
|
|
47
|
-
|
|
48
|
-
unless (time.saturday? || time.sunday? || time.hour > 20 || time.hour < 4) && @@trending.any?
|
|
68
|
+
if self.market_open || @@trending.empty?
|
|
49
69
|
i = 0
|
|
50
70
|
doc = Nokogiri::HTML(open('https://finviz.com/screener.ashx?v=110&s=ta_mostactive'))
|
|
51
71
|
10.times do
|
|
52
72
|
symbol = doc.css('tr.table-dark-row-cp a.screener-link-primary')[i].text
|
|
53
73
|
i += 1
|
|
54
|
-
@@trending <<
|
|
74
|
+
@@trending << self.create_or_return(symbol)
|
|
55
75
|
end
|
|
56
76
|
end
|
|
57
77
|
@@trending
|
data/lib/stock_info/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stock_info
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tom Kunkel
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-02-
|
|
11
|
+
date: 2019-02-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|