sbi-security 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +28 -0
- data/lib/sbi/security/cli.rb +10 -1
- data/lib/sbi/security/crawler.rb +19 -8
- data/lib/sbi/security/decorator/order_book_decorator.rb +14 -0
- data/lib/sbi/security/decorator/stock_decorator.rb +4 -0
- data/lib/sbi/security/order_book.rb +10 -0
- data/lib/sbi/security/stock.rb +1 -0
- data/lib/sbi/security/version.rb +1 -1
- data/lib/sbi/security.rb +2 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e69337392b0e46a91cdf5158e5c6d5742688129
|
4
|
+
data.tar.gz: 3995e86bdb82046a77afebf11f04a77c6497e073
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f36e009baac158e8892bf15e60e0215001cd5fa7441bd2c19ea7cfd7d0de4b2e5679ee2e8dd86daba11ef11703dbe2c5e6418e0a800d79c67d42c7f7c11ca0a
|
7
|
+
data.tar.gz: a4e833b76541eaa5125b5c67710e5440b6c295a59fdf77a3734b11f9921c2122606ab4b523288dbdfb1ae23882821dbc24877bab7d27d78deb6f20f66846b048
|
data/README.md
CHANGED
@@ -46,6 +46,34 @@ $ sbisec stock 3633
|
|
46
46
|
+--------+--------------+--------+--------+---------+-------+-------+-------+----------+--------+-----------+
|
47
47
|
| 3633 | GMOペパボ | 3,390 | -20 | -0.59 | 3,405 | 3,405 | 3,380 | 3,410 | 500 | 1,696,000 |
|
48
48
|
+--------+--------------+--------+--------+---------+-------+-------+-------+----------+--------+-----------+
|
49
|
+
|
50
|
+
|
51
|
+
+------------+--------+------------+
|
52
|
+
| 売気配株数 | 気配値 | 買気配株数 |
|
53
|
+
+------------+--------+------------+
|
54
|
+
| 3,800 | OVER | |
|
55
|
+
| 100 | 3,490 | |
|
56
|
+
| 400 | 3,450 | |
|
57
|
+
| 500 | 3,445 | |
|
58
|
+
| 500 | 3,435 | |
|
59
|
+
| 400 | 3,430 | |
|
60
|
+
| 100 | 3,420 | |
|
61
|
+
| 1,300 | 3,415 | |
|
62
|
+
| 200 | 3,410 | |
|
63
|
+
| 300 | 3,405 | |
|
64
|
+
| 前 200 | 3,400 | |
|
65
|
+
| | 3,390 | 前 500 |
|
66
|
+
| | 3,370 | 400 |
|
67
|
+
| | 3,365 | 200 |
|
68
|
+
| | 3,360 | 200 |
|
69
|
+
| | 3,355 | 100 |
|
70
|
+
| | 3,350 | 200 |
|
71
|
+
| | 3,345 | 200 |
|
72
|
+
| | 3,340 | 200 |
|
73
|
+
| | 3,335 | 200 |
|
74
|
+
| | 3,330 | 300 |
|
75
|
+
| | UNDER | 3,000 |
|
76
|
+
+------------+--------+------------+
|
49
77
|
```
|
50
78
|
|
51
79
|
## TODO
|
data/lib/sbi/security/cli.rb
CHANGED
@@ -24,8 +24,17 @@ module Sbi::Security
|
|
24
24
|
rows << stock.decorate.header
|
25
25
|
rows << :separator
|
26
26
|
rows << stock.decorate.format
|
27
|
+
stock_table = Terminal::Table.new(rows: rows)
|
27
28
|
|
28
|
-
|
29
|
+
rows = []
|
30
|
+
rows << stock.decorate.order_book_header
|
31
|
+
rows << :separator
|
32
|
+
stock.order_books.each do |order_book|
|
33
|
+
rows << order_book.decorate.format
|
34
|
+
end
|
35
|
+
order_book_table = Terminal::Table.new(rows: rows)
|
36
|
+
|
37
|
+
"#{stock_table}\n\n#{order_book_table}"
|
29
38
|
end
|
30
39
|
end
|
31
40
|
end
|
data/lib/sbi/security/crawler.rb
CHANGED
@@ -19,7 +19,7 @@ module Sbi::Security
|
|
19
19
|
def portfolio
|
20
20
|
find("img[title='ポートフォリオ']").click
|
21
21
|
|
22
|
-
stocks =
|
22
|
+
stocks = all(:xpath, '//table[@width="100%"]/tbody/tr[@align="center"]').drop(1).each_with_index.map do |tr, i|
|
23
23
|
_, code_and_name, _, count, value, price, price_ratio, price_ratio_percentage, profit, profit_percentage,
|
24
24
|
total_value = tr.all("td").map { |td| td.text.gsub(/,/, "") }
|
25
25
|
|
@@ -41,24 +41,34 @@ module Sbi::Security
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def stock(code)
|
44
|
-
|
44
|
+
find(:xpath, "//input[@id='top_stock_sec']").set code
|
45
45
|
find("img[title='株価検索']").click
|
46
46
|
|
47
47
|
# SBI security has XHR for fetching information. Need to wait until page finish to emulate JavaScript.
|
48
48
|
loop do
|
49
|
-
if
|
49
|
+
if find(:xpath, "//td[@id='MTB0_0']/p/em/span[@class='fxx01']").text != "--"
|
50
50
|
break
|
51
51
|
end
|
52
52
|
sleep 1
|
53
53
|
end
|
54
54
|
|
55
|
-
price_ratio, price_ratio_percentage =
|
56
|
-
start_price, end_price, highest_price, total_stock, lowest_price, total_price =
|
55
|
+
price_ratio, price_ratio_percentage = all(:xpath, "//td[@id='MTB0_1']/p/span").map { |td| td.text.gsub(/,/, "") }
|
56
|
+
start_price, end_price, highest_price, total_stock, lowest_price, total_price = all(:xpath, "//table[@class='tbl690']/tbody/tr/td/p/span[@class='fm01']").map { |td| td.text.gsub(/,/, "") }
|
57
|
+
|
58
|
+
order_books = all(:xpath, "//div[@class='itaTbl02']/table/tbody/tr").drop(1).map do |tr|
|
59
|
+
sell_volume, price, buy_volume = tr.all(:xpath, "./td").map(&:text)
|
60
|
+
|
61
|
+
OrderBook.new(
|
62
|
+
volume: sell_volume.empty? ? buy_volume : sell_volume,
|
63
|
+
price: price,
|
64
|
+
type: sell_volume.empty? ? "buy" : "sell"
|
65
|
+
)
|
66
|
+
end
|
57
67
|
|
58
68
|
Stock.new(
|
59
69
|
code: code,
|
60
|
-
name:
|
61
|
-
price:
|
70
|
+
name: find(:xpath, "//h3/span[@class='fxx01']").text,
|
71
|
+
price: find(:xpath, "//td[@id='MTB0_0']/p/em/span[@class='fxx01']").text.gsub(/,/, ""),
|
62
72
|
price_ratio: empty_string_to_num(price_ratio).to_i,
|
63
73
|
price_ratio_percentage: empty_string_to_num(price_ratio_percentage).to_f,
|
64
74
|
start_price: start_price.to_i,
|
@@ -66,7 +76,8 @@ module Sbi::Security
|
|
66
76
|
highest_price: highest_price.to_i,
|
67
77
|
total_stock: total_stock.to_i,
|
68
78
|
lowest_price: lowest_price.to_i,
|
69
|
-
total_price: total_price.to_i * 1000
|
79
|
+
total_price: total_price.to_i * 1000,
|
80
|
+
order_books: order_books
|
70
81
|
)
|
71
82
|
end
|
72
83
|
|
data/lib/sbi/security/stock.rb
CHANGED
data/lib/sbi/security/version.rb
CHANGED
data/lib/sbi/security.rb
CHANGED
@@ -18,7 +18,9 @@ require "sbi/security/decorator"
|
|
18
18
|
require "sbi/security/decorator/portfolio_decorator"
|
19
19
|
require "sbi/security/decorator/portfolio_stock_decorator"
|
20
20
|
require "sbi/security/decorator/stock_decorator"
|
21
|
+
require "sbi/security/decorator/order_book_decorator"
|
21
22
|
require "sbi/security/portfolio"
|
22
23
|
require "sbi/security/portfolio_stock"
|
24
|
+
require "sbi/security/order_book"
|
23
25
|
require "sbi/security/stock"
|
24
26
|
require "sbi/security/version"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sbi-security
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- camelmasa
|
@@ -156,10 +156,12 @@ files:
|
|
156
156
|
- lib/sbi/security/client.rb
|
157
157
|
- lib/sbi/security/crawler.rb
|
158
158
|
- lib/sbi/security/decorator.rb
|
159
|
+
- lib/sbi/security/decorator/order_book_decorator.rb
|
159
160
|
- lib/sbi/security/decorator/portfolio_decorator.rb
|
160
161
|
- lib/sbi/security/decorator/portfolio_stock_decorator.rb
|
161
162
|
- lib/sbi/security/decorator/stock_decorator.rb
|
162
163
|
- lib/sbi/security/formatter.rb
|
164
|
+
- lib/sbi/security/order_book.rb
|
163
165
|
- lib/sbi/security/portfolio.rb
|
164
166
|
- lib/sbi/security/portfolio_stock.rb
|
165
167
|
- lib/sbi/security/stock.rb
|