cryptum 0.0.382 → 0.0.383

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +5 -8
  3. data/lib/cryptum/api/exchange_rates.rb +0 -2
  4. data/lib/cryptum/api/orders.rb +0 -6
  5. data/lib/cryptum/api/portfolio.rb +0 -2
  6. data/lib/cryptum/api/rest.rb +3 -4
  7. data/lib/cryptum/api/signature.rb +0 -4
  8. data/lib/cryptum/api.rb +0 -6
  9. data/lib/cryptum/bot_conf.rb +0 -3
  10. data/lib/cryptum/event/parse.rb +5 -5
  11. data/lib/cryptum/event.rb +0 -2
  12. data/lib/cryptum/log.rb +18 -4
  13. data/lib/cryptum/open_ai.rb +129 -32
  14. data/lib/cryptum/option/environment.rb +0 -2
  15. data/lib/cryptum/option/parser.rb +0 -2
  16. data/lib/cryptum/order_book/generate.rb +0 -4
  17. data/lib/cryptum/order_book.rb +0 -3
  18. data/lib/cryptum/portfolio.rb +0 -2
  19. data/lib/cryptum/ui/command.rb +0 -2
  20. data/lib/cryptum/ui/market_trend.rb +0 -2
  21. data/lib/cryptum/ui/matrix.rb +0 -2
  22. data/lib/cryptum/ui/order/execute.rb +629 -0
  23. data/lib/cryptum/ui/order/execute_details.rb +300 -0
  24. data/lib/cryptum/ui/order/plan.rb +518 -0
  25. data/lib/cryptum/ui/order/plan_details.rb +243 -0
  26. data/lib/cryptum/ui/order/timer.rb +140 -0
  27. data/lib/cryptum/ui/order.rb +21 -0
  28. data/lib/cryptum/ui/portfolio.rb +0 -2
  29. data/lib/cryptum/ui/signal_engine.rb +0 -2
  30. data/lib/cryptum/ui/terminal_window.rb +0 -2
  31. data/lib/cryptum/ui/ticker.rb +0 -2
  32. data/lib/cryptum/ui.rb +1 -8
  33. data/lib/cryptum/version.rb +1 -1
  34. data/lib/cryptum/web_sock/coinbase.rb +0 -5
  35. data/lib/cryptum/web_sock/event_machine.rb +2 -6
  36. data/lib/cryptum.rb +16 -2
  37. data/spec/lib/cryptum/ui/{order_execute_details_spec.rb → order/execute_details_spec.rb} +2 -2
  38. data/spec/lib/cryptum/ui/{order_execution_spec.rb → order/execute_spec.rb} +2 -2
  39. data/spec/lib/cryptum/ui/order/plan_details_spec.rb +10 -0
  40. data/spec/lib/cryptum/ui/{order_timer_spec.rb → order/plan_spec.rb} +2 -2
  41. data/spec/lib/cryptum/ui/{order_plan_details_spec.rb → order/timer_spec.rb} +2 -2
  42. data/spec/lib/cryptum/ui/{order_plan_spec.rb → order_spec.rb} +2 -2
  43. metadata +13 -11
  44. data/lib/cryptum/ui/order_execute_details.rb +0 -300
  45. data/lib/cryptum/ui/order_execution.rb +0 -629
  46. data/lib/cryptum/ui/order_plan.rb +0 -518
  47. data/lib/cryptum/ui/order_plan_details.rb +0 -243
  48. data/lib/cryptum/ui/order_timer.rb +0 -140
