cryptum 0.0.385 → 0.0.387

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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +13 -4
  3. data/Gemfile +1 -1
  4. data/README.md +2 -2
  5. data/bin/cryptum +48 -61
  6. data/git_commit.sh +1 -0
  7. data/lib/cryptum/api/exchange_rates.rb +2 -2
  8. data/lib/cryptum/api/fees.rb +2 -2
  9. data/lib/cryptum/api/order_history.rb +2 -2
  10. data/lib/cryptum/api/orders.rb +8 -8
  11. data/lib/cryptum/api/portfolio.rb +2 -2
  12. data/lib/cryptum/api/products.rb +4 -4
  13. data/lib/cryptum/api/rest.rb +22 -24
  14. data/lib/cryptum/api/signature.rb +2 -2
  15. data/lib/cryptum/bot_conf.rb +7 -29
  16. data/lib/cryptum/event/bot_conf.rb +2 -2
  17. data/lib/cryptum/event/buy.rb +2 -2
  18. data/lib/cryptum/event/cancel.rb +2 -5
  19. data/lib/cryptum/event/exit.rb +3 -12
  20. data/lib/cryptum/event/gtfo.rb +2 -2
  21. data/lib/cryptum/event/history.rb +2 -8
  22. data/lib/cryptum/event/key_press.rb +2 -2
  23. data/lib/cryptum/event/order_book.rb +2 -2
  24. data/lib/cryptum/event/pane.rb +4 -4
  25. data/lib/cryptum/event/parse.rb +2 -10
  26. data/lib/cryptum/event/scroll.rb +12 -12
  27. data/lib/cryptum/event/sell.rb +2 -2
  28. data/lib/cryptum/log.rb +31 -11
  29. data/lib/cryptum/open_ai.rb +10 -9
  30. data/lib/cryptum/option/choice.rb +2 -6
  31. data/lib/cryptum/option/environment.rb +2 -2
  32. data/lib/cryptum/option/input_validation.rb +2 -2
  33. data/lib/cryptum/option/parser.rb +2 -2
  34. data/lib/cryptum/order_book/generate.rb +2 -2
  35. data/lib/cryptum/order_book/market_trend.rb +4 -15
  36. data/lib/cryptum/order_book/profit_margin.rb +2 -2
  37. data/lib/cryptum/portfolio/balance.rb +2 -2
  38. data/lib/cryptum/ui/command.rb +2 -5
  39. data/lib/cryptum/ui/exit.rb +9 -18
  40. data/lib/cryptum/ui/key_press_event.rb +2 -6
  41. data/lib/cryptum/ui/market_trend.rb +2 -8
  42. data/lib/cryptum/ui/matrix.rb +2 -5
  43. data/lib/cryptum/ui/order/execute.rb +2 -10
  44. data/lib/cryptum/ui/order/execute_details.rb +2 -8
  45. data/lib/cryptum/ui/order/plan.rb +11 -10
  46. data/lib/cryptum/ui/order/plan_details.rb +2 -8
  47. data/lib/cryptum/ui/order/timer.rb +2 -9
  48. data/lib/cryptum/ui/portfolio.rb +6 -10
  49. data/lib/cryptum/ui/signal_engine.rb +2 -5
  50. data/lib/cryptum/ui/terminal_window.rb +2 -6
  51. data/lib/cryptum/ui/ticker.rb +2 -8
  52. data/lib/cryptum/ui.rb +24 -61
  53. data/lib/cryptum/version.rb +1 -1
  54. data/lib/cryptum/web_sock/coinbase.rb +4 -7
  55. data/lib/cryptum/web_sock/event_machine.rb +15 -24
  56. data/lib/cryptum.rb +20 -7
  57. metadata +4 -4
@@ -30,8 +30,8 @@ module Cryptum
30
30
  event_history.order_execute_index_offset = 0 if event_history.order_execute_index_offset.negative?
31
31
  event_history.order_execute_row_to_select = 0 if event_history.order_execute_row_to_select.negative?
32
32
  end
33
- rescue StandardError => e
34
- raise e
33
+ rescue Interrupt, StandardError => e
34
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
35
35
  end
36
36
 
37
37
  # Supported Method Parameters::
@@ -66,8 +66,8 @@ module Cryptum
66
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
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
68
68
  end
69
- rescue StandardError => e
70
- raise e
69
+ rescue Interrupt, StandardError => e
70
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
71
71
  end
72
72
 
73
73
  # Supported Method Parameters::
@@ -94,8 +94,8 @@ module Cryptum
94
94
  event_history.order_execute_index_offset = 0 if event_history.order_execute_index_offset.negative?
95
95
  event_history.order_execute_row_to_select = 0 if event_history.order_execute_row_to_select.negative?
96
96
  end
97
- rescue StandardError => e
98
- raise e
97
+ rescue Interrupt, StandardError => e
98
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
99
99
  end
100
100
 
101
101
  # Supported Method Parameters::
@@ -122,8 +122,8 @@ module Cryptum
122
122
  event_history.order_execute_row_to_select = 0
123
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
124
124
  end
125
- rescue StandardError => e
126
- raise e
125
+ rescue Interrupt, StandardError => e
126
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
127
127
  end
128
128
 
129
129
  # Supported Method Parameters::
@@ -146,8 +146,8 @@ module Cryptum
146
146
  event_history.order_execute_row_to_select = 0
147
147
  event_history.order_execute_index_offset = 0
148
148
  end
149
- rescue StandardError => e
150
- raise e
149
+ rescue Interrupt, StandardError => e
150
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
151
151
  end
152
152
 
153
153
  # Supported Method Parameters::
@@ -180,8 +180,8 @@ module Cryptum
180
180
  event_history.order_execute_row_to_select = event_history.order_execute_max_records_available_to_display
181
181
  event_history.order_execute_index_offset = order_history_meta_length - event_history.order_execute_max_records_available_to_display
182
182
  end
183
- rescue StandardError => e
184
- raise e
183
+ rescue Interrupt, StandardError => e
184
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
185
185
  end
186
186
 
187
187
  # Display Usage for this Module
@@ -28,8 +28,8 @@ module Cryptum
28
28
  bot_conf: bot_conf,
29
29
  buy_order_id: buy_order_id
30
30
  )
31
- rescue StandardError => e
32
- raise e
31
+ rescue Interrupt, StandardError => e
32
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
33
33
  end
34
34
 
35
35
  # Display Usage for this Module
data/lib/cryptum/log.rb CHANGED
@@ -6,34 +6,54 @@ module Cryptum
6
6
  # Supported Method Parameters::
7
7
  # Cryptum::Log.create(
8
8
  # )
9
- public_class_method def self.create
10
- logger = Logger.new($stdout)
11
- level = opts[:level]
9
+ public_class_method def self.append(opts = {})
10
+ # Leave 10 "old" log files where
11
+ # each file is ~ 1,024,000 bytes
12
+ log_file = File.open('/tmp/cryptum.log', 'a')
13
+ logger = Logger.new(
14
+ log_file,
15
+ 10,
16
+ 1_024_000
17
+ )
18
+ level = opts[:level].to_s.downcase.to_sym
19
+ msg = opts[:msg]
20
+ which_self = opts[:which_self].to_s
21
+ event_history = opts[:event_history]
12
22
 
13
- case level.to_s.downcase.to_sym
23
+ exit_gracefully = false
24
+
25
+ case level
14
26
  when :debug
15
27
  logger.level = Logger::DEBUG
16
28
  when :error
17
29
  logger.level = Logger::ERROR
30
+ exit_gracefully = true
18
31
  when :fatal
32
+ # This is reserved for:
33
+ # Cryptum::UI::Exit
34
+ # module(s) if StandardError is triggered.
35
+ # This ensures we're not infintely attempting
36
+ # to log to file and exit.
19
37
  logger.level = Logger::FATAL
20
38
  when :unknown
21
39
  logger.level = Logger::UNKNOWN
22
40
  when :warn
23
41
  logger.level = Logger::WARN
24
- else
42
+ when :info
25
43
  logger.level = Logger::INFO
44
+ else
45
+ raise "ERROR: Invalid log level. Valid options are:\n:info\n:warn\n:unknown\n:fatal\n:error\n:debug"
26
46
  end
27
47
 
28
48
  logger.datetime_format = '%Y-%m-%d %H:%M:%S.%N'
29
-
30
- logger.formatter = proc do |severity, _datetime, _progname, msg|
31
- # TODO: Include datetime & progname vars
32
- "[#{severity}] #{msg}\n"
49
+ if msg.instance_of?(Interrupt)
50
+ logger.add(logger.level, 'CTRL+C Detected...Ended Session.', which_self)
51
+ else
52
+ logger.add(logger.level, msg, which_self)
33
53
  end
34
54
 
35
- logger
36
- rescue StandardError => e
55
+ Cryptum::UI::Exit.gracefully(event_history: event_history) if exit_gracefully
56
+ rescue Interrupt, StandardError => e
37
57
  raise e
38
58
  end
39
59
 
@@ -62,7 +62,8 @@ module Cryptum
62
62
  )
63
63
 
64
64
  else
65
- raise @@logger.error("Unsupported HTTP Method #{http_method} for #{self} Plugin")
65
+ e = "Unsupported HTTP Method #{http_method}"
66
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
66
67
  end
67
68
  response
68
69
  rescue RestClient::ExceptionWithResponse => e
@@ -74,8 +75,8 @@ module Cryptum
74
75
  f.puts "HTTP POST BODY: #{http_body.inspect}" if http_body != ''
75
76
  f.puts "#{e}\n#{e.response}\n\n\n"
76
77
  end
77
- rescue StandardError => e
78
- raise e
78
+ rescue Interrupt, StandardError => e
79
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
79
80
  end
80
81
 
81
82
  # Supported Method Parameters::
@@ -92,8 +93,8 @@ module Cryptum
92
93
  )
93
94
 
94
95
  JSON.parse(response, symbolize_names: true)
95
- rescue StandardError => e
96
- raise e
96
+ rescue Interrupt, StandardError => e
97
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
97
98
  end
98
99
 
99
100
  # Supported Method Parameters::
@@ -185,8 +186,8 @@ module Cryptum
185
186
  end
186
187
 
187
188
  json_resp
188
- rescue StandardError => e
189
- raise e
189
+ rescue Interrupt, StandardError => e
190
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
190
191
  end
191
192
 
192
193
  # Supported Method Parameters::
@@ -221,8 +222,8 @@ module Cryptum
221
222
  )
222
223
 
223
224
  JSON.parse(response, symbolize_names: true)
224
- rescue StandardError => e
225
- raise e
225
+ rescue Interrupt, StandardError => e
226
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
226
227
  end
227
228
 
228
229
  # Display Usage for this Module
@@ -16,13 +16,9 @@ module Cryptum
16
16
  :market_trend_reset,
17
17
  :market_trend_reset_label
18
18
 
19
- rescue Interrupt
20
- # Exit Gracefully if CTRL+C is Pressed During Session
21
- Cryptum::UI::Exit.gracefully(which_self: self)
22
- rescue StandardError => e
19
+ rescue Interrupt, StandardError => e
23
20
  # Produce a Stacktrace for anything else
24
- Curses.close_screen
25
- raise e
21
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
26
22
  end
27
23
  end
28
24
  end
@@ -30,8 +30,8 @@ module Cryptum
30
30
  end
31
31
 
32
32
  env
33
- rescue StandardError => e
34
- raise e
33
+ rescue Interrupt, StandardError => e
34
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
35
35
  end
36
36
 
37
37
  # Display Usage for this Module
@@ -72,8 +72,8 @@ module Cryptum
72
72
  puts `#{option_choice.driver_name} --help`
73
73
  exit 1
74
74
  end
75
- rescue StandardError => e
76
- raise e
75
+ rescue Interrupt, StandardError => e
76
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
77
77
  end
78
78
 
79
79
  # Display Usage for this Module
@@ -70,8 +70,8 @@ module Cryptum
70
70
  puts "ERROR: #{e.message}\n\n"
71
71
  puts `#{option_choice.driver_name} --help`
72
72
  exit 1
73
- rescue StandardError => e
74
- raise e
73
+ rescue Interrupt, StandardError => e
74
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
75
75
  end
76
76
 
77
77
  # Display Usage for this Module
@@ -90,8 +90,8 @@ module Cryptum
90
90
  end
91
91
 
92
92
  event_history
93
- rescue StandardError => e
94
- raise e
93
+ rescue Interrupt, StandardError => e
94
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
95
95
  end
96
96
 
97
97
  # Display Usage for this Module
@@ -14,17 +14,6 @@ module Cryptum
14
14
  event = opts[:event]
15
15
  indicator_status = opts[:indicator_status]
16
16
 
17
- # Compatible w/ l2update websocket channel
18
- # buy_or_sell = event[:changes].first[0].to_s.to_sym
19
- # case buy_or_sell
20
- # when :buy
21
- # event_history.order_book[:market_trend][:buy] += 1
22
- # when :sell
23
- # event_history.order_book[:market_trend][:sell] += 1
24
- # else
25
- # raise "UNKNOWN Value in event[:changes] => #{buy_or_sell}"
26
- # end
27
-
28
17
  # Compatible w/ l2update_batch websocket channel
29
18
  buy_count = event[:changes].select { |change| change.first == 'buy' }.length
30
19
  sell_count = event[:changes].select { |change| change.first == 'sell' }.length
@@ -69,8 +58,8 @@ module Cryptum
69
58
  indicator_hash[:ui] = "Market is #{motivation} | #{trend}"
70
59
 
71
60
  indicator_status.market_trend = indicator_hash
72
- rescue StandardError => e
73
- raise e
61
+ rescue Interrupt, StandardError => e
62
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
74
63
  end
75
64
 
76
65
  # public_class_method def self.reset(opts = {})
@@ -121,8 +110,8 @@ module Cryptum
121
110
  # event_history.order_book[:last_trend_reset] = Time.now.strftime(
122
111
  # '%Y-%m-%d %H:%M:%S.%N%z'
123
112
  # )
124
- # rescue StandardError => e
125
- # raise e
113
+ # rescue Interrupt, StandardError => e
114
+ # Cryptum::Log.append(level: :error, msg: e, which_self: self)
126
115
  # end
127
116
 
128
117
  # Display Usage for this Module
@@ -38,8 +38,8 @@ module Cryptum
38
38
  indicator_hash[:status] = profit_margin_status_out
39
39
 
40
40
  indicator_status.profit_margin = indicator_hash
41
- rescue StandardError => e
42
- raise e
41
+ rescue Interrupt, StandardError => e
42
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
43
43
  end
44
44
 
45
45
  # Display Usage for this Module
@@ -106,8 +106,8 @@ module Cryptum
106
106
  end
107
107
 
108
108
  event_history
109
- rescue StandardError => e
110
- raise e
109
+ rescue Interrupt, StandardError => e
110
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
111
111
  end
112
112
 
113
113
  # Display Usage for this Module
@@ -291,11 +291,8 @@ module Cryptum
291
291
  key_press_event.key_u ||
292
292
  key_press_event.key_w ||
293
293
  key_press_event.key_x
294
- rescue Interrupt
295
- # Exit Gracefully if CTRL+C is Pressed During Session
296
- Cryptum::UI::Exit.gracefully(which_self: self)
297
- rescue StandardError => e
298
- raise e
294
+ rescue Interrupt, StandardError => e
295
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
299
296
  end
300
297
 
301
298
  # Display Usage for this Module
@@ -5,32 +5,23 @@ module Cryptum
5
5
  # This Class is Used to Detect Key Press Events
6
6
  module Exit
7
7
  public_class_method def self.gracefully(opts = {})
8
- which_self = opts[:which_self]
9
8
  event_history = opts[:event_history]
10
- # option_choice = opts[:option_choice]
11
- # env = opts[:env]
12
9
 
13
- # Clear out candle data to ensure
14
- # Cryptum Statistics Only Apply to
15
- # Live Sessions
10
+ Curses.close_screen
11
+
12
+ exit 0
13
+ rescue Interrupt, StandardError => e
14
+ # Produce a Stacktrace for anything else
15
+ Cryptum::Log.append(level: :fatal, msg: e, which_self: self)
16
+ exit 1
17
+ ensure
16
18
  if event_history
19
+ order_book_file = event_history.order_book[:path]
17
20
  File.write(
18
21
  order_book_file,
19
22
  JSON.pretty_generate(event_history.order_book)
20
23
  )
21
24
  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
25
  end
35
26
 
36
27
  # Display a List of Every UI Module
@@ -21,13 +21,9 @@ module Cryptum
21
21
  :key_tab,
22
22
  :key_up_arrow
23
23
 
24
- rescue Interrupt
25
- # Exit Gracefully if CTRL+C is Pressed During Session
26
- Cryptum::UI::Exit.gracefully(which_self: self)
27
- rescue StandardError => e
24
+ rescue Interrupt, StandardError => e
28
25
  # Produce a Stacktrace for anything else
29
- Curses.close_screen
30
- raise e
26
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
31
27
  end
32
28
 
33
29
  # Display a List of Every UI Module
@@ -53,14 +53,8 @@ module Cryptum
53
53
  market_trend_win.refresh
54
54
 
55
55
  event_history
56
- rescue Interrupt
57
- # Exit Gracefully if CTRL+C is Pressed During Session
58
- Cryptum::UI::Exit.gracefully(
59
- which_self: self,
60
- event_history: event_history
61
- )
62
- rescue StandardError => e
63
- raise e
56
+ rescue Interrupt, StandardError => e
57
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
64
58
  end
65
59
 
66
60
  # Display Usage for this Module
@@ -168,11 +168,8 @@ module Cryptum
168
168
  end
169
169
  # matrix_row += matrix_arr[Random.rand(0..last_index)]
170
170
  matrix_row += matrix_arr.sample
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
171
+ rescue Interrupt, StandardError => e
172
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
176
173
  end
177
174
 
178
175
  # Display Usage for this Module
@@ -599,16 +599,8 @@ module Cryptum
599
599
  event_history.open_sell_orders_merge = false
600
600
 
601
601
  event_history
602
- rescue Interrupt
603
- # Exit Gracefully if CTRL+C is Pressed During Session
604
- Cryptum::UI::Exit.gracefully(
605
- which_self: self,
606
- event_history: event_history,
607
- option_choice: option_choice,
608
- env: env
609
- )
610
- rescue StandardError => e
611
- raise e
602
+ rescue Interrupt, StandardError => e
603
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
612
604
  end
613
605
 
614
606
  # Display Usage for this Module
@@ -276,14 +276,8 @@ module Cryptum
276
276
  order_execute_details_win.refresh
277
277
 
278
278
  event_history
279
- rescue Interrupt
280
- # Exit Gracefully if CTRL+C is Pressed During Session
281
- Cryptum::UI::Exit.gracefully(
282
- which_self: self,
283
- event_history: event_history
284
- )
285
- rescue StandardError => e
286
- raise e
279
+ rescue Interrupt, StandardError => e
280
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
287
281
  end
288
282
 
289
283
  # Display Usage for this Module
@@ -40,7 +40,15 @@ module Cryptum
40
40
  this_account = portfolio.select do |account|
41
41
  account[:currency] == crypto_currency.to_s
42
42
  end
43
- raise "ID for Crypto Currency, #{crypto_currency} Not Found" if this_account.empty?
43
+ if this_account.empty?
44
+ e = "ID for Crypto Currency, #{crypto_currency} Not Found"
45
+ Cryptum::Log.append(
46
+ level: :error,
47
+ msg: e,
48
+ which_self: self,
49
+ event_history: event_history
50
+ )
51
+ end
44
52
 
45
53
  balance = format("%0.#{crypto_smallest_decimal}f", this_account.first[:balance])
46
54
  fiat_portfolio = event_history.order_book[:fiat_portfolio]
@@ -491,15 +499,8 @@ module Cryptum
491
499
  order_plan_win.refresh
492
500
 
493
501
  event_history
494
- rescue Interrupt
495
- # Exit Gracefully if CTRL+C is Pressed During Session
496
- Cryptum::UI::Exit.gracefully(
497
- which_self: self,
498
- event_history: event_history,
499
- option_choice: option_choice
500
- )
501
- rescue StandardError => e
502
- raise e
502
+ rescue Interrupt, StandardError => e
503
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
503
504
  end
