cryptum 0.0.254 → 0.0.256

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: 189b9650a62af7d1ada241d68b1bb13bc6caade9fa90c99c853980cfa27eb7cf
4
- data.tar.gz: ad999e6ae19c037efe09ae347fd9703c3a9486613d5aebe8834c0d5fbc339f93
3
+ metadata.gz: 2687c6be08b4b287a0f9ad8192708a0f862b526933614bcd440607fa667e6e06
4
+ data.tar.gz: 00c9a699c865e8f91cdecafcc896e19a1481100c01e492c3bf53e15a22df9ee2
5
5
  SHA512:
6
- metadata.gz: ee711cb2ad49fee7f7a72ad77d15b5c8a194efb191b76c985a66f3ef37711c12abd8570446240eda6183c05c21a55ff6052867f98cd3c1ba974e8488fac5be94
7
- data.tar.gz: 952c46940311f74205453d46cf39625070ee2403801b152b57ee8e98bba619e6a30d51c757820eae2e98c40cf64ae62d42b910499ee02774900eb18616535c07
6
+ metadata.gz: fd74b3c4bd968db4e24b1a3fae5802b86d356619909e0d32a45d9d246d38c81a1b91714b3691f3ff7a3d95e2d4fcd0b57bdb408bfb89030062e1c57379379b5c
7
+ data.tar.gz: c2ec14727da1cfccc54afacb7760feb0062d640da5d7cc7e24189dcbad5c03c0e9aeacc339a619e53a192e236f43d98ddee672abc26349a20a2a630a48ae4a4d
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2022-11-30 17:25:04 UTC using RuboCop version 1.39.0.
3
+ # on 2022-12-01 19:02:17 UTC using RuboCop version 1.39.0.
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
@@ -103,11 +103,6 @@ Layout/TrailingWhitespace:
103
103
  - 'lib/cryptum/ui/order_plan.rb'
104
104
  - 'lib/cryptum/ui/order_timer.rb'
105
105
 
106
- # Offense count: 1
107
- Lint/NonLocalExitFromIterator:
108
- Exclude:
109
- - 'lib/cryptum/web_sock/event_machine.rb'
110
-
111
106
  # Offense count: 51
112
107
  Lint/UselessAssignment:
113
108
  Exclude:
@@ -125,16 +120,16 @@ Lint/UselessAssignment:
125
120
  - 'lib/cryptum/ui/signal_engine.rb'
126
121
  - 'lib/cryptum/ui/ticker.rb'
127
122
 
128
- # Offense count: 38
123
+ # Offense count: 39
129
124
  # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
130
125
  Metrics/AbcSize:
131
- Max: 371
126
+ Max: 388
132
127
 
133
128
  # Offense count: 7
134
129
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
135
130
  # AllowedMethods: refine
136
131
  Metrics/BlockLength:
137
- Max: 94
132
+ Max: 135
138
133
 
139
134
  # Offense count: 4
140
135
  # Configuration parameters: CountBlocks.
@@ -144,22 +139,22 @@ Metrics/BlockNesting:
144
139
  # Offense count: 16
145
140
  # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
146
141
  Metrics/CyclomaticComplexity:
147
- Max: 70
142
+ Max: 72
148
143
 
149
144
  # Offense count: 56
150
145
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
151
146
  Metrics/MethodLength:
152
- Max: 343
147
+ Max: 362
153
148
 
154
149
  # Offense count: 15
155
150
  # Configuration parameters: CountComments, CountAsOne.
156
151
  Metrics/ModuleLength:
157
152
  Max: 538
158
153
 
159
- # Offense count: 16
154
+ # Offense count: 17
160
155
  # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
161
156
  Metrics/PerceivedComplexity:
162
- Max: 73
157
+ Max: 75
163
158
 
164
159
  # Offense count: 1
165
160
  # Configuration parameters: AllowedConstants.
