ya_finance 0.0.3 → 0.0.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 +3 -1
- data/lib/ya_finance/current.rb +12 -2
- data/lib/ya_finance/http.rb +1 -17
- data/lib/ya_finance/past.rb +0 -2
- data/lib/ya_finance/scrapper/holders.rb +7 -5
- data/lib/ya_finance.rb +0 -2
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8f482ebdafd39e3fe9ac70a158af5abd450b18661e698bbb1f78617f8cfae18e
|
|
4
|
+
data.tar.gz: d1fcc298fff2126fbde03b8c6bc948d638b2347ff940bae5d3e8aaec65de065b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 181cf8a11afb8c4fbd6e7ef932048e0f400458dba45ace5148b81f580f8951e9c17e1968523aaa3ac6f5c815638969109cdaaaac477d3614a9c6a4d8f060e662
|
|
7
|
+
data.tar.gz: 98db47b652881b0d860a61f1d3bfa8e633325aab77b4672c289dc85bc2d7e171500b8603df4fa433efee81d67809ed9c3a90649171e2b77c5da55cca9466fd28
|
data/Gemfile
CHANGED
data/lib/ya_finance/current.rb
CHANGED
|
@@ -24,10 +24,20 @@ class YaFinance
|
|
|
24
24
|
YaFinance::Scrapper::Holders.process(response)
|
|
25
25
|
end
|
|
26
26
|
def options
|
|
27
|
-
fetch_v7("options/#{@ticker}")['optionChain']['result'][0]['options']
|
|
27
|
+
response = fetch_v7("options/#{@ticker}")['optionChain']['result'][0]['options'][0]
|
|
28
|
+
{
|
|
29
|
+
puts: remap_options(response['puts']),
|
|
30
|
+
calls: remap_options(response['calls']),
|
|
31
|
+
}
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
private
|
|
31
|
-
|
|
35
|
+
def remap_options(opts)
|
|
36
|
+
opts.map{|opt|
|
|
37
|
+
opt['expirationParsed'] = Time.at(opt['expiration']) unless opt['expiration'].nil?
|
|
38
|
+
opt['lastTradeDateParsed'] = Time.at(opt['lastTradeDate']) unless opt['lastTradeDate'].nil?
|
|
39
|
+
opt
|
|
40
|
+
}
|
|
41
|
+
end
|
|
32
42
|
end
|
|
33
43
|
end
|
data/lib/ya_finance/http.rb
CHANGED
|
@@ -10,20 +10,12 @@ class YaFinance::Http
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def self.fetch(uri)
|
|
13
|
-
|
|
14
|
-
@@http.override_headers["User-Agent"] = "YaFin/#{YaFinance::VERSION}"
|
|
15
|
-
@@http.request(uri)
|
|
16
|
-
end
|
|
17
|
-
def self.shutdown
|
|
18
|
-
@@http.shutdown
|
|
19
|
-
@@http = nil
|
|
13
|
+
Excon.get(uri.to_s, persistent: true, headers: {"User-Agent" => "YaFin/#{YaFinance::VERSION}"})
|
|
20
14
|
end
|
|
21
15
|
|
|
22
16
|
module FetchRoot
|
|
23
17
|
def fetch_root(path)
|
|
24
18
|
uri = URI("#{ROOT_URL}/#{path}")
|
|
25
|
-
puts uri
|
|
26
|
-
# @TODO: make a crawler?
|
|
27
19
|
YaFinance::Http.fetch(uri).body
|
|
28
20
|
end
|
|
29
21
|
end
|
|
@@ -31,8 +23,6 @@ class YaFinance::Http
|
|
|
31
23
|
module FetchHistorical
|
|
32
24
|
def fetch_historical(path)
|
|
33
25
|
uri = URI("#{HISTORICAL_URL}/#{path}")
|
|
34
|
-
puts uri
|
|
35
|
-
# @TODO: make a crawler?
|
|
36
26
|
YaFinance::Http.fetch(uri).body
|
|
37
27
|
end
|
|
38
28
|
end
|
|
@@ -40,8 +30,6 @@ class YaFinance::Http
|
|
|
40
30
|
module FetchFundamentals
|
|
41
31
|
def fetch_fundamentals(path)
|
|
42
32
|
uri = URI("#{FUNDAMENTALS_URL}/#{path}")
|
|
43
|
-
puts uri
|
|
44
|
-
# @TODO: make a crawler?
|
|
45
33
|
YaFinance::Http.fetch(uri).body
|
|
46
34
|
end
|
|
47
35
|
end
|
|
@@ -49,14 +37,12 @@ class YaFinance::Http
|
|
|
49
37
|
module FetchV7
|
|
50
38
|
def fetch_v7(path)
|
|
51
39
|
uri = URI("#{V7_URL}/#{path}")
|
|
52
|
-
puts uri
|
|
53
40
|
JSON.parse(YaFinance::Http.fetch(uri).body)
|
|
54
41
|
end
|
|
55
42
|
end
|
|
56
43
|
module FetchV8
|
|
57
44
|
def fetch_v8(path)
|
|
58
45
|
uri = URI("#{V8_URL}/#{path}")
|
|
59
|
-
puts uri
|
|
60
46
|
JSON.parse(YaFinance::Http.fetch(uri).body)
|
|
61
47
|
end
|
|
62
48
|
end
|
|
@@ -65,9 +51,7 @@ class YaFinance::Http
|
|
|
65
51
|
def fetch_v6(mod)
|
|
66
52
|
# modules = ['financialData', 'quoteType', 'defaultKeyStatistics', 'assetProfile', 'summaryDetail']
|
|
67
53
|
uri = URI("#{V6_URL}/#{ERB::Util.url_encode(@ticker)}?modules=#{mod}")
|
|
68
|
-
puts "#{uri}"
|
|
69
54
|
json = JSON.parse(YaFinance::Http.fetch(uri).body)
|
|
70
|
-
YaFinance::Http.shutdown
|
|
71
55
|
|
|
72
56
|
if json["quoteSummary"] && json["quoteSummary"]["error"]
|
|
73
57
|
return json["quoteSummary"]["error"]
|
data/lib/ya_finance/past.rb
CHANGED
|
@@ -5,11 +5,13 @@ class YaFinance
|
|
|
5
5
|
class Holders
|
|
6
6
|
def self.process(html)
|
|
7
7
|
doc = Oga.parse_xml(html)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
table = doc.css('[data-test] td').map{|e| e.text }
|
|
9
|
+
{
|
|
10
|
+
insiders_percent: table[0].to_f,
|
|
11
|
+
intitutions_percent: table[2].to_f,
|
|
12
|
+
institutions_float: table[4].to_f,
|
|
13
|
+
institutions_amount: table[6].to_i
|
|
14
|
+
}
|
|
13
15
|
end
|
|
14
16
|
end
|
|
15
17
|
end
|
data/lib/ya_finance.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "net/http/persistent" # @TODO: how to remove?
|
|
4
3
|
require "net/http"
|
|
5
4
|
require "open-uri"
|
|
6
5
|
require "ostruct"
|
|
@@ -27,4 +26,3 @@ end
|
|
|
27
26
|
|
|
28
27
|
Dir[File.join(__dir__, 'ya_finance', '*.rb')].each { |file| require file }
|
|
29
28
|
Dir[File.join(__dir__, 'ya_finance/scrapper', '*.rb')].each { |file| require file }
|
|
30
|
-
Dir[File.join(__dir__, 'ya_finance/insider_trading', '*.rb')].each { |file| require file }
|
metadata
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ya_finance
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gabriel Fonseca Engel
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-08-
|
|
11
|
+
date: 2023-08-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
|
-
description: Financial Information consumer with CLI working in 2023
|
|
13
|
+
description: Financial Information consumer with CLI working in 2023 - reads from
|
|
14
|
+
Yahoo Finances
|
|
14
15
|
email: gabrielfengel@gmail.com
|
|
15
16
|
executables:
|
|
16
17
|
- yafin
|
|
@@ -51,5 +52,5 @@ requirements: []
|
|
|
51
52
|
rubygems_version: 3.3.7
|
|
52
53
|
signing_key:
|
|
53
54
|
specification_version: 4
|
|
54
|
-
summary: Financial Information 2023 - Yahoo Finances
|
|
55
|
+
summary: Financial Information 2023 - reads from Yahoo Finances
|
|
55
56
|
test_files: []
|