watchcow 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/lib/watchcow/api_symbol.rb +1 -1
- data/lib/watchcow/client.rb +35 -30
- data/lib/watchcow/output.rb +10 -10
- data/lib/watchcow/rate.rb +15 -6
- data/lib/watchcow/version.rb +1 -1
- data/watchcow-0.0.3.gem +0 -0
- data/watchcow-0.0.4.gem +0 -0
- data/watchcow.gemspec +2 -2
- metadata +4 -43
- data/lib/notification_worker.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f445e4343b05fe230682a4f2c841acbea5be420df877eed931e949a3e9e51e1
|
4
|
+
data.tar.gz: f7b0ff6d26285b0310c8c47dfda9f7532906b9f6e2fdebeff5c979ec278ea774
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29b6d8fd8ef18b7da1a398a660e606a5028bc8d2a013f93b41bec9d94e3862a87debb67cc74ec379fcfce93bb6ca9e3273aa93bb2cc0251b63687c051bdae4d7
|
7
|
+
data.tar.gz: 0204b63fbd2e472ba1cd57dfc4be63ccbca6bc4b07939b52b2b8c08f4e40376a644f53253b08e4031fc091e0add53fe09bcfa68c911e545f9b69a7daf0b8e575
|
data/Gemfile
CHANGED
data/lib/watchcow/api_symbol.rb
CHANGED
data/lib/watchcow/client.rb
CHANGED
@@ -3,42 +3,47 @@ require 'watchcow/contract_info'
|
|
3
3
|
require 'watchcow/market_depth'
|
4
4
|
require 'active_support'
|
5
5
|
require 'watchcow/rate'
|
6
|
-
require 'watchcow/output'
|
6
|
+
# require 'watchcow/output'
|
7
7
|
|
8
|
-
$redis = Redis.new(url: ENV["REDIS_URL"] || "redis://localhost:6379/0")
|
8
|
+
# $redis = Redis.new(url: ENV["REDIS_URL"] || "redis://localhost:6379/0")
|
9
9
|
|
10
10
|
module Watchcow
|
11
11
|
class Client
|
12
12
|
class << self
|
13
13
|
def call
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
14
|
+
results = Watchcow::Rate.call
|
15
|
+
cq_list = results[:cq_list]
|
16
|
+
nq_list = results[:nq_list]
|
17
|
+
nw_list = results[:nw_list]
|
18
|
+
cw_list = results[:cw_list]
|
19
|
+
{
|
20
|
+
cq_list: cq_list,
|
21
|
+
nq_list: nq_list,
|
22
|
+
nw_list: nw_list,
|
23
|
+
cw_list: cw_list
|
24
|
+
}
|
25
|
+
# mark! best_arr_cq
|
26
|
+
# # CQ
|
27
|
+
# coin = best_cq.dig(:coin)
|
28
|
+
# best_margin = "annual margin: #{best_cq.dig(:margin)}%"
|
29
|
+
# days_remained = "days remained: #{best_cq.dig(:days)}"
|
30
|
+
# expected_margin = "expected margin: #{best_cq.dig(:expected_margin)}%"
|
31
|
+
# real_margin = "landed margin: #{best_cq.dig(:real_margin_expected)}%"
|
32
|
+
# puts "---"
|
33
|
+
# puts "CQ"
|
34
|
+
# cq_string = "#{coin}, #{best_margin}, #{days_remained}, #{expected_margin}, #{real_margin}"
|
35
|
+
# puts cq_string
|
36
|
+
# # NQ
|
37
|
+
# coin = best_nq.dig(:coin)
|
38
|
+
# best_margin = "annual margin: #{best_nq.dig(:margin)}%"
|
39
|
+
# days_remained = "days remained: #{best_nq.dig(:days)}"
|
40
|
+
# expected_margin = "expected margin: #{best_nq.dig(:expected_margin)}%"
|
41
|
+
# real_margin = "landed margin: #{best_nq.dig(:real_margin_expected)}%"
|
42
|
+
# puts "NQ"
|
43
|
+
# nq_string = "#{coin}, #{best_margin}, #{days_remained}, #{expected_margin}, #{real_margin}"
|
44
|
+
# puts nq_string
|
45
|
+
# puts "---"
|
46
|
+
# Watchcow::Output.call("<p>#{cq_string}</p><p>#{nq_string}</p>")
|
42
47
|
end
|
43
48
|
|
44
49
|
private
|
data/lib/watchcow/output.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
module Watchcow
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
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
|
data/lib/watchcow/rate.rb
CHANGED
@@ -2,6 +2,12 @@ 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
|
+
}
|
5
11
|
class << self
|
6
12
|
def call
|
7
13
|
results = []
|
@@ -9,7 +15,6 @@ module Watchcow
|
|
9
15
|
Watchcow::ApiSymbol.dm_types.each do |t|
|
10
16
|
dm_symbol = {symbol: "#{coin}_#{t}"}
|
11
17
|
spot_symbol = {symbol: "#{coin}usdt"}
|
12
|
-
|
13
18
|
begin
|
14
19
|
dm_result = Watchcow::MarketDepth.call(params: dm_symbol, k: :future)
|
15
20
|
# puts dm_symbol.dig(:symbol)
|
@@ -22,7 +27,6 @@ module Watchcow
|
|
22
27
|
days_remain = self.days_remain_of(coin, t)
|
23
28
|
dm_first_bid = dm_result.dig('tick', 'bids')[0][0].to_f
|
24
29
|
spot_first_bid = spot_result.dig('tick', 'bids')[0][0].to_f
|
25
|
-
|
26
30
|
margin_annual = (((dm_first_bid - spot_first_bid) / spot_first_bid) / days_remain * 365 * 100).round(6)
|
27
31
|
margin_expect = margin_annual / 365 * days_remain
|
28
32
|
|
@@ -40,17 +44,22 @@ module Watchcow
|
|
40
44
|
end
|
41
45
|
results_cq = results.select{|x| x[:coin].include?('cq')}
|
42
46
|
results_nq = results.select{|x| x[:coin].include?('nq')}
|
47
|
+
results_cw = results.select{|x| x[:coin].include?('cw')}
|
48
|
+
results_nw = results.select{|x| x[:coin].include?('nw')}
|
43
49
|
{
|
44
|
-
|
45
|
-
|
50
|
+
cq_list: results_cq.sort{|x,y| y[:expected_margin] <=> x[:expected_margin]},
|
51
|
+
nq_list: results_nq.sort{|x,y| y[:expected_margin] <=> x[:expected_margin]},
|
52
|
+
cw_list: results_cw.sort{|x,y| y[:expected_margin] <=> x[:expected_margin]},
|
53
|
+
nw_list: results_nw.sort{|x,y| y[:expected_margin] <=> x[:expected_margin]}
|
46
54
|
}
|
47
55
|
end
|
48
56
|
|
49
57
|
def days_remain_of symbol, t
|
50
58
|
@contract_info ||= Watchcow::ContractInfo.call
|
51
59
|
line = @contract_info.dig('data').select do |h|
|
52
|
-
mark = t == 'cq' ? 'quarter' : 'next_quarter'
|
53
|
-
h.dig('symbol') == symbol.upcase && h.dig('contract_type') == mark
|
60
|
+
# mark = t == 'cq' ? 'quarter' : 'next_quarter'
|
61
|
+
# h.dig('symbol') == symbol.upcase && h.dig('contract_type') == mark
|
62
|
+
h.dig('symbol') == symbol.upcase && h.dig('contract_type') == KEYS[t]
|
54
63
|
end.first
|
55
64
|
(line.dig("delivery_date").to_s.to_date - Time.now.to_date).to_i
|
56
65
|
end
|
data/lib/watchcow/version.rb
CHANGED
data/watchcow-0.0.3.gem
ADDED
Binary file
|
data/watchcow-0.0.4.gem
ADDED
Binary file
|
data/watchcow.gemspec
CHANGED
@@ -29,8 +29,8 @@ Gem::Specification.new do |spec|
|
|
29
29
|
# spec.add_dependency "example-gem", "~> 1.0"
|
30
30
|
|
31
31
|
spec.add_dependency "httparty", '~> 0.14', ">= 0.14.0"
|
32
|
-
spec.add_dependency "redis", '~> 3.3', ">= 3.3.5"
|
33
|
-
spec.add_dependency "sidekiq", '~> 5.2', ">= 5.2.9"
|
32
|
+
# spec.add_dependency "redis", '~> 3.3', ">= 3.3.5"
|
33
|
+
# spec.add_dependency "sidekiq", '~> 5.2', ">= 5.2.9"
|
34
34
|
spec.add_dependency "pry-rails", "~> 0.3.9"
|
35
35
|
|
36
36
|
# For more information and examples about making a new gem, checkout our
|
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.0.
|
4
|
+
version: 0.0.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-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -30,46 +30,6 @@ dependencies:
|
|
30
30
|
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '0.14'
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: redis
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '3.3'
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 3.3.5
|
43
|
-
type: :runtime
|
44
|
-
prerelease: false
|
45
|
-
version_requirements: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - "~>"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '3.3'
|
50
|
-
- - ">="
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: 3.3.5
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: sidekiq
|
55
|
-
requirement: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - "~>"
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '5.2'
|
60
|
-
- - ">="
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 5.2.9
|
63
|
-
type: :runtime
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - "~>"
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '5.2'
|
70
|
-
- - ">="
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: 5.2.9
|
73
33
|
- !ruby/object:Gem::Dependency
|
74
34
|
name: pry-rails
|
75
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,7 +62,6 @@ files:
|
|
102
62
|
- Rakefile
|
103
63
|
- bin/console
|
104
64
|
- bin/setup
|
105
|
-
- lib/notification_worker.rb
|
106
65
|
- lib/watchcow.rb
|
107
66
|
- lib/watchcow/api_symbol.rb
|
108
67
|
- lib/watchcow/client.rb
|
@@ -112,6 +71,8 @@ files:
|
|
112
71
|
- lib/watchcow/rate.rb
|
113
72
|
- lib/watchcow/version.rb
|
114
73
|
- watchcow-0.0.2.gem
|
74
|
+
- watchcow-0.0.3.gem
|
75
|
+
- watchcow-0.0.4.gem
|
115
76
|
- watchcow.gemspec
|
116
77
|
homepage: https://rubygems.org/gems
|
117
78
|
licenses:
|