504
505
 
505
506
  # Display Usage for this Module
@@ -219,14 +219,8 @@ module Cryptum
219
219
  order_plan_details_win.refresh
220
220
 
221
221
  event_history
222
- rescue Interrupt
223
- # Exit Gracefully if CTRL+C is Pressed During Session
224
- Cryptum::UI::Exit.gracefully(
225
- which_self: self,
226
- event_history: event_history
227
- )
228
- rescue StandardError => e
229
- raise e
222
+ rescue Interrupt, StandardError => e
223
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
230
224
  end
231
225
 
232
226
  # Display Usage for this Module
@@ -115,15 +115,8 @@ module Cryptum
115
115
  order_timer_win.refresh
116
116
 
117
117
  order_countdown.to_f
118
- rescue Interrupt
119
- # Exit Gracefully if CTRL+C is Pressed During Session
120
- Cryptum::UI::Exit.gracefully(
121
- which_self: self,
122
- event_history: event_history,
123
- option_choice: option_choice
124
- )
125
- rescue StandardError => e
126
- raise e
118
+ rescue Interrupt, StandardError => e
119
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
127
120
  end
128
121
 
129
122
  # Display Usage for this Module
@@ -38,7 +38,10 @@ module Cryptum
38
38
  this_account = portfolio.select do |account|
39
39
  account[:currency] == crypto_currency.to_s
40
40
  end
41
- raise "ID for Crypto Currency, #{crypto_currency} Not Found" if this_account.empty?
41
+ if this_account.empty?
42
+ e = "ID for Crypto Currency, #{crypto_currency} Not Found"
43
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
44
+ end
42
45
 
43
46
  balance = format("%0.#{crypto_smallest_decimal}f", this_account.first[:balance])
44
47
  balance_out = Cryptum.beautify_large_number(
@@ -197,15 +200,8 @@ module Cryptum
197
200
  portfolio_win.refresh
198
201
 
199
202
  event_history
200
- rescue Interrupt
201
- # Exit Gracefully if CTRL+C is Pressed During Session
202
- Cryptum::UI::Exit.gracefully(
203
- which_self: self,
204
- event_history: event_history,
205
- option_choice: option_choice
206
- )
207
- rescue StandardError => e
208
- raise e
203
+ rescue Interrupt, StandardError => e
204
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
209
205
  end
210
206
 
211
207
  # Display Usage for this Module
@@ -85,11 +85,8 @@ module Cryptum
85
85
  indicator_status.action_signal = action_signal
86
86
 
87
87
  indicator_status
88
- rescue Interrupt
89
- # Exit Gracefully if CTRL+C is Pressed During Session
90
- Cryptum::UI::Exit.gracefully(which_self: self)
91
- rescue StandardError => e
92
- raise e
88
+ rescue Interrupt, StandardError => e
89
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
93
90
  end
94
91
 
95
92
  # Display Usage for this Module
@@ -97,13 +97,9 @@ module Cryptum
97
97
  left: 0
98
98
  )
99
99
  end
100
- rescue Interrupt
101
- # Exit Gracefully if CTRL+C is Pressed During Session
102
- Cryptum::UI::Exit.gracefully(which_self: self)
103
- rescue StandardError => e
100
+ rescue Interrupt, StandardError => e
104
101
  # Produce a Stacktrace for anything else
105
- Curses.close_screen
106
- raise e
102
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
107
103
  end
108
104
  end
109
105
  end
@@ -295,14 +295,8 @@ module Cryptum
295
295
  ticker_win.refresh
296
296
 
297
297
  event_history
298
- rescue Interrupt
299
- # Exit Gracefully if CTRL+C is Pressed During Session
300
- Cryptum::UI::Exit.gracefully(
301
- which_self: self,
302
- event_history: event_history
303
- )
304
- rescue StandardError => e
305
- raise e
298
+ rescue Interrupt, StandardError => e
299
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
306
300
  end
307
301
 
308
302
  # Display Usage for this Module