cryptum 0.0.381 → 0.0.382

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 866bb0c564c84fd84b9795396ffabf73483cea8c71171e3de935545c9a5a7736
4
- data.tar.gz: 060b3793c66b3a31d7747d5677de5f7b346d14ac00714357188239080a19bd5d
3
+ metadata.gz: ba56f01c0c210153ad8a00b6d1ecb4f0d85c5d4f33dcc36c5edadc2943ed7c09
4
+ data.tar.gz: bd994aa742cb92dd98157b7eb3d1df8e43b0db0afa37079a6f205147189b10f8
5
5
  SHA512:
6
- metadata.gz: 07c342bb8da387ff8fad07303102860758b5be1334d6558732255a2f743a607bb5a881968f1da1506bda887819d82cd6d5a473b19380f9641dac3b7d43c2ae81
7
- data.tar.gz: 928cd958349f76561e312529f3787d708924031ca6e73cec4c3314d59b639479d3c1997d70c6227e27360c66ceee038a5260ab61c3b4104f98fea7f764a50b1d
6
+ metadata.gz: ce2c4c72240938237e5e772684cb844334442d3ab25c66c156b7d361586d900340169356ab04e10f01b58a324959e0ba4d4ea1885e4856535692f0a080a7d5fa
7
+ data.tar.gz: a96a551db08ea2e9df384baab42ea8b30c41a1ab07e592dd90f7a3be1020aa54c35a09daed79f5a787857fcb2673550d37f0eaf1042a9a987c6fe64e2555983a
data/.rubocop.yml CHANGED
@@ -13,6 +13,8 @@ Metrics/BlockLength:
13
13
  Max: 256
14
14
  Metrics/BlockNesting:
15
15
  Max: 4
16
+ Metrics/ClassLength:
17
+ Max: 512
16
18
  Metrics/CyclomaticComplexity:
17
19
  Max: 128
18
20
  Metrics/MethodLength:
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2023-03-30 22:47:49 UTC using RuboCop version 1.48.1.
3
+ # on 2023-03-31 15:11:10 UTC using RuboCop version 1.48.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -24,3 +24,9 @@ Style/ConditionalAssignment:
24
24
  # Configuration parameters: AllowedConstants.
25
25
  Style/Documentation:
26
26
  Enabled: false
27
+
28
+ # Offense count: 1
29
+ # This cop supports safe autocorrection (--autocorrect).
30
+ Style/RedundantSelf:
31
+ Exclude:
32
+ - 'lib/cryptum/api.rb'
data/Gemfile CHANGED
@@ -32,7 +32,6 @@ gem 'rubocop-rspec', '2.19.0'
32
32
  gem 'ruby-prof', '1.6.1'
33
33
  gem 'rvm', '1.11.3.9'
34
34
  gem 'sinatra', '3.0.5'
35
- gem 'thin', '1.8.1'
35
+ gem 'thin', '1.8.2'
36
36
  gem 'tty-prompt', '0.23.1'
37
- gem 'tty-spinner', '0.9.3'
38
37
  gem 'websocket-extensions', '0.1.5'
data/bin/cryptum CHANGED
@@ -30,7 +30,7 @@ begin
30
30
  # Generate an Order Book for Session Tracking
31
31
  # Load previous order_book_justification from
32
32
  # Order Book File (if it exists)
33
- event_history = Cryptum::OrderBook::Generate.new_order_book(
33
+ event_history = Cryptum::OrderBook::Generate.new(
34
34
  start_time: start_time,
35
35
  option_choice: option_choice,
36
36
  env: env
@@ -61,7 +61,7 @@ begin
61
61
  )
62
62
  rescue Interrupt
63
63
  # Exit Gracefully if CTRL+C is Pressed During Session
64
- Cryptum.exit_gracefully(
64
+ Cryptum::UI::Exit.gracefully(
65
65
  which_self: self,
66
66
  event_history: event_history,
67
67
  option_choice: option_choice,
@@ -243,7 +243,15 @@ module Cryptum
243
243
 
244
244
  public_class_method def self.help
245
245
  puts "USAGE:
246
- profiles = #{self}.get_profiles(
246
+ event_history = #{self}.submit_limit_order(
247
+ env: 'required - Coinbase::Option::Environment.get Object'
248
+ )
249
+
250
+ canceled_order_id_arr = #{self}.cancel_all_open_orders(
251
+ env: 'required - Coinbase::Option::Environment.get Object'
252
+ )
253
+
254
+ event_history = #{self}.gtfo(
247
255
  env: 'required - Coinbase::Option::Environment.get Object'
248
256
  )
249
257
  "
data/lib/cryptum/api.rb CHANGED
@@ -18,41 +18,8 @@ module Cryptum
18
18
  require 'cryptum/api/rest'
19
19
  require 'cryptum/api/signature'
20
20
 
21
- # public_class_method def self.get_profiles(opts = {})
22
- # option_choice = opts[:option_choice]
23
- # env = opts[:env]
24
-
25
- # profiles_api_call = '/profiles'
26
-
27
- # # We don't always get fees back from Coinbase...
28
- # # This is a hack to ensure we do.
29
- # profiles = {}
30
- # # loop do
31
- # profiles = Cryptum::API::Rest.call(
32
- # option_choice: option_choice,
33
- # env: env,
34
- # http_method: :GET,
35
- # api_call: profiles_api_call
36
- # )
37
-
38
- # # break unless fees.empty?
39
-
40
- # # sleep 0.3
41
- # # end
42
-
43
- # profiles
44
- # rescue StandardError => e
45
- # raise e
46
- # end
47
-
48
- # Display Usage for this Module
49
-
50
21
  public_class_method def self.help
