watchcow 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +18 -6
- data/lib/watchcow/api_symbol.rb +16 -1
- data/lib/watchcow/contract_info.rb +4 -0
- data/lib/watchcow/market_depth.rb +0 -1
- data/lib/watchcow/rate.rb +2 -9
- 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: 9278d3d386832cfad1db4406ee6c5b0343c2dd096135aaedd9a4cf98c6ff59cd
|
4
|
+
data.tar.gz: c098df95b942ed5ba925f5af509f3845378d79aca20103d6d11d7830711f3439
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd615fc5b8559d39e6f05d5f3f29da5742b0b6e5e25398b2446557e7e8bfc8f37708fafde6cc6ec743b885a27171eebbff077386db05ff0183dec45e8203fa89
|
7
|
+
data.tar.gz: 6d93a1703a8bc79de7e84ba126de8e39ddb435780b5a9d4f937b755dd17ed91d707de013d6ca5e1eb2d55ecb18136f02e3534b28166a6c9758b12a7d49620580
|
data/Gemfile.lock
CHANGED
@@ -1,23 +1,29 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
watchcow (0.
|
4
|
+
watchcow (0.1.11)
|
5
5
|
httparty (~> 0.14, >= 0.14.0)
|
6
6
|
pry-rails (~> 0.3.9)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
+
activesupport (6.1.3.2)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 1.6, < 2)
|
14
|
+
minitest (>= 5.1)
|
15
|
+
tzinfo (~> 2.0)
|
16
|
+
zeitwerk (~> 2.3)
|
11
17
|
coderay (1.1.3)
|
18
|
+
concurrent-ruby (1.1.8)
|
12
19
|
connection_pool (2.2.5)
|
13
20
|
diff-lcs (1.4.4)
|
14
|
-
httparty (0.
|
15
|
-
mime-types (~> 3.0)
|
21
|
+
httparty (0.14.0)
|
16
22
|
multi_xml (>= 0.5.2)
|
23
|
+
i18n (1.8.10)
|
24
|
+
concurrent-ruby (~> 1.0)
|
17
25
|
method_source (1.0.0)
|
18
|
-
|
19
|
-
mime-types-data (~> 3.2015)
|
20
|
-
mime-types-data (3.2021.0225)
|
26
|
+
minitest (5.14.3)
|
21
27
|
multi_xml (0.6.0)
|
22
28
|
pry (0.14.1)
|
23
29
|
coderay (~> 1.1)
|
@@ -44,11 +50,17 @@ GEM
|
|
44
50
|
connection_pool (~> 2.2, >= 2.2.2)
|
45
51
|
rack (~> 2.0)
|
46
52
|
rack-protection (>= 1.5.0)
|
53
|
+
tzinfo (2.0.4)
|
54
|
+
concurrent-ruby (~> 1.0)
|
55
|
+
zeitwerk (2.4.2)
|
47
56
|
|
48
57
|
PLATFORMS
|
49
58
|
x86_64-darwin-17
|
50
59
|
|
51
60
|
DEPENDENCIES
|
61
|
+
activesupport (~> 6.1, >= 6.1.3.2)
|
62
|
+
httparty (= 0.14.0)
|
63
|
+
pry-rails
|
52
64
|
rake (~> 13.0)
|
53
65
|
rspec (~> 3.0)
|
54
66
|
watchcow!
|
data/lib/watchcow/api_symbol.rb
CHANGED
@@ -6,7 +6,22 @@ module Watchcow
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def dm_types
|
9
|
-
|
9
|
+
data = mapping.select do |k, v|
|
10
|
+
v.in? current_types
|
11
|
+
end.keys
|
12
|
+
end
|
13
|
+
|
14
|
+
def current_types
|
15
|
+
Watchcow::ContractInfo.current_contracts
|
16
|
+
end
|
17
|
+
|
18
|
+
def mapping
|
19
|
+
{
|
20
|
+
'cq' => 'quarter',
|
21
|
+
'nq' => 'next_quarter',
|
22
|
+
'nw' => 'next_week',
|
23
|
+
'cw' => 'this_week'
|
24
|
+
}
|
10
25
|
end
|
11
26
|
end
|
12
27
|
end
|
data/lib/watchcow/rate.rb
CHANGED
@@ -2,12 +2,6 @@ require 'active_support/core_ext'
|
|
2
2
|
|
3
3
|
module Watchcow
|
4
4
|
class Rate
|
5
|
-
KEYS = {
|
6
|
-
'cq' => 'quarter',
|
7
|
-
'nq' => 'next_quarter',
|
8
|
-
'nw' => 'next_week',
|
9
|
-
'cw' => 'this_week'
|
10
|
-
}
|
11
5
|
class << self
|
12
6
|
def call coin=nil
|
13
7
|
results = []
|
@@ -26,14 +20,13 @@ module Watchcow
|
|
26
20
|
rescue
|
27
21
|
redo
|
28
22
|
end
|
29
|
-
|
23
|
+
|
30
24
|
dm_first_bid = dm_result.dig('tick', 'bids')[0][0].to_f
|
31
25
|
spot_first_bid = spot_result.dig('tick', 'bids')[0][0].to_f
|
32
26
|
margin_annual = (((dm_first_bid - spot_first_bid) / spot_first_bid) / days_remain * 365 * 100).round(6)
|
33
27
|
margin_expect = margin_annual / 365 * days_remain
|
34
28
|
base_gap = dm_first_bid - spot_first_bid
|
35
29
|
gap_rate = base_gap / dm_first_bid * 100
|
36
|
-
binding.pry if days_remain <= 0
|
37
30
|
real_margin_expect = (1.0 / spot_first_bid - 1.0 / dm_first_bid) * spot_first_bid * 100
|
38
31
|
result = {
|
39
32
|
coin: "#{coin}_#{t}",
|
@@ -64,7 +57,7 @@ module Watchcow
|
|
64
57
|
def days_remain_of symbol, t
|
65
58
|
@contract_info = Watchcow::ContractInfo.call
|
66
59
|
line = @contract_info.dig('data').select do |h|
|
67
|
-
h.dig('symbol') == symbol.upcase && h.dig('contract_type') ==
|
60
|
+
h.dig('symbol') == symbol.upcase && h.dig('contract_type') == Watchcow::ApiSymbol.mapping[t]
|
68
61
|
end.first
|
69
62
|
contract_time = "#{line.dig("delivery_date").to_date.to_s} 16:00".in_time_zone('Asia/Chongqing').to_time
|
70
63
|
((contract_time - Time.now.to_time) / 1.hours) / 24
|
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.12
|
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-06-
|
11
|
+
date: 2021-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|