histock-simplefilter 0.1.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.travis.yml +2 -0
- data/CHANGELOG.md +34 -2
- data/Gemfile +4 -0
- data/README.md +132 -17
- data/lib/histock/simplefilter/error.rb +2 -0
- data/lib/histock/simplefilter/fetch.rb +85 -30
- data/lib/histock/simplefilter/fetch/basic_financial_statements.rb +15 -0
- data/lib/histock/simplefilter/fetch/corporate_value.rb +15 -0
- data/lib/histock/simplefilter/fetch/profitability.rb +21 -0
- data/lib/histock/simplefilter/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fc728f6f0a3d2640bfb67ed6f62f5ea35417f05f7fb03fadc6ebb3adf55d256
|
4
|
+
data.tar.gz: 9adceb2e0fd319ff5af538a0b9c83537a89fa16f142db172bb220d66e95491e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c853c35a89f497d470fe0dd524a78e63b2ce5f356b97a33a55dc723517ce808e6fd7db26ed030c417199932bb916f12cede9f6a58b2f30c1d185ea256e640285
|
7
|
+
data.tar.gz: 79a8c59281249483f01b572570adf4eab80b026238924a0decb2ee06a460ea67736bd0cfc0c3d1217cf36dd93317aaefdc8828f1731dac1c6a9e4f1a9545050a
|
data/.rspec
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,42 @@
|
|
1
|
+
## v0.5.0
|
2
|
+
[full changelog](http://github.com/ysato5654/histock-simplefilter/compare/v0.4.1...v0.5.0)
|
3
|
+
|
4
|
+
* support new request
|
5
|
+
- price to earning ratio
|
6
|
+
- price book ratio
|
7
|
+
|
8
|
+
## v0.4.1
|
9
|
+
[full changelog](http://github.com/ysato5654/histock-simplefilter/compare/v0.4.0...v0.4.1)
|
10
|
+
|
11
|
+
* add error handling
|
12
|
+
|
13
|
+
## v0.4.0
|
14
|
+
[full changelog](http://github.com/ysato5654/histock-simplefilter/compare/v0.3.0...v0.4.0)
|
15
|
+
|
16
|
+
* support new request
|
17
|
+
- profit ratio
|
18
|
+
- income rate
|
19
|
+
|
20
|
+
## v0.3.0
|
21
|
+
[full changelog](http://github.com/ysato5654/histock-simplefilter/compare/v0.2.0...v0.3.0)
|
22
|
+
|
23
|
+
* change request name
|
24
|
+
- before: financial statements
|
25
|
+
after: monthly revenue
|
26
|
+
|
27
|
+
## v0.2.0
|
28
|
+
[full changelog](http://github.com/ysato5654/histock-simplefilter/compare/v0.1.2...v0.2.0)
|
29
|
+
|
30
|
+
* support new request
|
31
|
+
- financial statements
|
32
|
+
|
1
33
|
## v0.1.2
|
2
|
-
[full changelog](http://github.com/ysato5654/histock-
|
34
|
+
[full changelog](http://github.com/ysato5654/histock-simplefilter/compare/v0.1.1...v0.1.2)
|
3
35
|
|
4
36
|
* fix include path
|
5
37
|
|
6
38
|
## v0.1.1
|
7
|
-
[full changelog](http://github.com/ysato5654/histock-
|
39
|
+
[full changelog](http://github.com/ysato5654/histock-simplefilter/compare/v0.1.0...v0.1.1)
|
8
40
|
|
9
41
|
* update gemspec
|
10
42
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/histock-simplefilter.svg)](https://badge.fury.io/rb/histock-simplefilter)
|
2
2
|
[![Build Status](https://travis-ci.org/ysato5654/histock-simplefilter.svg?branch=master)](https://travis-ci.org/ysato5654/histock-simplefilter)
|
3
|
+
[![Coverage Status](https://coveralls.io/repos/github/ysato5654/histock-simplefilter/badge.svg?branch=master)](https://coveralls.io/github/ysato5654/histock-simplefilter?branch=master)
|
3
4
|
|
4
5
|
# Histock::Simplefilter
|
5
6
|
|
6
|
-
[HiStock嗨投資理財社群](https://histock.tw/)
|
7
|
+
histock-simplefilter is Ruby library to get the finance data of listed stock on the Taiwan stock exchange market from [HiStock嗨投資理財社群](https://histock.tw/).
|
8
|
+
The library provides you to basic output data.
|
9
|
+
|
10
|
+
If you would like to get more organized data, refer to [histock-filter](https://github.com/ysato5654/histock-filter).
|
7
11
|
|
8
12
|
## Installation
|
9
13
|
|
@@ -27,28 +31,139 @@ $ gem install histock-simplefilter
|
|
27
31
|
|
28
32
|
## Usage
|
29
33
|
|
30
|
-
|
34
|
+
### Basic Financial Statements (基本財報)
|
35
|
+
|
36
|
+
#### Monthly Revenue (每月營收)
|
37
|
+
|
38
|
+
```rb
|
39
|
+
require 'histock/simplefilter'
|
40
|
+
|
41
|
+
histock = Histock::Simplefilter.new
|
42
|
+
histock.monthly_revenue('2330') # code '2330' is TSMC
|
43
|
+
# [
|
44
|
+
# ["年度/月份", "單月營收", "去年同月營收", "單月月增率", "單月年增率", "累計營收", "去年累計營收", "累積年增率"],
|
45
|
+
# ["2020/04", "96,001,568", "74,693,616", "-15.4%", "28.5%", "406,598,784", "293,398,112", "38.6%"],
|
46
|
+
# ["2020/03", "113,519,600", "79,721,584", "21.5%", "42.4%", "310,597,184", "218,704,496", "42%"],
|
47
|
+
# ["2020/02", "93,394,448", "60,889,060", "-9.9%", "53.4%", "197,077,600", "138,982,896", "41.8%"],
|
48
|
+
# ["2020/01", "103,683,104", "78,093,824", "0.3%", "32.8%", "103,683,104", "78,093,824", "32.8%"],
|
49
|
+
# ["2019/12", "103,313,104", "89,830,600", "-4.2%", "15%", "1,069,985,024", "1,031,473,984", "3.7%"],
|
50
|
+
# ["2019/11", "107,884,400", "98,389,424", "1.7%", "9.6%", "966,672,320", "941,642,880", "2.7%"],
|
51
|
+
# ["2019/10", "106,039,504", "101,550,200", "3.8%", "4.4%", "858,787,904", "843,253,632", "1.8%"],
|
52
|
+
# ["2019/09", "102,170,096", "94,921,920", "-3.7%", "7.6%", "752,748,416", "741,703,424", "1.5%"],
|
53
|
+
# ["2019/08", "106,117,600", "91,055,040", "25.2%", "16.5%", "650,578,304", "646,781,376", "0.6%"],
|
54
|
+
# ["2019/07", "84,757,728", "74,370,928", "-1.3%", "14%", "544,460,672", "555,726,400", "-2%"],
|
55
|
+
# ["2019/06", "85,867,928", "70,438,304", "6.8%", "21.9%", "459,702,912", "481,355,488", "-4.5%"],
|
56
|
+
# ["2019/05", "80,436,928", "80,968,736", "7.7%", "-0.6%", "373,835,008", "410,917,184", "-9%"]
|
57
|
+
# ]
|
58
|
+
```
|
59
|
+
|
60
|
+
#### Income Statement (損益表)
|
61
|
+
|
62
|
+
```rb
|
63
|
+
histock = Histock::Simplefilter.new
|
64
|
+
histock.income_statement('2330')
|
65
|
+
# [
|
66
|
+
# ["年度/季別", "營收", "毛利", "營業利益", "稅前淨利", "稅後淨利"],
|
67
|
+
# ["2019Q4", "317,237,065", "159,240,985", "124,243,722", "128,781,973", "116,078,194"],
|
68
|
+
# ["2019Q3", "293,045,439", "139,432,161", "107,887,292", "112,336,271", "101,102,454"],
|
69
|
+
# ["2019Q2", "240,998,475", "103,673,230", "76,304,053", "80,545,440", "66,775,851"],
|
70
|
+
# ["2019Q1", "218,704,469", "90,352,125", "64,266,023", "68,181,652", "61,387,310"],
|
71
|
+
# ["2018Q4", "289,770,193", "138,042,400", "107,123,251", "111,082,092", "100,005,385"],
|
72
|
+
# ["2018Q3", "260,347,882", "123,380,843", "95,245,181", "98,896,942", "89,098,072"],
|
73
|
+
# ["2018Q2", "233,276,811", "111,588,104", "84,428,146", "87,587,608", "72,293,375"],
|
74
|
+
# ["2018Q1", "248,078,671", "124,974,694", "96,826,946", "99,943,621", "89,787,574"]
|
75
|
+
# ]
|
76
|
+
```
|
77
|
+
|
78
|
+
### Dividend Policy (股利政策)
|
79
|
+
|
80
|
+
#### 除權除息
|
31
81
|
|
32
82
|
```rb
|
33
83
|
histock = Histock::Simplefilter.new
|
34
|
-
histock.dividend_policy(
|
84
|
+
histock.dividend_policy('2330')
|
35
85
|
# [
|
36
86
|
# ["所屬年度", "發放年度", "除權日", "除息日", "除權息前股價", "股票股利", "現金股利", "EPS", "配息率", "現金殖利率", "扣抵稅率", "增資配股率", "增資認購價"],
|
37
|
-
# ["2019", "2020", "
|
38
|
-
# ["2019", "2020", "
|
39
|
-
# ["2018", "2019", "
|
40
|
-
# ["2018", "2019", "
|
41
|
-
# ["2018", "2019", "
|
42
|
-
# ["2017", "2018", "
|
43
|
-
# ["2016", "2017", "
|
44
|
-
# ["2015", "2016", "
|
45
|
-
# ["2014", "2015", "
|
46
|
-
# ["2013", "2014", "
|
47
|
-
# ["2012", "2013", "
|
48
|
-
# ["2011", "2012", "
|
49
|
-
# ["2010", "2011", "
|
50
|
-
# ["2009", "2010", "
|
87
|
+
# ["2019", "2020", "", "06/18", "297.5", "0", "2.5", "13.32", "0.1877", "0.0084", "0", "0", "0"],
|
88
|
+
# ["2019", "2020", "", "03/19", "260", "0", "2.5", "13.32", "0.1877", "0.0096", "0", "0", "0"],
|
89
|
+
# ["2018", "2019", "", "12/19", "344.5", "0", "2.5", "13.54", "0.1846", "0.0073", "0", "0", "0"],
|
90
|
+
# ["2018", "2019", "", "09/19", "267", "0", "2", "13.54", "0.1477", "0.0075", "0", "0", "0"],
|
91
|
+
# ["2018", "2019", "", "06/24", "248.5", "0", "8", "13.54", "0.5908", "0.0322", "0", "0", "0"],
|
92
|
+
# ["2017", "2018", "", "06/25", "227.5", "0", "8", "13.23", "0.6047", "0.0352", "0", "0", "0"],
|
93
|
+
# ["2016", "2017", "", "06/26", "217", "0", "7", "12.89", "0.5431", "0.0323", "0.1394", "0", "0"],
|
94
|
+
# ["2015", "2016", "", "06/27", "159", "0", "6", "11.82", "0.5076", "0.0377", "0.1257", "0", "0"],
|
95
|
+
# ["2014", "2015", "", "06/29", "146", "0", "4.5", "10.18", "0.442", "0.0308", "0.1113", "0", "0"],
|
96
|
+
# ["2013", "2014", "", "07/14", "136.5", "0", "3", "7.26", "0.4132", "0.022", "0.0978", "0", "0"],
|
97
|
+
# ["2012", "2013", "", "07/03", "110", "0", "3", "6.41", "0.468", "0.0273", "0.0775", "0", "0"],
|
98
|
+
# ["2011", "2012", "", "07/04", "84.2", "0", "3", "5.18", "0.5792", "0.0356", "0.0669", "0", "0"],
|
99
|
+
# ["2010", "2011", "", "06/29", "72.5", "0", "3", "6.24", "0.4808", "0.0414", "0.0496", "0", "0"],
|
100
|
+
# ["2009", "2010", "", "07/06", "61.4", "0", "3", "3.45", "0.8696", "0.0489", "0.0985", "0", "0"],
|
51
101
|
# ["2008", "2009", "07/15", "07/15", "55.8", "0.05", "3", "3.86", "0.7772", "0.0538", "0", "0", "0"],
|
52
102
|
# ["2007", "2008", "07/16", "07/16", "55.8", "0.05", "3.03", "-", "-", "0", "0.0186", "0.02", "0"]
|
53
103
|
# ]
|
54
104
|
```
|
105
|
+
|
106
|
+
### Profitability (獲利能力)
|
107
|
+
|
108
|
+
#### Profit Ratio (利潤比率)
|
109
|
+
|
110
|
+
```rb
|
111
|
+
histock = Histock::Simplefilter.new
|
112
|
+
histock.profit_ratio('2330')
|
113
|
+
```
|
114
|
+
|
115
|
+
#### Income Rate (報酬率)
|
116
|
+
|
117
|
+
```rb
|
118
|
+
histock = Histock::Simplefilter.new
|
119
|
+
# monthly data
|
120
|
+
histock.income_rate('2330', 'month')
|
121
|
+
# quarterly data
|
122
|
+
histock.income_rate('2330', 'quarter')
|
123
|
+
# yearly data
|
124
|
+
histock.income_rate('2330', 'year')
|
125
|
+
```
|
126
|
+
|
127
|
+
### Corporate Value (企業價值)
|
128
|
+
|
129
|
+
#### PER (本益比)
|
130
|
+
|
131
|
+
```rb
|
132
|
+
histock = Histock::Simplefilter.new
|
133
|
+
histock.price_to_earning_ratio('2330')
|
134
|
+
# [
|
135
|
+
# ["年度/月份", "本益比"],
|
136
|
+
# ["2020/06", "20.44"],
|
137
|
+
# [],
|
138
|
+
# :
|
139
|
+
# ]
|
140
|
+
```
|
141
|
+
|
142
|
+
#### PBR (股價淨值比)
|
143
|
+
|
144
|
+
```rb
|
145
|
+
histock = Histock::Simplefilter.new
|
146
|
+
histock.price_book_ratio('2330')
|
147
|
+
# [
|
148
|
+
# ["年度/月份", "股價淨值比"],
|
149
|
+
# ["2020/06", "4.89"],
|
150
|
+
# [],
|
151
|
+
# :
|
152
|
+
# ]
|
153
|
+
```
|
154
|
+
|
155
|
+
### Request Lists (Method)
|
156
|
+
|
157
|
+
| Category | Request (Ch) | Request (En) | Source URL |
|
158
|
+
|--|--|--|--|
|
159
|
+
| 基本財報 | 每月營收 | Monthly Revenue | https://histock.tw/stock/financial.aspx?no=CODE&t=1&st=1 |
|
160
|
+
| 基本財報 | 損益表 | Income Statement | https://histock.tw/stock/financial.aspx?no=CODE&t=1&st=4 |
|
161
|
+
| 股利政策 | 除權除息 | | https://histock.tw/stock/financial.aspx?no=CODE&t=2 |
|
162
|
+
| 獲利能力 | 利潤比率 | Profit Ratio | https://histock.tw/stock/financial.aspx?no=CODE&t=3&st=1 |
|
163
|
+
| 獲利能力 | 報酬率(單一季) | Income Rate | https://histock.tw/stock/financial.aspx?no=CODE&t=3&st=2&q=1 |
|
164
|
+
| 獲利能力 | 報酬率(近四季) | Income Rate | https://histock.tw/stock/financial.aspx?no=CODE&t=3&st=2&q=2 |
|
165
|
+
| 獲利能力 | 報酬率(年度) | Income Rate | https://histock.tw/stock/financial.aspx?no=CODE&t=3&st=2&q=3 |
|
166
|
+
| 企業價值 | 本益比 | Price-to-Earning Ratio | https://histock.tw/stock/financial.aspx?no=CODE&t=6&st=1 |
|
167
|
+
| 企業價值 | 股價淨值比 | Price-Book Ratio | https://histock.tw/stock/financial.aspx?no=CODE&t=6&st=2 |
|
168
|
+
|
169
|
+
(note) You can fill real code number in 'CODE' field.
|
@@ -1,9 +1,16 @@
|
|
1
1
|
require 'nokogiri'
|
2
|
+
require File.expand_path(File.dirname(__FILE__)) + '/error'
|
3
|
+
require File.expand_path(File.dirname(__FILE__)) + '/fetch/basic_financial_statements'
|
2
4
|
require File.expand_path(File.dirname(__FILE__)) + '/fetch/dividend_policy'
|
5
|
+
require File.expand_path(File.dirname(__FILE__)) + '/fetch/profitability'
|
6
|
+
require File.expand_path(File.dirname(__FILE__)) + '/fetch/corporate_value'
|
3
7
|
|
4
8
|
module Histock
|
5
9
|
module Fetch
|
10
|
+
include BasicFinancialStatements
|
6
11
|
include DividendPolicy
|
12
|
+
include Profitability
|
13
|
+
include CorporateValue
|
7
14
|
|
8
15
|
private
|
9
16
|
|
@@ -11,8 +18,19 @@ module Histock
|
|
11
18
|
doc = Nokogiri::HTML.parse(html, nil, @charset)
|
12
19
|
# => Nokogiri::HTML::Document
|
13
20
|
|
14
|
-
|
15
|
-
|
21
|
+
case query
|
22
|
+
when :monthly_revenue, :dividend_policy
|
23
|
+
nodes = doc.xpath("//div[@class='row-stock']/div[@class='tb-outline']/table[@class='tb-stock text-center tbBasic']")
|
24
|
+
# => Nokogiri::XML::NodeSet
|
25
|
+
when :income_statement
|
26
|
+
nodes = doc.xpath("//div[@class='row-stock']/div[@class='tb-outline']/div/table[@class='tb-stock tbBasic']")
|
27
|
+
when :profit_ratio, :income_rate
|
28
|
+
nodes = doc.xpath("//div[@class='row-stock w1060']/div[@class='tb-outline']/div/table[@class='tb-stock tbBasic']")
|
29
|
+
when :price_to_earning_ratio
|
30
|
+
nodes = doc.xpath("//div[@class='row-stock w740']/table[@class='tb-stock tb-outline tbBasic']")
|
31
|
+
when :price_book_ratio
|
32
|
+
nodes = doc.xpath("//div[@class='row-stock']/table[@class='tb-stock tb-outline tbBasic']")
|
33
|
+
end
|
16
34
|
|
17
35
|
raise InformationNotFound if nodes.empty?
|
18
36
|
raise XMLNodeSetError unless nodes.length.is_one?
|
@@ -20,14 +38,55 @@ module Histock
|
|
20
38
|
node = nodes.first
|
21
39
|
# => Nokogiri::XML::Element
|
22
40
|
|
23
|
-
|
41
|
+
parse_table(:query => query, :element => node)
|
42
|
+
end
|
43
|
+
|
44
|
+
def parse_table query:, element:
|
45
|
+
if children_is_tbody(:element => element)
|
46
|
+
table = parse_tr(:query => query, :element => fetch_tbody(:element => element))
|
47
|
+
else
|
48
|
+
table = parse_tr(:query => query, :element => element)
|
49
|
+
end
|
50
|
+
|
51
|
+
case query
|
52
|
+
when :price_to_earning_ratio, :price_book_ratio
|
53
|
+
_table = Array.new
|
54
|
+
|
55
|
+
_table.concat([table[0][0..1]])
|
56
|
+
|
57
|
+
# remove header
|
58
|
+
table.slice!(0)
|
59
|
+
|
60
|
+
until table.flatten.empty? do
|
61
|
+
_table.concat(table.map { |e| e.slice!(0, 2) })
|
62
|
+
end
|
63
|
+
|
64
|
+
table = _table
|
65
|
+
end
|
66
|
+
|
67
|
+
table
|
68
|
+
end
|
69
|
+
|
70
|
+
def children_is_tbody element:
|
71
|
+
nodes = element.children
|
72
|
+
|
73
|
+
nodes.length.is_one? and nodes.first.name == 'tbody'
|
74
|
+
end
|
75
|
+
|
76
|
+
def fetch_tbody element:
|
77
|
+
element.children
|
78
|
+
end
|
79
|
+
|
80
|
+
# column
|
81
|
+
def parse_tr query:, element:
|
82
|
+
array = Array.new
|
24
83
|
|
25
|
-
|
84
|
+
element.children.each do |e|
|
26
85
|
next unless e.element?
|
27
86
|
|
28
87
|
case e.name
|
29
88
|
when 'tr'
|
30
|
-
value =
|
89
|
+
value = parse_th_td(:query => query, :element => e)
|
31
90
|
|
32
91
|
array.push value unless value.empty?
|
33
92
|
else
|
@@ -35,46 +94,42 @@ module Histock
|
|
35
94
|
end
|
36
95
|
end
|
37
96
|
|
97
|
+
case query
|
98
|
+
when :monthly_revenue
|
99
|
+
header = array.delete_at(0)
|
100
|
+
header.delete_at(-1)
|
101
|
+
header.delete_at(-1)
|
102
|
+
|
103
|
+
header.push array.delete_at(0)
|
104
|
+
header.flatten!
|
105
|
+
|
106
|
+
array.unshift(header)
|
107
|
+
end
|
108
|
+
|
38
109
|
array
|
39
110
|
end
|
40
111
|
|
41
|
-
|
42
|
-
|
112
|
+
# row
|
113
|
+
def parse_th_td query:, element:
|
114
|
+
array = Array.new
|
43
115
|
|
44
116
|
element.children.each do |e|
|
117
|
+
next unless e.element?
|
118
|
+
|
45
119
|
case e.name
|
46
|
-
when 'th' then
|
47
|
-
when 'td' then
|
48
|
-
else
|
120
|
+
when 'th' then array.push e.children.text.gsub(/\<br\>/, '')
|
121
|
+
when 'td' then array.push e.children.text
|
122
|
+
else raise TableFormatError
|
49
123
|
end
|
50
124
|
end
|
51
125
|
|
52
|
-
|
126
|
+
array
|
53
127
|
end
|
54
128
|
end
|
55
129
|
end
|
56
130
|
|
57
131
|
class Integer
|
58
|
-
def is_zero?
|
59
|
-
self == 0
|
60
|
-
end
|
61
|
-
|
62
132
|
def is_one?
|
63
133
|
self == 1
|
64
134
|
end
|
65
135
|
end
|
66
|
-
|
67
|
-
class String
|
68
|
-
def is_currency?
|
69
|
-
(self =~ /^[+-]?[0-9]*[\,]?[0-9]*[\.]?[0-9]+$/).nil? ? false : true
|
70
|
-
end
|
71
|
-
|
72
|
-
def to_currency
|
73
|
-
unless self.is_currency?
|
74
|
-
STDERR.puts "#{__FILE__}:#{__LINE__}: argument - #{self}"
|
75
|
-
raise ArgumentError
|
76
|
-
end
|
77
|
-
|
78
|
-
self.gsub(/[\,]/, '').to_f
|
79
|
-
end
|
80
|
-
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Histock
|
2
|
+
module Fetch
|
3
|
+
module BasicFinancialStatements
|
4
|
+
def monthly_revenue(code)
|
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}
|
11
|
+
parse(:query => __method__, :html => get('/financial.aspx', params))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Histock
|
2
|
+
module Fetch
|
3
|
+
module CorporateValue
|
4
|
+
def price_to_earning_ratio(code)
|
5
|
+
params = {:no => code, :t => 6, :st => 1}
|
6
|
+
parse(:query => __method__, :html => get('/financial.aspx', params))
|
7
|
+
end
|
8
|
+
|
9
|
+
def price_book_ratio(code)
|
10
|
+
params = {:no => code, :t => 6, :st => 2}
|
11
|
+
parse(:query => __method__, :html => get('/financial.aspx', params))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
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, period)
|
10
|
+
case period
|
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 raise ArgumentError
|
15
|
+
end
|
16
|
+
|
17
|
+
parse(:query => __method__, :html => get('/financial.aspx', params))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: histock-simplefilter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.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-
|
11
|
+
date: 2020-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -102,7 +102,10 @@ files:
|
|
102
102
|
- lib/histock/simplefilter/connection.rb
|
103
103
|
- lib/histock/simplefilter/error.rb
|
104
104
|
- lib/histock/simplefilter/fetch.rb
|
105
|
+
- lib/histock/simplefilter/fetch/basic_financial_statements.rb
|
106
|
+
- lib/histock/simplefilter/fetch/corporate_value.rb
|
105
107
|
- lib/histock/simplefilter/fetch/dividend_policy.rb
|
108
|
+
- lib/histock/simplefilter/fetch/profitability.rb
|
106
109
|
- lib/histock/simplefilter/version.rb
|
107
110
|
homepage: https://github.com/ysato5654/histock-simplefilter
|
108
111
|
licenses:
|
@@ -126,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
129
|
- !ruby/object:Gem::Version
|
127
130
|
version: '0'
|
128
131
|
requirements: []
|
129
|
-
rubygems_version: 3.1.
|
132
|
+
rubygems_version: 3.1.3
|
130
133
|
signing_key:
|
131
134
|
specification_version: 4
|
132
135
|
summary: HiStock (https://histock.tw/) filter
|