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,300 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'logger'
4
-
5
- module Cryptum
6
- module UI
7
- # This plugin is used to Display Order Execute Details
8
- # selected from the Order Execute Window Pane.
9
- module OrderExecuteDetails
10
- # Supported Method Parameters::
11
- # Cryptum::UI::OrderExecuteDetails.refresh(
12
- # )
13
-
14
- public_class_method def self.refresh(opts = {})
15
- event_history = opts[:event_history]
16
- order_execute_details_win = opts[:order_execute_details_win]
17
-
18
- order_meta_data = event_history.order_execute_selected_data
19
-
20
- order_color = order_meta_data[:color].to_sym
21
- case order_color
22
- when :cyan, :red
23
- order_id = order_meta_data[:buy_order_id]
24
- when :green, :magenta, :yellow
25
- order_id = order_meta_data[:sell_order_id]
26
- when :white
27
- order_id = 'Expired'
28
- else
29
- order_id = 'N/A'
30
- end
31
-
32
- order_id_details = "- ID: #{order_id}"
33
-
34
- order_history_arr = event_history.order_book[:order_history].select do |order|
35
- order if order[:id] == order_id
36
- end
37
-
38
- if order_history_arr.empty? && order_color == :yellow
39
- order_meta_data.delete(:sell_order_id)
40
- order_id = order_meta_data[:buy_order_id]
41
- order_meta_data[:color] = :cyan
42
- order_history_arr = event_history.order_book[:order_history].select do |order|
43
- order if order[:id] == order_id
44
- end
45
- end
46
-
47
- order_type_ln = '- Type: N/A'
48
- order_status_ln = '- Status: N/A'
49
- fill_fees = 'N/A'
50
- fill_size = 'N/A'
51
- executed_value = 'N/A'
52
- market_type = 'N/A'
53
- settled = 'N/A'
54
- unless order_history_arr.empty?
55
- order_history = order_history_arr.first
56
- order_type = order_history[:type].capitalize
57
- time_in_force = order_history[:time_in_force].upcase
58
- order_status = order_history[:status].upcase
59
- created_at = order_history[:created_at]
60
- fill_fees = order_history[:fill_fees]
61
- fill_size = order_history[:filled_size]
62
- executed_value = order_history[:executed_value]
63
- market_type = order_history[:market_type]
64
- settled = order_history[:settled]
65
-
66
- order_side = order_history[:side].capitalize
67
- case order_side.to_sym
68
- when :Buy
69
- expire_time = order_history[:expire_time]
70
- done_at = order_history[:done_at]
71
- order_meta_data[:color] = :cyan if done_at
72
- when :Sell
73
- done_at = order_history[:done_at]
74
- end
75
-
76
- order_type_ln = "- Type: #{order_type} #{order_side} #{time_in_force}"
77
- order_type_ln = "- Type: #{order_type} #{order_side} #{time_in_force} 1m" if time_in_force == 'GTT'
78
- order_status_ln = "- Status: #{order_status}"
79
- end
80
-
81
- if created_at && (!expire_time || !done_at)
82
- order_hist_created_finished_ln = "- Creation Date: #{created_at} | Finished Date: N/A"
83
- elsif created_at && expire_time && !done_at
84
- order_hist_created_finished_ln = "- Creation Date: #{created_at} | Expiring Date: #{expire_time}"
85
- elsif created_at && done_at
86
- order_hist_created_finished_ln = "- Creation Date: #{created_at} | Finished Date: #{done_at}"
87
- else
88
- order_hist_created_finished_ln = '- Creation Date: N/A | Finished Date: N/A'
89
- end
90
-
91
- invest_out = Cryptum.beautify_large_number(
92
- value: order_meta_data[:invest]
93
- )
94
- price_out = Cryptum.beautify_large_number(
95
- value: order_meta_data[:price]
96
- )
97
- size_out = Cryptum.beautify_large_number(
98
- value: order_meta_data[:size]
99
- )
100
- target_price_out = Cryptum.beautify_large_number(
101
- value: order_meta_data[:target_price]
102
- )
103
-
104
- invest = "$#{invest_out} @ "
105
- tick = "$#{price_out} = "
106
- size = "*#{size_out} + "
107
- tpm_out = "#{order_meta_data[:tpm]}% = "
108
- targ_tick = "$#{target_price_out}"
109
- profit = " | Profit: $#{order_meta_data[:profit]}"
110
-
111
- details_ln1 = "- Slice Plan: #{invest}#{tick}#{size}#{tpm_out}#{targ_tick}#{profit}"
112
- details_ln2 = "- Fees: $#{fill_fees} | Fill Size: *#{fill_size}"
113
- details_ln3 = "- Executed Value: $#{executed_value} | Market Type: #{market_type} | Settled: #{settled}"
114
-
115
- # UI
116
- col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
117
-
118
- # ROW 1
119
- out_line_no = 0
120
- line_color = order_color
121
- header_color = order_color
122
- header_style = :bold
123
- style = :bold
124
- header_style = :reverse if event_history.order_execute_details_win_active
125
-
126
- Cryptum::UI.line(
127
- ui_win: order_execute_details_win,
128
- out_line_no: out_line_no,
129
- color: line_color
130
- )
131
-
132
- # ROW 2
133
- out_line_no += 1
134
- order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
135
- order_execute_details_win.clrtoeol
136
- Cryptum::UI.colorize(
137
- ui_win: order_execute_details_win,
138
- color: header_color,
139
- style: header_style,
140
- string: ''.ljust(col_just1, ' ')
141
- )
142
-
143
- header_str = "- ORDER ##{order_meta_data[:plan_no]} DETAILS -"
144
- order_execute_details_win.setpos(
145
- out_line_no,
146
- Cryptum::UI.col_center(str: header_str)
147
- )
148
-
149
- Cryptum::UI.colorize(
150
- ui_win: order_execute_details_win,
151
- color: order_color,
152
- style: header_style,
153
- string: header_str
154
- )
155
-
156
- # ROW 3
157
- out_line_no += 1
158
- order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
159
- order_execute_details_win.clrtoeol
160
-
161
- Cryptum::UI.colorize(
162
- ui_win: order_execute_details_win,
163
- color: order_color,
164
- style: style,
165
- string: order_id_details.ljust(col_just1, ' ')
166
- )
167
-
168
- # ROW 4
169
- out_line_no += 1
170
- order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
171
- order_execute_details_win.clrtoeol
172
-
173
- Cryptum::UI.colorize(
174
- ui_win: order_execute_details_win,
175
- color: order_color,
176
- style: style,
177
- string: order_type_ln.ljust(col_just1, ' ')
178
- )
179
-
180
- # ROW 5
181
- out_line_no += 1
182
- order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
183
- order_execute_details_win.clrtoeol
184
-
185
- Cryptum::UI.colorize(
186
- ui_win: order_execute_details_win,
187
- color: order_color,
188
- style: style,
189
- string: order_status_ln.ljust(col_just1, ' ')
190
- )
191
-
192
- # ROW 6
193
- out_line_no += 1
194
- order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
195
- order_execute_details_win.clrtoeol
196
-
197
- Cryptum::UI.colorize(
198
- ui_win: order_execute_details_win,
199
- color: order_color,
200
- style: style,
201
- string: order_hist_created_finished_ln.ljust(col_just1, ' ')
202
- )
203
-
204
- # ROW 7
205
- out_line_no += 1
206
- order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
207
- order_execute_details_win.clrtoeol
208
-
209
- Cryptum::UI.colorize(
210
- ui_win: order_execute_details_win,
211
- color: order_color,
212
- style: style,
213
- string: details_ln1.ljust(col_just1, ' ')
214
- )
215
-
216
- # ROW 8
217
- out_line_no += 1
218
- order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
219
- order_execute_details_win.clrtoeol
220
-
221
- Cryptum::UI.colorize(
222
- ui_win: order_execute_details_win,
223
- color: order_color,
224
- style: style,
225
- string: details_ln2.ljust(col_just1, ' ')
226
- )
227
-
228
- # ROW 9
229
- out_line_no += 1
230
- order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
231
- order_execute_details_win.clrtoeol
232
-
233
- Cryptum::UI.colorize(
234
- ui_win: order_execute_details_win,
235
- color: order_color,
236
- style: style,
237
- string: details_ln3.ljust(col_just1, ' ')
238
- )
239
-
240
- # Clear to OK ROW
241
- ok_row = 9
242
- out_line_no += 1
243
- to_ok_row = ok_row - 1
244
- (out_line_no..to_ok_row).each do |clr_line|
245
- order_execute_details_win.setpos(clr_line, Cryptum::UI.col_first)
246
- Cryptum::UI.colorize(
247
- ui_win: order_execute_details_win,
248
- color: order_color,
249
- style: :normal,
250
- string: ''.ljust(col_just1, ' ')
251
- )
252
- end
253
-
254
- # OK ROW
255
- out_line_no = ok_row
256
- order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
257
- order_execute_details_win.clrtoeol
258
- Cryptum::UI.colorize(
259
- ui_win: order_execute_details_win,
260
- color: order_color,
261
- string: ''.ljust(col_just1, ' ')
262
- )
263
-
264
- header_str = '- OK -'
265
- order_execute_details_win.setpos(
266
- out_line_no,
267
- Cryptum::UI.col_center(str: header_str)
268
- )
269
-
270
- Cryptum::UI.colorize(
271
- ui_win: order_execute_details_win,
272
- color: order_color,
273
- style: :reverse,
274
- string: header_str
275
- )
276
-
277
- order_execute_details_win.refresh
278
-
279
- event_history
280
- rescue Interrupt
281
- # Exit Gracefully if CTRL+C is Pressed During Session
282
- Cryptum::UI::Exit.gracefully(
283
- which_self: self,
284
- event_history: event_history
285
- )
286
- rescue StandardError => e
287
- raise e
288
- end
289
-
290
- # Display Usage for this Module
291
-
292
- public_class_method def self.help
293
- puts "USAGE:
294
- #{self}.refresh(
295
- )
296
- "
297
- end
298
- end
299
- end
300
- end