watchcow 0.1.1 → 0.1.6

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: 9ce85d0bb1815237ea4947df90d00329edfac41c75fdfd71cd6f2b509ea41a9e
4
- data.tar.gz: 2260c60ceb4e70662a335bbd9e4f4a57a1340a35f4f5e97144fde699b7e8f598
3
+ metadata.gz: c1b15c9de20d884e068ef230f92b09657a1cf93af7f1373d003ec1e8478b630c
4
+ data.tar.gz: 91899f1fe1756b5dbd28f5adb7c76335660491c7151114b0d850e64745fc9af9
5
5
  SHA512:
6
- metadata.gz: f74a57c2b531877f0873fe635c48df9fcc6ff03b28baa6486575eac88d6a992d5cd342f657dc54cb07bd56c7cb43c68c460151718845b2d8d20afd2116d558a8
7
- data.tar.gz: 627e9ac1658d62bb397aafc9df9dacdbeafcfc385166822f6190df38c1e51e3e9711838b88b4b5ae6dfbff5e78c7b90f7d156263cbe18dca77e6c02658f5d8c4
6
+ metadata.gz: 98a8e7ec181598f1e06b1d6716759e002e4cb7c435e31d01c385726e0fa0a3d130ec0a566a6f7056fd17afea6f66e3fdb589c95ea2f59e9260adc0e3819050d0
7
+ data.tar.gz: 07f6533ef510386861017afd3bb116f9134237256e83eddd721d7dea2b7e2a60db2ed619b546f561887c625ce5d5bfe778f53557fe8743e2be85ee169a6a951c
@@ -7,8 +7,8 @@ require 'watchcow/rate'
7
7
  module Watchcow
8
8
  class Client
9
9
  class << self
10
- def call
11
- results = Watchcow::Rate.call
10
+ def call(coin=nil)
11
+ results = Watchcow::Rate.call(coin)
12
12
  cq_list = results[:cq_list]
13
13
  nq_list = results[:nq_list]
14
14
  nw_list = results[:nw_list]
@@ -21,6 +21,43 @@ module Watchcow
21
21
  }
22
22
  results.to_json
23
23
  end
24
+
25
+ def stare 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')}, #{x.dig('days')} days left
44
+ annual margin: #{x.dig('margin')}%
45
+ landed margin: #{x.dig('real_margin_expected')}%
46
+ dm bid: #{x.dig('dm_first_bid')}, spot bid: #{x.dig('spot_first_bid')}
47
+ CONTENT
48
+ puts t
49
+ end
50
+ end
51
+
52
+ def all_text results
53
+ results.map do |k, v|
54
+ v.map do |c|
55
+ c.values.map{|x| x}
56
+ end
57
+ end.inject(&:+).map do |str|
58
+ "<p>#{str}</p>"
59
+ end
60
+ end
24
61
  end
25
62
  end
26
63
  end
data/lib/watchcow/rate.rb CHANGED
@@ -9,9 +9,10 @@ module Watchcow
9
9
  'cw' => 'this_week'
10
10
  }
11
11
  class << self
12
- def call
12
+ def call coin=nil
13
13
  results = []
14
- Watchcow::ApiSymbol.contract_list.each do |coin|
14
+ coin_list = coin.nil? ? Watchcow::ApiSymbol.contract_list : [coin]
15
+ coin_list.each do |coin|
15
16
  Watchcow::ApiSymbol.dm_types.each do |t|
16
17
  dm_symbol = {symbol: "#{coin}_#{t}"}
17
18
  spot_symbol = {symbol: "#{coin}usdt"}
@@ -20,11 +21,12 @@ module Watchcow
20
21
  # puts dm_symbol.dig(:symbol)
21
22
  spot_result = Watchcow::MarketDepth.call(params: spot_symbol, k: :spot)
22
23
  # puts spot_symbol.dig(:symbol)
24
+ dm_result = JSON.parse dm_result
25
+ days_remain = self.days_remain_of(coin, t)
23
26
  rescue
24
27
  redo
25
28
  end
26
- dm_result = JSON.parse dm_result
27
- days_remain = self.days_remain_of(coin, t)
29
+
28
30
  dm_first_bid = dm_result.dig('tick', 'bids')[0][0].to_f
29
31
  spot_first_bid = spot_result.dig('tick', 'bids')[0][0].to_f
30
32
  margin_annual = (((dm_first_bid - spot_first_bid) / spot_first_bid) / days_remain * 365 * 100).round(6)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Watchcow
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.6"
5
5
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watchcow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - DrinE Liu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-17 00:00:00.000000000 Z
11
+ date: 2021-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -67,7 +67,6 @@ 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
71
  - lib/watchcow/version.rb
73
72
  - watchcow-0.0.2.gem
@@ -76,6 +75,7 @@ files:
76
75
  - watchcow-0.0.5.gem
77
76
  - watchcow-0.0.6.gem
78
77
  - watchcow-0.0.7.gem
78
+ - watchcow-0.0.9.gem
79
79
  - watchcow.gemspec
80
80
  homepage: https://rubygems.org/gems
81
81
  licenses:
@@ -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