watchcow 0.0.9 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/watchcow/client.rb +43 -2
- data/lib/watchcow/rate.rb +7 -5
- data/lib/watchcow/version.rb +1 -1
- data/watchcow-0.0.9.gem +0 -0
- metadata +3 -3
- data/lib/watchcow/output.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4ab5d0732e75c883a3d49c49f3df8135ddebe108def030247efadd9dfcadae5
|
4
|
+
data.tar.gz: 527d958620db506d46f9673f6ab88cd99153211384399aea1eb284836135c343
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85275053ba4d1d752fe63748de876c4e427d832b371f3db86982dacbb194b66fdba925cdbf8bacc8d43c0cc1f02bafffb65543c03751a017a9e07624d02d4efd
|
7
|
+
data.tar.gz: 55664d43e1eea63184a6231f45df738692bf218511a669843dc27a909986c7b1c8c22be1a9b78e0ea5a31abdb28dfe648cd0c56fd4d4c35833d5f57243f35fdd
|
data/lib/watchcow/client.rb
CHANGED
@@ -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,47 @@ 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')}
|
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
|
64
|
+
end
|
24
65
|
end
|
25
66
|
end
|
26
67
|
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
|
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
|
-
|
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)
|
@@ -37,7 +39,7 @@ module Watchcow
|
|
37
39
|
margin: margin_annual,
|
38
40
|
days: days_remain,
|
39
41
|
expected_margin: margin_expect,
|
40
|
-
real_margin_expected: real_margin_expect
|
42
|
+
real_margin_expected: real_margin_expect,
|
41
43
|
dm_first_bid: dm_first_bid,
|
42
44
|
spot_first_bid: spot_first_bid
|
43
45
|
}
|
data/lib/watchcow/version.rb
CHANGED
data/watchcow-0.0.9.gem
ADDED
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.
|
4
|
+
version: 0.1.5
|
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-
|
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:
|