watchcow 0.1.4 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/lib/watchcow/client.rb +9 -11
- data/lib/watchcow/rate.rb +5 -6
- data/lib/watchcow/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99751f179eb4c15e3b19d81e778b8fb6c3c99e5582fb51ce0130aaa8ab436b8d
|
4
|
+
data.tar.gz: d78b9d8c59613ca84e186c5a2ff783fb68817fb32ec0aa2ff727a88b213f346a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75ef29d231100e343af3879050df3945dafe1e30fab0a5dd9d5e998e4595144e963264d87585c238fb0916198d942f984612b01e610645f5da67c63ef33b2302
|
7
|
+
data.tar.gz: 18f09893ef9c952b124f79f119379c0a16bcb86b2b60e9a022b2ac0f61c49a202ddcf4f28ce6ba1743e824e8988171befbfb23640504f16aa5073896444ea8fd
|
data/.gitignore
CHANGED
data/lib/watchcow/client.rb
CHANGED
@@ -38,17 +38,15 @@ module Watchcow
|
|
38
38
|
best_cw = cw.first
|
39
39
|
best_nw = nw.first
|
40
40
|
text = [best_nq, best_cq, best_nw, best_cw].each do |x|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
CONTENT
|
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
|
+
---
|
48
|
+
|
49
|
+
CONTENT
|
52
50
|
puts t
|
53
51
|
end
|
54
52
|
end
|
data/lib/watchcow/rate.rb
CHANGED
@@ -21,18 +21,18 @@ module Watchcow
|
|
21
21
|
# puts dm_symbol.dig(:symbol)
|
22
22
|
spot_result = Watchcow::MarketDepth.call(params: spot_symbol, k: :spot)
|
23
23
|
# puts spot_symbol.dig(:symbol)
|
24
|
+
dm_result = JSON.parse dm_result
|
25
|
+
days_remain = self.days_remain_of(coin, t)
|
24
26
|
rescue
|
25
27
|
redo
|
26
28
|
end
|
27
|
-
|
28
|
-
days_remain = self.days_remain_of(coin, t)
|
29
|
+
|
29
30
|
dm_first_bid = dm_result.dig('tick', 'bids')[0][0].to_f
|
30
31
|
spot_first_bid = spot_result.dig('tick', 'bids')[0][0].to_f
|
31
32
|
margin_annual = (((dm_first_bid - spot_first_bid) / spot_first_bid) / days_remain * 365 * 100).round(6)
|
32
33
|
margin_expect = margin_annual / 365 * days_remain
|
33
34
|
|
34
35
|
real_margin_expect = (1.0 / spot_first_bid - 1.0 / dm_first_bid) * spot_first_bid * 100
|
35
|
-
|
36
36
|
result = {
|
37
37
|
coin: "#{coin}_#{t}",
|
38
38
|
margin: margin_annual,
|
@@ -60,11 +60,10 @@ module Watchcow
|
|
60
60
|
def days_remain_of symbol, t
|
61
61
|
@contract_info ||= Watchcow::ContractInfo.call
|
62
62
|
line = @contract_info.dig('data').select do |h|
|
63
|
-
# mark = t == 'cq' ? 'quarter' : 'next_quarter'
|
64
|
-
# h.dig('symbol') == symbol.upcase && h.dig('contract_type') == mark
|
65
63
|
h.dig('symbol') == symbol.upcase && h.dig('contract_type') == KEYS[t]
|
66
64
|
end.first
|
67
|
-
|
65
|
+
contract_time = "#{line.dig("delivery_date").to_date.to_s} 16:00".in_time_zone('Asia/Chongqing').to_time
|
66
|
+
((contract_time - Time.now.to_time) / 1.hours) / 24
|
68
67
|
end
|
69
68
|
end
|
70
69
|
end
|
data/lib/watchcow/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.9
|
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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|