cryptum 0.0.386 → 0.0.387

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +13 -4
  3. data/README.md +2 -2
  4. data/bin/cryptum +48 -65
  5. data/git_commit.sh +1 -0
  6. data/lib/cryptum/api/exchange_rates.rb +2 -2
  7. data/lib/cryptum/api/fees.rb +2 -2
  8. data/lib/cryptum/api/order_history.rb +2 -2
  9. data/lib/cryptum/api/orders.rb +8 -8
  10. data/lib/cryptum/api/portfolio.rb +2 -2
  11. data/lib/cryptum/api/products.rb +4 -4
  12. data/lib/cryptum/api/rest.rb +22 -24
  13. data/lib/cryptum/api/signature.rb +2 -2
  14. data/lib/cryptum/bot_conf.rb +7 -26
  15. data/lib/cryptum/event/bot_conf.rb +2 -2
  16. data/lib/cryptum/event/buy.rb +2 -2
  17. data/lib/cryptum/event/cancel.rb +2 -5
  18. data/lib/cryptum/event/exit.rb +2 -2
  19. data/lib/cryptum/event/gtfo.rb +2 -2
  20. data/lib/cryptum/event/history.rb +2 -8
  21. data/lib/cryptum/event/key_press.rb +2 -2
  22. data/lib/cryptum/event/order_book.rb +2 -2
  23. data/lib/cryptum/event/pane.rb +4 -4
  24. data/lib/cryptum/event/parse.rb +2 -10
  25. data/lib/cryptum/event/scroll.rb +12 -12
  26. data/lib/cryptum/event/sell.rb +2 -2
  27. data/lib/cryptum/log.rb +31 -11
  28. data/lib/cryptum/open_ai.rb +10 -9
  29. data/lib/cryptum/option/choice.rb +2 -5
  30. data/lib/cryptum/option/environment.rb +2 -2
  31. data/lib/cryptum/option/input_validation.rb +2 -2
  32. data/lib/cryptum/option/parser.rb +2 -2
  33. data/lib/cryptum/order_book/generate.rb +2 -2
  34. data/lib/cryptum/order_book/market_trend.rb +4 -15
  35. data/lib/cryptum/order_book/profit_margin.rb +2 -2
  36. data/lib/cryptum/portfolio/balance.rb +2 -2
  37. data/lib/cryptum/ui/command.rb +2 -5
  38. data/lib/cryptum/ui/exit.rb +3 -2
  39. data/lib/cryptum/ui/key_press_event.rb +2 -5
  40. data/lib/cryptum/ui/market_trend.rb +2 -5
  41. data/lib/cryptum/ui/matrix.rb +2 -5
  42. data/lib/cryptum/ui/order/execute.rb +2 -5
  43. data/lib/cryptum/ui/order/execute_details.rb +2 -5
  44. data/lib/cryptum/ui/order/plan.rb +11 -6
  45. data/lib/cryptum/ui/order/plan_details.rb +2 -5
  46. data/lib/cryptum/ui/order/timer.rb +2 -5
  47. data/lib/cryptum/ui/portfolio.rb +6 -6
  48. data/lib/cryptum/ui/signal_engine.rb +2 -5
  49. data/lib/cryptum/ui/terminal_window.rb +2 -5
  50. data/lib/cryptum/ui/ticker.rb +2 -5
  51. data/lib/cryptum/ui.rb +24 -61
  52. data/lib/cryptum/version.rb +1 -1
  53. data/lib/cryptum/web_sock/coinbase.rb +4 -7
  54. data/lib/cryptum/web_sock/event_machine.rb +14 -11
  55. data/lib/cryptum.rb +20 -6
  56. metadata +1 -1
data/lib/cryptum/ui.rb CHANGED
@@ -46,13 +46,9 @@ module Cryptum
46
46
  # This object is used to pass all of the UI sections
47
47
  # around to various Cryptum modules
48
48
  Cryptum::UI::TerminalWindow.new
49
- rescue Interrupt
50
- # Exit Gracefully if CTRL+C is Pressed During Session
51
- Cryptum::UI::Exit.gracefully
52
- rescue StandardError => e
49
+ rescue Interrupt, StandardError => e
53
50
  # Produce a Stacktrace for anything else
54
- Curses.close_screen
55
- raise e
51
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
56
52
  end
57
53
 
58
54
  # Create New Curses Window
@@ -71,13 +67,10 @@ module Cryptum
71
67
  window.nodelay = true
72
68
 
73
69
  window
74
- rescue Interrupt
75
- # Exit Gracefully if CTRL+C is Pressed During Session
76
- Cryptum::UI::Exit.gracefully
77
- rescue StandardError => e
70
+ rescue Interrupt, StandardError => e
78
71
  # Produce a Stacktrace for anything else
79
72
  Curses.close_screen
80
- raise e
73
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
81
74
  end
82
75
 
83
76
  # Draw a Box Around a Window
@@ -97,13 +90,9 @@ module Cryptum
97
90
  style: style,
