watchcow 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/watchcow.rb +1 -2
- data/lib/watchcow/client.rb +5 -0
- data/lib/watchcow/stare.rb +50 -0
- data/lib/watchcow/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: 18f98bbeb12754d97497bdeecf6d61b07683a89ccb37aa9bfd68a5cdc16567db
|
4
|
+
data.tar.gz: 2b57f17b2c5fd791e1dc085a7b546e4612dd349862d5ae0484e494750a91a3c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9730873a76343753eca447c9b9ff8255d94421d1310324041257fec76fc90e85c8734a31cbadae622451a4e0300c8122a77a3674eff83f140bdc1c0f1d1cd1d8
|
7
|
+
data.tar.gz: dce9af75b01ba206bc8d7b74a1a3d2d392947173531a07c54db5169673a21fa6ef408f50b426ca6e0ddbdead018b7cce355539053439d4ae1eedc89fdf911345
|
data/lib/watchcow.rb
CHANGED
data/lib/watchcow/client.rb
CHANGED
@@ -3,6 +3,7 @@ require 'watchcow/contract_info'
|
|
3
3
|
require 'watchcow/market_depth'
|
4
4
|
require 'active_support'
|
5
5
|
require 'watchcow/rate'
|
6
|
+
require 'watchcow/stare'
|
6
7
|
|
7
8
|
module Watchcow
|
8
9
|
class Client
|
@@ -21,6 +22,10 @@ module Watchcow
|
|
21
22
|
}
|
22
23
|
results.to_json
|
23
24
|
end
|
25
|
+
|
26
|
+
def stare coin
|
27
|
+
Watchcow::Stare.do coin
|
28
|
+
end
|
24
29
|
end
|
25
30
|
end
|
26
31
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Watchcow
|
2
|
+
class Stare
|
3
|
+
class << self
|
4
|
+
def do(coin)
|
5
|
+
while true
|
6
|
+
r = Watchcow::Client.call(coin)
|
7
|
+
result = JSON.parse(r)
|
8
|
+
list_text(result)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def list_text results
|
15
|
+
cq = results.dig('cq_list')
|
16
|
+
nq = results.dig('nq_list')
|
17
|
+
cw = results.dig('cw_list')
|
18
|
+
nw = results.dig('nw_list')
|
19
|
+
best_cq = cq.first
|
20
|
+
best_nq = nq.first
|
21
|
+
best_cw = cw.first
|
22
|
+
best_nw = nw.first
|
23
|
+
text = [best_nq, best_cq, best_nw, best_cw].each do |x|
|
24
|
+
t =
|
25
|
+
<<-CONTENT
|
26
|
+
#{x.dig('coin')}
|
27
|
+
remained: #{x.dig('days')}
|
28
|
+
annual margin: #{x.dig('margin')}%
|
29
|
+
expected margin: #{x.dig('expected_margin')}%
|
30
|
+
landed margin: #{x.dig('real_margin_expected')}%
|
31
|
+
first dm bid: #{x.dig('dm_first_bid')}
|
32
|
+
first spot bid: #{x.dig('spot_first_bid')}
|
33
|
+
|
34
|
+
CONTENT
|
35
|
+
puts t
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def all_text results
|
40
|
+
results.map do |k, v|
|
41
|
+
v.map do |c|
|
42
|
+
c.values.map{|x| x}
|
43
|
+
end
|
44
|
+
end.inject(&:+).map do |str|
|
45
|
+
"<p>#{str}</p>"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/watchcow/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watchcow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DrinE Liu
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- lib/watchcow/market_depth.rb
|
70
70
|
- lib/watchcow/output.rb
|
71
71
|
- lib/watchcow/rate.rb
|
72
|
+
- lib/watchcow/stare.rb
|
72
73
|
- lib/watchcow/version.rb
|
73
74
|
- watchcow-0.0.2.gem
|
74
75
|
- watchcow-0.0.3.gem
|