@@ -212,7 +207,7 @@ Style/RedundantReturn:
212
207
  Exclude:
213
208
  - 'lib/cryptum.rb'
214
209
 
215
- # Offense count: 2
210
+ # Offense count: 4
216
211
  # This cop supports safe autocorrection (--autocorrect).
217
212
  Style/RedundantSelf:
218
213
  Exclude:
@@ -249,7 +244,7 @@ Style/TrailingCommaInArrayLiteral:
249
244
  Exclude:
250
245
  - 'lib/cryptum/matrix.rb'
251
246
 
252
- # Offense count: 10
247
+ # Offense count: 16
253
248
  # This cop supports safe autocorrection (--autocorrect).
254
249
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
255
250
  # URISchemes: http, https
@@ -24,7 +24,15 @@ module Cryptum
24
24
  :time_between_orders,
25
25
  :time_between_orders_max,
26
26
  :time_between_orders_min,
27
- :time_between_orders_reset
27
+ :time_between_orders_reset,
28
+ :order_plan_win_active,
29
+ :order_plan_index_offset,
30
+ :order_plan_max_rows_to_display,
31
+ :order_plan_row_to_select,
32
+ :order_execute_win_active,
33
+ :order_execute_index_offset,
34
+ :order_execute_max_rows_to_display,
35
+ :order_execute_row_to_select
28
36
 
29
37
  def initialize(opts = {})
30
38
  # option_choice = opts[:option_choice]
@@ -42,6 +50,14 @@ module Cryptum
42
50
  self.reconnected = false
43
51
  self.red_pill = false
44
52
  self.reset_market_trend = false
53
+ self.order_plan_win_active = true
54
+ self.order_plan_index_offset = 0
55
+ self.order_plan_max_rows_to_display = 7
56
+ self.order_plan_row_to_select = self.order_plan_index_offset
57
+ self.order_execute_win_active = false
58
+ self.order_execute_index_offset = 0
59
+ self.order_execute_max_rows_to_display = 6
60
+ self.order_execute_row_to_select = self.order_execute_index_offset
45
61
 
46
62
  # 10 minutes
47
63
  self.time_between_orders = 600
@@ -97,13 +97,6 @@ module Cryptum
97
97
  ]
98
98
  # ROW 1
99
99
  out_line_no = 0
