cryptum 0.0.253 → 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: de7aa17b3fb681ba04be33a6deb553a69288bda764c5dd986629885e01a2b844
4
- data.tar.gz: 4cd2964dea4a496037635def94cccce1592ba2fa6d1f6b9245cbb2ffa324619d
3
+ metadata.gz: 821d3666c9176e49b63ba26c032d24a901e1c5eab538726d8b675860156190fd
4
+ data.tar.gz: 7a58108f07d42aefce9112c6349e76c802590ed9e21b829f3d96ae22700483de
5
5
  SHA512:
6
- metadata.gz: 18cc950260a9780e3cedc068f68e3663ff9bba8fa4be7f50e93ea047a8930dc5fe22743f3b98a9f28f8ad717ed1ac4ac7edb3dc2c74588430d78e3480ec05b34
7
- data.tar.gz: 4e9bdff3af78b80049811e4af5b4d16b63c17ab80630dc26a689c7cda9fb23615e0af0233a85aba4d2ce466e7d948b5425a9cee923191fd5fce60b25d88de62c
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-07-06 00:27:10 UTC using RuboCop version 1.31.1.
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
@@ -120,41 +120,41 @@ Lint/UselessAssignment:
120
120
  - 'lib/cryptum/ui/signal_engine.rb'
121
121
  - 'lib/cryptum/ui/ticker.rb'
122
122
 
123
- # Offense count: 38
124
- # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
123
+ # Offense count: 39
124
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
125
125
  Metrics/AbcSize:
126
- Max: 371
126
+ Max: 384
127
127
 
128
128
  # Offense count: 7
129
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
130
- # IgnoredMethods: refine
129
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
130
+ # AllowedMethods: refine
131
131
  Metrics/BlockLength:
132
- Max: 84
132
+ Max: 117
133
133
 
134
134
  # Offense count: 4
135
135
  # Configuration parameters: CountBlocks.
136
136
  Metrics/BlockNesting:
137
137
  Max: 4
138
138
 
139
- # Offense count: 15
140
- # Configuration parameters: IgnoredMethods.
139
+ # Offense count: 16
140
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
141
141
  Metrics/CyclomaticComplexity:
142
- Max: 70
142
+ Max: 72
143
143
 
144
144
  # Offense count: 56
145
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
145
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
146
146
  Metrics/MethodLength:
147
- Max: 343
147
+ Max: 361
148
148
 
149
149
  # Offense count: 15
150
150
  # Configuration parameters: CountComments, CountAsOne.
151
151
  Metrics/ModuleLength:
152
152
  Max: 538
153
153
 
154
- # Offense count: 16
155
- # Configuration parameters: IgnoredMethods.
154
+ # Offense count: 17
155
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
156
156
  Metrics/PerceivedComplexity:
157
- Max: 73
157
+ Max: 75
158
158
 
159
159
  # Offense count: 1
160
160
  # Configuration parameters: AllowedConstants.
@@ -183,7 +183,7 @@ Style/Next:
183
183
 
184
184
  # Offense count: 4
185
185
  # This cop supports safe autocorrection (--autocorrect).
186
- # Configuration parameters: Strict, AllowedNumbers.
186
+ # Configuration parameters: Strict, AllowedNumbers, AllowedPatterns.
187
187
  Style/NumericLiterals:
188
188
  MinDigits: 7
189
189
 
data/lib/cryptum/api.rb CHANGED
@@ -438,7 +438,6 @@ module Cryptum
438
438
  public_class_method def self.cancel_all_open_orders(opts = {})
439
439
  env = opts[:env]
440
440
  option_choice = opts[:option_choice]
441
- # order_type = opts[:order_type]
442
441
  event_notes = opts[:event_notes]
443
442
 
444
443
  product_id = option_choice.symbol.to_s.gsub('_', '-').upcase
@@ -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
data/lib/cryptum/event.rb CHANGED
@@ -6,7 +6,7 @@ module Cryptum
6
6
  # This plugin is used to parse Coinbase Pro Web Socket Events in the HTTP Response
7
7
  module Event
8
8
  autoload :Buy, 'cryptum/event/buy'
9
- autoload :Cancel, 'cryptum/event/cancel'
9
+ autoload :Buy, 'cryptum/event/cancel'
10
10
  autoload :History, 'cryptum/event/history'
11
11
  autoload :KeyPress, 'cryptum/event/key_press'
12
12
  autoload :Sell, 'cryptum/event/sell'
@@ -19,6 +19,14 @@ module Cryptum
19
19
  ui_win: command_win
20
20
  )
21
21
 
22
+ if key_press_event.key_c
23
+ key_c_color = :cyan
24
+ key_c_style = :reverse
25
+ else
26
+ key_c_color = :white
27
+ key_c_style = :bold
28
+ end
29
+
22
30
  if key_press_event.key_g
23
31
  key_g_color = :cyan
24
32
  key_g_style = :reverse
@@ -62,19 +70,23 @@ module Cryptum
62
70
  command_str_r2_arr = [
63
71
  "* v#{Cryptum::VERSION} >>> ",
64
72
  '[',
73
+ 'C',
74
+ ']ancel Open Orders',
75
+ ' | ',
76
+ '[',
65
77
  'G',
66
78
  ']TFO',
67
79
  ' | ',
68
80
  '[',
69
81
  'r',
70
- ']eload bot conf',
71
- ' | ',
72
- '[',
73
- 'u',
74
- ']pdate summary'
82
+ ']eload bot conf'
75
83
  ]
76
84
 
77
85
  command_str_r3_arr = [
86
+ '[',
87
+ 'u',
88
+ ']pdate summary',
89
+ ' | ',
78
90
  '[',
79
91
  'w',
80
92
  ']rite order book',
@@ -85,19 +97,13 @@ module Cryptum
85
97
  ]
86
98
  # ROW 1
87
99
  out_line_no = 0
88
- Cryptum::UI.line(
89
- ui_win: command_win,
90
- out_line_no: out_line_no
91
- )
92
-
93
- # ROW 2
94
- out_line_no += 1
95
100
  command_win.setpos(
96
101
  out_line_no,
97
102
  Cryptum::UI.col_center(str: command_str_r2_arr.join(''))
98
103
  )
99
104
  command_win.clrtoeol
100
105
 
106
+ # * v#{Cryptum::VERSION} >>>
101
107
  Cryptum::UI.colorize(
102
108
  ui_win: command_win,
103
109
  color: :yellow,
@@ -105,24 +111,25 @@ module Cryptum
105
111
  string: command_str_r2_arr.first
106
112
  )
107
113
 
114
+ # [C]ancel Open Orders
108
115
  Cryptum::UI.colorize(
109
116
  ui_win: command_win,
110
- color: key_g_color,
111
- style: key_g_style,
117
+ color: key_c_color,
118
+ style: key_c_style,
112
119
  string: command_str_r2_arr[1]
113
120
  )
114
121
 
115
122
  Cryptum::UI.colorize(
116
123
  ui_win: command_win,
117
124
  color: :yellow,
118
- style: key_g_style,
125
+ style: key_c_style,
119
126
  string: command_str_r2_arr[2]
120
127
  )
121
128
 
122
129
  Cryptum::UI.colorize(
123
130
  ui_win: command_win,
124
- color: key_g_color,
125
- style: key_g_style,
131
+ color: key_c_color,
132
+ style: key_c_style,
126
133
  string: command_str_r2_arr[3]
127
134
  )
128
135
 
@@ -133,24 +140,24 @@ module Cryptum
133
140
  string: command_str_r2_arr[4]
134
141
  )
135
142
 
143
+ # [G]TFO
136
144
  Cryptum::UI.colorize(
137
145
  ui_win: command_win,
138
- color: key_r_color,
139
- style: key_r_style,
146
+ color: key_g_color,
147
+ style: key_g_style,
140
148
  string: command_str_r2_arr[5]
141
149
  )
142
150
 
143
151
  Cryptum::UI.colorize(
144
152
  ui_win: command_win,
145
153
  color: :yellow,
146
- style: key_r_style,
154
+ style: key_g_style,
147
155
  string: command_str_r2_arr[6]
148
156
  )
149
157
 
150
158
  Cryptum::UI.colorize(
151
159
  ui_win: command_win,
152
- color: key_r_color,
153
- style: key_r_style,
160
+ color: key_g_color,
154
161
  string: command_str_r2_arr[7]
155
162
  )
156
163
 
@@ -161,25 +168,26 @@ module Cryptum
161
168
  string: command_str_r2_arr[8]
162
169
  )
163
170
 
171
+ # [r]eload bot conf
164
172
  Cryptum::UI.colorize(
165
173
  ui_win: command_win,
166
- color: key_u_color,
167
- style: key_u_style,
174
+ color: key_r_color,
175
+ style: key_r_style,
168
176
  string: command_str_r2_arr[9]
169
177
  )
170
178
 
171
179
  Cryptum::UI.colorize(
172
180
  ui_win: command_win,
173
181
  color: :yellow,
174
- style: key_u_style,
182
+ style: key_r_style,
175
183
  string: command_str_r2_arr[10]
176
184
  )
177
185
 
178
186
  Cryptum::UI.colorize(
179
187
  ui_win: command_win,
180
- color: key_u_color,
181
- style: key_u_style,
182
- string: command_str_r2_arr[11]
188
+ color: key_r_color,
189
+ style: key_r_style,
190
+ string: command_str_r2_arr.last
183
191
  )
184
192
 
185
193
  # ROW 3
@@ -190,46 +198,76 @@ module Cryptum
190
198
  )
191
199
  command_win.clrtoeol
192
200
 
201
+ # [u]date summary
202
+ Cryptum::UI.colorize(
203
+ ui_win: command_win,
204
+ color: key_u_color,
205
+ string: command_str_r3_arr.first
206
+ )
207
+
208
+ Cryptum::UI.colorize(
209
+ ui_win: command_win,
210
+ color: :yellow,
211
+ style: key_u_style,
212
+ string: command_str_r3_arr[1]
213
+ )
214
+
215
+ Cryptum::UI.colorize(
216
+ ui_win: command_win,
217
+ color: key_u_color,
218
+ style: key_u_style,
219
+ string: command_str_r3_arr[2]
220
+ )
221
+
222
+ # |
223
+ Cryptum::UI.colorize(
224
+ ui_win: command_win,
225
+ color: :white,
226
+ string: command_str_r3_arr[3]
227
+ )
228
+
229
+ # [w]rite order book
193
230
  Cryptum::UI.colorize(
194
231
  ui_win: command_win,
195
232
  color: key_w_color,
196
233
  style: key_w_style,
197
- string: command_str_r3_arr.first
234
+ string: command_str_r3_arr[4]
198
235
  )
199
236
 
200
237
  Cryptum::UI.colorize(
201
238
  ui_win: command_win,
202
239
  color: :yellow,
203
240
  style: key_w_style,
204
- string: command_str_r3_arr[1]
241
+ string: command_str_r3_arr[5]
205
242
  )
206
243
 
207
244
  Cryptum::UI.colorize(
208
245
  ui_win: command_win,
209
246
  color: key_w_color,
210
247
  style: key_w_style,
211
- string: command_str_r3_arr[2]
248
+ string: command_str_r3_arr[6]
212
249
  )
213
250
 
214
251
  # |
215
252
  Cryptum::UI.colorize(
216
253
  ui_win: command_win,
217
254
  color: :white,
218
- string: command_str_r3_arr[3]
255
+ string: command_str_r3_arr[7]
219
256
  )
220
257
 
258
+ # e[x]it
221
259
  Cryptum::UI.colorize(
222
260
  ui_win: command_win,
223
261
  color: key_x_color,
224
262
  style: key_x_style,
225
- string: command_str_r3_arr[4]
263
+ string: command_str_r3_arr[8]
226
264
  )
227
265
 
228
266
  Cryptum::UI.colorize(
229
267
  ui_win: command_win,
230
268
  color: :yellow,
231
269
  style: key_x_style,
232
- string: command_str_r3_arr[5]
270
+ string: command_str_r3_arr[9]
233
271
  )
234
272
 
235
273
  Cryptum::UI.colorize(
@@ -4,11 +4,17 @@ module Cryptum
4
4
  module UI
5
5
  # This Class is Used to Detect Key Press Events
6
6
  class KeyPressEvent
7
- attr_accessor :key_g,
7
+ attr_accessor :key_c,
8
+ :key_g,
8
9
  :key_r,
9
10
  :key_u,
10
11
  :key_w,
11
- :key_x
12
+ :key_x,
13
+ :key_ansi,
14
+ :key_down,
15
+ :key_esc,
16
+ :key_tab,
17
+ :key_up
12
18
 
13
19
  rescue Interrupt
14
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,24 +30,30 @@ 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
48
51
  case color
49
52
  when :green
50
- intent = "- Waiting for Open Sell Orders to Trigger -"
53
+ # TODO: add condition to check if open sell orders exist.
54
+ # If so intent should be something like, "- SEE LIMIT SELL ORDERS -"
55
+ # Otherwise, intent should be something like, "- WAIT FOR MARKET TREND SHIFT -"
56
+ intent = "- SEE LIMIT SELL ORDERS -"
51
57
  else
52
58
  trend = 'BEAR'
53
59
  speed = 'FAST'
@@ -56,7 +62,7 @@ module Cryptum
56
62
  speed = 'SLOW'
57
63
  end
58
64
 
59
- intent = "#{speed} #{trend} BUY: #{order_countdown} of #{time_between_order_exec_out}"
65
+ intent = "#{trend} - #{speed} BUY: #{order_countdown} of #{time_between_order_exec_out}"
60
66
  intent = '- BUYING PAUSED -' if event_history.red_pill
61
67
  end
62
68
 
@@ -68,13 +74,6 @@ module Cryptum
68
74
 
69
75
  # ROW 1
70
76
  out_line_no = 0
71
- Cryptum::UI.line(
72
- ui_win: order_timer_win,
73
- out_line_no: out_line_no
74
- )
75
-
76
- # ROW 2
77
- out_line_no += 1
78
77
  order_timer_win.setpos(out_line_no, Cryptum::UI.col_first)
79
78
  order_timer_win.clrtoeol
80
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(
@@ -209,7 +200,7 @@ module Cryptum
209
200
  ui_win: ticker_win,
210
201
  color: :white,
211
202
  style: :bold,
212
- string: 'Highest | Lowest Sell Price:'
203
+ string: 'High | Low Limit Sell Prices:'
213
204
  )
214
205
 
215
206
  ticker_win.setpos(out_line_no, Cryptum::UI.col_third)
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,20 @@ 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
284
+ when 'C'
285
+ key_press_event.key_c = true
278
286
  when 'G'
279
287
  key_press_event.key_g = true
280
288
  when 'r'
@@ -285,8 +293,17 @@ module Cryptum
285
293
  key_press_event.key_w = true
286
294
  when 'x'
287
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
288
300
  end
289
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
+
290
307
  key_press_event
291
308
  rescue Interrupt
292
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.253'
4
+ VERSION = '0.0.255'
5
5
  end
@@ -54,6 +54,7 @@ module Cryptum
54
54
 
55
55
  ws.on :message do |event|
56
56
  ai_enabled = bot_conf[:artifical_intelligence]
57
+
57
58
  event_history.event = JSON.parse(
58
59
  event.data,
59
60
  symbolize_names: true
@@ -77,6 +78,16 @@ module Cryptum
77
78
  # Detect Key Press Events
78
79
  Cryptum::Event::KeyPress.detect(terminal_win: terminal_win)
79
80
 
81
+ # Cancel ALL Open Orders when
82
+ # C is pressed
83
+ if terminal_win.key_press_event.key_c
84
+ Cryptum::API.cancel_all_open_orders(
85
+ env: env,
86
+ option_choice: option_choice
87
+ )
88
+ terminal_win.key_press_event.key_c = false
89
+ end
90
+
80
91
  # Get the F* Out (GTFO) when
81
92
  # G is pressed
82
93
  if terminal_win.key_press_event.key_g
@@ -116,6 +127,43 @@ module Cryptum
116
127
  env: env
117
128
  )
118
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
119
167
  end
120
168
 
121
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.253
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-29 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