cryptum 0.0.296 → 0.0.298

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf9e8ff5a30bf0d5fec67e64e7e4129a6a27d243161f04b7ff0b6b08bbcb4461
4
- data.tar.gz: bae6f468bb256f068bd7287f0e614776acf24bbf36543a103dba9be858b2b3ac
3
+ metadata.gz: 69d06a9abd94dc426eaabdddc720bbde8342c4ec6a88a8da70a5b7234b436bbd
4
+ data.tar.gz: 3cba0ca35d6ef1cf0b68310d0785498a2bb9c8eaf6561c207cd5950ef8d72125
5
5
  SHA512:
6
- metadata.gz: 96c0366773165cc0d799e08976e3af8a9c734e6cef220dbae4ec13268102c78a5aebd0c4aafc54a1f007380c566997a08be47faa23a186acc9ad19f41e4806af
7
- data.tar.gz: 421f86639fa6d674ba652f6ef3abc69518a5c0218ab6c57e1e4fc0a700a4f946e42c3ab3f9bd3cd5d569d73324eb3dc9977ee75ab0360960d3821e6dceec31cf
6
+ metadata.gz: c8d446c8b67ad4dded344e2c5935afd9333f2265b94203a56a396ffd90c5bfb6d874f8dcedd35d6f1c4d930c8729ffd0baadba9e7e2ba220958ee1c36ad8c576
7
+ data.tar.gz: 214f94202661ca2f5b77153b8c572b42b0c444ce3755b16a9262e2c8d6f74b9d03508d6e1c23f66b779c9988c8eafcca11cf04a40f5a7dcdf456237fbade97f8
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-12-08 03:39:16 UTC using RuboCop version 1.39.0.
3
+ # on 2022-12-08 22:21:57 UTC using RuboCop version 1.40.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
@@ -73,6 +73,14 @@ Layout/MultilineOperationIndentation:
73
73
  - 'lib/cryptum/ui/order_execution.rb'
74
74
  - 'lib/cryptum/ui/ticker.rb'
75
75
 
76
+ # Offense count: 1
77
+ # This cop supports safe autocorrection (--autocorrect).
78
+ # Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
79
+ # SupportedStylesForExponentOperator: space, no_space
80
+ Layout/SpaceAroundOperators:
81
+ Exclude:
82
+ - 'lib/cryptum/ui/order_execution.rb'
83
+
76
84
  # Offense count: 13
77
85
  # This cop supports safe autocorrection (--autocorrect).
78
86
  # Configuration parameters: AllowInHeredoc.
@@ -85,14 +93,14 @@ Layout/TrailingWhitespace:
85
93
  - 'lib/cryptum/ui/order_plan.rb'
86
94
  - 'lib/cryptum/ui/order_timer.rb'
87
95
 
88
- # Offense count: 85
96
+ # Offense count: 87
89
97
  Lint/UselessAssignment:
90
98
  Enabled: false
91
99
 
92
100
  # Offense count: 47
93
101
  # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
94
102
  Metrics/AbcSize:
95
- Max: 407
103
+ Max: 419
96
104
 
97
105
  # Offense count: 7
98
106
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
@@ -108,22 +116,22 @@ Metrics/BlockNesting:
108
116
  # Offense count: 19
109
117
  # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
110
118
  Metrics/CyclomaticComplexity:
111
- Max: 76
119
+ Max: 75
112
120
 
113
121
  # Offense count: 68
114
122
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
115
123
  Metrics/MethodLength:
116
- Max: 390
124
+ Max: 406
117
125
 
118
126
  # Offense count: 17
119
127
  # Configuration parameters: CountComments, CountAsOne.
120
128
  Metrics/ModuleLength:
121
129
  Max: 538
122
130
 
123
- # Offense count: 19
131
+ # Offense count: 20
124
132
  # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
125
133
  Metrics/PerceivedComplexity:
126
- Max: 79
134
+ Max: 78
127
135
 
128
136
  # Offense count: 5
129
137
  # This cop supports safe autocorrection (--autocorrect).
@@ -216,9 +224,9 @@ Style/TrailingCommaInArrayLiteral:
216
224
  Exclude:
217
225
  - 'lib/cryptum/matrix.rb'
218
226
 
219
- # Offense count: 21
227
+ # Offense count: 27
220
228
  # This cop supports safe autocorrection (--autocorrect).
221
229
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
222
230
  # URISchemes: http, https
223
231
  Layout/LineLength:
224
- Max: 216
232
+ Max: 222
data/lib/cryptum/api.rb CHANGED
@@ -560,9 +560,10 @@ module Cryptum
560
560
  total_holdings
561
561
  )
562
562
 
563
- File.open(fiat_portfolio_file, 'w') do |f|
564
- f.puts fiat_portfolio.to_json
565
- end
563
+ File.write(
564
+ fiat_portfolio_file,
565
+ JSON.pretty_generate(fiat_portfolio)
566
+ )
566
567
 
567
568
  crypto_portfolio
568
569
  rescue StandardError => e
@@ -28,12 +28,14 @@ module Cryptum
28
28
  :order_plan_details_win_active,
29
29
  :order_plan_index_offset,
30
30
  :order_plan_max_rows_to_display,
31
+ :order_plan_max_records_available_to_display,
31
32
  :order_plan_row_to_select,
32
33
  :order_plan_selected_data,
33
34
  :order_execute_win_active,
34
35
  :order_execute_details_win_active,
35
36
  :order_execute_index_offset,
36
37
  :order_execute_max_rows_to_display,
38
+ :order_execute_max_records_available_to_display,
37
39
  :order_execute_row_to_select,
38
40
  :order_execute_selected_data,
39
41
  :recalculate_order_plan
@@ -57,12 +59,14 @@ module Cryptum
57
59
  self.order_plan_details_win_active = false
58
60
  self.order_plan_index_offset = 0
59
61
  self.order_plan_max_rows_to_display = 6
62
+ self.order_plan_max_records_available_to_display = 6
60
63
  self.order_plan_row_to_select = order_plan_index_offset
61
64
  self.order_plan_selected_data = { color: :white }
62
65
  self.order_execute_win_active = false
63
66
  self.order_execute_details_win_active = false
64
67
  self.order_execute_index_offset = 0
65
68
  self.order_execute_max_rows_to_display = 6
69
+ self.order_execute_max_records_available_to_display = 6
66
70
  self.order_execute_row_to_select = order_execute_index_offset
67
71
  self.order_execute_selected_data = { color: :white }
68
72
  self.recalculate_order_plan = false
@@ -45,16 +45,26 @@ module Cryptum
45
45
  terminal_win.key_press_event.key_esc = false
46
46
  terminal_win.key_press_event.key_down_arrow = false
47
47
 
48
+ order_book = event_history.order_book
49
+
48
50
  if event_history.order_plan_win_active
51
+ order_plan_length = order_book[:order_plan].length
52
+ last_row = order_plan_length - 1
53
+ event_history.order_plan_max_records_available_to_display = last_row if last_row < event_history.order_plan_max_rows_to_display
54
+
49
55
  event_history.order_plan_row_to_select += 1
50
- event_history.order_plan_index_offset += 1 if event_history.order_plan_row_to_select > event_history.order_plan_max_rows_to_display
51
- event_history.order_plan_row_to_select = event_history.order_plan_max_rows_to_display if event_history.order_plan_row_to_select > event_history.order_plan_max_rows_to_display
56
+ event_history.order_plan_index_offset += 1 if event_history.order_plan_row_to_select > event_history.order_plan_max_records_available_to_display
57
+ event_history.order_plan_row_to_select = event_history.order_plan_max_records_available_to_display if event_history.order_plan_row_to_select > event_history.order_plan_max_records_available_to_display
52
58
  end
53
59
 
54
60
  if event_history.order_execute_win_active
61
+ order_history_meta_length = order_book[:order_history_meta].length
62
+ last_row = order_history_meta_length - 1
63
+ event_history.order_execute_max_records_available_to_display = last_row if last_row < event_history.order_execute_max_rows_to_display
64
+
55
65
  event_history.order_execute_row_to_select += 1
56
- event_history.order_execute_index_offset += 1 if event_history.order_execute_row_to_select > event_history.order_execute_max_rows_to_display
57
- event_history.order_execute_row_to_select = event_history.order_execute_max_rows_to_display if event_history.order_execute_row_to_select > event_history.order_execute_max_rows_to_display
66
+ event_history.order_execute_index_offset += 1 if event_history.order_execute_row_to_select > event_history.order_execute_max_records_available_to_display
67
+ event_history.order_execute_row_to_select = event_history.order_execute_max_records_available_to_display if event_history.order_execute_row_to_select > event_history.order_execute_max_records_available_to_display
58
68
  end
59
69
  rescue StandardError => e
60
70
  raise e
@@ -99,16 +109,18 @@ module Cryptum
99
109
  terminal_win.key_press_event.key_esc = false
100
110
  terminal_win.key_press_event.key_page_down = false
101
111
 
112
+ order_book = event_history.order_book
113
+
102
114
  if event_history.order_plan_win_active
115
+ order_plan_length = order_book[:order_plan].length
103
116
  event_history.order_plan_row_to_select = 0
104
- event_history.order_plan_index_offset += event_history.order_plan_max_rows_to_display + 1
105
- event_history.order_plan_row_to_select = event_history.order_plan_max_rows_to_display if event_history.order_plan_row_to_select > event_history.order_plan_max_rows_to_display
117
+ event_history.order_plan_index_offset += event_history.order_plan_max_rows_to_display + 1 unless event_history.order_plan_index_offset > order_plan_length
106
118
  end
107
119
 
108
120
  if event_history.order_execute_win_active
121
+ order_history_meta_length = order_book[:order_history_meta].length
109
122
  event_history.order_execute_row_to_select = 0
110
- event_history.order_execute_index_offset += event_history.order_execute_max_rows_to_display + 1
111
- event_history.order_execute_row_to_select = event_history.order_execute_max_rows_to_display if event_history.order_execute_row_to_select > event_history.order_execute_max_rows_to_display
123
+ event_history.order_execute_index_offset += event_history.order_execute_max_rows_to_display + 1 unless event_history.order_execute_index_offset > order_history_meta_length
112
124
  end
113
125
  rescue StandardError => e
114
126
  raise e
@@ -149,16 +161,24 @@ module Cryptum
149
161
  terminal_win.key_press_event.key_esc = false
150
162
  terminal_win.key_press_event.key_end = false
151
163
 
164
+ order_book = event_history.order_book
165
+
152
166
  if event_history.order_plan_win_active
153
- order_plan_length = event_history.order_book[:order_plan].length
154
- event_history.order_plan_row_to_select = event_history.order_plan_max_rows_to_display
155
- event_history.order_plan_index_offset = order_plan_length - event_history.order_plan_max_rows_to_display
167
+ order_plan_length = order_book[:order_plan].length
168
+ last_row = order_plan_length - 1
169
+ event_history.order_plan_max_records_available_to_display = last_row if last_row < event_history.order_plan_max_rows_to_display
170
+
171
+ event_history.order_plan_row_to_select = event_history.order_plan_max_records_available_to_display
172
+ event_history.order_plan_index_offset = order_plan_length - event_history.order_plan_max_records_available_to_display
156
173
  end
157
174
 
158
175
  if event_history.order_execute_win_active
159
- order_history_meta_length = event_history.order_book[:order_history_meta].length
160
- event_history.order_execute_row_to_select = event_history.order_plan_max_rows_to_display
161
- event_history.order_execute_index_offset = order_history_meta_length - event_history.order_execute_max_rows_to_display
176
+ order_history_meta_length = order_book[:order_history_meta].length
177
+ last_row = order_history_meta_length - 1
178
+ event_history.order_execute_max_records_available_to_display = last_row if last_row < event_history.order_execute_max_rows_to_display
179
+
180
+ event_history.order_execute_row_to_select = event_history.order_execute_max_records_available_to_display
181
+ event_history.order_execute_index_offset = order_history_meta_length - event_history.order_execute_max_records_available_to_display
162
182
  end
163
183
  rescue StandardError => e
164
184
  raise e
@@ -412,12 +412,18 @@ module Cryptum
412
412
  )
413
413
 
414
414
  # ROWS 3-10
415
+ max_rows_to_display = event_history.order_execute_max_rows_to_display
416
+ max_records_available_to_display = event_history.order_execute_max_records_available_to_display
415
417
  first_row = event_history.order_execute_index_offset
416
- last_row = first_row + event_history.order_execute_max_rows_to_display
417
- last_row = first_row if last_row < first_row
418
+ last_row = first_row + max_rows_to_display
419
+ remaining_blank_rows = 0
418
420
  if last_row >= order_history_meta.length
419
- first_row = last_row - event_history.order_execute_max_rows_to_display
421
+ last_row = order_history_meta.length - 1
422
+ event_history.order_execute_max_records_available_to_display = last_row if last_row < max_rows_to_display
423
+ first_row = event_history.order_execute_max_records_available_to_display - last_row
424
+ # event_history.order_execute_index_offset = first_row
420
425
  event_history.order_execute_index_offset = first_row
426
+ remaining_blank_rows = max_rows_to_display - last_row
421
427
  end
422
428
 
423
429
  if order_history_meta.any?
@@ -451,7 +457,7 @@ module Cryptum
451
457
  profit_out = Cryptum.beautify_large_number(
452
458
  value: meta[:profit]
453
459
  )
454
- plan_no = "#{meta[:plan_no]}|"
460
+ plan_no = meta[:plan_no]
455
461
 
456
462
  buy_created_at_hash_arr = order_history.select do |oh|
457
463
  oh[:id] == meta[:buy_order_id]
@@ -471,7 +477,7 @@ module Cryptum
471
477
  targ_tick = "$#{target_price_out}"
472
478
  profit = "|Profit: $#{meta[:profit]}"
473
479
 
474
- order_exec_ln = "#{buy_created_at}|#{invest}#{tick}#{size}#{tpm_out}#{targ_tick}#{profit}"
480
+ order_exec_ln = "#{buy_created_at}|#{invest}#{tick}#{size}#{tpm_out}#{targ_tick}#{profit}|#{plan_no}"
475
481
 
476
482
  order_execute_win.setpos(out_line_no, Cryptum::UI.col_first)
477
483
  order_execute_win.clrtoeol
@@ -485,8 +491,23 @@ module Cryptum
485
491
  event_history.order_execute_selected_data = selected_order
486
492
  end
487
493
 
494
+ # Clear to SUMMARY
495
+ # (Only Applicable if order_book[:order_history_meta] < max_rows_to_display)
496
+ out_line_no+=1
497
+ rows_to_blank = (out_line_no + remaining_blank_rows) - 1
498
+ (out_line_no..rows_to_blank).each do |clr_line|
499
+ out_line_no = clr_line
500
+ order_execute_win.setpos(clr_line, Cryptum::UI.col_first)
501
+ order_execute_win.clrtoeol
502
+ Cryptum::UI.colorize(
503
+ ui_win: order_execute_win,
504
+ color: :white,
505
+ style: :normal,
506
+ string: ''.ljust(col_just1, ' ')
507
+ )
508
+ end
509
+
488
510
  # ROW 10
489
- out_line_no += 1
490
511
  order_execute_win.setpos(out_line_no, Cryptum::UI.col_first)
491
512
  order_execute_win.clrtoeol
492
513
  Cryptum::UI.colorize(
@@ -331,12 +331,19 @@ module Cryptum
331
331
  plan_color = :cyan if market_trend_color == :red
332
332
  plan_color = :green if market_trend_color == :green
333
333
 
334
+ # ROWS 3-10
335
+ max_rows_to_display = event_history.order_plan_max_rows_to_display
336
+ max_records_available_to_display = event_history.order_plan_max_records_available_to_display
334
337
  first_row = event_history.order_plan_index_offset
335
- last_row = first_row + event_history.order_plan_max_rows_to_display
338
+ last_row = first_row + max_rows_to_display
339
+ remaining_blank_rows = 0
336
340
  if last_row >= order_plan.length
337
341
  last_row = order_plan.length - 1
338
- first_row = last_row - event_history.order_plan_max_rows_to_display
342
+ event_history.order_plan_max_records_available_to_display = last_row if last_row < max_rows_to_display
343
+ first_row = last_row - event_history.order_plan_max_records_available_to_display
339
344
  event_history.order_plan_index_offset = first_row
345
+ event_history.order_plan_index_offset = first_row
346
+ remaining_blank_rows = max_rows_to_display - last_row
340
347
  end
341
348
 
342
349
  selected_order = event_history.order_plan_selected_data
@@ -402,8 +409,23 @@ module Cryptum
402
409
  end
403
410
  end
404
411
 
405
- # ROW 10
412
+ # Clear to SUMMARY
413
+ # (Only Applicable if order_book[:order_plan] < max_rows_to_display)
406
414
  out_line_no += 1
415
+ rows_to_blank = (out_line_no + remaining_blank_rows) - 1
416
+ (out_line_no..remaining_blank_rows).each do |clr_line|
417
+ out_line_no = clr_line
418
+ order_plan_win.setpos(clr_line, Cryptum::UI.col_first)
419
+ Cryptum::UI.colorize(
420
+ ui_win: order_plan_win,
421
+ color: :white,
422
+ style: :normal,
423
+ string: ''.ljust(col_just1, ' ')
424
+ )
425
+ end
426
+
427
+ # ROW 10
428
+ # out_line_no += 1
407
429
  order_plan_win.setpos(out_line_no, Cryptum::UI.col_first)
408
430
  order_plan_win.clrtoeol
409
431
  Cryptum::UI.colorize(
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptum
4
- VERSION = '0.0.296'
4
+ VERSION = '0.0.298'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.296
4
+ version: 0.0.298
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.