100
- Cryptum::UI.line(
101
- ui_win: command_win,
102
- out_line_no: out_line_no
103
- )
104
-
105
- # ROW 2
106
- out_line_no += 1
107
100
  command_win.setpos(
108
101
  out_line_no,
109
102
  Cryptum::UI.col_center(str: command_str_r2_arr.join(''))
@@ -9,7 +9,12 @@ module Cryptum
9
9
  :key_r,
10
10
  :key_u,
11
11
  :key_w,
12
- :key_x
12
+ :key_x,
13
+ :key_ansi,
14
+ :key_down_arrow,
15
+ :key_esc,
16
+ :key_tab,
17
+ :key_up_arrow
13
18
 
14
19
  rescue Interrupt
15
20
  # Exit Gracefully if CTRL+C is Pressed During Session
@@ -375,9 +375,14 @@ module Cryptum
375
375
 
376
376
  # ROW 1
377
377
  out_line_no = 0
378
+ line_color = :white
379
+ style = :bold
380
+ line_color = :red if event_history.order_execute_win_active
381
+
378
382
  Cryptum::UI.line(
379
383
  ui_win: order_execute_win,
380
- out_line_no: out_line_no
384
+ out_line_no: out_line_no,
385
+ color: line_color
381
386
  )
382
387
 
383
388
  # ROW 2
@@ -387,7 +392,7 @@ module Cryptum
387
392
  Cryptum::UI.colorize(
388
393
  ui_win: order_execute_win,
389
394
  color: :white,
390
- style: :bold,
395
+ style: style,
391
396
  string: 'Open Sell Orders | 24 Hr Stats:'
392
397
  )
393
398
 
@@ -395,6 +400,7 @@ module Cryptum
395
400
  Cryptum::UI.colorize(
396
401
  ui_win: order_execute_win,
397
402
  color: :white,
403
+ style: style,
398
404
  string: "#{total_to_sell} | #{order_hist_meta_expired} Expired | #{order_hist_meta_sold} Sold | $#{gains_24h_out} Gained".rjust(
399
405
  col_just3,
400
406
  '.'
@@ -405,15 +411,26 @@ module Cryptum
405
411
  out_line_no += 1
406
412
  Cryptum::UI.line(
407
413
  ui_win: order_execute_win,
408
- out_line_no: out_line_no
414
+ out_line_no: out_line_no,
415
+ color: line_color
409
416
  )
410
417
 
411
418
 
412
419
  # ROWS 4-10
413
- order_history_meta.reverse[0..6].each do |meta|
420
+ first_row = event_history.order_execute_index_offset
421
+ last_row = first_row + event_history.order_execute_max_rows_to_display
422
+ if last_row >= order_history_meta.length
423
+ last_row = order_history_meta.length - 1
424
+ first_row = last_row - event_history.order_execute_max_rows_to_display
425
+ event_history.order_execute_index_offset = first_row
426
+ end
427
+
428
+ order_history_meta.reverse[first_row..last_row].each do |meta|
414
429
  out_line_no += 1
430
+ current_line = out_line_no - 3
431
+
415
432
  style = :normal
416
- style = :highlight if out_line_no == 1
433
+ style = :highlight if event_history.order_execute_row_to_select == current_line
417
434
  risk_alloc_out = Cryptum.beautify_large_number(
418
435
  value: meta[:risk_alloc]
419
436
  )
@@ -464,6 +481,12 @@ module Cryptum
464
481
  )
465
482
  end
466
483
 
484
+ Cryptum::UI.line(
485
+ ui_win: order_execute_win,
486
+ out_line_no: out_line_no,
487
+ color: line_color
488
+ )
489
+
467
490
  order_execute_win.refresh
468
491
 
469
492
  # Reset Order Ready Boolean
@@ -199,9 +199,14 @@ module Cryptum
199
199
 
200
200
  # ROW 1
201
201
  out_line_no = 0
202
+ line_color = :white
203
+ style = :bold
204
+ line_color = :red if event_history.order_plan_win_active
205
+
202
206
  Cryptum::UI.line(
203
207
  ui_win: order_plan_win,
204
- out_line_no: out_line_no
208
+ out_line_no: out_line_no,
209
+ color: line_color
205
210
  )
206
211
 
207
212
  # ROW 2
@@ -211,7 +216,7 @@ module Cryptum
211
216
  Cryptum::UI.colorize(
212
217
  ui_win: order_plan_win,
213
218
  color: :white,
214
- style: :bold,
219
+ style: style,
215
220
  string: "Order Plan ##{order_plan_prefix} Summary:"
216
221
  )
217
222
 
@@ -219,6 +224,7 @@ module Cryptum
219
224
  Cryptum::UI.colorize(
220
225
  ui_win: order_plan_win,
221
226
  color: :white,
227
+ style: style,
222
228
  string: "$#{order_plan_volume_out} w #{max_order_plan_slices} Slices | $#{order_plan_profit_sum_out} 2 Gain | #{order_plan_exec_percent}% Done".rjust(
223
229
  col_just3,
224
230
  '.'
@@ -229,7 +235,8 @@ module Cryptum
229
235
  out_line_no += 1
230
236
  Cryptum::UI.line(
231
237
  ui_win: order_plan_win,
232
- out_line_no: out_line_no
238
+ out_line_no: out_line_no,
239
+ color: line_color
233
240
  )
234
241
 
235
242
  # ROWS 4-10
@@ -310,10 +317,20 @@ module Cryptum
310
317
  plan_color = :cyan if color == :red
311
318
  plan_color = :green if color == :green
312
319
 
313
- order_plan[0..6].each do |order|
320
+ first_row = event_history.order_plan_index_offset
321
+ last_row = first_row + event_history.order_plan_max_rows_to_display
322
+ if last_row >= order_plan.length
323
+ last_row = order_plan.length - 1
324
+ first_row = last_row - event_history.order_plan_max_rows_to_display
325
+ event_history.order_plan_index_offset = first_row
326
+ end
327
+
328
+ order_plan[first_row..last_row].each do |order|
314
329
  out_line_no += 1
330
+ current_line = out_line_no - 3
331
+
315
332
  style = :normal
316
- style = :highlight if out_line_no == 1
333
+ style = :highlight if event_history.order_plan_row_to_select == current_line
317
334
  fiat_avail_out = Cryptum.beautify_large_number(
318
335
  value: order[:fiat_available]
319
336
  )
@@ -361,6 +378,12 @@ module Cryptum
361
378
  end
362
379
  end
363
380
 
381
+ Cryptum::UI.line(
382
+ ui_win: order_plan_win,
383
+ out_line_no: out_line_no,
384
+ color: line_color
385
+ )
386
+
364
387
  order_plan_win.refresh
365
388
 
366
389
  # event_history
@@ -30,18 +30,21 @@ module Cryptum
30
30
  trend_timer_begin = Time.parse(last_trend_reset_time)
31
31
  trend_timer_end = trend_timer_begin + time_between_trend_reset
32
32
  trend_time_remaining = trend_timer_end - Time.now
33
- trend_countdown = format('%0.4f', trend_time_remaining)
33
+ trend_countdown = Cryptum.beautify_large_number(
34
+ value: format('%0.2f', trend_time_remaining)
35
+ )
34
36
 
35
37
  # Market Trend Reset Timer
36
38
  time_between_order_exec = event_history.time_between_orders
37
- time_between_order_exec_out = format(
38
- '%0.4f',
39
- time_between_order_exec
39
+ time_between_order_exec_out = Cryptum.beautify_large_number(
40
+ value: format('%0.2f', time_between_order_exec)
40
41
  )
41
42
  order_begin_time = Time.parse(last_order_exec_time)
42
43
  order_end_time = order_begin_time + time_between_order_exec
43
44
  order_exec_time_remaining = order_end_time - Time.now
44
- order_countdown = format('%0.4f', order_exec_time_remaining)
45
+ order_countdown = Cryptum.beautify_large_number(
46
+ value: format('%0.2f', order_exec_time_remaining)
47
+ )
45
48
 
46
49
  color = :white
47
50
  color = indicator_status.market_trend[:color] if indicator_status.market_trend
@@ -71,13 +74,6 @@ module Cryptum
71
74
 
72
75
  # ROW 1
73
76
  out_line_no = 0
74
- Cryptum::UI.line(
75
- ui_win: order_timer_win,
76
- out_line_no: out_line_no
77
- )
78
-
79
- # ROW 2
80
- out_line_no += 1
81
77
  order_timer_win.setpos(out_line_no, Cryptum::UI.col_first)
82
78
  order_timer_win.clrtoeol
83
79
  Cryptum::UI.colorize(
@@ -42,16 +42,16 @@ module Cryptum
42
42
  )
43
43
 
44
44
  self.order_plan_section = Cryptum::UI.window(
45
- height: 10,
45
+ height: 12,
46
46
  width: 0,
47
47
  top: 13,
48
48
  left: 0
49
49
  )
50
50
 
51
51
  self.order_timer_section = Cryptum::UI.window(
52
- height: 2,
52
+ height: 1,
53
53
  width: 0,
54
- top: 23,
54
+ top: 24,
55
55
  left: 0
56
56
  )
57
57
 
@@ -70,14 +70,14 @@ module Cryptum
70
70
  )
71
71
 
72
72
  self.order_execute_section = Cryptum::UI.window(
73
- height: 10,
73
+ height: 11,
74
74
  width: 0,
75
75
  top: 29,
76
76
  left: 0
77
77
  )
78
78
 
79
79
  self.command_section = Cryptum::UI.window(
80
- height: 4,
80
+ height: 3,
81
81
  width: 0,
82
82
  top: 39,
83
83
  left: 0
@@ -161,21 +161,12 @@ module Cryptum
161
161
  out_line_no += 1
162
162
  ticker_win.setpos(out_line_no, Cryptum::UI.col_first)
163
163
  ticker_win.clrtoeol
164
- if Curses.can_change_color?
165
- Cryptum::UI.colorize(
166
- ui_win: ticker_win,
167
- color: :rainbow,
168
- style: :bold,
169
- string: symbol_out.ljust(col_just1)
170
- )
171
- else
172
- Cryptum::UI.colorize(
173
- ui_win: ticker_win,
174
- color: :yellow,
175
- style: :bold,
176
- string: symbol_out.ljust(col_just1)
177
- )
178
- end
164
+ Cryptum::UI.colorize(
165
+ ui_win: ticker_win,
166
+ color: :yellow,
167
+ style: :bold,
168
+ string: symbol_out.ljust(col_just1)
169
+ )
179
170
 
180
171
  ticker_win.setpos(out_line_no, Cryptum::UI.col_second)
181
172
  Cryptum::UI.colorize(
data/lib/cryptum/ui.rb CHANGED
@@ -87,24 +87,19 @@ module Cryptum
87
87
  public_class_method def self.line(opts = {})
88
88
  ui_win = opts[:ui_win]
89
89
  out_line_no = opts[:out_line_no].to_i
90
+ color = opts[:color]
91
+ color ||= :white
92
+
93
+ style = :normal
94
+ style = :bold unless color == :white
90
95
 
91
96
  ui_win.setpos(out_line_no, 0)
92
- if Curses.can_change_color?
93
- colorize(
94
- ui_win: ui_win,
95
- color: :custom,
96
- red: 192,
97
- green: 192,
98
- blue: 192,
99
- string: "\u2500" * Curses.cols
100
- )
101
- else
102
- colorize(
103
- ui_win: ui_win,
104
- color: :white,
105
- string: "\u2500" * Curses.cols
106
- )
107
- end
97
+ colorize(
98
+ ui_win: ui_win,
99
+ color: color,
100
+ style: style,
101
+ string: "\u2500" * Curses.cols
102
+ )
108
103
  rescue Interrupt
109
104
  # Exit Gracefully if CTRL+C is Pressed During Session
110
105
  Cryptum.exit_gracefully(which_self: self)
@@ -274,7 +269,18 @@ module Cryptum
274
269
  key_press_event = opts[:key_press_event]
275
270
  ui_win = opts[:ui_win]
276
271
 
277
- case ui_win.getch
272
+ key_press = ui_win.get_char
273
+
274
+ # Useful for detecting and logging actual key presses to file
275
+ # unless key_press.nil?
276
+ # File.open('/tmp/detect_key_press_in_ui-cryptum.txt', 'a') do |f|
277
+ # f.puts key_press.class
278
+ # f.print key_press.inspect
279
+ # f.puts "\n\n\n"
280
+ # end
281
+ # end
282
+
283
+ case key_press
278
284
  when 'C'
279
285
  key_press_event.key_c = true
280
286
  when 'G'
@@ -287,8 +293,17 @@ module Cryptum
287
293
  key_press_event.key_w = true
288
294
  when 'x'
289
295
  key_press_event.key_x = true
296
+ when "\t"
297
+ key_press_event.key_tab = true
298
+ when "\e"
299
+ key_press_event.key_esc = true
290
300
  end
291
301
 
302
+ # What a hack to detect up / down arrow key presses.
303
+ key_press_event.key_ansi = true if key_press_event.key_esc && key_press == '['
304
+ key_press_event.key_up_arrow = true if key_press_event.key_ansi && key_press == 'A'
305
+ key_press_event.key_down_arrow = true if key_press_event.key_ansi && key_press == 'B'
306
+
292
307
  key_press_event
293
308
  rescue Interrupt
294
309
  # Exit Gracefully if CTRL+C is Pressed During Session
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptum
4
- VERSION = '0.0.254'
4
+ VERSION = '0.0.256'
5
5
  end
@@ -127,6 +127,61 @@ module Cryptum
127
127
  env: env
128
128
  )
129
129
  end
130
+
131
+ # Scroll Down Order Plan / Order Execution Window Panes
132
+ if terminal_win.key_press_event.key_down_arrow
133
+ terminal_win.key_press_event.key_ansi = false
134
+ terminal_win.key_press_event.key_esc = false
135
+ terminal_win.key_press_event.key_down_arrow = false
136
+ if event_history.order_plan_win_active
137
+ order_plan_max_row_index = event_history.order_plan_max_rows_to_display - 1
138
+ event_history.order_plan_row_to_select += 1
139
+ event_history.order_plan_index_offset += 1 if event_history.order_plan_row_to_select > order_plan_max_row_index
140
+ event_history.order_plan_row_to_select = order_plan_max_row_index if event_history.order_plan_row_to_select > order_plan_max_row_index
141
+ end
142
+
143
+ if event_history.order_execute_win_active
144
+ order_execute_max_row_index = event_history.order_execute_max_rows_to_display - 1
145
+ event_history.order_execute_row_to_select += 1
146
+ event_history.order_execute_index_offset += 1 if event_history.order_execute_row_to_select > order_execute_max_row_index
147
+ event_history.order_execute_row_to_select = order_execute_max_row_index if event_history.order_execute_row_to_select > order_execute_max_row_index
148
+
149
+ end
150
+ end
151
+
152
+ # TAB through Order Plan / Order Execution Window Panes
153
+ if terminal_win.key_press_event.key_tab
154
+ terminal_win.key_press_event.key_tab = false
155
+
156
+ if event_history.order_plan_win_active
157
+ event_history.order_plan_win_active = false
158
+ event_history.order_execute_win_active = true
159
+ else
160
+ event_history.order_plan_win_active = true
161
+ event_history.order_execute_win_active = false
162
+ end
163
+ end
164
+
165
+ # Scroll Up Order Plan / Order Execution Window Panes
166
+ if terminal_win.key_press_event.key_up_arrow
167
+ terminal_win.key_press_event.key_ansi = false
168
+ terminal_win.key_press_event.key_esc = false
169
+ terminal_win.key_press_event.key_up_arrow = false
170
+
171
+ if event_history.order_plan_win_active
172
+ event_history.order_plan_row_to_select -= 1
173
+ event_history.order_plan_index_offset -= 1 if event_history.order_plan_row_to_select.negative?
174
+ event_history.order_plan_index_offset = 0 if event_history.order_plan_index_offset.negative?
175
+ event_history.order_plan_row_to_select = 0 if event_history.order_plan_row_to_select.negative?
176
+ end
177
+
178
+ if event_history.order_execute_win_active
179
+ event_history.order_execute_row_to_select -= 1
180
+ event_history.order_execute_index_offset -= 1 if event_history.order_execute_row_to_select.negative?
181
+ event_history.order_execute_index_offset = 0 if event_history.order_execute_index_offset.negative?
182
+ event_history.order_execute_row_to_select = 0 if event_history.order_execute_row_to_select.negative?
183
+ end
184
+ end
130
185
  end
131
186
 
132
187
  ws.on :close do
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.254
4
+ version: 0.0.256
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-30 00:00:00.000000000 Z
11
+ date: 2022-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable