histock-simplefilter 0.3.0 → 0.4.0
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/CHANGELOG.md +7 -0
- data/README.md +45 -0
- data/lib/histock/simplefilter/fetch/basic_financial_statements.rb +6 -1
- data/lib/histock/simplefilter/fetch/profitability.rb +21 -0
- data/lib/histock/simplefilter/fetch.rb +15 -4
- data/lib/histock/simplefilter/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 870c913ca40a6b8d8101d3f737fad3134b88df9896fdecb45e0bbe5eade98671
|
4
|
+
data.tar.gz: b877b752c719067f7110e8eecfae0821976ffa776ed3a47bc769bdc2f67fbbaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48479a08b6a662dc749f10460024a1de8e23633b388f7b1cc24dc8ac094e1d7401b036b40fa2c3f52bbfada7109702fb1566d321b5821d79f2422e8569d94ce8
|
7
|
+
data.tar.gz: 4dfafe49a6ab840eefd4e8ccfb7b9615b75d9744e3eb2038b1cf769adef087830d40bcb0346af807f14b66a9df06e0edf69d7965f557bd8b9dcb161dcae6fe05
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## v0.4.0
|
2
|
+
[full changelog](http://github.com/ysato5654/histock-simplefilter/compare/v0.3.0...v0.4.0)
|
3
|
+
|
4
|
+
* support new request
|
5
|
+
- profit ratio
|
6
|
+
- income rate
|
7
|
+
|
1
8
|
## v0.3.0
|
2
9
|
[full changelog](http://github.com/ysato5654/histock-simplefilter/compare/v0.2.0...v0.3.0)
|
3
10
|
|
data/README.md
CHANGED
@@ -57,6 +57,26 @@ histock.monthly_revenue('2330') # code '2330' is TSMC
|
|
57
57
|
# ]
|
58
58
|
```
|
59
59
|
|
60
|
+
#### Income Statement (損益表)
|
61
|
+
|
62
|
+
```rb
|
63
|
+
require 'histock/simplefilter'
|
64
|
+
|
65
|
+
histock = Histock::Simplefilter.new
|
66
|
+
histock.income_statement('2330') # code '2330' is TSMC
|
67
|
+
# [
|
68
|
+
# ["年度/季別", "營收", "毛利", "營業利益", "稅前淨利", "稅後淨利"],
|
69
|
+
# ["2019Q4", "317,237,065", "159,240,985", "124,243,722", "128,781,973", "116,078,194"],
|
70
|
+
# ["2019Q3", "293,045,439", "139,432,161", "107,887,292", "112,336,271", "101,102,454"],
|
71
|
+
# ["2019Q2", "240,998,475", "103,673,230", "76,304,053", "80,545,440", "66,775,851"],
|
72
|
+
# ["2019Q1", "218,704,469", "90,352,125", "64,266,023", "68,181,652", "61,387,310"],
|
73
|
+
# ["2018Q4", "289,770,193", "138,042,400", "107,123,251", "111,082,092", "100,005,385"],
|
74
|
+
# ["2018Q3", "260,347,882", "123,380,843", "95,245,181", "98,896,942", "89,098,072"],
|
75
|
+
# ["2018Q2", "233,276,811", "111,588,104", "84,428,146", "87,587,608", "72,293,375"],
|
76
|
+
# ["2018Q1", "248,078,671", "124,974,694", "96,826,946", "99,943,621", "89,787,574"]
|
77
|
+
# ]
|
78
|
+
```
|
79
|
+
|
60
80
|
### Dividend Policy (股利政策)
|
61
81
|
|
62
82
|
#### 除權除息
|
@@ -86,3 +106,28 @@ histock.dividend_policy('2330') # code '2330' is TSMC
|
|
86
106
|
# ["2007", "2008", "07/16", "07/16", "55.8", "0.05", "3.03", "-", "-", "0", "0.0186", "0.02", "0"]
|
87
107
|
# ]
|
88
108
|
```
|
109
|
+
|
110
|
+
### Profitability (獲利能力)
|
111
|
+
|
112
|
+
#### Profit Ratio (利潤比率)
|
113
|
+
|
114
|
+
```rb
|
115
|
+
require 'histock/simplefilter'
|
116
|
+
|
117
|
+
histock = Histock::Simplefilter.new
|
118
|
+
histock.profit_ratio('2330') # code '2330' is TSMC
|
119
|
+
```
|
120
|
+
|
121
|
+
#### Income Rate (報酬率)
|
122
|
+
|
123
|
+
```rb
|
124
|
+
require 'histock/simplefilter'
|
125
|
+
|
126
|
+
histock = Histock::Simplefilter.new
|
127
|
+
# monthly data
|
128
|
+
histock.income_rate('2330', 'month') # code '2330' is TSMC
|
129
|
+
# quarterly data
|
130
|
+
histock.income_rate('2330', 'quarter')
|
131
|
+
# yearly data
|
132
|
+
histock.income_rate('2330', 'year')
|
133
|
+
```
|
@@ -2,7 +2,12 @@ module Histock
|
|
2
2
|
module Fetch
|
3
3
|
module BasicFinancialStatements
|
4
4
|
def monthly_revenue(code)
|
5
|
-
params = {:no => code, :t => 1}
|
5
|
+
params = {:no => code, :t => 1, :st => 1}
|
6
|
+
parse(:query => __method__, :html => get('/financial.aspx', params))
|
7
|
+
end
|
8
|
+
|
9
|
+
def income_statement(code)
|
10
|
+
params = {:no => code, :t => 1, :st => 4}
|
6
11
|
parse(:query => __method__, :html => get('/financial.aspx', params))
|
7
12
|
end
|
8
13
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Histock
|
2
|
+
module Fetch
|
3
|
+
module Profitability
|
4
|
+
def profit_ratio(code)
|
5
|
+
params = {:no => code, :t => 3, :st => 1}
|
6
|
+
parse(:query => __method__, :html => get('/financial.aspx', params))
|
7
|
+
end
|
8
|
+
|
9
|
+
def income_rate(code, term)
|
10
|
+
case term
|
11
|
+
when 'month' then params = {:no => code, :t => 3, :st => 2, :q => 1}
|
12
|
+
when 'quarter' then params = {:no => code, :t => 3, :st => 2, :q => 2}
|
13
|
+
when 'year' then params = {:no => code, :t => 3, :st => 2, :q => 3}
|
14
|
+
else
|
15
|
+
end
|
16
|
+
|
17
|
+
parse(:query => __method__, :html => get('/financial.aspx', params))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'nokogiri'
|
2
|
-
require File.expand_path(File.dirname(__FILE__)) + '/fetch/dividend_policy'
|
3
2
|
require File.expand_path(File.dirname(__FILE__)) + '/fetch/basic_financial_statements'
|
3
|
+
require File.expand_path(File.dirname(__FILE__)) + '/fetch/dividend_policy'
|
4
|
+
require File.expand_path(File.dirname(__FILE__)) + '/fetch/profitability'
|
4
5
|
|
5
6
|
module Histock
|
6
7
|
module Fetch
|
7
|
-
include DividendPolicy
|
8
8
|
include BasicFinancialStatements
|
9
|
+
include DividendPolicy
|
10
|
+
include Profitability
|
9
11
|
|
10
12
|
private
|
11
13
|
|
@@ -13,8 +15,15 @@ module Histock
|
|
13
15
|
doc = Nokogiri::HTML.parse(html, nil, @charset)
|
14
16
|
# => Nokogiri::HTML::Document
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
+
case query
|
19
|
+
when :monthly_revenue, :dividend_policy
|
20
|
+
nodes = doc.xpath("//div[@class='row-stock']/div[@class='tb-outline']/table[@class='tb-stock text-center tbBasic']")
|
21
|
+
# => Nokogiri::XML::NodeSet
|
22
|
+
when :income_statement
|
23
|
+
nodes = doc.xpath("//div[@class='row-stock']/div[@class='tb-outline']/div/table[@class='tb-stock tbBasic']")
|
24
|
+
when :profit_ratio, :income_rate
|
25
|
+
nodes = doc.xpath("//div[@class='row-stock w1060']/div[@class='tb-outline']/div/table[@class='tb-stock tbBasic']")
|
26
|
+
end
|
18
27
|
|
19
28
|
raise InformationNotFound if nodes.empty?
|
20
29
|
raise XMLNodeSetError unless nodes.length.is_one?
|
@@ -66,6 +75,8 @@ module Histock
|
|
66
75
|
array = Array.new
|
67
76
|
|
68
77
|
element.children.each do |e|
|
78
|
+
next unless e.element?
|
79
|
+
|
69
80
|
case e.name
|
70
81
|
when 'th' then array.push e.children.text.gsub(/\<br\>/, '')
|
71
82
|
when 'td' then array.push e.children.text
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: histock-simplefilter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuya Sato
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- lib/histock/simplefilter/fetch.rb
|
105
105
|
- lib/histock/simplefilter/fetch/basic_financial_statements.rb
|
106
106
|
- lib/histock/simplefilter/fetch/dividend_policy.rb
|
107
|
+
- lib/histock/simplefilter/fetch/profitability.rb
|
107
108
|
- lib/histock/simplefilter/version.rb
|
108
109
|
homepage: https://github.com/ysato5654/histock-simplefilter
|
109
110
|
licenses:
|