watchcow 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18f98bbeb12754d97497bdeecf6d61b07683a89ccb37aa9bfd68a5cdc16567db
4
- data.tar.gz: 2b57f17b2c5fd791e1dc085a7b546e4612dd349862d5ae0484e494750a91a3c7
3
+ metadata.gz: b9be8072f67eb62cbc4b7cf1ba09f62d336121edd4190cf0cf8c90c5a72bda52
4
+ data.tar.gz: ff1d7c9ec0a90d00f591a097240192b2b971e6dbece3e8fea816a313f15551ae
5
5
  SHA512:
6
- metadata.gz: 9730873a76343753eca447c9b9ff8255d94421d1310324041257fec76fc90e85c8734a31cbadae622451a4e0300c8122a77a3674eff83f140bdc1c0f1d1cd1d8
7
- data.tar.gz: dce9af75b01ba206bc8d7b74a1a3d2d392947173531a07c54db5169673a21fa6ef408f50b426ca6e0ddbdead018b7cce355539053439d4ae1eedc89fdf911345
6
+ metadata.gz: 2f16346c204fe851b6d09c42c69e6fe38fb4a98bf29f2ba877650d17f72f6f477dbdd0d8732715b3a9d8488a44cc14a4e5cc353c88fd36a874641375391dcd8c
7
+ data.tar.gz: 8fd9836528fc159891f4889b964b5a5bfb3eeca1ed490fc62c5f2d9b0ce04fa6d928bb0a47ceda1745f2b6e580bd4aacf937a619650e37d5134534c2abf2e9e9
@@ -3,7 +3,6 @@ require 'watchcow/contract_info'
3
3
  require 'watchcow/market_depth'
4
4
  require 'active_support'
5
5
  require 'watchcow/rate'
6
- require 'watchcow/stare'
7
6
 
8
7
  module Watchcow
9
8
  class Client
@@ -24,7 +23,44 @@ module Watchcow
24
23
  end
25
24
 
26
25
  def stare coin
27
- Watchcow::Stare.do coin
26
+ while true
27
+ list_text(JSON.parse(call(coin)))
28
+ end
29
+ end
30
+
31
+ def list_text results
32
+ cq = results.dig('cq_list')
33
+ nq = results.dig('nq_list')
34
+ cw = results.dig('cw_list')
35
+ nw = results.dig('nw_list')
36
+ best_cq = cq.first
37
+ best_nq = nq.first
38
+ best_cw = cw.first
39
+ best_nw = nw.first
40
+ text = [best_nq, best_cq, best_nw, best_cw].each do |x|
41
+ t =
42
+ <<-CONTENT
43
+ #{x.dig('coin')}
44
+ remained: #{x.dig('days')}
45
+ annual margin: #{x.dig('margin')}%
46
+ expected margin: #{x.dig('expected_margin')}%
47
+ landed margin: #{x.dig('real_margin_expected')}%
48
+ first dm bid: #{x.dig('dm_first_bid')}
49
+ first spot bid: #{x.dig('spot_first_bid')}
50
+
51
+ CONTENT
52
+ puts t
53
+ end
54
+ end
55
+
56
+ def all_text results
57
+ results.map do |k, v|
58
+ v.map do |c|
59
+ c.values.map{|x| x}
60
+ end
61
+ end.inject(&:+).map do |str|
62
+ "<p>#{str}</p>"
63
+ end
28
64
  end
29
65
  end
30
66
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Watchcow
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - DrinE Liu
@@ -67,9 +67,7 @@ files:
67
67
  - lib/watchcow/client.rb
68
68
  - lib/watchcow/contract_info.rb
69
69
  - lib/watchcow/market_depth.rb
70
- - lib/watchcow/output.rb
71
70
  - lib/watchcow/rate.rb
72
- - lib/watchcow/stare.rb
73
71
  - lib/watchcow/version.rb
74
72
  - watchcow-0.0.2.gem
75
73
  - watchcow-0.0.3.gem
@@ -1,10 +0,0 @@
1
- # module Watchcow
2
- # class Output
3
- # class << self
4
- # def call text
5
- # path = File.expand_path('~/', __FILE__)
6
- # File.open("#{path}/info.html", 'w+'){|f| f.write(text)}
7
- # end
8
- # end
9
- # end
10
- # end
@@ -1,50 +0,0 @@
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