sqa 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/checksums/sqa-0.0.13.gem.sha512 +1 -0
- data/checksums/sqa-0.0.14.gem.sha512 +1 -0
- data/lib/sqa/stock.rb +78 -0
- data/lib/sqa/version.rb +1 -1
- data/lib/sqa.rb +5 -7
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41df647860d7465185b8f069d1fb51edcb540d4114cfd56c898e3373426e0bb8
|
4
|
+
data.tar.gz: 130b1023a4530a645ea90bf323c16dd4fb22a887222e073209b8edbfeeb6731f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b28c7bf4231e3ced4046e83f5afd256a0dc155500493b8d2c3cee43695e8ef203534a0642dc4028830f3d068653d6a9016a785b3343611a18209cb1cfb6f4694
|
7
|
+
data.tar.gz: 20ee19fe13781e473953ed4fcae73ce8e687ce1808fc74fa02d834364b7b02df14c7dab4cc0390efbae0f48328d71f27aab96318fad28052588d7b623abf4fe3
|
@@ -0,0 +1 @@
|
|
1
|
+
524fd82ea9501f1b1b1a3bf3e0f1a500e675d3f4664d342b8b377995f310c1e40a597f61d8e0bf8d2fa8dd83202f7a415b517df371dbf370c25f59fb0fb42d96
|
@@ -0,0 +1 @@
|
|
1
|
+
c5eea4fb74e6ab7b7b1715a81598585ec540a3eb1e9b902ca339ff0a2ba9cc7624ae3f43e00b5fbbad1d3d510ed938e8f91154c0bee2e14d6503564b1b0ccfb1
|
data/lib/sqa/stock.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# lib/sqa/stock.rb
|
2
2
|
|
3
|
+
require 'active_support/core_ext/string' # for String#underscore
|
4
|
+
require 'hashie' # for Hashie::Mash
|
5
|
+
|
6
|
+
|
7
|
+
# SMELL: SQA::Stock is now pretty coupled to the Alpha Vantage
|
8
|
+
# API service. Should that stuff be extracted into a
|
9
|
+
# separate class and injected by the requiring program?
|
10
|
+
|
3
11
|
class SQA::Stock
|
12
|
+
CONNECTION = Faraday.new(url: "https://www.alphavantage.co")
|
13
|
+
|
4
14
|
attr_accessor :company_name
|
5
15
|
attr_accessor :df # The DataFrane
|
6
16
|
attr_accessor :ticker
|
@@ -51,4 +61,72 @@ class SQA::Stock
|
|
51
61
|
def to_s
|
52
62
|
"#{ticker} with #{@df.size} data points from #{@df.timestamp.first} to #{@df.timestamp.last}"
|
53
63
|
end
|
64
|
+
|
65
|
+
# TODO: Turn this into a class Stock::Overview
|
66
|
+
# which is a sub-class of Hashie::Dash
|
67
|
+
def overview
|
68
|
+
return @overview unless @overview.nil?
|
69
|
+
|
70
|
+
temp = JSON.parse(
|
71
|
+
CONNECTION.get("/query?function=OVERVIEW&symbol=#{@ticker.upcase}&apikey=#{Nenv.av_api_key}")
|
72
|
+
.to_hash[:body]
|
73
|
+
)
|
74
|
+
|
75
|
+
# TODO: CamelCase hash keys look common in Alpha Vantage
|
76
|
+
# JSON; look at making a special Hashie-based class
|
77
|
+
# to convert the keys to normal Ruby standards.
|
78
|
+
|
79
|
+
temp2 = {}
|
80
|
+
|
81
|
+
string_values = %w[ address asset_type cik country currency description dividend_date ex_dividend_date exchange fiscal_year_end industry latest_quarter name sector symbol ]
|
82
|
+
|
83
|
+
temp.keys.each do |k|
|
84
|
+
new_k = k.underscore
|
85
|
+
temp2[new_k] = string_values.include?(new_k) ? temp[k] : temp[k].to_f
|
86
|
+
end
|
87
|
+
|
88
|
+
@overview = Hashie::Mash.new temp2
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
#############################################
|
93
|
+
## Class Methods
|
94
|
+
|
95
|
+
class << self
|
96
|
+
@@top = nil
|
97
|
+
|
98
|
+
# Top Gainers, Losers and Most Active for most
|
99
|
+
# recent closed trading day.
|
100
|
+
#
|
101
|
+
def top
|
102
|
+
return @@top unless @@top.nil?
|
103
|
+
|
104
|
+
mash = Hashie::Mash.new(
|
105
|
+
JSON.parse(
|
106
|
+
CONNECTION.get(
|
107
|
+
"/query?function=TOP_GAINERS_LOSERS&apikey=#{Nenv.av_api_key}"
|
108
|
+
).to_hash[:body]
|
109
|
+
)
|
110
|
+
)
|
111
|
+
|
112
|
+
keys = mash.top_gainers.first.keys
|
113
|
+
|
114
|
+
%w[top_gainers top_losers most_actively_traded].each do |collection|
|
115
|
+
mash.send(collection).each do |e|
|
116
|
+
keys.each do |k|
|
117
|
+
case k
|
118
|
+
when 'ticker'
|
119
|
+
# Leave it as a String
|
120
|
+
when 'volume'
|
121
|
+
e[k] = e[k].to_i
|
122
|
+
else
|
123
|
+
e[k] = e[k].to_f
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
@@top = mash
|
130
|
+
end
|
131
|
+
end
|
54
132
|
end
|
data/lib/sqa/version.rb
CHANGED
data/lib/sqa.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
require 'active_support'
|
5
5
|
require 'active_support/core_ext/string'
|
6
|
+
require 'amazing_print'
|
6
7
|
require 'daru'
|
7
8
|
require 'date'
|
8
9
|
require 'descriptive_statistics'
|
@@ -22,6 +23,9 @@ module SQA
|
|
22
23
|
class << self
|
23
24
|
@@config = nil
|
24
25
|
|
26
|
+
# Initializes the SQA modules
|
27
|
+
# returns the configuration
|
28
|
+
#
|
25
29
|
def init(argv=ARGV)
|
26
30
|
if argv.is_a? String
|
27
31
|
argv = argv.split()
|
@@ -44,13 +48,7 @@ module SQA
|
|
44
48
|
Daru.lazy_update = config.lazy_update
|
45
49
|
Daru.plotting_library = config.plotting_library
|
46
50
|
|
47
|
-
|
48
|
-
debug_me{[
|
49
|
-
:config
|
50
|
-
]}
|
51
|
-
end
|
52
|
-
|
53
|
-
nil
|
51
|
+
config
|
54
52
|
end
|
55
53
|
|
56
54
|
def debug?() = @@config.debug?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dewayne VanHoozer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -281,6 +281,8 @@ files:
|
|
281
281
|
- checksums/sqa-0.0.10.gem.sha512
|
282
282
|
- checksums/sqa-0.0.11.gem.sha512
|
283
283
|
- checksums/sqa-0.0.12.gem.sha512
|
284
|
+
- checksums/sqa-0.0.13.gem.sha512
|
285
|
+
- checksums/sqa-0.0.14.gem.sha512
|
284
286
|
- checksums/sqa-0.0.2.gem.sha512
|
285
287
|
- checksums/sqa-0.0.3.gem.sha512
|
286
288
|
- checksums/sqa-0.0.4.gem.sha512
|