51
- puts "USAGE:
52
- profiles = #{self}.get_profiles(
53
- env: 'required - Coinbase::Option::Environment.get Object'
54
- )
55
- "
22
+ puts self.constants
56
23
  end
57
24
  end
58
25
  end
@@ -45,7 +45,11 @@ module Cryptum
45
45
  retry
46
46
  rescue Interrupt
47
47
  # Exit Gracefully if CTRL+C is Pressed During Session
48
- Cryptum.exit_gracefully(which_self: self)
48
+ Cryptum::UI::Exit.gracefully(
49
+ which_self: self,
50
+ event_history: event_history,
51
+ option_choice: option_choice
52
+ )
49
53
  rescue StandardError => e
50
54
  # Produce a Stacktrace for anything else
51
55
  Curses.close_screen
@@ -148,7 +152,11 @@ module Cryptum
148
152
  retry
149
153
  rescue Interrupt
150
154
  # Exit Gracefully if CTRL+C is Pressed During Session
151
- Cryptum.exit_gracefully(which_self: self)
155
+ Cryptum::UI::Exit.gracefully(
156
+ which_self: self,
157
+ event_history: event_history,
158
+ option_choice: option_choice
159
+ )
152
160
  rescue StandardError => e
153
161
  # Produce a Stacktrace for anything else
154
162
  Curses.close_screen
@@ -178,7 +186,10 @@ module Cryptum
178
186
  retry
179
187
  rescue Interrupt
180
188
  # Exit Gracefully if CTRL+C is Pressed During Session
181
- Cryptum.exit_gracefully(which_self: self)
189
+ Cryptum::UI::Exit.gracefully(
190
+ which_self: self,
191
+ option_choice: option_choice
192
+ )
182
193
  rescue StandardError => e
183
194
  # Produce a Stacktrace for anything else
184
195
  Curses.close_screen
@@ -14,7 +14,7 @@ module Cryptum
14
14
  env = opts[:env]
15
15
 
16
16
  terminal_win.key_press_event.key_x = false
