cryptum 0.0.254 → 0.0.255

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: 821d3666c9176e49b63ba26c032d24a901e1c5eab538726d8b675860156190fd
4
+ data.tar.gz: 7a58108f07d42aefce9112c6349e76c802590ed9e21b829f3d96ae22700483de
5
5
  SHA512:
6
- metadata.gz: ee711cb2ad49fee7f7a72ad77d15b5c8a194efb191b76c985a66f3ef37711c12abd8570446240eda6183c05c21a55ff6052867f98cd3c1ba974e8488fac5be94
7
- data.tar.gz: 952c46940311f74205453d46cf39625070ee2403801b152b57ee8e98bba619e6a30d51c757820eae2e98c40cf64ae62d42b910499ee02774900eb18616535c07
6
+ metadata.gz: 97c6fc6168fd04c6f4c6d55994ab27908977c4c7969aff195a60fb01f3e7a43f510056a16ff49f3e08e5d1f0f701f7f0633e85eda55ee4f4333ddcdbea169996
7
+ data.tar.gz: 98a384029779c042d4059ed5194ffd65ba9179bfe7e1cc8a1746efc30cc53ee06be84bce7190adb4a893dca6114e4a950b739217b6906b41035d563b64672862
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 03:19:16 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: 384
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: 117
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: 361
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.
@@ -24,7 +24,11 @@ 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_highlighted,
29
+ :order_plan_line,
30
+ :order_execute_win_highlighted,
31
+ :order_execute_line
28
32
 
29
33
  def initialize(opts = {})
30
34
  # option_choice = opts[:option_choice]
@@ -42,6 +46,10 @@ module Cryptum
42
46
  self.reconnected = false
43
47
  self.red_pill = false
44
48
  self.reset_market_trend = false
49
+ self.order_plan_win_highlighted = true
50
+ self.order_plan_line = 0
51
+ self.order_execute_win_highlighted = false
52
+ self.order_execute_line = 0
45
53
 
46
54
  # 10 minutes
47
55
  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,
15
+ :key_esc,
16
+ :key_tab,
17
+ :key_up
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_highlighted
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,24 @@ 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_line
421
+ last_row = first_row + 6
422
+ if last_row >= order_history_meta.length
423
+ last_row = order_history_meta.length - 1
424
+ first_row = last_row - 6
425
+ event_history.order_execute_line = first_row
426
+ end
427
+
428
+ order_history_meta.reverse[first_row..last_row].each do |meta|
414
429
  out_line_no += 1
415
430
  style = :normal
416
- style = :highlight if out_line_no == 1
431
+ style = :highlight if event_history.order_execute_win_highlighted
417
432
  risk_alloc_out = Cryptum.beautify_large_number(
418
433
  value: meta[:risk_alloc]
419
434
  )
@@ -464,6 +479,12 @@ module Cryptum
464
479
  )
465
480
  end
466
481
 
482
+ Cryptum::UI.line(
483
+ ui_win: order_execute_win,
484
+ out_line_no: out_line_no,
485
+ color: line_color
486
+ )
487
+
467
488
  order_execute_win.refresh
468
489
 
469
490
  # 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_highlighted
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,18 @@ 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_line
321
+ last_row = first_row + 7
322
+ if last_row >= order_plan.length
323
+ last_row = order_plan.length - 1
324
+ first_row = last_row - 7
325
+ event_history.order_plan_line = first_row
326
+ end
327
+
328
+ order_plan[first_row..last_row].each do |order|
314
329
  out_line_no += 1
315
330
  style = :normal
316
- style = :highlight if out_line_no == 1
331
+ style = :highlight if event_history.order_plan_win_highlighted
317
332
  fiat_avail_out = Cryptum.beautify_large_number(
318
333
  value: order[:fiat_available]
319
334
  )
@@ -361,6 +376,12 @@ module Cryptum
361
376
  end
362
377
  end
363
378
 
379
+ Cryptum::UI.line(
380
+ ui_win: order_plan_win,
381
+ out_line_no: out_line_no,
382
+ color: line_color
383
+ )
384
+
364
385
  order_plan_win.refresh
365
386
 
366
387
  # 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 = true if key_press_event.key_ansi && key_press == 'A'
305
+ key_press_event.key_down = 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.255'
5
5
  end
@@ -127,6 +127,43 @@ 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
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 = false
136
+
137
+ event_history.order_plan_line += 1 if event_history.order_plan_win_highlighted
138
+
139
+ event_history.order_execute_line += 1 if event_history.order_execute_win_highlighted
140
+ end
141
+
142
+ # TAB through Order Plan / Order Execution Window Panes
143
+ if terminal_win.key_press_event.key_tab
144
+ terminal_win.key_press_event.key_tab = false
145
+
146
+ if event_history.order_plan_win_highlighted
147
+ event_history.order_plan_win_highlighted = false
148
+ event_history.order_execute_win_highlighted = true
149
+ else
150
+ event_history.order_plan_win_highlighted = true
151
+ event_history.order_execute_win_highlighted = false
152
+ end
153
+ end
154
+
155
+ # Scroll Up Order Plan / Order Execution Window Panes
156
+ if terminal_win.key_press_event.key_up
157
+ terminal_win.key_press_event.key_ansi = false
158
+ terminal_win.key_press_event.key_esc = false
159
+ terminal_win.key_press_event.key_up = false
160
+
161
+ event_history.order_plan_line -= 1 if event_history.order_plan_win_highlighted &&
162
+ event_history.order_plan_line.positive?
163
+
164
+ event_history.order_execute_line -= 1 if event_history.order_execute_win_highlighted &&
165
+ event_history.order_execute_line.positive?
166
+ end
130
167
  end
131
168
 
132
169
  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.255
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