histock-filter 0.4.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +173 -12
- data/histock-filter.gemspec +1 -1
- data/lib/histock/filter.rb +16 -11
- data/lib/histock/filter/helper.rb +23 -0
- data/lib/histock/filter/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e1d2c1a1efb3cccc24b6e4fb796ffe98782a9cb197d3cf4172bd499a86ba4bf
|
4
|
+
data.tar.gz: f159be1dc865569c188c2443cfff0feda32f5d481b8b0a1c187f1fbda30211da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 131c409570ebe7cc1a28dca89b4a03e677573994ab241999d4585a72cf1722fe628efdbd9ebf21de257072a57354b17b33fd14631bc8eccb305b02c69ff1bd96
|
7
|
+
data.tar.gz: d1d90f1e7ea9e0b74ced86f93a8427a70af98c3b8e0829da9aff068cf6c129ae66b5f9aef37551233bbe8a31b3de6f6874b5672b4ad6645b8f13fe2e76c825fe
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -34,26 +34,187 @@ $ gem install histock-filter
|
|
34
34
|
### Dividend Policy
|
35
35
|
|
36
36
|
```rb
|
37
|
+
require 'histock/filter'
|
38
|
+
|
37
39
|
histock = Histock::Filter.new
|
38
40
|
histock.dividend_policy('2330')
|
39
41
|
# [
|
40
|
-
# {
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
42
|
+
# {
|
43
|
+
# "所屬年度" => "2019",
|
44
|
+
# "發放年度" => "2020",
|
45
|
+
# "除權日" => "",
|
46
|
+
# "除息日" => "06/18",
|
47
|
+
# "除權息前股價" => 297.5,
|
48
|
+
# "股票股利" => 0,
|
49
|
+
# "現金股利" => 2.5,
|
50
|
+
# "EPS" => 13.32,
|
51
|
+
# "配息率" => 18.77,
|
52
|
+
# "現金殖利率" => 0.84,
|
53
|
+
# "扣抵稅率" => 0.00,
|
54
|
+
# "增資配股率" => 0,
|
55
|
+
# "增資認購價" => 0
|
56
|
+
# },
|
57
|
+
# {},
|
58
|
+
# :
|
59
|
+
# ]
|
60
|
+
```
|
61
|
+
|
62
|
+
### Basic Financial Statements
|
63
|
+
|
64
|
+
#### Monthly Revenue
|
65
|
+
|
66
|
+
| key | type |
|
67
|
+
|-----|------|
|
68
|
+
| 年度/月份 | string |
|
69
|
+
| 單月營收 | integer |
|
70
|
+
| 去年同月營收 | integer |
|
71
|
+
| 單月月增率 | float |
|
72
|
+
| 單月年增率 | float |
|
73
|
+
| 累計營收 | integer |
|
74
|
+
| 去年累計營收 | integer |
|
75
|
+
| 累積年增率 | float |
|
76
|
+
|
77
|
+
```rb
|
78
|
+
require 'histock/filter'
|
79
|
+
|
80
|
+
histock = Histock::Filter.new
|
81
|
+
histock.monthly_revenue('2330')
|
82
|
+
# [
|
83
|
+
# {
|
84
|
+
# "年度/月份" => "2020/04",
|
85
|
+
# "單月營收" => 96001568,
|
86
|
+
# "去年同月營收" => 74693616,
|
87
|
+
# "單月月增率" => -15.4,
|
88
|
+
# "單月年增率" => 28.5,
|
89
|
+
# "累計營收" => 406598784,
|
90
|
+
# "去年累計營收" => 293398112,
|
91
|
+
# "累積年增率" => 38.6
|
92
|
+
# },
|
93
|
+
# {},
|
94
|
+
# :
|
95
|
+
# ]
|
96
|
+
```
|
97
|
+
|
98
|
+
#### Income Statement
|
99
|
+
|
100
|
+
| key | type |
|
101
|
+
|-----|------|
|
102
|
+
| 年度/季別 | string |
|
103
|
+
| 營收 | integer |
|
104
|
+
| 毛利 | integer |
|
105
|
+
| 營業利益 | integer |
|
106
|
+
| 稅前淨利 | integer |
|
107
|
+
| 稅後淨利 | integer |
|
108
|
+
|
109
|
+
```rb
|
110
|
+
histock = Histock::Filter.new
|
111
|
+
histock.income_statement('2330')
|
112
|
+
# [
|
113
|
+
# {
|
114
|
+
# "年度/季別"" => "2019Q4",
|
115
|
+
# "營收" => 317237065,
|
116
|
+
# "毛利" => 159240985,
|
117
|
+
# "營業利益" => 124243722,
|
118
|
+
# "稅前淨利" => 128781973,
|
119
|
+
# "稅後淨利" => 116078194
|
120
|
+
# },
|
121
|
+
# {},
|
122
|
+
# :
|
44
123
|
# ]
|
45
124
|
```
|
46
125
|
|
47
|
-
###
|
126
|
+
### Profitability
|
127
|
+
|
128
|
+
#### Profit Ratio
|
129
|
+
|
130
|
+
| key | type |
|
131
|
+
|-----|------|
|
132
|
+
| 年度/季別 | string |
|
133
|
+
| 毛利率 | float |
|
134
|
+
| 營業利益率 | float |
|
135
|
+
| 稅前淨利率 | float |
|
136
|
+
| 稅後淨利率 | float |
|
48
137
|
|
49
138
|
```rb
|
50
|
-
histock = Histock::
|
51
|
-
histock.
|
139
|
+
histock = Histock::Filter.new
|
140
|
+
histock.profit_ratio('2330')
|
141
|
+
# [
|
142
|
+
# {
|
143
|
+
# "年度/季別" => "2019Q4",
|
144
|
+
# "毛利率" => 50.20,
|
145
|
+
# "營業利益率" => 39.16,
|
146
|
+
# "稅前淨利率" => 40.59,
|
147
|
+
# "稅後淨利率" => 36.59
|
148
|
+
# },
|
149
|
+
# {},
|
150
|
+
# :
|
151
|
+
# ]
|
152
|
+
```
|
153
|
+
|
154
|
+
#### Income Rate
|
155
|
+
|
156
|
+
##### Monthly Data
|
157
|
+
|
158
|
+
| key | type |
|
159
|
+
|-----|------|
|
160
|
+
| 年度/季別 | string |
|
161
|
+
| ROE | float |
|
162
|
+
| ROA | float |
|
163
|
+
|
164
|
+
```rb
|
165
|
+
histock = Histock::Filter.new
|
166
|
+
histock.income_rate('2330', 'month')
|
167
|
+
# [
|
168
|
+
# {
|
169
|
+
# "年度/季別" => "2020Q1",
|
170
|
+
# "ROE" => 7.10,
|
171
|
+
# "ROA" => 5.08
|
172
|
+
# },
|
173
|
+
# {},
|
174
|
+
# :
|
175
|
+
# ]
|
176
|
+
```
|
177
|
+
|
178
|
+
##### Quarterly Data
|
179
|
+
|
180
|
+
| key | type |
|
181
|
+
|-----|------|
|
182
|
+
| 年度/季別 | string |
|
183
|
+
| 近四季ROE | float |
|
184
|
+
| 近四季ROA | float |
|
185
|
+
|
186
|
+
```rb
|
187
|
+
histock = Histock::Filter.new
|
188
|
+
histock.income_rate('2330', 'quarter')
|
189
|
+
# [
|
190
|
+
# {
|
191
|
+
# "年度/季別" => "2020Q1",
|
192
|
+
# "近四季ROE" => 23.45,
|
193
|
+
# "近四季ROA" => 17.70
|
194
|
+
# },
|
195
|
+
# {},
|
196
|
+
# :
|
197
|
+
# ]
|
198
|
+
```
|
199
|
+
|
200
|
+
##### Yearly Data
|
201
|
+
|
202
|
+
| key | type |
|
203
|
+
|-----|------|
|
204
|
+
| 年度 | string |
|
205
|
+
| 年度ROE | float |
|
206
|
+
| 年度ROA | float |
|
207
|
+
|
208
|
+
```rb
|
209
|
+
histock = Histock::Filter.new
|
210
|
+
histock.income_rate('2330', 'year')
|
52
211
|
# [
|
53
|
-
# {
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
212
|
+
# {
|
213
|
+
# "年度" => "2019",
|
214
|
+
# "年度ROE" => 20.93,
|
215
|
+
# "年度ROA" => 15.86
|
216
|
+
# },
|
217
|
+
# {},
|
218
|
+
# :
|
58
219
|
# ]
|
59
220
|
```
|
data/histock-filter.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_runtime_dependency 'histock-simplefilter', '~> 0.4.0'
|
30
30
|
|
31
31
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
32
|
-
spec.add_development_dependency 'rake', '
|
32
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
33
33
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
34
|
spec.add_development_dependency 'travis', '>= 1.9.0'
|
35
35
|
end
|
data/lib/histock/filter.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'histock/simplefilter'
|
2
2
|
require File.expand_path(File.dirname(__FILE__)) + '/filter/version'
|
3
|
+
require File.expand_path(File.dirname(__FILE__)) + '/filter/helper'
|
3
4
|
|
4
5
|
module Histock
|
5
6
|
class Filter
|
@@ -16,31 +17,35 @@ module Histock
|
|
16
17
|
histock = Histock::Simplefilter.new
|
17
18
|
table = histock.send(method_name, param)
|
18
19
|
|
19
|
-
table
|
20
|
+
parse(table)
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
24
|
CONFIG.last.each do |method_name|
|
24
25
|
define_method method_name do |param, param2|
|
25
|
-
raise ArgumentError if param2 == 'month'
|
26
|
-
|
27
26
|
histock = Histock::Simplefilter.new
|
28
27
|
table = histock.send(method_name, param, param2)
|
29
28
|
|
30
|
-
table
|
29
|
+
parse(table)
|
31
30
|
end
|
32
31
|
end
|
33
|
-
end
|
34
32
|
|
35
|
-
|
36
|
-
end
|
33
|
+
private
|
37
34
|
|
38
|
-
|
35
|
+
def parse(table)
|
36
|
+
list = table[1..-1].map { |e| table.first.zip(e).to_h }
|
39
37
|
|
40
|
-
|
38
|
+
list.each do |hash|
|
39
|
+
hash.each do |key, val|
|
40
|
+
if Histock::Helper.is_persentage?(val)
|
41
|
+
hash[key] = Histock::Helper.persentage_to_number(val)
|
42
|
+
elsif Histock::Helper.is_currency?(val)
|
43
|
+
hash[key] = Histock::Helper.currency_to_number(val)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
41
47
|
|
42
|
-
|
43
|
-
@message = 'currently not supported'
|
48
|
+
list
|
44
49
|
end
|
45
50
|
end
|
46
51
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Histock
|
2
|
+
class Helper
|
3
|
+
class << self
|
4
|
+
def is_persentage?(str)
|
5
|
+
str.match(/^[+-]?([0-9]+(\.[0-9]*)?|\.[0-9]+)%$/).nil? ? false : true
|
6
|
+
end
|
7
|
+
|
8
|
+
def is_currency?(str)
|
9
|
+
str.match(/^[+-]?\d{1,3}(,\d{3})*$/).nil? ? false : true
|
10
|
+
end
|
11
|
+
|
12
|
+
# should check str by 'is_persentage?' method before calling this method
|
13
|
+
def persentage_to_number(str)
|
14
|
+
str.to_s.gsub(/%/,'').to_f
|
15
|
+
end
|
16
|
+
|
17
|
+
# should check str by 'is_currency?' method before calling this method
|
18
|
+
def currency_to_number(str)
|
19
|
+
str.to_s.gsub(/[$,]/,'').to_i
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: histock-filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuya Sato
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: histock-simplefilter
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- bin/setup
|
100
100
|
- histock-filter.gemspec
|
101
101
|
- lib/histock/filter.rb
|
102
|
+
- lib/histock/filter/helper.rb
|
102
103
|
- lib/histock/filter/version.rb
|
103
104
|
homepage: https://github.com/ysato5654/histock-filter
|
104
105
|
licenses:
|