17
- Cryptum.exit_gracefully(
17
+ Cryptum::UI::Exit.gracefully(
18
18
  which_self: self,
19
19
  event_history: event_history,
20
20
  option_choice: option_choice,
@@ -195,7 +195,10 @@ module Cryptum
195
195
  end
196
196
  rescue Interrupt
197
197
  # Exit Gracefully if CTRL+C is Pressed During Session
198
- Cryptum.exit_gracefully(which_self: self)
198
+ Cryptum::UI::Exit.gracefully(
199
+ which_self: self,
200
+ option_choice: option_choice
201
+ )
199
202
  rescue StandardError => e
200
203
  # Produce a Stacktrace for anything else
201
204
  raise e
@@ -152,7 +152,7 @@ module Cryptum
152
152
  event_history
153
153
  rescue Interrupt
154
154
  # Exit Gracefully if CTRL+C is Pressed During Session
155
- Cryptum.exit_gracefully(
155
+ Cryptum::UI::Exit.gracefully(
156
156
  which_self: self,
157
157
  event_history: event_history,
158
158
  option_choice: option_choice,
@@ -18,7 +18,7 @@ module Cryptum
18
18
 
19
19
  rescue Interrupt
20
20
  # Exit Gracefully if CTRL+C is Pressed During Session
21
- Cryptum.exit_gracefully(which_self: self)
21
+ Cryptum::UI::Exit.gracefully(which_self: self)
22
22
  rescue StandardError => e
23
23
  # Produce a Stacktrace for anything else
24
24
  Curses.close_screen
@@ -3,19 +3,18 @@
3
3
  require 'io/console'
4
4
  require 'json'
5
5
  require 'logger'
6
- require 'tty-spinner'
7
6
 
8
7
  module Cryptum
9
8
  # This module is used to define the Order Book Data Structure
10
9
  module OrderBook
11
10
  module Generate
12
11
  # Supported Method Parameters::
13
- # Cryptum::OrderBook.generate(
12
+ # Cryptum::OrderBook::Generate.new(
14
13
  # symbol: 'required - target symbol (e.g. btc-usd)',
15
14
  # this_product: 'required - this_product',
16
15
  # )
17
16
 
18
- public_class_method def self.new_order_book(opts = {})
17
+ public_class_method def self.new(opts = {})
19
18
  start_time = opts[:start_time]
20
19
  option_choice = opts[:option_choice]
21
20
  env = opts[:env]
@@ -103,7 +102,7 @@ module Cryptum
103
102
 
104
103
  public_class_method def self.help
105
104
  puts "USAGE:
106
- order_book = #{self}.new_order_book(
105
+ order_book = #{self}.new(
107
106
  symbol: 'required - target symbol (e.g. btc-usd)',
108
107
  this_product: 'required - this_product'
109
108
  )
@@ -295,7 +295,7 @@ module Cryptum
295
295
  key_press_event.key_x
296
296
  rescue Interrupt
297
297
  # Exit Gracefully if CTRL+C is Pressed During Session
298
- Cryptum.exit_gracefully(which_self: self)
298
+ Cryptum::UI::Exit.gracefully(which_self: self)
299
299
  rescue StandardError => e
300
300
  raise e
301
301
  end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cryptum
4
+ module UI
5
+ # This Class is Used to Detect Key Press Events
6
+ module Exit
7
+ public_class_method def self.gracefully(opts = {})
8
+ which_self = opts[:which_self]
9
+ event_history = opts[:event_history]
10
+ # option_choice = opts[:option_choice]
11
+ # env = opts[:env]
12
+
13
+ # Clear out candle data to ensure
14
+ # Cryptum Statistics Only Apply to
15
+ # Live Sessions
16
+ if event_history
17
+ File.write(
18
+ order_book_file,
19
+ JSON.pretty_generate(event_history.order_book)
20
+ )
21
+ end
22
+
23
+ Curses.close_screen
24
+ puts "Interrupt detected in #{which_self}...goodbye."
25
+
26
+ exit 0
27
+ rescue NameError
28
+ puts "\nInterrupt detected in #{which_self}...goodbye."
29
+
30
+ exit 0
31
+ rescue StandardError => e
32
+ # Produce a Stacktrace for anything else
33
+ raise e
34
+ end
35
+
36
+ # Display a List of Every UI Module
37
+
38
+ public_class_method def self.help
39
+ constants.sort
40
+ end
41
+ end
42
+ end
43
+ end
@@ -23,7 +23,7 @@ module Cryptum
23
23
 
24
24
  rescue Interrupt
25
25
  # Exit Gracefully if CTRL+C is Pressed During Session
26
- Cryptum.exit_gracefully(which_self: self)
26
+ Cryptum::UI::Exit.gracefully(which_self: self)
27
27
  rescue StandardError => e
28
28
  # Produce a Stacktrace for anything else
29
29
  Curses.close_screen
@@ -57,7 +57,10 @@ module Cryptum
57
57
  event_history
58
58
  rescue Interrupt
59
59
  # Exit Gracefully if CTRL+C is Pressed During Session
60
- Cryptum.exit_gracefully(which_self: self)
60
+ Cryptum::UI::Exit.gracefully(
61
+ which_self: self,
62
+ event_history: event_history
63
+ )
61
64
  rescue StandardError => e
62
65
  raise e
63
66
  end
@@ -0,0 +1,187 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+
5
+ module Cryptum
6
+ # This plugin is used to Refresh the Cryptum console UI
7
+ module UI
8
+ # This plugin is used as a visual representation of being in a, "Red Pill" state
9
+ module Matrix
10
+ # Supported Method Parameters::
11
+ # Cryptum::Matrix.generate(
12
+ # cols: cols
13
+ # )
14
+
15
+ public_class_method def self.generate(opts = {})
16
+ # Need to divide by two for wide characters
17
+ cols = opts[:cols].to_i
18
+
19
+ matrix_arr = [
20
+ 0x30a0.chr('UTF-8'),
21
+ 0x30a1.chr('UTF-8'),
22
+ 0x30a2.chr('UTF-8'),
23
+ 0x30a3.chr('UTF-8'),
24
+ 0x30a4.chr('UTF-8'),
25
+ 0x30a5.chr('UTF-8'),
26
+ 0x30a6.chr('UTF-8'),
27
+ 0x30a7.chr('UTF-8'),
28
+ 0x30a8.chr('UTF-8'),
29
+ 0x30a9.chr('UTF-8'),
30
+ 0x30aa.chr('UTF-8'),
31
+ 0x30ab.chr('UTF-8'),
32
+ 0x30ac.chr('UTF-8'),
33
+ 0x30ad.chr('UTF-8'),
34
+ 0x30ae.chr('UTF-8'),
35
+ 0x30af.chr('UTF-8'),
36
+ 0x30b0.chr('UTF-8'),
37
+ 0x30b1.chr('UTF-8'),
38
+ 0x30b2.chr('UTF-8'),
39
+ 0x30b3.chr('UTF-8'),
40
+ 0x30b4.chr('UTF-8'),
41
+ 0x30b5.chr('UTF-8'),
42
+ 0x30b6.chr('UTF-8'),
43
+ 0x30b7.chr('UTF-8'),
44
+ 0x30b8.chr('UTF-8'),
45
+ 0x30b9.chr('UTF-8'),
46
+ 0x30ba.chr('UTF-8'),
47
+ 0x30bb.chr('UTF-8'),
48
+ 0x30bc.chr('UTF-8'),
49
+ 0x30bd.chr('UTF-8'),
50
+ 0x30be.chr('UTF-8'),
51
+ 0x30bf.chr('UTF-8'),
52
+ 0x30c0.chr('UTF-8'),
53
+ 0x30c1.chr('UTF-8'),
54
+ 0x30c2.chr('UTF-8'),
55
+ 0x30c3.chr('UTF-8'),
56
+ 0x30c4.chr('UTF-8'),
57
+ 0x30c5.chr('UTF-8'),
58
+ 0x30c6.chr('UTF-8'),
59
+ 0x30c7.chr('UTF-8'),
60
+ 0x30c8.chr('UTF-8'),
61
+ 0x30c9.chr('UTF-8'),
62
+ 0x30ca.chr('UTF-8'),
63
+ 0x30cb.chr('UTF-8'),
64
+ 0x30cc.chr('UTF-8'),
65
+ 0x30cd.chr('UTF-8'),
66
+ 0x30ce.chr('UTF-8'),
67
+ 0x30cf.chr('UTF-8'),
68
+ 0x30d0.chr('UTF-8'),
69
+ 0x30d1.chr('UTF-8'),
70
+ 0x30d2.chr('UTF-8'),
71
+ 0x30d3.chr('UTF-8'),
72
+ 0x30d4.chr('UTF-8'),
73
+ 0x30d5.chr('UTF-8'),
74
+ 0x30d6.chr('UTF-8'),
75
+ 0x30d7.chr('UTF-8'),
76
+ 0x30d8.chr('UTF-8'),
77
+ 0x30d9.chr('UTF-8'),
78
+ 0x30da.chr('UTF-8'),
79
+ 0x30db.chr('UTF-8'),
80
+ 0x30dc.chr('UTF-8'),
81
+ 0x30dd.chr('UTF-8'),
82
+ 0x30de.chr('UTF-8'),
83
+ 0x30df.chr('UTF-8'),
84
+ 0x30e0.chr('UTF-8'),
85
+ 0x30e1.chr('UTF-8'),
86
+ 0x30e2.chr('UTF-8'),
87
+ 0x30e3.chr('UTF-8'),
88
+ 0x30e4.chr('UTF-8'),
89
+ 0x30e5.chr('UTF-8'),
90
+ 0x30e6.chr('UTF-8'),
91
+ 0x30e7.chr('UTF-8'),
92
+ 0x30e8.chr('UTF-8'),
93
+ 0x30e9.chr('UTF-8'),
94
+ 0x30ea.chr('UTF-8'),
95
+ 0x30eb.chr('UTF-8'),
96
+ 0x30ec.chr('UTF-8'),
97
+ 0x30ed.chr('UTF-8'),
98
+ 0x30ee.chr('UTF-8'),
99
+ 0x30ef.chr('UTF-8'),
100
+ 0x30f0.chr('UTF-8'),
101
+ 0x30f1.chr('UTF-8'),
102
+ 0x30f2.chr('UTF-8'),
103
+ 0x30f3.chr('UTF-8'),
104
+ 0x30f4.chr('UTF-8'),
105
+ 0x30f5.chr('UTF-8'),
106
+ 0x30f6.chr('UTF-8'),
107
+ 0x30f7.chr('UTF-8'),
108
+ 0x30f8.chr('UTF-8'),
109
+ 0x30f9.chr('UTF-8'),
110
+ 0x30fa.chr('UTF-8'),
111
+ 0x30fb.chr('UTF-8'),
112
+ 0x30fc.chr('UTF-8'),
113
+ 0x30fd.chr('UTF-8'),
114
+ 0x30fe.chr('UTF-8'),
115
+ '0 ',
116
+ '1 ',
117
+ '2 ',
118
+ '3 ',
119
+ '4 ',
120
+ '5 ',
121
+ '6 ',
122
+ '7 ',
123
+ '8 ',
124
+ '9 ',
125
+ 'A ',
126
+ 'c ',
127
+ 'R ',
128
+ 'y ',
129
+ 'P ',
130
+ 't ',
131
+ 'U ',
132
+ 'm ',
133
+ 'x ',
134
+ 'Z ',
135
+ ': ',
136
+ '{ ',
137
+ '[ ',
138
+ '} ',
139
+ '] ',
140
+ '| ',
141
+ '` ',
142
+ '~ ',
143
+ '! ',
144
+ '@ ',
145
+ '# ',
146
+ '$ ',
147
+ '% ',
148
+ '^ ',
149
+ '& ',
150
+ '* ',
151
+ '( ',
152
+ ') ',
153
+ '_ ',
154
+ '- ',
155
+ '= ',
156
+ '+ ',
157
+ '> ',
158
+ '< ',
159
+ '. ',
160
+ ', '
161
+ ]
162
+
163
+ last_index = matrix_arr.length - 1
164
+
165
+ matrix_row = ''
166
+ most_cols = cols - 1
167
+ most_cols.times.each do
168
+ matrix_row += "#{matrix_arr[Random.rand(0..last_index)]} "
169
+ end
170
+ matrix_row += matrix_arr[Random.rand(0..last_index)]
171
+ rescue Interrupt
172
+ # Exit Gracefully if CTRL+C is Pressed During Session
173
+ Cryptum::UI::Exit.gracefully(which_self: self)
174
+ rescue StandardError => e
175
+ raise e
176
+ end
177
+
178
+ # Display Usage for this Module
179
+
180
+ public_class_method def self.help
181
+ puts "USAGE:
182
+ matrix_row = #{self}.generate(cols: Curses.cols)
183
+ "
184
+ end
185
+ end
186
+ end
187
+ end
@@ -279,7 +279,10 @@ module Cryptum
279
279
  event_history
280
280
  rescue Interrupt
281
281
  # Exit Gracefully if CTRL+C is Pressed During Session
282
- Cryptum.exit_gracefully(which_self: self)
282
+ Cryptum::UI::Exit.gracefully(
283
+ which_self: self,
284
+ event_history: event_history
285
+ )
283
286
  rescue StandardError => e
284
287
  raise e
285
288
  end
@@ -604,7 +604,12 @@ module Cryptum
604
604
  event_history
605
605
  rescue Interrupt
606
606
  # Exit Gracefully if CTRL+C is Pressed During Session
607
- Cryptum.exit_gracefully(which_self: self)
607
+ Cryptum::UI::Exit.gracefully(
608
+ which_self: self,
609
+ event_history: event_history,
610
+ option_choice: option_choice,
611
+ env: env
612
+ )
608
613
  rescue StandardError => e
609
614
  raise e
610
615
  end
@@ -334,7 +334,7 @@ module Cryptum
334
334
 
335
335
  max_rows_to_display.times.each do
336
336
  out_line_no += 1
337
- this_matrix_row = Cryptum::Matrix.generate(cols: Curses.cols)
337
+ this_matrix_row = Cryptum::UI::Matrix.generate(cols: Curses.cols)
338
338
  order_plan_win.setpos(out_line_no, Cryptum::UI.col_first)
339
339
  order_plan_win.clrtoeol
340
340
  Cryptum::UI.colorize(
@@ -494,7 +494,11 @@ module Cryptum
494
494
  event_history
495
495
  rescue Interrupt
496
496
  # Exit Gracefully if CTRL+C is Pressed During Session
497
- Cryptum.exit_gracefully(which_self: self)
497
+ Cryptum::UI::Exit.gracefully(
498
+ which_self: self,
499
+ event_history: event_history,
500
+ option_choice: option_choice
501
+ )
498
502
  rescue StandardError => e
499
503
  raise e
500
504
  end
@@ -222,7 +222,10 @@ module Cryptum
222
222
  event_history
223
223
  rescue Interrupt
224
224
  # Exit Gracefully if CTRL+C is Pressed During Session
225
- Cryptum.exit_gracefully(which_self: self)
225
+ Cryptum::UI::Exit.gracefully(
226
+ which_self: self,
227
+ event_history: event_history
228
+ )
226
229
  rescue StandardError => e
227
230
  raise e
228
231
  end
@@ -118,7 +118,11 @@ module Cryptum
118
118
  order_countdown.to_f
119
119
  rescue Interrupt
120
120
  # Exit Gracefully if CTRL+C is Pressed During Session
121
- Cryptum.exit_gracefully(which_self: self)
121
+ Cryptum::UI::Exit.gracefully(
122
+ which_self: self,
123
+ event_history: event_history,
124
+ option_choice: option_choice
125
+ )
122
126
  rescue StandardError => e
123
127
  raise e
124
128
  end
@@ -201,7 +201,11 @@ module Cryptum
201
201
  event_history
202
202
  rescue Interrupt
203
203
  # Exit Gracefully if CTRL+C is Pressed During Session
204
- Cryptum.exit_gracefully(which_self: self)
204
+ Cryptum::UI::Exit.gracefully(
205
+ which_self: self,
206
+ event_history: event_history,
207
+ option_choice: option_choice
208
+ )
205
209
  rescue StandardError => e
206
210
  raise e
207
211
  end
@@ -89,7 +89,7 @@ module Cryptum
89
89
  indicator_status
90
90
  rescue Interrupt
91
91
  # Exit Gracefully if CTRL+C is Pressed During Session
92
- Cryptum.exit_gracefully(which_self: self)
92
+ Cryptum::UI::Exit.gracefully(which_self: self)
93
93
  rescue StandardError => e
94
94
  raise e
95
95
  end
@@ -101,7 +101,7 @@ module Cryptum
101
101
  end
102
102
  rescue Interrupt
103
103
  # Exit Gracefully if CTRL+C is Pressed During Session
104
- Cryptum.exit_gracefully(which_self: self)
104
+ Cryptum::UI::Exit.gracefully(which_self: self)
105
105
  rescue StandardError => e
106
106
  # Produce a Stacktrace for anything else
107
107
  Curses.close_screen
@@ -299,7 +299,10 @@ module Cryptum
299
299
  event_history
300
300
  rescue Interrupt
301
301
  # Exit Gracefully if CTRL+C is Pressed During Session
302
- Cryptum.exit_gracefully(which_self: self)
302
+ Cryptum::UI::Exit.gracefully(
303
+ which_self: self,
304
+ event_history: event_history
305
+ )
303
306
  rescue StandardError => e
304
307
  raise e
305
308
  end
data/lib/cryptum/ui.rb CHANGED
@@ -7,18 +7,20 @@ module Cryptum
7
7
  # Cryptum::UI Module used for Presenting the
8
8
  # Cryptum Curses Interface
9
9
  module UI
10
+ require 'cryptum/ui/command'
11
+ require 'cryptum/ui/exit'
10
12
  require 'cryptum/ui/key_press_event'
11
- require 'cryptum/ui/terminal_window'
12
- require 'cryptum/ui/ticker'
13
- require 'cryptum/ui/portfolio'
13
+ require 'cryptum/ui/market_trend'
14
+ require 'cryptum/ui/matrix'
15
+ require 'cryptum/ui/order_execution'
16
+ require 'cryptum/ui/order_execute_details'
14
17
  require 'cryptum/ui/order_plan'
15
18
  require 'cryptum/ui/order_plan_details'
16
19
  require 'cryptum/ui/order_timer'
17
- require 'cryptum/ui/market_trend'
20
+ require 'cryptum/ui/portfolio'
18
21
  require 'cryptum/ui/signal_engine'
19
- require 'cryptum/ui/order_execution'
20
- require 'cryptum/ui/order_execute_details'
21
- require 'cryptum/ui/command'
22
+ require 'cryptum/ui/terminal_window'
23
+ require 'cryptum/ui/ticker'
22
24
 
23
25
  # Initialize the UI
24
26
  public_class_method def self.init
@@ -53,7 +55,7 @@ module Cryptum
53
55
  Cryptum::UI::TerminalWindow.new
54
56
  rescue Interrupt
55
57
  # Exit Gracefully if CTRL+C is Pressed During Session
56
- Cryptum.exit_gracefully(which_self: self)
58
+ Cryptum::UI::Exit.gracefully(which_self: self)
57
59
  rescue StandardError => e
58
60
  # Produce a Stacktrace for anything else
59
61
  Curses.close_screen
@@ -78,7 +80,7 @@ module Cryptum
78
80
  window
79
81
  rescue Interrupt
80
82
  # Exit Gracefully if CTRL+C is Pressed During Session
81
- Cryptum.exit_gracefully(which_self: self)
83
+ Cryptum::UI::Exit.gracefully(which_self: self)
82
84
  rescue StandardError => e
83
85
  # Produce a Stacktrace for anything else
84
86
  Curses.close_screen
@@ -104,7 +106,7 @@ module Cryptum
104
106
  )
105
107
  rescue Interrupt
106
108
  # Exit Gracefully if CTRL+C is Pressed During Session
107
- Cryptum.exit_gracefully(which_self: self)
109
+ Cryptum::UI::Exit.gracefully(which_self: self)
108
110
  rescue StandardError => e
109
111
  # Produce a Stacktrace for anything else
110
112
  Curses.close_screen
@@ -202,7 +204,7 @@ module Cryptum
202
204
  end
203
205
  rescue Interrupt
204
206
  # Exit Gracefully if CTRL+C is Pressed During Session
205
- Cryptum.exit_gracefully(which_self: self)
207
+ Cryptum::UI::Exit.gracefully(which_self: self)
206
208
  rescue StandardError => e
207
209
  # Produce a Stacktrace for anything else
208
210
  Curses.close_screen
@@ -217,7 +219,7 @@ module Cryptum
217
219
  (Curses.cols / 2) - str_divided_by_two
218
220
  rescue Interrupt
219
221
  # Exit Gracefully if CTRL+C is Pressed During Session
220
- Cryptum.exit_gracefully(which_self: self)
222
+ Cryptum::UI::Exit.gracefully(which_self: self)
221
223
  rescue StandardError => e
222
224
  # Produce a Stacktrace for anything else
223
225
  Curses.close_screen
@@ -228,7 +230,7 @@ module Cryptum
228
230
  0
229
231
  rescue Interrupt
230
232
  # Exit Gracefully if CTRL+C is Pressed During Session
231
- Cryptum.exit_gracefully(which_self: self)
233
+ Cryptum::UI::Exit.gracefully(which_self: self)
232
234
  rescue StandardError => e
233
235
  # Produce a Stacktrace for anything else
234
236
  Curses.close_screen
@@ -240,7 +242,7 @@ module Cryptum
240
242
  (Curses.cols / 8) + 5
241
243
  rescue Interrupt
242
244
  # Exit Gracefully if CTRL+C is Pressed During Session
243
- Cryptum.exit_gracefully(which_self: self)
245
+ Cryptum::UI::Exit.gracefully(which_self: self)
244
246
  rescue StandardError => e
245
247
  # Produce a Stacktrace for anything else
246
248
  Curses.close_screen
@@ -252,7 +254,7 @@ module Cryptum
252
254
  ((Curses.cols / 8) * 3) + 2
253
255
  rescue Interrupt
254
256
  # Exit Gracefully if CTRL+C is Pressed During Session
255
- Cryptum.exit_gracefully(which_self: self)
257
+ Cryptum::UI::Exit.gracefully(which_self: self)
256
258
  rescue StandardError => e
257
259
  # Produce a Stacktrace for anything else
258
260
  Curses.close_screen
@@ -264,7 +266,7 @@ module Cryptum
264
266
  ((Curses.cols / 4) * 3) - 3
265
267
  rescue Interrupt
266
268
  # Exit Gracefully if CTRL+C is Pressed During Session
267
- Cryptum.exit_gracefully(which_self: self)
269
+ Cryptum::UI::Exit.gracefully(which_self: self)
268
270
  rescue StandardError => e
269
271
  # Produce a Stacktrace for anything else
270
272
  Curses.close_screen
@@ -327,7 +329,7 @@ module Cryptum
327
329
  key_press_event
328
330
  rescue Interrupt
329
331
  # Exit Gracefully if CTRL+C is Pressed During Session
330
- Cryptum.exit_gracefully(which_self: self)
332
+ Cryptum::UI::Exit.gracefully(which_self: self)
331
333
  rescue StandardError => e
332
334
  # Produce a Stacktrace for anything else
333
335
  Curses.close_screen
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptum
4
- VERSION = '0.0.381'
4
+ VERSION = '0.0.382'
5
5
  end
@@ -54,7 +54,7 @@ module Cryptum
54
54
  ws
55
55
  rescue Interrupt
56
56
  # Exit Gracefully if CTRL+C is Pressed During Session
57
- Cryptum.exit_gracefully(which_self: self)
57
+ Cryptum::UI::Exit.gracefully(which_self: self)
58
58
  rescue StandardError => e
59
59
  raise e
60
60
  end
@@ -255,7 +255,7 @@ module Cryptum
255
255
  end
256
256
  rescue Interrupt
257
257
  # Exit Gracefully if CTRL+C is Pressed During Session
258
- Cryptum.exit_gracefully(
258
+ Cryptum::UI::Exit.gracefully(
259
259
  which_self: self,
260
260
  event_history: event_history,
261
261
  option_choice: option_choice,
data/lib/cryptum.rb CHANGED
@@ -4,7 +4,6 @@ require 'rbtrace'
4
4
  require 'yaml'
5
5
  require 'json'
6
6
  require 'fileutils'
7
- require 'tty-spinner'
8
7
  # Root-Level Namespace for cryptum
9
8
  module Cryptum
10
9
  $stdout.sync = true
@@ -14,7 +13,6 @@ module Cryptum
14
13
  require 'cryptum/bot_conf'
15
14
  require 'cryptum/event'
16
15
  require 'cryptum/log'
17
- require 'cryptum/matrix'
18
16
  require 'cryptum/open_ai'
19
17
  require 'cryptum/option'
20
18
  require 'cryptum/order_book'
@@ -85,35 +83,6 @@ module Cryptum
85
83
  raise e
86
84
  end
87
85
 
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
86
  public_class_method def self.help
118
87
  constants.sort
119
88
  end
@@ -2,9 +2,9 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Cryptum::Matrix do
5
+ describe Cryptum::UI::Exit do
6
6
  it 'should display information for existing help method' do
7
- help_response = Cryptum::Matrix
7
+ help_response = Cryptum::UI::Exit
8
8
  expect(help_response).to respond_to :help
9
9
  end
10
10
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Cryptum::UI::Matrix do
6
+ it 'should display information for existing help method' do
7
+ help_response = Cryptum::UI::Matrix
8
+ expect(help_response).to respond_to :help
9
+ end
10
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.381
4
+ version: 0.0.382
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-30 00:00:00.000000000 Z
11
+ date: 2023-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -310,14 +310,14 @@ dependencies:
310
310
  requirements:
311
311
  - - '='
312
312
  - !ruby/object:Gem::Version
313
- version: 1.8.1
313
+ version: 1.8.2
314
314
  type: :runtime
315
315
  prerelease: false
316
316
  version_requirements: !ruby/object:Gem::Requirement
317
317
  requirements:
318
318
  - - '='
319
319
  - !ruby/object:Gem::Version
320
- version: 1.8.1
320
+ version: 1.8.2
321
321
  - !ruby/object:Gem::Dependency
322
322
  name: tty-prompt
323
323
  requirement: !ruby/object:Gem::Requirement
@@ -332,20 +332,6 @@ dependencies:
332
332
  - - '='
333
333
  - !ruby/object:Gem::Version
334
334
  version: 0.23.1
335
- - !ruby/object:Gem::Dependency
336
- name: tty-spinner
337
- requirement: !ruby/object:Gem::Requirement
338
- requirements:
339
- - - '='
340
- - !ruby/object:Gem::Version
341
- version: 0.9.3
342
- type: :runtime
343
- prerelease: false
344
- version_requirements: !ruby/object:Gem::Requirement
345
- requirements:
346
- - - '='
347
- - !ruby/object:Gem::Version
348
- version: 0.9.3
349
335
  - !ruby/object:Gem::Dependency
350
336
  name: websocket-extensions
351
337
  requirement: !ruby/object:Gem::Requirement
@@ -431,7 +417,6 @@ files:
431
417
  - lib/cryptum/event/scroll.rb
432
418
  - lib/cryptum/event/sell.rb
433
419
  - lib/cryptum/log.rb
434
- - lib/cryptum/matrix.rb
435
420
  - lib/cryptum/open_ai.rb
436
421
  - lib/cryptum/option.rb
437
422
  - lib/cryptum/option/choice.rb
@@ -447,8 +432,10 @@ files:
447
432
  - lib/cryptum/portfolio/balance.rb
448
433
  - lib/cryptum/ui.rb
449
434
  - lib/cryptum/ui/command.rb
435
+ - lib/cryptum/ui/exit.rb
450
436
  - lib/cryptum/ui/key_press_event.rb
451
437
  - lib/cryptum/ui/market_trend.rb
438
+ - lib/cryptum/ui/matrix.rb
452
439
  - lib/cryptum/ui/order_execute_details.rb
453
440
  - lib/cryptum/ui/order_execution.rb
454
441
  - lib/cryptum/ui/order_plan.rb
@@ -488,7 +475,6 @@ files:
488
475
  - spec/lib/cryptum/event/sell_spec.rb
489
476
  - spec/lib/cryptum/event_spec.rb
490
477
  - spec/lib/cryptum/log_spec.rb
491
- - spec/lib/cryptum/matrix_spec.rb
492
478
  - spec/lib/cryptum/open_ai_spec.rb
493
479
  - spec/lib/cryptum/option/choice_spec.rb
494
480
  - spec/lib/cryptum/option/environment_spec.rb
@@ -503,8 +489,10 @@ files:
503
489
  - spec/lib/cryptum/portfolio/balance_spec.rb
504
490
  - spec/lib/cryptum/portfolio_spec.rb
505
491
  - spec/lib/cryptum/ui/command_spec.rb
492
+ - spec/lib/cryptum/ui/exit_spec.rb
506
493
  - spec/lib/cryptum/ui/key_press_event_spec.rb
507
494
  - spec/lib/cryptum/ui/market_trend_spec.rb
495
+ - spec/lib/cryptum/ui/matrix_spec.rb
508
496
  - spec/lib/cryptum/ui/order_execute_details_spec.rb
509
497
  - spec/lib/cryptum/ui/order_execution_spec.rb
510
498
  - spec/lib/cryptum/ui/order_plan_details_spec.rb
@@ -1,181 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'logger'
4
-
5
- module Cryptum
6
- # This plugin is used for my own entertainment
7
- module Matrix
8
- # Supported Method Parameters::
9
- # Cryptum::Matrix.generate(
10
- # cols: cols
11
- # )
12
-
13
- public_class_method def self.generate(opts = {})
14
- # Need to divide by two for wide characters
15
- cols = opts[:cols].to_i
16
-
17
- matrix_arr = [
18
- 0x30a0.chr('UTF-8'),
19
- 0x30a1.chr('UTF-8'),
20
- 0x30a2.chr('UTF-8'),
21
- 0x30a3.chr('UTF-8'),
22
- 0x30a4.chr('UTF-8'),
23
- 0x30a5.chr('UTF-8'),
24
- 0x30a6.chr('UTF-8'),
25
- 0x30a7.chr('UTF-8'),
26
- 0x30a8.chr('UTF-8'),
27
- 0x30a9.chr('UTF-8'),
28
- 0x30aa.chr('UTF-8'),
29
- 0x30ab.chr('UTF-8'),
30
- 0x30ac.chr('UTF-8'),
31
- 0x30ad.chr('UTF-8'),
32
- 0x30ae.chr('UTF-8'),
33
- 0x30af.chr('UTF-8'),
34
- 0x30b0.chr('UTF-8'),
35
- 0x30b1.chr('UTF-8'),
36
- 0x30b2.chr('UTF-8'),
37
- 0x30b3.chr('UTF-8'),
38
- 0x30b4.chr('UTF-8'),
39
- 0x30b5.chr('UTF-8'),
40
- 0x30b6.chr('UTF-8'),
41
- 0x30b7.chr('UTF-8'),
42
- 0x30b8.chr('UTF-8'),
43
- 0x30b9.chr('UTF-8'),
44
- 0x30ba.chr('UTF-8'),
45
- 0x30bb.chr('UTF-8'),
46
- 0x30bc.chr('UTF-8'),
47
- 0x30bd.chr('UTF-8'),
48
- 0x30be.chr('UTF-8'),
49
- 0x30bf.chr('UTF-8'),
50
- 0x30c0.chr('UTF-8'),
51
- 0x30c1.chr('UTF-8'),
52
- 0x30c2.chr('UTF-8'),
53
- 0x30c3.chr('UTF-8'),
54
- 0x30c4.chr('UTF-8'),
55
- 0x30c5.chr('UTF-8'),
56
- 0x30c6.chr('UTF-8'),
57
- 0x30c7.chr('UTF-8'),
58
- 0x30c8.chr('UTF-8'),
59
- 0x30c9.chr('UTF-8'),
60
- 0x30ca.chr('UTF-8'),
61
- 0x30cb.chr('UTF-8'),
62
- 0x30cc.chr('UTF-8'),
63
- 0x30cd.chr('UTF-8'),
64
- 0x30ce.chr('UTF-8'),
65
- 0x30cf.chr('UTF-8'),
66
- 0x30d0.chr('UTF-8'),
67
- 0x30d1.chr('UTF-8'),
68
- 0x30d2.chr('UTF-8'),
69
- 0x30d3.chr('UTF-8'),
70
- 0x30d4.chr('UTF-8'),
71
- 0x30d5.chr('UTF-8'),
72
- 0x30d6.chr('UTF-8'),
73
- 0x30d7.chr('UTF-8'),
74
- 0x30d8.chr('UTF-8'),
75
- 0x30d9.chr('UTF-8'),
76
- 0x30da.chr('UTF-8'),
77
- 0x30db.chr('UTF-8'),
78
- 0x30dc.chr('UTF-8'),
79
- 0x30dd.chr('UTF-8'),
80
- 0x30de.chr('UTF-8'),
81
- 0x30df.chr('UTF-8'),
82
- 0x30e0.chr('UTF-8'),
83
- 0x30e1.chr('UTF-8'),
84
- 0x30e2.chr('UTF-8'),
85
- 0x30e3.chr('UTF-8'),
86
- 0x30e4.chr('UTF-8'),
87
- 0x30e5.chr('UTF-8'),
88
- 0x30e6.chr('UTF-8'),
89
- 0x30e7.chr('UTF-8'),
90
- 0x30e8.chr('UTF-8'),
91
- 0x30e9.chr('UTF-8'),
92
- 0x30ea.chr('UTF-8'),
93
- 0x30eb.chr('UTF-8'),
94
- 0x30ec.chr('UTF-8'),
95
- 0x30ed.chr('UTF-8'),
96
- 0x30ee.chr('UTF-8'),
97
- 0x30ef.chr('UTF-8'),
98
- 0x30f0.chr('UTF-8'),
99
- 0x30f1.chr('UTF-8'),
100
- 0x30f2.chr('UTF-8'),
101
- 0x30f3.chr('UTF-8'),
102
- 0x30f4.chr('UTF-8'),
103
- 0x30f5.chr('UTF-8'),
104
- 0x30f6.chr('UTF-8'),
105
- 0x30f7.chr('UTF-8'),
106
- 0x30f8.chr('UTF-8'),
107
- 0x30f9.chr('UTF-8'),
108
- 0x30fa.chr('UTF-8'),
109
- 0x30fb.chr('UTF-8'),
110
- 0x30fc.chr('UTF-8'),
111
- 0x30fd.chr('UTF-8'),
112
- 0x30fe.chr('UTF-8'),
113
- '0 ',
114
- '1 ',
115
- '2 ',
116
- '3 ',
117
- '4 ',
118
- '5 ',
119
- '6 ',
120
- '7 ',
121
- '8 ',
122
- '9 ',
123
- 'A ',
124
- 'c ',
125
- 'R ',
126
- 'y ',
127
- 'P ',
128
- 't ',
129
- 'U ',
130
- 'm ',
131
- 'x ',
132
- 'Z ',
133
- ': ',
134
- '{ ',
135
- '[ ',
136
- '} ',
137
- '] ',
138
- '| ',
139
- '` ',
140
- '~ ',
141
- '! ',
142
- '@ ',
143
- '# ',
144
- '$ ',
145
- '% ',
146
- '^ ',
147
- '& ',
148
- '* ',
149
- '( ',
150
- ') ',
151
- '_ ',
152
- '- ',
153
- '= ',
154
- '+ ',
155
- '> ',
156
- '< ',
157
- '. ',
158
- ', '
159
- ]
160
-
161
- last_index = matrix_arr.length - 1
162
-
163
- matrix_row = ''
164
- most_cols = cols - 1
165
- most_cols.times.each do
166
- matrix_row += "#{matrix_arr[Random.rand(0..last_index)]} "
167
- end
168
- matrix_row += matrix_arr[Random.rand(0..last_index)]
169
- rescue StandardError => e
170
- raise e
171
- end
172
-
173
- # Display Usage for this Module
174
-
175
- public_class_method def self.help
176
- puts "USAGE:
177
- logger = #{self}.create()
178
- "
179
- end
180
- end
181
- end