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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a103bd6703fb1ae5b370496b0ea1fe7539d288998a974e2c6b0404f77521cc28
4
- data.tar.gz: 298abafd272b2fd43766391438e46add06c55970e7410dfdce03d4563ebdbadd
3
+ metadata.gz: 18f98bbeb12754d97497bdeecf6d61b07683a89ccb37aa9bfd68a5cdc16567db
4
+ data.tar.gz: 2b57f17b2c5fd791e1dc085a7b546e4612dd349862d5ae0484e494750a91a3c7
5
5
  SHA512:
6
- metadata.gz: 06042404a46134caec73eddab358bf7e34bd537759484f7ea398e0dd8dae635223ee63a84efb810074180de07df2c6f42a2d8f12ff6616e22cbbc940a73d412c
7
- data.tar.gz: a1b001a5eb99baba0f2a89691417ea4cacac8a6355e1a14af1f01fa313e7a8bae115e58615b2aebb033c28108e37226d7489ffff5578bfb8ba8b254aca71c7e0
6
+ metadata.gz: 9730873a76343753eca447c9b9ff8255d94421d1310324041257fec76fc90e85c8734a31cbadae622451a4e0300c8122a77a3674eff83f140bdc1c0f1d1cd1d8
7
+ data.tar.gz: dce9af75b01ba206bc8d7b74a1a3d2d392947173531a07c54db5169673a21fa6ef408f50b426ca6e0ddbdead018b7cce355539053439d4ae1eedc89fdf911345
data/lib/watchcow.rb CHANGED
@@ -2,5 +2,4 @@
2
2
  require 'json'
3
3
  require 'httparty'
4
4
  require "pry"
5
- require 'watchcow/client'
6
- require 'watchcow/stare'
5
+ require 'watchcow/client'
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Watchcow
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
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.2
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