98
91
  string: "\u2500" * Curses.cols
99
92
  )
100
- rescue Interrupt
101
- # Exit Gracefully if CTRL+C is Pressed During Session
102
- Cryptum::UI::Exit.gracefully
103
- rescue StandardError => e
93
+ rescue Interrupt, StandardError => e
104
94
  # Produce a Stacktrace for anything else
105
- Curses.close_screen
106
- raise e
95
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
107
96
  end
108
97
 
109
98
  # Jump to First Column
@@ -173,7 +162,8 @@ module Cryptum
173
162
  color_fg = color_id
174
163
  color_bg = bg
175
164
  else
176
- raise "Color Not Implemented for this Method: #{color}"
165
+ e = "Color Not Implemented for this Method: #{color}"
166
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
177
167
  end
178
168
 
179
169
  case style
@@ -188,20 +178,17 @@ module Cryptum
188
178
  when :reverse
189
179
  font = Curses::A_REVERSE
190
180
  else
191
- raise "Font Style Not Implemented for this Method: #{style}"
181
+ e = "Font Style Not Implemented for this Method: #{style}"
182
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
192
183
  end
193
184
 
194
185
  Curses.init_pair(color_id, color_fg, color_bg)
195
186
  ui_win.attron(Curses.color_pair(color_id) | font) do
196
187
  ui_win.addstr(string)
197
188
  end
198
- rescue Interrupt
199
- # Exit Gracefully if CTRL+C is Pressed During Session
200
- Cryptum::UI::Exit.gracefully
201
- rescue StandardError => e
189
+ rescue Interrupt, StandardError => e
202
190
  # Produce a Stacktrace for anything else
203
- Curses.close_screen
204
- raise e
191
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
205
192
  end
206
193
 
207
194
  # Jump to First Column
@@ -210,60 +197,40 @@ module Cryptum
210
197
 
211
198
  str_divided_by_two = str.length / 2
212
199
  (Curses.cols / 2) - str_divided_by_two
213
- rescue Interrupt
214
- # Exit Gracefully if CTRL+C is Pressed During Session
215
- Cryptum::UI::Exit.gracefully
216
- rescue StandardError => e
200
+ rescue Interrupt, StandardError => e
217
201
  # Produce a Stacktrace for anything else
218
- Curses.close_screen
219
- raise e
202
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
220
203
  end
221
204
 
222
205
  public_class_method def self.col_first
223
206
  0
224
- rescue Interrupt
225
- # Exit Gracefully if CTRL+C is Pressed During Session
226
- Cryptum::UI::Exit.gracefully
227
- rescue StandardError => e
207
+ rescue Interrupt, StandardError => e
228
208
  # Produce a Stacktrace for anything else
229
- Curses.close_screen
230
- raise e
209
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
231
210
  end
232
211
 
233
212
  # Jump to Second Column
234
213
  public_class_method def self.col_second
235
214
  (Curses.cols / 8) + 5
236
- rescue Interrupt
237
- # Exit Gracefully if CTRL+C is Pressed During Session
238
- Cryptum::UI::Exit.gracefully
239
- rescue StandardError => e
215
+ rescue Interrupt, StandardError => e
240
216
  # Produce a Stacktrace for anything else
241
- Curses.close_screen
242
- raise e
217
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
243
218
  end
244
219
 
245
220
  # Jump to Third Column
246
221
  public_class_method def self.col_third
247
222
  ((Curses.cols / 8) * 3) + 2
248
- rescue Interrupt
249
- # Exit Gracefully if CTRL+C is Pressed During Session
250
- Cryptum::UI::Exit.gracefully
251
- rescue StandardError => e
223
+ rescue Interrupt, StandardError => e
252
224
  # Produce a Stacktrace for anything else
253
- Curses.close_screen
254
- raise e
225
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
255
226
  end
256
227
 
257
228
  # Jump to Fourth Column
258
229
  public_class_method def self.col_fourth
259
230
  ((Curses.cols / 4) * 3) - 3
260
- rescue Interrupt
261
- # Exit Gracefully if CTRL+C is Pressed During Session
262
- Cryptum::UI::Exit.gracefully
263
- rescue StandardError => e
231
+ rescue Interrupt, StandardError => e
264
232
  # Produce a Stacktrace for anything else
265
- Curses.close_screen
266
- raise e
233
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
267
234
  end
268
235
 
269
236
  public_class_method def self.detect_key_press_in_ui(opts = {})
@@ -320,13 +287,9 @@ module Cryptum
320
287
  end
321
288
 
322
289
  key_press_event
323
- rescue Interrupt
324
- # Exit Gracefully if CTRL+C is Pressed During Session
325
- Cryptum::UI::Exit.gracefully
326
- rescue StandardError => e
290
+ rescue Interrupt, StandardError => e
327
291
  # Produce a Stacktrace for anything else
328
- Curses.close_screen
329
- raise e
292
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
330
293
  end
331
294
 
332
295
  # Display a List of Every UI Module
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptum
4
- VERSION = '0.0.386'
4
+ VERSION = '0.0.387'
5
5
  end
@@ -48,11 +48,8 @@ module Cryptum
48
48
  end
49
49
 
50
50
  ws
51
- rescue Interrupt
52
- # Exit Gracefully if CTRL+C is Pressed During Session
53
- Cryptum::UI::Exit.gracefully
54
- rescue StandardError => e
55
- raise e
51
+ rescue Interrupt, StandardError => e
52
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
56
53
  end
57
54
 
58
55
  public_class_method def self.subscribe_message(opts = {})
@@ -84,8 +81,8 @@ module Cryptum
84
81
  \"timestamp\": \"#{api_timestamp}\",
85
82
  \"signature\": \"#{api_signature}\"
86
83
  }"
87
- rescue StandardError => e
88
- raise e
84
+ rescue Interrupt, StandardError => e
85
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
89
86
  end
90
87
 
91
88
  # Display Usage for this Module
@@ -182,6 +182,9 @@ module Cryptum
182
182
  end
183
183
 
184
184
  ws.on :close do
185
+ # raise when remote peer forces reset...this
186
+ # is then caught below and reattempts to connect
187
+ # until conn_attempt > max_conn_attempts
185
188
  raise Errno::ECONNRESET
186
189
  end
187
190
 
@@ -230,24 +233,24 @@ module Cryptum
230
233
  Errno::ECONNRESET,
231
234
  LoadError => e
232
235
 
233
- File.open('/tmp/cryptum-errors.txt', 'a') do |f|
234
- f.puts Time.now.strftime('%Y-%m-%d %H:%M:%S.%N %z')
235
- f.puts "Module: #{self}"
236
- f.puts "#{e}\n\n\n"
237
- end
236
+ Cryptum::Log.append(level: :debug, msg: e, which_self: self)
238
237
 
239
- raise e if conn_attempt > max_conn_attempts
238
+ if conn_attempt > max_conn_attempts
239
+ Cryptum::Log.append(
240
+ level: :error,
241
+ msg: e,
242
+ which_self: self,
243
+ event_history: event_history
244
+ )
245
+ end
240
246
 
241
247
  sleep 1
242
248
  retry
243
249
  ensure
244
250
  $stdout.flush
245
251
  end
246
- rescue Interrupt
247
- # Exit Gracefully if CTRL+C is Pressed During Session
248
- Cryptum::UI::Exit.gracefully(event_history: event_history)
249
- rescue StandardError => e
250
- raise e
252
+ rescue Interrupt, StandardError => e
253
+ Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
251
254
  end
252
255
 
253
256
  # Display Usage for this Module
data/lib/cryptum.rb CHANGED
@@ -37,38 +37,56 @@ module Cryptum
37
37
 
38
38
  public_class_method def self.bin
39
39
  File.join root, 'bin'
40
+ rescue Interrupt, StandardError => e
41
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
40
42
  end
41
43
 
42
44
  public_class_method def self.etc
43
45
  File.join root, 'etc'
46
+ rescue Interrupt, StandardError => e
47
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
44
48
  end
45
49
 
46
50
  public_class_method def self.lib
47
51
  File.join root, 'lib'
52
+ rescue Interrupt, StandardError => e
53
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
48
54
  end
49
55
 
50
56
  public_class_method def self.order_book
51
57
  File.join root, 'order_book'
58
+ rescue Interrupt, StandardError => e
59
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
52
60
  end
53
61
 
54
62
  public_class_method def self.root
55
63
  File.dirname __dir__
64
+ rescue Interrupt, StandardError => e
65
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
56
66
  end
57
67
 
58
68
  public_class_method def self.open_symbol
59
69
  "\u00f8"
70
+ rescue Interrupt, StandardError => e
71
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
60
72
  end
61
73
 
62
74
  public_class_method def self.up_arrow
63
75
  "\u2191"
76
+ rescue Interrupt, StandardError => e
77
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
64
78
  end
65
79
 
66
80
  public_class_method def self.down_arrow
67
81
  "\u2193"
82
+ rescue Interrupt, StandardError => e
83
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
68
84
  end
69
85
 
70
86
  public_class_method def self.flat_arrow
71
87
  '_'
88
+ rescue Interrupt, StandardError => e
89
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
72
90
  end
73
91
 
74
92
  # Add Commas to Large Numbers to Make it Easier to Read
@@ -88,12 +106,8 @@ module Cryptum
88
106
  beautify_num = "-#{beautify_whole}.#{fraction}" if is_negative
89
107
 
90
108
  beautify_num
91
- rescue Interrupt
92
- # Exit Gracefully if CTRL+C is Pressed During Session
93
- Cryptum.exit_gracefully(which_self: self)
94
- rescue StandardError => e
95
- # Produce a Stacktrace for anything else
96
- raise e
109
+ rescue Interrupt, StandardError => e
110
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
97
111
  end
98
112
 
99
113
  public_class_method def self.help
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.386
4
+ version: 0.0.387
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.