@@ -1,629 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'logger'
4
-
5
- module Cryptum
6
- # This plugin is used to Refresh the Cryptum console UI
7
- module UI
8
- module OrderExecution
9
- # Supported Method Parameters::
10
- # Cryptum::UI::Candle.refresh(
11
- # order_book: 'required - Order Book Data Structure',
12
- # event: 'required - Event from Coinbase Web Socket'
13
- # )
14
-
15
- public_class_method def self.refresh(opts = {})
16
- option_choice = opts[:option_choice]
17
- order_execute_win = opts[:order_execute_win]
18
- env = opts[:env]
19
- event_history = opts[:event_history]
20
- indicator_status = opts[:indicator_status]
21
- bot_conf = opts[:bot_conf]
22
-
23
- event_type = event_history.event_type if option_choice.autotrade
24
- event_side = event_history.event[:side].to_s.to_sym if option_choice.autotrade
25
- event_reason = event_history.event[:reason].to_s.to_sym if option_choice.autotrade
26
-
27
- ticker_price = event_history.order_book[:ticker_price].to_f
28
- open_24h = event_history.order_book[:open_24h].to_f
29
- this_product = event_history.order_book[:this_product]
30
- min_market_funds = this_product[:min_market_funds]
31
- base_increment = this_product[:base_increment]
32
- quote_increment = this_product[:quote_increment]
33
- crypto_smallest_decimal = base_increment.to_s.split('.')[-1].length
34
- fiat_smallest_decimal = quote_increment.to_s.split('.')[-1].length
35
-
36
- last_three_prices_arr = []
37
- last_ticker_price = event_history.order_book[:ticker_price].to_f
38
- second_to_last_ticker_price = event_history.order_book[:ticker_price_second_to_last].to_f
39
- third_to_last_ticker_price = event_history.order_book[:ticker_price_third_to_last].to_f
40
- last_three_prices_arr.push(last_ticker_price)
41
- last_three_prices_arr.push(second_to_last_ticker_price)
42
- last_three_prices_arr.push(third_to_last_ticker_price)
43
- limit_price = last_three_prices_arr.sort[1]
44
- return event_history unless limit_price.positive?
45
-
46
- tpm = bot_conf[:target_profit_margin_percent].to_f
47
- tpm_cast_as_decimal = tpm / 100
48
-
49
- order_history_meta = event_history.order_book[:order_history_meta]
50
- order_history = event_history.order_book[:order_history] if option_choice.autotrade
51
-
52
- margin_percent_open_24h = (1 - (open_24h / ticker_price)) * 100
53
- cast_margin_to_sec = margin_percent_open_24h * 0.1
54
-
55
- # Reset times to max or default depending on
56
- # BULL or BEAR market trend
57
- event_history.bullish_trend = true if cast_margin_to_sec.positive?
58
- event_history.bullish_trend = false if cast_margin_to_sec.negative?
59
-
60
- buy_total = event_history.order_book[:market_trend][:buy].to_i
61
- sell_total = event_history.order_book[:market_trend][:sell].to_i
62
-
63
- if event_history.order_book[:order_plan].length.positive?
64
- if event_history.order_ready
65
- event_history.order_book[:last_order_exec] = Time.now.strftime(
66
- '%Y-%m-%d %H:%M:%S.%N%z'
67
- )
68
- end
69
-
70
- # BUY
71
- # Reset times to max or default depending on
72
- # BULL or BEAR market trend
73
- event_history.time_between_orders = event_history.time_between_orders_max if buy_total >= sell_total &&
74
- !event_history.bullish_trend
75
-
76
- event_history.time_between_orders = event_history.time_between_orders_reset if sell_total > buy_total &&
77
- !event_history.bullish_trend
78
-
79
- if event_history.order_ready &&
80
- indicator_status.action_signal == :buy &&
81
- !event_history.red_pill
82
-
83
- if option_choice.autotrade
84
- this_order = event_history.order_book[:order_plan].first
85
-
86
- # If price is greater than the previous order,
87
- # force it to be slightly less
88
- last_order = order_history_meta.select do |order|
89
- order if order[:color] == 'yellow'
90
- end.last
91
-
92
- last_purchase_price = 0.0
93
- last_purchase_price = last_order[:price].to_f if last_order
94
-
95
- limit_price = last_purchase_price - quote_increment.to_f if last_purchase_price.positive? && last_purchase_price < limit_price
96
-
97
- # Debug last order
98
- File.open('/tmp/cryptum-errors.txt', 'a') do |f|
99
- f.puts "Last Order: #{last_order}"
100
- f.puts "Last Purchase Price: #{last_purchase_price}"
101
- f.puts "Limit Price (Should be <= quote_increment-- ^): #{limit_price}"
102
- f.puts "\n\n\n"
103
- end
104
-
105
- price = format(
106
- "%0.#{fiat_smallest_decimal}f",
107
- limit_price
108
- )
109
-
110
- size = this_order[:invest].to_f / limit_price
111
-
112
- loop do
113
- size = size.to_f + base_increment.to_f
114
- break if (size.to_f * price.to_f) > min_market_funds.to_f
115
- end
116
-
117
- size = format(
118
- "%0.#{crypto_smallest_decimal}f",
119
- size
120
- )
121
-
122
- fiat_invested_this_order = size.to_f * price.to_f
123
-
124
- fiat_portfolio = event_history.order_book[:fiat_portfolio]
125
- fiat_avail_to_trade = format('%0.2f', fiat_portfolio.first[:available])
126
-
127
- event_history.red_pill = true if fiat_invested_this_order > fiat_avail_to_trade.to_f
128
-
129
- unless event_history.red_pill
130
- event_history = Cryptum::API::Orders.submit_limit_order(
131
- option_choice: option_choice,
132
- env: env,
133
- price: price,
134
- size: size,
135
- buy_or_sell: :buy,
136
- event_history: event_history,
137
- bot_conf: bot_conf
138
- )
139
- end
140
- else
141
- this_order = event_history.order_book[:order_plan].shift
142
- # Mock Order ID
143
- this_order[:buy_order_id] = format(
144
- '%0.6i',
145
- Random.rand(0..999_999)
146
- )
147
-
148
- this_order[:price] = limit_price.to_s
149
- this_order[:size] = format(
150
- "%0.#{crypto_smallest_decimal}f",
151
- this_order[:invest].to_f / limit_price
152
- )
153
-
154
- targ_price = limit_price + (limit_price * tpm_cast_as_decimal)
155
- this_order[:tpm] = format(
156
- '%0.2f',
157
- tpm
158
- )
159
- this_order[:target_price] = format(
160
- "%0.#{fiat_smallest_decimal}f",
161
- targ_price
162
- )
163
- this_order[:color] = :cyan
164
- order_history_meta.push(this_order)
165
- end
166
-
167
- # SAUCE 4 (SAUCE 3 RELATES TO SAUCE 4)
168
- # Time between orders
169
- # Increment n Seconds between buys to
170
- # account for bearish and bullish trends
171
- dynamic_time_increment = cast_margin_to_sec * -1
172
-
173
- # Lets also take balance into play
174
- balance_as_arbitrary_float = fiat_avail_to_trade.to_f / 1_000_000
175
- tbo = dynamic_time_increment - balance_as_arbitrary_float
176
-
177
- event_history.time_between_orders += tbo
178
-
179
- # Time between orders should never
180
- # be less than event_history.time_between_orders_min
181
- event_history.time_between_orders = event_history.time_between_orders_min if event_history.time_between_orders < event_history.time_between_orders_min
182
- # Time between orders should never
183
- # be more than event_history.time_between_orders_max
184
- event_history.time_between_orders = event_history.time_between_orders_max if event_history.time_between_orders > event_history.time_between_orders_max
185
- end
186
-
187
- # SELL
188
- # Once buy arders are fulfilled submit a
189
- # limit sell order for fulfillment
190
- unless option_choice.autotrade
191
- # Testing logic via Mock
192
- event_type_arr = %i[received open done]
193
- last_et_index = event_type_arr.length - 1
194
- rand_et_index = Random.rand(0..last_et_index)
195
- event_type = event_type_arr[rand_et_index]
196
-
197
- event_side_arr = %i[buy sell]
198
- last_es_index = event_side_arr.length - 1
199
- rand_es_index = Random.rand(0..last_es_index)
200
- event_side = event_type_arr[rand_es_index].to_s.to_sym
201
- event_reason = 'mock'
202
- end
203
- end
204
-
205
- # Update Completed Sell Orders w/ Green
206
- if event_type == :open &&
207
- event_side == :buy
208
-
209
- buy_order_id = event_history.event[:order_id]
210
- order_history_meta.each do |meta|
211
- meta[:color] = :red if meta[:buy_order_id] == buy_order_id
212
- end
213
- end
214
-
215
- if event_type == :done &&
216
- event_side == :buy &&
217
- event_reason == :canceled
218
-
219
- buy_order_id = event_history.event[:order_id]
220
- order_history_meta.each do |meta|
221
- next unless meta[:buy_order_id] == buy_order_id
222
-
223
- meta[:done_at] = Time.now.strftime('%Y-%m-%d %H:%M:%S.%N%z')
224
- meta[:color] = :white
225
- end
226
- end
227
-
228
- if event_type == :done &&
229
- event_side == :buy &&
230
- event_reason != :canceled
231
-
232
- if option_choice.autotrade
233
- order_ready_to_sell_arr = order_history_meta.select do |meta|
234
- meta[:buy_order_id] == event_history.event[:order_id]
235
- end
236
- else
237
- last_index = order_history_meta.length - 1
238
- rand_index = Random.rand(0..last_index)
239
- order_ready_to_sell_arr = [
240
- order_history_meta[rand_index]
241
- ]
242
- end
243
-
244
- if order_ready_to_sell_arr.length.positive?
245
- order_ready_to_sell = order_ready_to_sell_arr.first
246
- buy_order_id = order_ready_to_sell[:buy_order_id]
247
-
248
- if option_choice.autotrade
249
- price = format(
250
- "%0.#{fiat_smallest_decimal}f",
251
- order_ready_to_sell[:target_price]
252
- )
253
-
254
- size = order_ready_to_sell[:size]
255
-
256
- Cryptum::API::Orders.submit_limit_order(
257
- option_choice: option_choice,
258
- env: env,
259
- price: price,
260
- size: size,
261
- buy_or_sell: :sell,
262
- event_history: event_history,
263
- bot_conf: bot_conf,
264
- buy_order_id: buy_order_id
265
- )
266
- else
267
- sell_order_id = format(
268
- '%0.2i',
269
- Random.rand(0..999_999)
270
- )
271
-
272
- event_history.order_book[:order_history_meta].each do |meta|
273
- if meta[:buy_order_id] == buy_order_id
274
- meta[:sell_order_id] = sell_order_id
275
- meta[:color] = :yellow
276
- end
277
- end
278
- end
279
- end
280
- end
281
-
282
- # Update Canceled Sell Orders w/ Black &&
283
- # Include done_at Timestamp for 24h gain calc
284
- if event_type == :done &&
285
- event_side == :sell &&
286
- event_reason == :canceled
287
-
288
- sell_order_id = event_history.event[:order_id]
289
- order_history_meta.each do |meta|
290
- next unless meta[:sell_order_id] == sell_order_id
291
-
292
- meta[:done_at] = Time.now.strftime('%Y-%m-%d %H:%M:%S.%N%z')
293
-
294
- # TODO: Retry sell order if the original sell order expires.
295
-
296
- # Reinitiate GTFO if the previous GTFO Order Expires.
297
- terminal_win.key_press_event.key_g = true if meta[:color] == :magenta
298
- meta[:color] = :white
299
- end
300
- end
301
-
302
- # Update Completed Sell Orders w/ Green &&
303
- # Include done_at Timestamp for 24h gain calc
304
- if event_type == :done &&
305
- event_side == :sell &&
306
- event_reason != :canceled
307
-
308
- sell_order_id = event_history.event[:order_id]
309
- order_history_meta.each do |meta|
310
- next unless meta[:sell_order_id] == sell_order_id
311
-
312
- meta[:done_at] = Time.now.strftime('%Y-%m-%d %H:%M:%S.%N%z')
313
- meta[:color] = :green
314
- end
315
- end
316
-
317
- # OK, now let's tally up everything...
318
- twenty_four_hrs_ago = Time.now - 86_400
319
-
320
- # Snag all sold orders
321
- oh_meta_sold_arr = order_history_meta.select do |ohm|
322
- ohm[:color].to_sym == :green && ohm.key?(:done_at)
323
- end
324
- order_hist_meta_sold = oh_meta_sold_arr.length
325
-
326
- # Snag all sold orders within past 24 hrs
327
- ohm_sold_twenty_four_arr = []
328
- unless oh_meta_sold_arr.empty?
329
- ohm_sold_twenty_four_arr = oh_meta_sold_arr.select do |o|
330
- Time.parse(o[:done_at]) >= twenty_four_hrs_ago
331
- end
332
- end
333
- order_hist_meta_sold_twenty_four = ohm_sold_twenty_four_arr.length
334
-
335
- # Snag all expired orders
336
- oh_meta_expired_arr = order_history_meta.select do |ohm|
337
- ohm[:color].to_sym == :white && ohm.key?(:done_at)
338
- end
339
- order_hist_meta_expired = oh_meta_expired_arr.length
340
-
341
- # Snag all expired orders within past 24 hrs
342
- ohm_expire_twenty_four_arr = []
343
- unless oh_meta_expired_arr.empty?
344
- ohm_expire_twenty_four_arr = oh_meta_expired_arr.select do |o|
345
- Time.parse(o[:done_at]) >= twenty_four_hrs_ago
346
- end
347
- end
348
- order_hist_meta_24h_expired = ohm_expire_twenty_four_arr.length
349
-
350
- # Calculate total gains and gains within past 24 hrs
351
- gains_sum = oh_meta_sold_arr.map do |ohms|
352
- ohms[:profit].to_f
353
- end.sum
354
-
355
- gains_out = Cryptum.beautify_large_number(
356
- value: format(
357
- '%0.2f',
358
- gains_sum
359
- )
360
- )
361
-
362
- gains_24h_sum = ohm_sold_twenty_four_arr.map do |ohms|
363
- ohms[:profit].to_f
364
- end.sum
365
-
366
- gains_24h_out = Cryptum.beautify_large_number(
367
- value: format(
368
- '%0.2f',
369
- gains_24h_sum
370
- )
371
- )
372
-
373
- total_to_sell = order_history.select do |oh|
374
- oh[:status].to_sym == :open && oh[:side].to_sym == :sell
375
- end.length
376
-
377
- event_history.open_sell_orders = total_to_sell
378
- oh_meta_total_selling_profit_arr = order_history_meta.select do |ohm|
379
- ohm[:color].to_sym == :yellow
380
- end
381
-
382
- total_selling_profit = oh_meta_total_selling_profit_arr.map do |ohms|
383
- ohms[:profit].to_f
384
- end.sum
385
-
386
- total_selling_profit_out = Cryptum.beautify_large_number(
387
- value: format(
388
- '%0.2f',
389
- total_selling_profit
390
- )
391
- )
392
-
393
- # TODO: when event_history.open_sell_orders > event_history.open_sell_orders_max
394
- # Capture highest amount to sell, cancel all orders, and create _one_ limit sell
395
- # order set to a price of the previously captured highest amount to sell.
396
- event_history.open_sell_orders_merge = true if total_to_sell > event_history.open_sell_orders_max
397
-
398
- # TODO: Everything Above this Line Needs to be Indicators ^
399
-
400
- # UI
401
- col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
402
- col_just4 = Curses.cols - Cryptum::UI.col_fourth
403
-
404
- # ROW 1
405
- out_line_no = 0
406
- line_color = :white
407
- header_color = :white
408
- header_style = :bold
409
- style = :bold
410
- if event_history.order_execute_win_active
411
- line_color = :blue
412
- header_color = :blue
413
- header_style = :reverse
414
- end
415
-
416
- Cryptum::UI.line(
417
- ui_win: order_execute_win,
418
- out_line_no: out_line_no,
419
- color: line_color
420
- )
421
-
422
- # ROW 2
423
- out_line_no += 1
424
- order_execute_win.setpos(out_line_no, Cryptum::UI.col_first)
425
- order_execute_win.clrtoeol
426
- Cryptum::UI.colorize(
427
- ui_win: order_execute_win,
428
- color: header_color,
429
- style: header_style,
430
- string: ''.ljust(col_just1, ' ')
431
- )
432
-
433
- header_str = '- ORDER HISTORY -'
434
- order_execute_win.setpos(
435
- out_line_no,
436
- Cryptum::UI.col_center(str: header_str)
437
- )
438
-
439
- Cryptum::UI.colorize(
440
- ui_win: order_execute_win,
441
- color: header_color,
442
- style: header_style,
443
- string: header_str
444
- )
445
-
446
- order_execute_win.setpos(out_line_no, Cryptum::UI.col_fourth)
447
- order_execute_win.clrtoeol
448
- Cryptum::UI.colorize(
449
- ui_win: order_execute_win,
450
- color: header_color,
451
- style: header_style,
452
- string: ''.ljust(col_just4, ' ')
453
- )
454
-
455
- # ROWS 3-10
456
- remaining_blank_rows = 0
457
- remaining_blank_rows = max_rows_to_display if order_history_meta.empty?
458
- max_rows_to_display = event_history.order_execute_max_rows_to_display
459
- first_row = event_history.order_execute_index_offset
460
- last_row = first_row + max_rows_to_display
461
- if last_row >= order_history_meta.length
462
- last_row = order_history_meta.length - 1
463
- event_history.order_execute_max_records_available_to_display = last_row if last_row < max_rows_to_display
464
- first_row = last_row - event_history.order_execute_max_records_available_to_display
465
- event_history.order_execute_index_offset = first_row
466
- remaining_blank_rows = max_rows_to_display - last_row
467
- end
468
-
469
- if order_history_meta.any?
470
- selected_order = event_history.order_execute_selected_data
471
- order_history_meta.reverse[first_row..last_row].each do |meta|
472
- out_line_no += 1
473
- current_line = out_line_no - 2
474
-
475
- style = :normal
476
- if event_history.order_execute_row_to_select == current_line
477
- style = :highlight
478
- selected_order = meta
479
- selected_order[:color] = meta[:color]
480
- end
481
-
482
- invest_out = Cryptum.beautify_large_number(
483
- value: meta[:invest]
484
- )
485
- price_out = Cryptum.beautify_large_number(
486
- value: meta[:price]
487
- )
488
- size_out = Cryptum.beautify_large_number(
489
- value: meta[:size]
490
- )
491
- target_price_out = Cryptum.beautify_large_number(
492
- value: meta[:target_price]
493
- )
494
- plan_no = meta[:plan_no]
495
-
496
- buy_created_at_hash_arr = order_history.select do |oh|
497
- oh[:id] == meta[:buy_order_id]
498
- end
499
-
500
- buy_created_at = '____-__-__ __:__:__'
501
- unless buy_created_at_hash_arr.empty?
502
- buy_created_at = Time.parse(
503
- buy_created_at_hash_arr.first[:created_at]
504
- ).strftime('%Y-%m-%d %H:%M:%S')
505
- end
506
-
507
- invest = "$#{invest_out} @ "
508
- tick = "$#{price_out} = "
509
- size = "*#{size_out} + "
510
- tpm_out = "#{meta[:tpm]}% = "
511
- targ_tick = "$#{target_price_out}"
512
- profit = "|Profit: $#{meta[:profit]}"
513
-
514
- order_exec_ln = "#{buy_created_at}|#{invest}#{tick}#{size}#{tpm_out}#{targ_tick}#{profit}|#{plan_no}"
515
-
516
- order_execute_win.setpos(out_line_no, Cryptum::UI.col_first)
517
- order_execute_win.clrtoeol
518
- Cryptum::UI.colorize(
519
- ui_win: order_execute_win,
520
- color: meta[:color],
521
- style: style,
522
- string: order_exec_ln.ljust(col_just1, '.')
523
- )
524
-
525
- Cryptum::UI.colorize(
526
- ui_win: order_execute_win,
527
- color: meta[:color],
528
- style: style,
529
- string: ''.ljust(col_just4, ' ')
530
- )
531
- end
532
- event_history.order_execute_selected_data = selected_order
533
- end
534
-
535
- # Clear to SUMMARY
536
- # (Only Applicable if order_book[:order_history_meta] < max_rows_to_display)
537
- # out_line_no += 1
538
- if remaining_blank_rows.positive?
539
- rows_to_blank = out_line_no + remaining_blank_rows
540
- out_line_no += 1
541
- (out_line_no..rows_to_blank).each do |clr_line|
542
- out_line_no = clr_line
543
- order_execute_win.setpos(clr_line, Cryptum::UI.col_first)
544
- order_execute_win.clrtoeol
545
- Cryptum::UI.colorize(
546
- ui_win: order_execute_win,
547
- color: :white,
548
- style: :normal,
549
- string: ''.ljust(col_just1, ' ')
550
- )
551
- end
552
- end
553
-
554
- # ROW 10
555
- out_line_no += 1
556
- order_execute_win.setpos(out_line_no, Cryptum::UI.col_first)
557
- order_execute_win.clrtoeol
558
- Cryptum::UI.colorize(
559
- ui_win: order_execute_win,
560
- color: header_color,
561
- style: header_style,
562
- string: ''.ljust(col_just1, ' ')
563
- )
564
-
565
- header_str = "SELLING: #{total_to_sell} w tProf: $#{total_selling_profit_out} | "
566
- header_str += "SOLD 24h: #{order_hist_meta_sold_twenty_four} Tot: #{order_hist_meta_sold} | "
567
- header_str += "GAINS 24h: $#{gains_24h_out} Tot: $#{gains_out} | "
568
- header_str += "EXPIRED 24h: #{order_hist_meta_24h_expired} Tot: #{order_hist_meta_expired}"
569
- order_execute_win.setpos(
570
- out_line_no,
571
- Cryptum::UI.col_center(str: header_str)
572
- )
573
-
574
- Cryptum::UI.colorize(
575
- ui_win: order_execute_win,
576
- color: header_color,
577
- style: header_style,
578
- string: header_str
579
- )
580
-
581
- # order_execute_win.setpos(out_line_no, Cryptum::UI.col_fourth)
582
- # order_execute_win.clrtoeol
583
- # Cryptum::UI.colorize(
584
- # ui_win: order_execute_win,
585
- # color: header_color,
586
- # style: header_style,
587
- # string: ''.ljust(col_just4, ' ')
588
- # )
589
-
590
- # ROW 11
591
- out_line_no += 1
592
- Cryptum::UI.line(
593
- ui_win: order_execute_win,
594
- out_line_no: out_line_no,
595
- color: line_color
596
- )
597
-
598
- order_execute_win.refresh
599
-
600
- # Reset Order Ready && Open Sell Orders Merge (If Applicable) Booleans
601
- event_history.order_ready = false
602
- event_history.open_sell_orders_merge = false
603
-
604
- event_history
605
- rescue Interrupt
606
- # Exit Gracefully if CTRL+C is Pressed During Session
607
- Cryptum::UI::Exit.gracefully(
608
- which_self: self,
609
- event_history: event_history,
610
- option_choice: option_choice,
611
- env: env
612
- )
613
- rescue StandardError => e
614
- raise e
615
- end
616
-
617
- # Display Usage for this Module
618
-
619
- public_class_method def self.help
620
- puts "USAGE:
621
- #{self}.refresh(
622
- order_book: 'required - Order Book Data Structure',
623
- event: 'required - Event from Coinbase Web Socket'
624
- )
625
- "
626
- end
627
- end
628
- end
629
- end