cryptum 0.0.321 → 0.0.322
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/cryptum-forecast +9 -9
- data/lib/cryptum/bot_conf.rb +7 -3
- data/lib/cryptum/event.rb +1 -1
- data/lib/cryptum/option/choice.rb +1 -1
- data/lib/cryptum/option.rb +9 -9
- data/lib/cryptum/order_book/generate.rb +12 -14
- data/lib/cryptum/order_book.rb +0 -36
- data/lib/cryptum/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ea4631099b7ad8ff94d00136248b662803cfba132ab021303bea8964f89dc78
|
4
|
+
data.tar.gz: efa2d3a350d174059f33ce86b6f3d04a6dce885b4c5b7649a185d2c13607c5a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ed9f8234e09f5de2b916cd2769019427d2db893e3498e8e728b7e52b542d617f0766e2dce1d3ba73f7236330780bd306a403205918629beaf253feee0508366
|
7
|
+
data.tar.gz: 3c87ccb59b8f82a553d7cb37261490610f979200e858b1892b07c300bf1314d13aafdeace8382562a7f313acc43c8edb27b2c91c8c0d2c4b7feab247d8856d29
|
data/README.md
CHANGED
data/bin/cryptum-forecast
CHANGED
@@ -11,7 +11,7 @@ class Choice
|
|
11
11
|
:cycles_complete,
|
12
12
|
:driver_name,
|
13
13
|
:proxy,
|
14
|
-
:
|
14
|
+
:session_root,
|
15
15
|
:sandbox,
|
16
16
|
:symbol,
|
17
17
|
:tpm,
|
@@ -60,9 +60,9 @@ begin
|
|
60
60
|
|
61
61
|
options.on(
|
62
62
|
'-rPATH',
|
63
|
-
'--
|
63
|
+
'--session-root=PATH',
|
64
64
|
'<Optional - Directory of Cloned Repo (Defaults to Dir.pwd)">'
|
65
|
-
) { |r| option_choice.
|
65
|
+
) { |r| option_choice.session_root = r }
|
66
66
|
|
67
67
|
options.on(
|
68
68
|
'-tTPM',
|
@@ -83,16 +83,16 @@ begin
|
|
83
83
|
reason = :symbol
|
84
84
|
end
|
85
85
|
|
86
|
-
option_choice.
|
86
|
+
option_choice.session_root = Dir.pwd if option_choice.session_root.nil?
|
87
87
|
|
88
88
|
if option_choice.autotrade_percent.to_f > 100
|
89
89
|
usage = true
|
90
90
|
reason = :autotrade_percent
|
91
91
|
end
|
92
92
|
|
93
|
-
unless Dir.exist?(option_choice.
|
93
|
+
unless Dir.exist?(option_choice.session_root)
|
94
94
|
usage = true
|
95
|
-
reason = :
|
95
|
+
reason = :session_root
|
96
96
|
end
|
97
97
|
|
98
98
|
if usage
|
@@ -101,8 +101,8 @@ begin
|
|
101
101
|
puts 'ERROR: --autotrade PERCENT value cannot exceed 100'
|
102
102
|
when :symbol
|
103
103
|
puts "ERROR: --symbol Flag is Required.\n\n"
|
104
|
-
when :
|
105
|
-
puts "ERROR: #{option_choice.
|
104
|
+
when :session_root
|
105
|
+
puts "ERROR: #{option_choice.session_root} does not exist.\n\n"
|
106
106
|
end
|
107
107
|
|
108
108
|
puts `#{option_choice.driver_name} --help`
|
@@ -125,7 +125,7 @@ begin
|
|
125
125
|
|
126
126
|
# crypto = products.last[:base_currency]
|
127
127
|
fiat = products.last[:quote_currency]
|
128
|
-
fiat_portfolio_file = "#{option_choice.
|
128
|
+
fiat_portfolio_file = "#{option_choice.session_root}/order_books/#{fiat}_PORTFOLIO.json"
|
129
129
|
|
130
130
|
# portfolio = Cryptum::API.get_portfolio(
|
131
131
|
# option_choice: option_choice,
|
data/lib/cryptum/bot_conf.rb
CHANGED
@@ -10,10 +10,12 @@ module Cryptum
|
|
10
10
|
option_choice = opts[:option_choice]
|
11
11
|
event_history = opts[:event_history]
|
12
12
|
|
13
|
-
|
13
|
+
session_root = option_choice.session_root
|
14
|
+
symbol = option_choice.symbol
|
15
|
+
bot_conf_file = "#{session_root}/etc/bot_confs/#{symbol}_bot_conf.yaml"
|
14
16
|
unless File.exist?(bot_conf_file)
|
15
17
|
FileUtils.cp(
|
16
|
-
"#{
|
18
|
+
"#{session_root}/etc/bot_confs/BOT_CONF.TEMPLATE",
|
17
19
|
bot_conf_file
|
18
20
|
)
|
19
21
|
end
|
@@ -161,7 +163,9 @@ module Cryptum
|
|
161
163
|
key = opts[:key].to_s.to_sym
|
162
164
|
value = opts[:value]
|
163
165
|
|
164
|
-
|
166
|
+
session_root = option_choice.session_root
|
167
|
+
symbol = option_choice.symbol
|
168
|
+
bot_conf_file = "#{session_root}/etc/bot_confs/#{symbol}_bot_conf.yaml"
|
165
169
|
|
166
170
|
bot_conf[key] = value
|
167
171
|
File.write(bot_conf_file, bot_conf.to_yaml)
|
data/lib/cryptum/event.rb
CHANGED
@@ -35,7 +35,7 @@ module Cryptum
|
|
35
35
|
# order_history = event_history.order_book[:order_history]
|
36
36
|
this_product = event_history.order_book[:this_product]
|
37
37
|
fiat = this_product[:quote_currency]
|
38
|
-
fiat_portfolio_file = "#{option_choice.
|
38
|
+
fiat_portfolio_file = "#{option_choice.session_root}/order_books/#{fiat}_PORTFOLIO.json"
|
39
39
|
|
40
40
|
# Determine if Summary UI needs updated data
|
41
41
|
event_history = Cryptum::Portfolio::Balance.refresh(
|
data/lib/cryptum/option.rb
CHANGED
@@ -43,9 +43,9 @@ module Cryptum
|
|
43
43
|
|
44
44
|
options.on(
|
45
45
|
'-rPATH',
|
46
|
-
'--
|
47
|
-
'<Optional - Directory
|
48
|
-
) { |r| option_choice.
|
46
|
+
'--session-root=PATH',
|
47
|
+
'<Optional - Directory with etc && order_books (Defaults to ~/cryptum)>'
|
48
|
+
) { |r| option_choice.session_root = r }
|
49
49
|
|
50
50
|
options.on(
|
51
51
|
'-S',
|
@@ -82,11 +82,11 @@ module Cryptum
|
|
82
82
|
reason = :symbol
|
83
83
|
end
|
84
84
|
|
85
|
-
option_choice.
|
85
|
+
option_choice.session_root = "#{Dir.home}/cryptum" if option_choice.session_root.nil?
|
86
86
|
|
87
|
-
unless Dir.exist?(option_choice.
|
87
|
+
unless Dir.exist?(option_choice.session_root)
|
88
88
|
usage = true
|
89
|
-
reason = :
|
89
|
+
reason = :session_root
|
90
90
|
end
|
91
91
|
|
92
92
|
option_choice.market_trend_reset = 86_400 if option_choice.market_trend_reset.to_i.zero?
|
@@ -130,8 +130,8 @@ module Cryptum
|
|
130
130
|
case reason
|
131
131
|
when :symbol
|
132
132
|
puts "ERROR: --symbol Flag is Required.\n\n"
|
133
|
-
when :
|
134
|
-
puts "ERROR: #{option_choice.
|
133
|
+
when :session_root
|
134
|
+
puts "ERROR: #{option_choice.session_root} does not exist.\n\n"
|
135
135
|
when :market_trend_reset
|
136
136
|
puts "ERROR: #{option_choice.market_trend_reset} - Possible values are: 604_800 || 86_400 || 14_400 || 10_800 || 7_200 || 3_600 || 2_700 || 1_800 || 900 || 300 || 180 || 60\n\n"
|
137
137
|
end
|
@@ -168,7 +168,7 @@ module Cryptum
|
|
168
168
|
public_class_method def self.get_env(opts = {})
|
169
169
|
option_choice = opts[:option_choice]
|
170
170
|
|
171
|
-
yaml_conf_file = "#{option_choice.
|
171
|
+
yaml_conf_file = "#{option_choice.session_root}/etc/coinbase_pro.yaml"
|
172
172
|
yaml_conf = YAML.load_file(
|
173
173
|
yaml_conf_file,
|
174
174
|
symbolize_names: true
|
@@ -20,16 +20,9 @@ module Cryptum
|
|
20
20
|
option_choice = opts[:option_choice]
|
21
21
|
env = opts[:env]
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
if File.exist?(order_book_file)
|
27
|
-
last_order_book = Cryptum::OrderBook.analyze(
|
28
|
-
order_book_file: order_book_file,
|
29
|
-
option_choice: option_choice
|
30
|
-
)
|
31
|
-
order_history_meta = last_order_book[:order_history_meta] unless last_order_book[:order_history_meta].empty?
|
32
|
-
end
|
23
|
+
session_root = option_choice.session_root
|
24
|
+
symbol = option_choice.symbol
|
25
|
+
order_book_file = "#{session_root}/order_books/#{symbol}.ORDER_BOOK.json"
|
33
26
|
|
34
27
|
# Only need to retrieve a product list once / session.
|
35
28
|
products = Cryptum::API.get_products(
|
@@ -43,7 +36,7 @@ module Cryptum
|
|
43
36
|
|
44
37
|
order_book = {
|
45
38
|
path: order_book_file,
|
46
|
-
symbol:
|
39
|
+
symbol: symbol,
|
47
40
|
open_24h: 0.00,
|
48
41
|
high_24h: 0.00,
|
49
42
|
low_24h: 0.00,
|
@@ -51,8 +44,6 @@ module Cryptum
|
|
51
44
|
ticker_price: 0.00,
|
52
45
|
ticker_price_second_to_last: 0.00,
|
53
46
|
ticker_price_third_to_last: 0.00,
|
54
|
-
highest_pie_in_sky_buy_percent: 0.00,
|
55
|
-
highest_pie_in_sky_sell_percent: 0.00,
|
56
47
|
sequence: -1,
|
57
48
|
this_product: this_product,
|
58
49
|
portfolio: [],
|
@@ -70,7 +61,7 @@ module Cryptum
|
|
70
61
|
sell_end: '--'
|
71
62
|
},
|
72
63
|
order_history: [],
|
73
|
-
order_history_meta:
|
64
|
+
order_history_meta: []
|
74
65
|
}
|
75
66
|
|
76
67
|
# Order History Retention ---------------------------------------#
|
@@ -83,6 +74,13 @@ module Cryptum
|
|
83
74
|
order_book: order_book
|
84
75
|
)
|
85
76
|
|
77
|
+
if File.exist?(order_book_file)
|
78
|
+
order_book = JSON.parse(
|
79
|
+
File.read(order_book_file),
|
80
|
+
symbolize_names: true
|
81
|
+
)
|
82
|
+
end
|
83
|
+
|
86
84
|
event_history.order_book = order_book
|
87
85
|
|
88
86
|
event_history
|
data/lib/cryptum/order_book.rb
CHANGED
@@ -112,42 +112,6 @@ module Cryptum
|
|
112
112
|
raise e
|
113
113
|
end
|
114
114
|
|
115
|
-
# Supported Method Parameters::
|
116
|
-
# Cryptum::OrderBook.analyze(
|
117
|
-
# order_book_file: 'required - path to order book file'
|
118
|
-
# )
|
119
|
-
public_class_method def self.analyze(opts = {})
|
120
|
-
order_book_file = opts[:order_book_file]
|
121
|
-
option_choice = opts[:option_choice]
|
122
|
-
# TODO: Handle File that exists
|
123
|
-
# w/ Zero size...N number of
|
124
|
-
# attempts? Timeout may be better.
|
125
|
-
order_book = JSON.parse(
|
126
|
-
File.read(order_book_file),
|
127
|
-
symbolize_names: true
|
128
|
-
)
|
129
|
-
|
130
|
-
order_book[:option_choice] = option_choice
|
131
|
-
|
132
|
-
bot_conf = Cryptum::BotConf.read(option_choice: option_choice)
|
133
|
-
order_book[:bot_conf] = bot_conf
|
134
|
-
|
135
|
-
env = Cryptum::Option.get_env(option_choice: option_choice)
|
136
|
-
order_book[:env] = env
|
137
|
-
|
138
|
-
order_book
|
139
|
-
rescue JSON::ParserError => e
|
140
|
-
File.open('/tmp/cryptum-errors.txt', 'a') do |f|
|
141
|
-
f.puts Time.now.strftime('%Y-%m-%d %H:%M:%S.%N %z')
|
142
|
-
f.puts "Module: #{self}"
|
143
|
-
f.puts "#{e}\n\n\n"
|
144
|
-
end
|
145
|
-
|
146
|
-
retry
|
147
|
-
rescue StandardError => e
|
148
|
-
raise e
|
149
|
-
end
|
150
|
-
|
151
115
|
# Display Usage for this Module
|
152
116
|
public_class_method def self.help
|
153
117
|
constants.sort
|
data/lib/cryptum/version.rb
CHANGED