cryptum 0.0.358 → 0.0.360
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +16 -0
- data/.gitignore +30 -0
- data/.rspec +3 -0
- data/.rspec_status +0 -0
- data/.rubocop.yml +31 -0
- data/.rubocop_todo.yml +36 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +38 -0
- data/LICENSE +674 -0
- data/README.md +87 -0
- data/Rakefile +19 -0
- data/bin/cryptum +73 -0
- data/bin/cryptum-forecast +200 -0
- data/bin/cryptum-repl +73 -0
- data/bin/cryptum_autoinc_version +38 -0
- data/build_cryptum_gem.sh +58 -0
- data/cryptum.gemspec +52 -0
- data/cryptum_container.sh +1 -0
- data/docker/cryptum.json +60 -0
- data/docker/cryptum_container.sh +59 -0
- data/docker/packer_secrets.json.EXAMPLE +7 -0
- data/docker/provisioners/cryptum.sh +11 -0
- data/docker/provisioners/docker_bashrc.sh +2 -0
- data/docker/provisioners/docker_rvm.sh +22 -0
- data/docker/provisioners/init_image.sh +28 -0
- data/docker/provisioners/post_install.sh +6 -0
- data/docker/provisioners/ruby.sh +16 -0
- data/docker/provisioners/upload_globals.sh +49 -0
- data/etc/bot_confs/.gitkeep +0 -0
- data/etc/bot_confs/BOT_CONF.TEMPLATE +10 -0
- data/etc/coinbase_pro.yaml.EXAMPLE +8 -0
- data/etc/open_ai.yaml.EXAMPLE +1 -0
- data/git_commit.sh +22 -0
- data/lib/cryptum/api.rb +688 -0
- data/lib/cryptum/bot_conf.rb +197 -0
- data/lib/cryptum/event/bot_conf.rb +34 -0
- data/lib/cryptum/event/buy.rb +145 -0
- data/lib/cryptum/event/cancel.rb +35 -0
- data/lib/cryptum/event/exit.rb +35 -0
- data/lib/cryptum/event/gtfo.rb +36 -0
- data/lib/cryptum/event/history.rb +108 -0
- data/lib/cryptum/event/key_press.rb +64 -0
- data/lib/cryptum/event/order_book.rb +34 -0
- data/lib/cryptum/event/pane.rb +65 -0
- data/lib/cryptum/event/parse.rb +181 -0
- data/lib/cryptum/event/scroll.rb +200 -0
- data/lib/cryptum/event/sell.rb +124 -0
- data/lib/cryptum/event.rb +27 -0
- data/lib/cryptum/log.rb +34 -0
- data/lib/cryptum/matrix.rb +181 -0
- data/lib/cryptum/open_ai.rb +156 -0
- data/lib/cryptum/option/choice.rb +28 -0
- data/lib/cryptum/option.rb +206 -0
- data/lib/cryptum/order_book/generate.rb +114 -0
- data/lib/cryptum/order_book/indicator.rb +15 -0
- data/lib/cryptum/order_book/market_trend.rb +137 -0
- data/lib/cryptum/order_book/profit_margin.rb +55 -0
- data/lib/cryptum/order_book.rb +19 -0
- data/lib/cryptum/portfolio/balance.rb +123 -0
- data/lib/cryptum/portfolio.rb +15 -0
- data/lib/cryptum/ui/command.rb +314 -0
- data/lib/cryptum/ui/key_press_event.rb +33 -0
- data/lib/cryptum/ui/market_trend.rb +77 -0
- data/lib/cryptum/ui/order_execute_details.rb +297 -0
- data/lib/cryptum/ui/order_execution.rb +573 -0
- data/lib/cryptum/ui/order_plan.rb +512 -0
- data/lib/cryptum/ui/order_plan_details.rb +240 -0
- data/lib/cryptum/ui/order_timer.rb +136 -0
- data/lib/cryptum/ui/portfolio.rb +221 -0
- data/lib/cryptum/ui/signal_engine.rb +109 -0
- data/lib/cryptum/ui/terminal_window.rb +111 -0
- data/lib/cryptum/ui/ticker.rb +319 -0
- data/lib/cryptum/ui.rb +343 -0
- data/lib/cryptum/version.rb +5 -0
- data/lib/cryptum/web_sock/coinbase.rb +104 -0
- data/lib/cryptum/web_sock/event_machine.rb +276 -0
- data/lib/cryptum/web_sock.rb +16 -0
- data/lib/cryptum.rb +120 -0
- data/order_books/.gitkeep +0 -0
- data/reinstall_cryptum_gemset.sh +29 -0
- data/spec/lib/cryptum/api_spec.rb +10 -0
- data/spec/lib/cryptum/event_spec.rb +10 -0
- data/spec/lib/cryptum/log_spec.rb +10 -0
- data/spec/lib/cryptum/option_spec.rb +10 -0
- data/spec/lib/cryptum/order_book/generate_spec.rb +10 -0
- data/spec/lib/cryptum/order_book/market_trend_spec.rb +10 -0
- data/spec/lib/cryptum/order_book_spec.rb +10 -0
- data/spec/lib/cryptum/ui/command_spec.rb +10 -0
- data/spec/lib/cryptum/ui/ticker_spec.rb +10 -0
- data/spec/lib/cryptum/ui_spec.rb +10 -0
- data/spec/lib/cryptum/web_sock_spec.rb +10 -0
- data/spec/lib/cryptum_spec.rb +10 -0
- data/spec/spec_helper.rb +3 -0
- data/upgrade_Gemfile_gems.sh +20 -0
- data/upgrade_cryptum.sh +13 -0
- data/upgrade_gem.sh +4 -0
- data/upgrade_ruby.sh +45 -0
- metadata +112 -9
@@ -0,0 +1,276 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eventmachine'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Cryptum
|
7
|
+
# This plugin is used to Establish a Web
|
8
|
+
# Socket Connection with Coinbase
|
9
|
+
module WebSock
|
10
|
+
# This module is the primary module to handle
|
11
|
+
# Web Socket Events from Coinbase
|
12
|
+
module EventMachine
|
13
|
+
# Supported Method Parameters::
|
14
|
+
# Cryptum::WS.run(
|
15
|
+
# )
|
16
|
+
public_class_method def self.run(opts = {})
|
17
|
+
env = opts[:env]
|
18
|
+
option_choice = opts[:option_choice]
|
19
|
+
terminal_win = opts[:terminal_win]
|
20
|
+
event_history = opts[:event_history]
|
21
|
+
indicator_status = opts[:indicator_status]
|
22
|
+
bot_conf = opts[:bot_conf]
|
23
|
+
|
24
|
+
max_conn_attempts = 30
|
25
|
+
conn_attempt = 0
|
26
|
+
|
27
|
+
begin
|
28
|
+
conn_attempt += 1
|
29
|
+
event_history.reconnected = true if conn_attempt > 1
|
30
|
+
|
31
|
+
EM.run do
|
32
|
+
# Iterate as fast as possible
|
33
|
+
# This ensures candle timing is accurate
|
34
|
+
# and everything is fast as possible
|
35
|
+
# Defaults to 100ms, 5ms is the lowest possible
|
36
|
+
delay_ms = 5
|
37
|
+
delay_ms_cast_as_decimal = delay_ms * 0.001
|
38
|
+
EM.set_quantum(delay_ms)
|
39
|
+
|
40
|
+
ws = Cryptum::WebSock::Coinbase.connect(
|
41
|
+
option_choice: option_choice,
|
42
|
+
env: env
|
43
|
+
)
|
44
|
+
|
45
|
+
ws.on :open do |_event|
|
46
|
+
ws.send(
|
47
|
+
Cryptum::WebSock::Coinbase.subscribe_message(
|
48
|
+
option_choice: option_choice,
|
49
|
+
env: env
|
50
|
+
)
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
ws.on :message do |event|
|
55
|
+
# TODO: The Speed of the UI is dictated by the
|
56
|
+
# Frequency of WebSocket Messages Coming Through.
|
57
|
+
# Explore another way to decouple required events
|
58
|
+
# (such as keypresses) from only being triggered
|
59
|
+
# when messages come through.
|
60
|
+
|
61
|
+
event_history.event = JSON.parse(
|
62
|
+
event.data,
|
63
|
+
symbolize_names: true
|
64
|
+
)
|
65
|
+
event_history.event_type = event_history.event[:type].to_s.to_sym
|
66
|
+
|
67
|
+
event_history = Cryptum::Event::Parse.websocket_msg(
|
68
|
+
env: env,
|
69
|
+
terminal_win: terminal_win,
|
70
|
+
option_choice: option_choice,
|
71
|
+
event_history: event_history,
|
72
|
+
indicator_status: indicator_status,
|
73
|
+
bot_conf: bot_conf
|
74
|
+
)
|
75
|
+
|
76
|
+
# Detect Key Press Events
|
77
|
+
Cryptum::Event::KeyPress.detect(terminal_win: terminal_win)
|
78
|
+
|
79
|
+
# Cancel ALL Open Orders when
|
80
|
+
# C is pressed
|
81
|
+
if terminal_win.key_press_event.key_c
|
82
|
+
Cryptum::Event::Cancel.open_orders(
|
83
|
+
terminal_win: terminal_win,
|
84
|
+
option_choice: option_choice,
|
85
|
+
env: env
|
86
|
+
)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Get the F* Out (GTFO) when
|
90
|
+
# G is pressed
|
91
|
+
if terminal_win.key_press_event.key_g
|
92
|
+
event_history = Cryptum::Event::GTFO.now(
|
93
|
+
terminal_win: terminal_win,
|
94
|
+
option_choice: option_choice,
|
95
|
+
env: env,
|
96
|
+
event_history: event_history,
|
97
|
+
bot_conf: bot_conf
|
98
|
+
)
|
99
|
+
end
|
100
|
+
|
101
|
+
# Reload Bot Conf when r is Pressed
|
102
|
+
if terminal_win.key_press_event.key_r
|
103
|
+
bot_conf = Cryptum::Event::BotConf.reload(
|
104
|
+
terminal_win: terminal_win,
|
105
|
+
event_history: event_history,
|
106
|
+
option_choice: option_choice
|
107
|
+
)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Only Write Order Book to File when
|
111
|
+
# W is Pressed
|
112
|
+
if terminal_win.key_press_event.key_w
|
113
|
+
Cryptum::Event::OrderBook.write(
|
114
|
+
terminal_win: terminal_win,
|
115
|
+
event_history: event_history
|
116
|
+
)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Exit if x is Pressed
|
120
|
+
if terminal_win.key_press_event.key_x
|
121
|
+
Cryptum::Event::Exit.gracefully(
|
122
|
+
terminal_win: terminal_win,
|
123
|
+
event_history: event_history,
|
124
|
+
option_choice: option_choice,
|
125
|
+
env: env
|
126
|
+
)
|
127
|
+
end
|
128
|
+
|
129
|
+
# TAB through Order Plan / Order Execution Window Panes
|
130
|
+
if terminal_win.key_press_event.key_tab
|
131
|
+
Cryptum::Event::Pane.switch(
|
132
|
+
terminal_win: terminal_win,
|
133
|
+
event_history: event_history
|
134
|
+
)
|
135
|
+
end
|
136
|
+
|
137
|
+
# Scroll Up Order Plan / Order Execution Window Panes
|
138
|
+
if terminal_win.key_press_event.key_up_arrow
|
139
|
+
Cryptum::Event::Scroll.up(
|
140
|
+
terminal_win: terminal_win,
|
141
|
+
event_history: event_history
|
142
|
+
)
|
143
|
+
end
|
144
|
+
|
145
|
+
# Scroll Down Order Plan / Order Execution Window Panes
|
146
|
+
if terminal_win.key_press_event.key_down_arrow
|
147
|
+
Cryptum::Event::Scroll.down(
|
148
|
+
terminal_win: terminal_win,
|
149
|
+
event_history: event_history
|
150
|
+
)
|
151
|
+
end
|
152
|
+
|
153
|
+
# Scroll Up Order Plan / Order Execution Window Panes Faster
|
154
|
+
if terminal_win.key_press_event.key_page_up
|
155
|
+
Cryptum::Event::Scroll.page_up(
|
156
|
+
terminal_win: terminal_win,
|
157
|
+
event_history: event_history
|
158
|
+
)
|
159
|
+
end
|
160
|
+
|
161
|
+
# Scroll Down Order Plan / Order Execution Window Panes Faster
|
162
|
+
if terminal_win.key_press_event.key_page_down
|
163
|
+
Cryptum::Event::Scroll.page_down(
|
164
|
+
terminal_win: terminal_win,
|
165
|
+
event_history: event_history
|
166
|
+
)
|
167
|
+
end
|
168
|
+
|
169
|
+
# Scroll to Top of Order Plan / Order Execution Window Panes
|
170
|
+
if terminal_win.key_press_event.key_home
|
171
|
+
Cryptum::Event::Scroll.top(
|
172
|
+
terminal_win: terminal_win,
|
173
|
+
event_history: event_history
|
174
|
+
)
|
175
|
+
end
|
176
|
+
|
177
|
+
# Scroll to Bottom of Order Plan / Order Execution Window Panes
|
178
|
+
if terminal_win.key_press_event.key_end
|
179
|
+
Cryptum::Event::Scroll.bottom(
|
180
|
+
terminal_win: terminal_win,
|
181
|
+
event_history: event_history
|
182
|
+
)
|
183
|
+
end
|
184
|
+
|
185
|
+
# Open / Close Order Plan / Order Execution Details Window
|
186
|
+
if terminal_win.key_press_event.key_enter
|
187
|
+
Cryptum::Event::Pane.toggle_details(
|
188
|
+
terminal_win: terminal_win,
|
189
|
+
event_history: event_history
|
190
|
+
)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
ws.on :close do
|
195
|
+
raise Errno::ECONNRESET
|
196
|
+
end
|
197
|
+
|
198
|
+
EM.add_periodic_timer(delay_ms_cast_as_decimal) do
|
199
|
+
order_countdown = Cryptum::UI::OrderTimer.refresh(
|
200
|
+
option_choice: option_choice,
|
201
|
+
event_history: event_history,
|
202
|
+
order_timer_win: terminal_win.order_timer_section,
|
203
|
+
indicator_status: indicator_status,
|
204
|
+
key_press_event: terminal_win.key_press_event
|
205
|
+
)
|
206
|
+
|
207
|
+
if (order_countdown.zero? || order_countdown.negative?) &&
|
208
|
+
!event_history.red_pill
|
209
|
+
|
210
|
+
# Ready to Submit a BUY order
|
211
|
+
event_history.order_ready = true
|
212
|
+
|
213
|
+
# Reload Bot Conf (i.e. Risk Allocation),
|
214
|
+
# Recalculate Order Plan, and Write to File
|
215
|
+
terminal_win.key_press_event.key_r = true
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
EM.add_periodic_timer(option_choice.market_trend_reset) do
|
220
|
+
# NOTE: To ensure the integrity of event_history is maintained,
|
221
|
+
# changes to its contenta _MUST_ stay in thos block.
|
222
|
+
event_history.order_book[:market_trend][:buy] = 0
|
223
|
+
event_history.order_book[:market_trend][:sell] = 0
|
224
|
+
event_history.order_book[:last_trend_reset] = Time.now.strftime(
|
225
|
+
'%Y-%m-%d %H:%M:%S.%N%z'
|
226
|
+
)
|
227
|
+
|
228
|
+
# Reload Bot Conf (i.e. Risk Allocation)
|
229
|
+
# Recalculate Order Plan, and Write to File
|
230
|
+
terminal_win.key_press_event.key_r = true
|
231
|
+
# IMPORTANT:
|
232
|
+
# Wait for Order Plan recalculation to occur
|
233
|
+
# once Cryptum::UI::OrderPlan is refreshed
|
234
|
+
# in Cryptum::Event _BEFORE_ writing the order
|
235
|
+
# book to file.
|
236
|
+
end
|
237
|
+
end
|
238
|
+
rescue Faye::WebSocket::API::ErrorEvent,
|
239
|
+
Errno::ECONNREFUSED,
|
240
|
+
Errno::ECONNRESET,
|
241
|
+
LoadError => e
|
242
|
+
|
243
|
+
File.open('/tmp/cryptum-errors.txt', 'a') do |f|
|
244
|
+
f.puts Time.now.strftime('%Y-%m-%d %H:%M:%S.%N %z')
|
245
|
+
f.puts "Module: #{self}"
|
246
|
+
f.puts "#{e}\n\n\n"
|
247
|
+
end
|
248
|
+
|
249
|
+
raise e if conn_attempt > max_conn_attempts
|
250
|
+
|
251
|
+
sleep 1
|
252
|
+
retry
|
253
|
+
ensure
|
254
|
+
$stdout.flush
|
255
|
+
end
|
256
|
+
rescue Interrupt
|
257
|
+
# Exit Gracefully if CTRL+C is Pressed During Session
|
258
|
+
Cryptum.exit_gracefully(
|
259
|
+
which_self: self,
|
260
|
+
event_history: event_history,
|
261
|
+
option_choice: option_choice,
|
262
|
+
env: env
|
263
|
+
)
|
264
|
+
rescue StandardError => e
|
265
|
+
raise e
|
266
|
+
end
|
267
|
+
|
268
|
+
# Display Usage for this Module
|
269
|
+
public_class_method def self.help
|
270
|
+
puts "USAGE:
|
271
|
+
logger = #{self}.create()
|
272
|
+
"
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cryptum
|
4
|
+
# This plugin is used to Establish a Web
|
5
|
+
# Socket Connection with Coinbase
|
6
|
+
module WebSock
|
7
|
+
require 'cryptum/web_sock/coinbase'
|
8
|
+
require 'cryptum/web_sock/event_machine'
|
9
|
+
|
10
|
+
# Display Usage for this Module
|
11
|
+
|
12
|
+
public_class_method def self.help
|
13
|
+
constants.sort
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/cryptum.rb
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rbtrace'
|
4
|
+
require 'yaml'
|
5
|
+
require 'json'
|
6
|
+
require 'fileutils'
|
7
|
+
require 'tty-spinner'
|
8
|
+
# Root-Level Namespace for cryptum
|
9
|
+
module Cryptum
|
10
|
+
$stdout.sync = true
|
11
|
+
$stdout.flush
|
12
|
+
|
13
|
+
require 'cryptum/api'
|
14
|
+
require 'cryptum/bot_conf'
|
15
|
+
require 'cryptum/event'
|
16
|
+
require 'cryptum/log'
|
17
|
+
require 'cryptum/matrix'
|
18
|
+
require 'cryptum/open_ai'
|
19
|
+
require 'cryptum/option'
|
20
|
+
require 'cryptum/order_book'
|
21
|
+
require 'cryptum/portfolio'
|
22
|
+
require 'cryptum/ui'
|
23
|
+
require 'cryptum/version'
|
24
|
+
require 'cryptum/web_sock'
|
25
|
+
|
26
|
+
public_class_method def self.bin
|
27
|
+
File.join root, 'bin'
|
28
|
+
end
|
29
|
+
|
30
|
+
public_class_method def self.etc
|
31
|
+
File.join root, 'etc'
|
32
|
+
end
|
33
|
+
|
34
|
+
public_class_method def self.lib
|
35
|
+
File.join root, 'lib'
|
36
|
+
end
|
37
|
+
|
38
|
+
public_class_method def self.order_book
|
39
|
+
File.join root, 'order_book'
|
40
|
+
end
|
41
|
+
|
42
|
+
public_class_method def self.root
|
43
|
+
File.dirname __dir__
|
44
|
+
end
|
45
|
+
|
46
|
+
public_class_method def self.open_symbol
|
47
|
+
"\u00f8"
|
48
|
+
end
|
49
|
+
|
50
|
+
public_class_method def self.up_arrow
|
51
|
+
"\u2191"
|
52
|
+
end
|
53
|
+
|
54
|
+
public_class_method def self.down_arrow
|
55
|
+
"\u2193"
|
56
|
+
end
|
57
|
+
|
58
|
+
public_class_method def self.flat_arrow
|
59
|
+
'_'
|
60
|
+
end
|
61
|
+
|
62
|
+
# Add Commas to Large Numbers to Make it Easier to Read
|
63
|
+
public_class_method def self.beautify_large_number(opts = {})
|
64
|
+
value = opts[:value].to_s
|
65
|
+
|
66
|
+
split_str_num = value.split('.')
|
67
|
+
whole_num = split_str_num.first
|
68
|
+
fraction = 0
|
69
|
+
fraction = split_str_num.last if split_str_num.length > 1
|
70
|
+
|
71
|
+
is_negative = false
|
72
|
+
is_negative = true if whole_num.chars.first == '-'
|
73
|
+
whole_num = whole_num[1..] if is_negative
|
74
|
+
beautify_whole = whole_num.reverse.scan(/.{1,3}/).join(',').reverse
|
75
|
+
beautify_num = "#{beautify_whole}.#{fraction}" unless is_negative
|
76
|
+
beautify_num = "-#{beautify_whole}.#{fraction}" if is_negative
|
77
|
+
|
78
|
+
beautify_num
|
79
|
+
rescue Interrupt
|
80
|
+
# Exit Gracefully if CTRL+C is Pressed During Session
|
81
|
+
Cryptum.exit_gracefully(which_self: self)
|
82
|
+
rescue StandardError => e
|
83
|
+
# Produce a Stacktrace for anything else
|
84
|
+
Curses.close_screen
|
85
|
+
raise e
|
86
|
+
end
|
87
|
+
|
88
|
+
public_class_method def self.exit_gracefully(opts = {})
|
89
|
+
which_self = opts[:which_self]
|
90
|
+
event_history = opts[:event_history]
|
91
|
+
# option_choice = opts[:option_choice]
|
92
|
+
# env = opts[:env]
|
93
|
+
|
94
|
+
# Clear out candle data to ensure
|
95
|
+
# Cryptum Statistics Only Apply to
|
96
|
+
# Live Sessions
|
97
|
+
if event_history
|
98
|
+
File.write(
|
99
|
+
order_book_file,
|
100
|
+
JSON.pretty_generate(event_history.order_book)
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
Curses.close_screen
|
105
|
+
puts "Interrupt detected in #{which_self}...goodbye."
|
106
|
+
|
107
|
+
exit 0
|
108
|
+
rescue NameError
|
109
|
+
puts "\nInterrupt detected in #{which_self}...goodbye."
|
110
|
+
|
111
|
+
exit 0
|
112
|
+
rescue StandardError => e
|
113
|
+
# Produce a Stacktrace for anything else
|
114
|
+
raise e
|
115
|
+
end
|
116
|
+
|
117
|
+
public_class_method def self.help
|
118
|
+
constants.sort
|
119
|
+
end
|
120
|
+
end
|
File without changes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/bin/bash --login
|
2
|
+
# USE THIS SCRIPT WHEN UPGRADING VERSIONS IN Gemfile
|
3
|
+
if [[ $CRYPTUM_ROOT == '' ]]; then
|
4
|
+
if [[ ! -d '/opt/cryptum' ]]; then
|
5
|
+
cryptum_root=$(pwd)
|
6
|
+
else
|
7
|
+
cryptum_root='/opt/cryptum'
|
8
|
+
fi
|
9
|
+
else
|
10
|
+
cryptum_root="${CRYPTUM_ROOT}"
|
11
|
+
fi
|
12
|
+
|
13
|
+
if [[ -f '/etc/profile.d/rvm.sh' ]]; then
|
14
|
+
source /etc/profile.d/rvm.sh
|
15
|
+
fi
|
16
|
+
|
17
|
+
ruby_version=`cat ${cryptum_root}/.ruby-version`
|
18
|
+
ruby_gemset=`cat ${cryptum_root}/.ruby-gemset`
|
19
|
+
rvm use ruby-$ruby_version@global
|
20
|
+
rvm gemset --force delete $ruby_gemset
|
21
|
+
if [[ -f "${cryptum_root}/Gemfile.lock" ]]; then
|
22
|
+
rvmsudo rm $cryptum_root/Gemfile.lock
|
23
|
+
fi
|
24
|
+
|
25
|
+
rvm use ruby-$ruby_version@$ruby_gemset --create
|
26
|
+
export rvmsudo_secure_path=1
|
27
|
+
rvmsudo gem install bundler
|
28
|
+
rvmsudo bundle install
|
29
|
+
rvm --default ruby-$ruby_version@$ruby_gemset
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Cryptum::OrderBook::Generate do
|
6
|
+
it 'should display information for existing help method' do
|
7
|
+
help_response = Cryptum::OrderBook::Generate
|
8
|
+
expect(help_response).to respond_to :help
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Cryptum::OrderBook::MarketTrend do
|
6
|
+
it 'should display information for existing help method' do
|
7
|
+
help_response = Cryptum::OrderBook::MarketTrend
|
8
|
+
expect(help_response).to respond_to :help
|
9
|
+
end
|
10
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/bin/bash --login
|
2
|
+
cat Gemfile | awk '{print $2}' | grep -E "^'.+$" | grep -v -e rubygems.org | while read gem; do
|
3
|
+
this_gem=`echo $gem | sed "s/'//g" | sed 's/\,//g'`
|
4
|
+
latest_version=`gem search -r $this_gem | grep -E "^${this_gem}\s.+$" | awk '{print $2}' | sed 's/(//g' | sed 's/)//g' | sed 's/,//g'`
|
5
|
+
echo "${this_gem} => $latest_version"
|
6
|
+
os=`uname -s`
|
7
|
+
if [[ $os == 'Linux' ]]; then
|
8
|
+
if [[ $this_gem == 'bundler' ]]; then
|
9
|
+
sed -i "s/^gem '${this_gem}'.*$/gem '${this_gem}', '>=${latest_version}'/g" Gemfile
|
10
|
+
else
|
11
|
+
sed -i "s/^gem '${this_gem}'.*$/gem '${this_gem}', '${latest_version}'/g" Gemfile
|
12
|
+
fi
|
13
|
+
elif [[ $os == 'Darwin' ]]; then
|
14
|
+
if [[ $this_gem == 'bundler' ]]; then
|
15
|
+
sed -i '' "s/^gem '${this_gem}'.*$/gem '${this_gem}', '>=${latest_version}'/g" Gemfile
|
16
|
+
else
|
17
|
+
sed -i '' "s/^gem '${this_gem}'.*$/gem '${this_gem}', '${latest_version}'/g" Gemfile
|
18
|
+
fi
|
19
|
+
fi
|
20
|
+
done
|
data/upgrade_cryptum.sh
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/bin/bash --login
|
2
|
+
if [[ $CRYPTUM_ROOT == '' ]]; then
|
3
|
+
if [[ ! -d '/opt/cryptum' ]]; then
|
4
|
+
cryptum_root=$(pwd)
|
5
|
+
else
|
6
|
+
cryptum_root='/opt/cryptum'
|
7
|
+
fi
|
8
|
+
else
|
9
|
+
cryptum_root="${CRYPTUM_ROOT}"
|
10
|
+
fi
|
11
|
+
|
12
|
+
export rvmsudo_secure_path=1
|
13
|
+
rvmsudo /bin/bash --login -c "cd ${cryptum_root} && ./build_cryptum_gem.sh"
|
data/upgrade_gem.sh
ADDED
data/upgrade_ruby.sh
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/bin/bash --login
|
2
|
+
# USE THIS SCRIPT WHEN UPGRADING RUBY
|
3
|
+
if [[ $CRYPTUM_ROOT == '' ]]; then
|
4
|
+
if [[ ! -d '/opt/cryptum' ]]; then
|
5
|
+
cryptum_root=$(pwd)
|
6
|
+
else
|
7
|
+
cryptum_root='/opt/cryptum'
|
8
|
+
fi
|
9
|
+
else
|
10
|
+
cryptum_root="${CRYPTUM_ROOT}"
|
11
|
+
fi
|
12
|
+
|
13
|
+
function usage() {
|
14
|
+
echo $"Usage: $0 <new ruby version e.g. 2.4.4> <optional bool running from build_cryptum_gem.sh>"
|
15
|
+
exit 1
|
16
|
+
}
|
17
|
+
|
18
|
+
if [[ -f '/etc/profile.d/rvm.sh' ]]; then
|
19
|
+
source /etc/profile.d/rvm.sh
|
20
|
+
fi
|
21
|
+
|
22
|
+
new_ruby_version=$1
|
23
|
+
if [[ $2 != '' ]]; then
|
24
|
+
old_ruby_version=$2
|
25
|
+
else
|
26
|
+
old_ruby_version=`cat ${cryptum_root}/.ruby-version`
|
27
|
+
fi
|
28
|
+
|
29
|
+
ruby_gemset=`cat ${cryptum_root}/.ruby-gemset`
|
30
|
+
|
31
|
+
if [[ $# < 1 ]]; then
|
32
|
+
usage
|
33
|
+
fi
|
34
|
+
|
35
|
+
# Upgrade RVM
|
36
|
+
export rvmsudo_secure_path=1
|
37
|
+
rvmsudo rvm get head
|
38
|
+
rvm reload
|
39
|
+
|
40
|
+
# Install New Version of RubyGems & Ruby
|
41
|
+
cd $cryptum_root && ./upgrade_gem.sh
|
42
|
+
rvmsudo rvm install ruby-$new_ruby_version
|
43
|
+
echo $new_ruby_version > $cryptum_root/.ruby-version
|
44
|
+
|
45
|
+
cd $cryptum_root && rvm use $new_ruby_version@$ruby_gemset && ./build_cryptum_gem.sh
|