cryptum 0.0.381 → 0.0.383
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 +4 -4
- data/.rubocop.yml +2 -0
- data/.rubocop_todo.yml +11 -8
- data/Gemfile +1 -2
- data/bin/cryptum +2 -2
- data/lib/cryptum/api/exchange_rates.rb +0 -2
- data/lib/cryptum/api/orders.rb +9 -7
- data/lib/cryptum/api/portfolio.rb +0 -2
- data/lib/cryptum/api/rest.rb +3 -4
- data/lib/cryptum/api/signature.rb +0 -4
- data/lib/cryptum/api.rb +1 -40
- data/lib/cryptum/bot_conf.rb +14 -6
- data/lib/cryptum/event/exit.rb +1 -1
- data/lib/cryptum/event/history.rb +4 -1
- data/lib/cryptum/event/parse.rb +6 -6
- data/lib/cryptum/event.rb +0 -2
- data/lib/cryptum/log.rb +18 -4
- data/lib/cryptum/open_ai.rb +129 -32
- data/lib/cryptum/option/choice.rb +1 -1
- data/lib/cryptum/option/environment.rb +0 -2
- data/lib/cryptum/option/parser.rb +0 -2
- data/lib/cryptum/order_book/generate.rb +3 -8
- data/lib/cryptum/order_book.rb +0 -3
- data/lib/cryptum/portfolio.rb +0 -2
- data/lib/cryptum/ui/command.rb +1 -3
- data/lib/cryptum/ui/exit.rb +43 -0
- data/lib/cryptum/ui/key_press_event.rb +1 -1
- data/lib/cryptum/ui/market_trend.rb +4 -3
- data/lib/cryptum/ui/matrix.rb +185 -0
- data/lib/cryptum/ui/order/execute.rb +629 -0
- data/lib/cryptum/ui/order/execute_details.rb +300 -0
- data/lib/cryptum/ui/order/plan.rb +518 -0
- data/lib/cryptum/ui/order/plan_details.rb +243 -0
- data/lib/cryptum/ui/order/timer.rb +140 -0
- data/lib/cryptum/ui/order.rb +21 -0
- data/lib/cryptum/ui/portfolio.rb +5 -3
- data/lib/cryptum/ui/signal_engine.rb +1 -3
- data/lib/cryptum/ui/terminal_window.rb +1 -3
- data/lib/cryptum/ui/ticker.rb +4 -3
- data/lib/cryptum/ui.rb +17 -22
- data/lib/cryptum/version.rb +1 -1
- data/lib/cryptum/web_sock/coinbase.rb +1 -6
- data/lib/cryptum/web_sock/event_machine.rb +3 -7
- data/lib/cryptum.rb +16 -33
- data/spec/lib/cryptum/{matrix_spec.rb → ui/exit_spec.rb} +2 -2
- data/spec/lib/cryptum/ui/{order_plan_spec.rb → matrix_spec.rb} +2 -2
- data/spec/lib/cryptum/ui/{order_execute_details_spec.rb → order/execute_details_spec.rb} +2 -2
- data/spec/lib/cryptum/ui/{order_execution_spec.rb → order/execute_spec.rb} +2 -2
- data/spec/lib/cryptum/ui/{order_plan_details_spec.rb → order/plan_details_spec.rb} +2 -2
- data/spec/lib/cryptum/ui/order/plan_spec.rb +10 -0
- data/spec/lib/cryptum/ui/order/timer_spec.rb +10 -0
- data/spec/lib/cryptum/ui/{order_timer_spec.rb → order_spec.rb} +2 -2
- metadata +20 -30
- data/lib/cryptum/matrix.rb +0 -181
- data/lib/cryptum/ui/order_execute_details.rb +0 -297
- data/lib/cryptum/ui/order_execution.rb +0 -624
- data/lib/cryptum/ui/order_plan.rb +0 -514
- data/lib/cryptum/ui/order_plan_details.rb +0 -240
- data/lib/cryptum/ui/order_timer.rb +0 -136
@@ -0,0 +1,243 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cryptum
|
4
|
+
module UI
|
5
|
+
# This plugin is used to Display Order Plan Details
|
6
|
+
# selected from the Order Plan Window Pane.
|
7
|
+
module Order
|
8
|
+
module PlanDetails
|
9
|
+
# Supported Method Parameters::
|
10
|
+
# Cryptum::UI::Order::PlanDetails.refresh(
|
11
|
+
# )
|
12
|
+
|
13
|
+
public_class_method def self.refresh(opts = {})
|
14
|
+
event_history = opts[:event_history]
|
15
|
+
order_plan_details_win = opts[:order_plan_details_win]
|
16
|
+
|
17
|
+
order = event_history.order_plan_selected_data
|
18
|
+
tpm = order[:tpm]
|
19
|
+
autotrade_percent = order[:autotrade_percent]
|
20
|
+
order_color = order[:color]
|
21
|
+
|
22
|
+
fiat_avail_out = Cryptum.beautify_large_number(
|
23
|
+
value: order[:fiat_available]
|
24
|
+
)
|
25
|
+
risk_alloc_out = Cryptum.beautify_large_number(
|
26
|
+
value: order[:risk_alloc]
|
27
|
+
)
|
28
|
+
slice_alloc_out = Cryptum.beautify_large_number(
|
29
|
+
value: order[:slice_alloc]
|
30
|
+
)
|
31
|
+
previous_slice_invest_out = Cryptum.beautify_large_number(
|
32
|
+
value: order[:previous_slice_invest]
|
33
|
+
)
|
34
|
+
invest_out = Cryptum.beautify_large_number(
|
35
|
+
value: order[:invest]
|
36
|
+
)
|
37
|
+
profit_out = Cryptum.beautify_large_number(
|
38
|
+
value: order[:profit]
|
39
|
+
)
|
40
|
+
tpm_out = format('%0.2f', tpm)
|
41
|
+
return_out = Cryptum.beautify_large_number(
|
42
|
+
value: order[:return]
|
43
|
+
)
|
44
|
+
autotrade_ln1_details = "1. Autotrade is set to #{autotrade_percent}% of $#{fiat_avail_out}, making $#{risk_alloc_out} available for this slice in"
|
45
|
+
autotrade_ln2_details = ' the order plan.'
|
46
|
+
if order[:last_slice]
|
47
|
+
slice_alloc_ln1_details = "2. Since $#{risk_alloc_out} is the remaining amount within the criteria defined in the Autotrade % above,"
|
48
|
+
slice_alloc_ln2_details = " $#{invest_out} will be allocated for this slice."
|
49
|
+
else
|
50
|
+
slice_alloc_ln1_details = "2. With $#{risk_alloc_out} available and a slice allocation of #{order[:allocation_percent]}%, $#{slice_alloc_out} plus the previous"
|
51
|
+
slice_alloc_ln2_details = " slice of $#{previous_slice_invest_out} results in $#{invest_out} being allocated for this slice."
|
52
|
+
end
|
53
|
+
profit_ln1_details = "3. With a slice allocation of $#{invest_out}, plus a TPM equal to #{tpm_out}%, $#{return_out} will be returned"
|
54
|
+
profit_ln2_details = " once sold. With $#{invest_out} invested, the gross profit equals $#{profit_out}, minus any Maker &"
|
55
|
+
profit_ln3_details = ' Taker (transaction) fees.'
|
56
|
+
|
57
|
+
# UI
|
58
|
+
col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
|
59
|
+
|
60
|
+
# ROW 1
|
61
|
+
out_line_no = 0
|
62
|
+
line_color = order_color
|
63
|
+
header_color = order_color
|
64
|
+
header_style = :bold
|
65
|
+
style = :bold
|
66
|
+
header_style = :reverse if event_history.order_plan_details_win_active
|
67
|
+
|
68
|
+
Cryptum::UI.line(
|
69
|
+
ui_win: order_plan_details_win,
|
70
|
+
out_line_no: out_line_no,
|
71
|
+
color: line_color
|
72
|
+
)
|
73
|
+
|
74
|
+
# ROW 2
|
75
|
+
out_line_no += 1
|
76
|
+
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
77
|
+
order_plan_details_win.clrtoeol
|
78
|
+
Cryptum::UI.colorize(
|
79
|
+
ui_win: order_plan_details_win,
|
80
|
+
color: header_color,
|
81
|
+
style: header_style,
|
82
|
+
string: ''.ljust(col_just1, ' ')
|
83
|
+
)
|
84
|
+
|
85
|
+
header_str = "- ORDER SLICE ##{order[:plan_no]} DETAILS -"
|
86
|
+
order_plan_details_win.setpos(
|
87
|
+
out_line_no,
|
88
|
+
Cryptum::UI.col_center(str: header_str)
|
89
|
+
)
|
90
|
+
|
91
|
+
Cryptum::UI.colorize(
|
92
|
+
ui_win: order_plan_details_win,
|
93
|
+
color: order_color,
|
94
|
+
style: header_style,
|
95
|
+
string: header_str
|
96
|
+
)
|
97
|
+
|
98
|
+
# ROW 3
|
99
|
+
out_line_no += 1
|
100
|
+
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
101
|
+
order_plan_details_win.clrtoeol
|
102
|
+
|
103
|
+
Cryptum::UI.colorize(
|
104
|
+
ui_win: order_plan_details_win,
|
105
|
+
color: order_color,
|
106
|
+
style: style,
|
107
|
+
string: autotrade_ln1_details.ljust(col_just1, ' ')
|
108
|
+
)
|
109
|
+
|
110
|
+
# ROW 4
|
111
|
+
out_line_no += 1
|
112
|
+
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
113
|
+
order_plan_details_win.clrtoeol
|
114
|
+
|
115
|
+
Cryptum::UI.colorize(
|
116
|
+
ui_win: order_plan_details_win,
|
117
|
+
color: order_color,
|
118
|
+
style: style,
|
119
|
+
string: autotrade_ln2_details.ljust(col_just1, ' ')
|
120
|
+
)
|
121
|
+
|
122
|
+
# ROW 5
|
123
|
+
out_line_no += 1
|
124
|
+
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
125
|
+
order_plan_details_win.clrtoeol
|
126
|
+
|
127
|
+
Cryptum::UI.colorize(
|
128
|
+
ui_win: order_plan_details_win,
|
129
|
+
color: order_color,
|
130
|
+
style: style,
|
131
|
+
string: slice_alloc_ln1_details.ljust(col_just1, ' ')
|
132
|
+
)
|
133
|
+
|
134
|
+
# ROW 6
|
135
|
+
out_line_no += 1
|
136
|
+
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
137
|
+
order_plan_details_win.clrtoeol
|
138
|
+
|
139
|
+
Cryptum::UI.colorize(
|
140
|
+
ui_win: order_plan_details_win,
|
141
|
+
color: order_color,
|
142
|
+
style: style,
|
143
|
+
string: slice_alloc_ln2_details.ljust(col_just1, ' ')
|
144
|
+
)
|
145
|
+
|
146
|
+
# ROW 7
|
147
|
+
out_line_no += 1
|
148
|
+
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
149
|
+
order_plan_details_win.clrtoeol
|
150
|
+
|
151
|
+
Cryptum::UI.colorize(
|
152
|
+
ui_win: order_plan_details_win,
|
153
|
+
color: order_color,
|
154
|
+
style: style,
|
155
|
+
string: profit_ln1_details.ljust(col_just1, ' ')
|
156
|
+
)
|
157
|
+
|
158
|
+
# ROW 8
|
159
|
+
out_line_no += 1
|
160
|
+
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
161
|
+
order_plan_details_win.clrtoeol
|
162
|
+
|
163
|
+
Cryptum::UI.colorize(
|
164
|
+
ui_win: order_plan_details_win,
|
165
|
+
color: order_color,
|
166
|
+
style: style,
|
167
|
+
string: profit_ln2_details.ljust(col_just1, ' ')
|
168
|
+
)
|
169
|
+
|
170
|
+
# ROW 9
|
171
|
+
out_line_no += 1
|
172
|
+
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
173
|
+
order_plan_details_win.clrtoeol
|
174
|
+
|
175
|
+
Cryptum::UI.colorize(
|
176
|
+
ui_win: order_plan_details_win,
|
177
|
+
color: order_color,
|
178
|
+
style: style,
|
179
|
+
string: profit_ln3_details.ljust(col_just1, ' ')
|
180
|
+
)
|
181
|
+
|
182
|
+
# Clear to OK ROW
|
183
|
+
ok_row = 9
|
184
|
+
out_line_no += 1
|
185
|
+
to_ok_row = ok_row - 1
|
186
|
+
(out_line_no..to_ok_row).each do |clr_line|
|
187
|
+
order_plan_details_win.setpos(clr_line, Cryptum::UI.col_first)
|
188
|
+
Cryptum::UI.colorize(
|
189
|
+
ui_win: order_plan_details_win,
|
190
|
+
color: order_color,
|
191
|
+
style: :normal,
|
192
|
+
string: ''.ljust(col_just1, ' ')
|
193
|
+
)
|
194
|
+
end
|
195
|
+
|
196
|
+
# OK ROW
|
197
|
+
out_line_no = ok_row
|
198
|
+
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
199
|
+
order_plan_details_win.clrtoeol
|
200
|
+
Cryptum::UI.colorize(
|
201
|
+
ui_win: order_plan_details_win,
|
202
|
+
color: order_color,
|
203
|
+
string: ''.ljust(col_just1, ' ')
|
204
|
+
)
|
205
|
+
|
206
|
+
header_str = '- OK -'
|
207
|
+
order_plan_details_win.setpos(
|
208
|
+
out_line_no,
|
209
|
+
Cryptum::UI.col_center(str: header_str)
|
210
|
+
)
|
211
|
+
|
212
|
+
Cryptum::UI.colorize(
|
213
|
+
ui_win: order_plan_details_win,
|
214
|
+
color: order_color,
|
215
|
+
style: :reverse,
|
216
|
+
string: header_str
|
217
|
+
)
|
218
|
+
|
219
|
+
order_plan_details_win.refresh
|
220
|
+
|
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
|
230
|
+
end
|
231
|
+
|
232
|
+
# Display Usage for this Module
|
233
|
+
|
234
|
+
public_class_method def self.help
|
235
|
+
puts "USAGE:
|
236
|
+
#{self}.refresh(
|
237
|
+
)
|
238
|
+
"
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cryptum
|
4
|
+
module UI
|
5
|
+
# This plugin is used to Refresh the Cryptum Status Section UI
|
6
|
+
module Order
|
7
|
+
module Timer
|
8
|
+
# Supported Method Parameters::
|
9
|
+
# Cryptum::UI::Timer.refresh(
|
10
|
+
# )
|
11
|
+
|
12
|
+
public_class_method def self.refresh(opts = {})
|
13
|
+
option_choice = opts[:option_choice]
|
14
|
+
event_history = opts[:event_history]
|
15
|
+
order_timer_win = opts[:order_timer_win]
|
16
|
+
indicator_status = opts[:indicator_status]
|
17
|
+
|
18
|
+
last_trend_reset_time = event_history.order_book[:last_trend_reset]
|
19
|
+
last_order_exec_time = event_history.order_book[:last_order_exec]
|
20
|
+
|
21
|
+
# Market Trend Reset Timer
|
22
|
+
time_between_trend_reset = option_choice.market_trend_reset
|
23
|
+
trend_timer_begin = Time.parse(last_trend_reset_time)
|
24
|
+
trend_timer_end = trend_timer_begin + time_between_trend_reset
|
25
|
+
trend_time_remaining = trend_timer_end - Time.now
|
26
|
+
|
27
|
+
if trend_time_remaining.zero? || trend_time_remaining.negative?
|
28
|
+
event_history.order_book[:market_trend][:buy] = 0
|
29
|
+
event_history.order_book[:market_trend][:sell] = 0
|
30
|
+
event_history.order_book[:last_trend_reset] = Time.now.strftime(
|
31
|
+
'%Y-%m-%d %H:%M:%S.%N%z'
|
32
|
+
)
|
33
|
+
|
34
|
+
last_trend_reset_time = event_history.order_book[:last_trend_reset]
|
35
|
+
time_between_trend_reset = option_choice.market_trend_reset
|
36
|
+
trend_timer_begin = Time.parse(last_trend_reset_time)
|
37
|
+
trend_timer_end = trend_timer_begin + time_between_trend_reset
|
38
|
+
trend_time_remaining = trend_timer_end - Time.now
|
39
|
+
end
|
40
|
+
|
41
|
+
trend_countdown = Cryptum.beautify_large_number(
|
42
|
+
value: format('%0.2f', trend_time_remaining)
|
43
|
+
)
|
44
|
+
|
45
|
+
# Market Trend Reset Timer
|
46
|
+
time_between_order_exec = event_history.time_between_orders
|
47
|
+
time_between_order_exec_out = Cryptum.beautify_large_number(
|
48
|
+
value: format('%0.2f', time_between_order_exec)
|
49
|
+
)
|
50
|
+
order_begin_time = Time.parse(last_order_exec_time)
|
51
|
+
order_end_time = order_begin_time + time_between_order_exec
|
52
|
+
order_exec_time_remaining = order_end_time - Time.now
|
53
|
+
order_countdown = Cryptum.beautify_large_number(
|
54
|
+
value: format('%0.2f', order_exec_time_remaining)
|
55
|
+
)
|
56
|
+
|
57
|
+
buy_total = event_history.order_book[:market_trend][:buy].to_i
|
58
|
+
sell_total = event_history.order_book[:market_trend][:sell].to_i
|
59
|
+
|
60
|
+
color = :white
|
61
|
+
color = indicator_status.market_trend[:color] if indicator_status.market_trend
|
62
|
+
case color
|
63
|
+
when :green
|
64
|
+
# TODO: add condition to check if open sell orders exist.
|
65
|
+
# If so intent should be something like, "- SEE ORDER HISTORY -"
|
66
|
+
# Otherwise, intent should be something like, "- WAIT FOR MARKET TREND SHIFT -"
|
67
|
+
intent = "- #{Cryptum.down_arrow} SEE ORDER HISTORY #{Cryptum.down_arrow} -"
|
68
|
+
else
|
69
|
+
speed = 'FAST'
|
70
|
+
speed = 'SLOW' if buy_total >= sell_total
|
71
|
+
|
72
|
+
intent = "- #{speed} BUY: #{order_countdown} of #{time_between_order_exec_out} -"
|
73
|
+
intent = '- BUYING PAUSED -' if event_history.red_pill
|
74
|
+
end
|
75
|
+
|
76
|
+
# Have a Clock
|
77
|
+
clock = Time.now.strftime('%Y-%m-%d %H:%M:%S%z')
|
78
|
+
|
79
|
+
# UI
|
80
|
+
col_just4 = (Curses.cols - Cryptum::UI.col_fourth) - 1
|
81
|
+
|
82
|
+
# ROW 1
|
83
|
+
# COLUMN 1
|
84
|
+
out_line_no = 0
|
85
|
+
order_timer_win.setpos(out_line_no, Cryptum::UI.col_first)
|
86
|
+
order_timer_win.clrtoeol
|
87
|
+
Cryptum::UI.colorize(
|
88
|
+
ui_win: order_timer_win,
|
89
|
+
color: :white,
|
90
|
+
style: :bold,
|
91
|
+
string: "#{option_choice.market_trend_reset_label} M. Trend Rst: #{trend_countdown}"
|
92
|
+
)
|
93
|
+
|
94
|
+
# COLUMN 2
|
95
|
+
order_timer_win.setpos(
|
96
|
+
out_line_no,
|
97
|
+
Cryptum::UI.col_center(str: intent)
|
98
|
+
)
|
99
|
+
Cryptum::UI.colorize(
|
100
|
+
ui_win: order_timer_win,
|
101
|
+
color: :white,
|
102
|
+
style: :bold,
|
103
|
+
string: intent
|
104
|
+
)
|
105
|
+
|
106
|
+
# COLUMN 3
|
107
|
+
order_timer_win.setpos(out_line_no, Cryptum::UI.col_fourth)
|
108
|
+
Cryptum::UI.colorize(
|
109
|
+
ui_win: order_timer_win,
|
110
|
+
color: :white,
|
111
|
+
style: :bold,
|
112
|
+
string: clock.rjust(col_just4)
|
113
|
+
)
|
114
|
+
|
115
|
+
order_timer_win.refresh
|
116
|
+
|
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
|
127
|
+
end
|
128
|
+
|
129
|
+
# Display Usage for this Module
|
130
|
+
|
131
|
+
public_class_method def self.help
|
132
|
+
puts "USAGE:
|
133
|
+
#{self}.refresh(
|
134
|
+
)
|
135
|
+
"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cryptum
|
4
|
+
# Cryptum::UI Module used for Presenting the
|
5
|
+
# Cryptum Curses Interface
|
6
|
+
module UI
|
7
|
+
module Order
|
8
|
+
require 'cryptum/ui/order/execute'
|
9
|
+
require 'cryptum/ui/order/execute_details'
|
10
|
+
require 'cryptum/ui/order/plan'
|
11
|
+
require 'cryptum/ui/order/plan_details'
|
12
|
+
require 'cryptum/ui/order/timer'
|
13
|
+
|
14
|
+
# Display a List of Every UI Module
|
15
|
+
|
16
|
+
public_class_method def self.help
|
17
|
+
constants.sort
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/cryptum/ui/portfolio.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'logger'
|
4
|
-
|
5
3
|
module Cryptum
|
6
4
|
# This plugin is used to Refresh the Cryptum console UI
|
7
5
|
module UI
|
@@ -201,7 +199,11 @@ module Cryptum
|
|
201
199
|
event_history
|
202
200
|
rescue Interrupt
|
203
201
|
# Exit Gracefully if CTRL+C is Pressed During Session
|
204
|
-
Cryptum.
|
202
|
+
Cryptum::UI::Exit.gracefully(
|
203
|
+
which_self: self,
|
204
|
+
event_history: event_history,
|
205
|
+
option_choice: option_choice
|
206
|
+
)
|
205
207
|
rescue StandardError => e
|
206
208
|
raise e
|
207
209
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'logger'
|
4
|
-
|
5
3
|
module Cryptum
|
6
4
|
# This plugin is used to Refresh the Cryptum console UI
|
7
5
|
module UI
|
@@ -89,7 +87,7 @@ module Cryptum
|
|
89
87
|
indicator_status
|
90
88
|
rescue Interrupt
|
91
89
|
# Exit Gracefully if CTRL+C is Pressed During Session
|
92
|
-
Cryptum.
|
90
|
+
Cryptum::UI::Exit.gracefully(which_self: self)
|
93
91
|
rescue StandardError => e
|
94
92
|
raise e
|
95
93
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'logger'
|
4
|
-
|
5
3
|
module Cryptum
|
6
4
|
module UI
|
7
5
|
# This Class is Used by Cryptum::Event to
|
@@ -101,7 +99,7 @@ module Cryptum
|
|
101
99
|
end
|
102
100
|
rescue Interrupt
|
103
101
|
# Exit Gracefully if CTRL+C is Pressed During Session
|
104
|
-
Cryptum.
|
102
|
+
Cryptum::UI::Exit.gracefully(which_self: self)
|
105
103
|
rescue StandardError => e
|
106
104
|
# Produce a Stacktrace for anything else
|
107
105
|
Curses.close_screen
|
data/lib/cryptum/ui/ticker.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'logger'
|
4
|
-
|
5
3
|
module Cryptum
|
6
4
|
# This plugin is used to Refresh the Cryptum console UI
|
7
5
|
module UI
|
@@ -299,7 +297,10 @@ module Cryptum
|
|
299
297
|
event_history
|
300
298
|
rescue Interrupt
|
301
299
|
# Exit Gracefully if CTRL+C is Pressed During Session
|
302
|
-
Cryptum.
|
300
|
+
Cryptum::UI::Exit.gracefully(
|
301
|
+
which_self: self,
|
302
|
+
event_history: event_history
|
303
|
+
)
|
303
304
|
rescue StandardError => e
|
304
305
|
raise e
|
305
306
|
end
|
data/lib/cryptum/ui.rb
CHANGED
@@ -1,24 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'curses'
|
4
|
-
require 'time'
|
5
|
-
|
6
3
|
module Cryptum
|
7
4
|
# Cryptum::UI Module used for Presenting the
|
8
5
|
# Cryptum Curses Interface
|
9
6
|
module UI
|
7
|
+
require 'cryptum/ui/command'
|
8
|
+
require 'cryptum/ui/exit'
|
10
9
|
require 'cryptum/ui/key_press_event'
|
11
|
-
require 'cryptum/ui/terminal_window'
|
12
|
-
require 'cryptum/ui/ticker'
|
13
|
-
require 'cryptum/ui/portfolio'
|
14
|
-
require 'cryptum/ui/order_plan'
|
15
|
-
require 'cryptum/ui/order_plan_details'
|
16
|
-
require 'cryptum/ui/order_timer'
|
17
10
|
require 'cryptum/ui/market_trend'
|
11
|
+
require 'cryptum/ui/matrix'
|
12
|
+
require 'cryptum/ui/order'
|
13
|
+
require 'cryptum/ui/portfolio'
|
18
14
|
require 'cryptum/ui/signal_engine'
|
19
|
-
require 'cryptum/ui/
|
20
|
-
require 'cryptum/ui/
|
21
|
-
require 'cryptum/ui/command'
|
15
|
+
require 'cryptum/ui/terminal_window'
|
16
|
+
require 'cryptum/ui/ticker'
|
22
17
|
|
23
18
|
# Initialize the UI
|
24
19
|
public_class_method def self.init
|
@@ -53,7 +48,7 @@ module Cryptum
|
|
53
48
|
Cryptum::UI::TerminalWindow.new
|
54
49
|
rescue Interrupt
|
55
50
|
# Exit Gracefully if CTRL+C is Pressed During Session
|
56
|
-
Cryptum.
|
51
|
+
Cryptum::UI::Exit.gracefully(which_self: self)
|
57
52
|
rescue StandardError => e
|
58
53
|
# Produce a Stacktrace for anything else
|
59
54
|
Curses.close_screen
|
@@ -78,7 +73,7 @@ module Cryptum
|
|
78
73
|
window
|
79
74
|
rescue Interrupt
|
80
75
|
# Exit Gracefully if CTRL+C is Pressed During Session
|
81
|
-
Cryptum.
|
76
|
+
Cryptum::UI::Exit.gracefully(which_self: self)
|
82
77
|
rescue StandardError => e
|
83
78
|
# Produce a Stacktrace for anything else
|
84
79
|
Curses.close_screen
|
@@ -104,7 +99,7 @@ module Cryptum
|
|
104
99
|
)
|
105
100
|
rescue Interrupt
|
106
101
|
# Exit Gracefully if CTRL+C is Pressed During Session
|
107
|
-
Cryptum.
|
102
|
+
Cryptum::UI::Exit.gracefully(which_self: self)
|
108
103
|
rescue StandardError => e
|
109
104
|
# Produce a Stacktrace for anything else
|
110
105
|
Curses.close_screen
|
@@ -202,7 +197,7 @@ module Cryptum
|
|
202
197
|
end
|
203
198
|
rescue Interrupt
|
204
199
|
# Exit Gracefully if CTRL+C is Pressed During Session
|
205
|
-
Cryptum.
|
200
|
+
Cryptum::UI::Exit.gracefully(which_self: self)
|
206
201
|
rescue StandardError => e
|
207
202
|
# Produce a Stacktrace for anything else
|
208
203
|
Curses.close_screen
|
@@ -217,7 +212,7 @@ module Cryptum
|
|
217
212
|
(Curses.cols / 2) - str_divided_by_two
|
218
213
|
rescue Interrupt
|
219
214
|
# Exit Gracefully if CTRL+C is Pressed During Session
|
220
|
-
Cryptum.
|
215
|
+
Cryptum::UI::Exit.gracefully(which_self: self)
|
221
216
|
rescue StandardError => e
|
222
217
|
# Produce a Stacktrace for anything else
|
223
218
|
Curses.close_screen
|
@@ -228,7 +223,7 @@ module Cryptum
|
|
228
223
|
0
|
229
224
|
rescue Interrupt
|
230
225
|
# Exit Gracefully if CTRL+C is Pressed During Session
|
231
|
-
Cryptum.
|
226
|
+
Cryptum::UI::Exit.gracefully(which_self: self)
|
232
227
|
rescue StandardError => e
|
233
228
|
# Produce a Stacktrace for anything else
|
234
229
|
Curses.close_screen
|
@@ -240,7 +235,7 @@ module Cryptum
|
|
240
235
|
(Curses.cols / 8) + 5
|
241
236
|
rescue Interrupt
|
242
237
|
# Exit Gracefully if CTRL+C is Pressed During Session
|
243
|
-
Cryptum.
|
238
|
+
Cryptum::UI::Exit.gracefully(which_self: self)
|
244
239
|
rescue StandardError => e
|
245
240
|
# Produce a Stacktrace for anything else
|
246
241
|
Curses.close_screen
|
@@ -252,7 +247,7 @@ module Cryptum
|
|
252
247
|
((Curses.cols / 8) * 3) + 2
|
253
248
|
rescue Interrupt
|
254
249
|
# Exit Gracefully if CTRL+C is Pressed During Session
|
255
|
-
Cryptum.
|
250
|
+
Cryptum::UI::Exit.gracefully(which_self: self)
|
256
251
|
rescue StandardError => e
|
257
252
|
# Produce a Stacktrace for anything else
|
258
253
|
Curses.close_screen
|
@@ -264,7 +259,7 @@ module Cryptum
|
|
264
259
|
((Curses.cols / 4) * 3) - 3
|
265
260
|
rescue Interrupt
|
266
261
|
# Exit Gracefully if CTRL+C is Pressed During Session
|
267
|
-
Cryptum.
|
262
|
+
Cryptum::UI::Exit.gracefully(which_self: self)
|
268
263
|
rescue StandardError => e
|
269
264
|
# Produce a Stacktrace for anything else
|
270
265
|
Curses.close_screen
|
@@ -327,7 +322,7 @@ module Cryptum
|
|
327
322
|
key_press_event
|
328
323
|
rescue Interrupt
|
329
324
|
# Exit Gracefully if CTRL+C is Pressed During Session
|
330
|
-
Cryptum.
|
325
|
+
Cryptum::UI::Exit.gracefully(which_self: self)
|
331
326
|
rescue StandardError => e
|
332
327
|
# Produce a Stacktrace for anything else
|
333
328
|
Curses.close_screen
|
data/lib/cryptum/version.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'faye/websocket'
|
4
|
-
require 'websocket/extensions'
|
5
|
-
require 'permessage_deflate'
|
6
|
-
|
7
3
|
module Cryptum
|
8
4
|
# This plugin is used to Establish a Web
|
9
5
|
# Socket Connection with Coinbase
|
@@ -54,7 +50,7 @@ module Cryptum
|
|
54
50
|
ws
|
55
51
|
rescue Interrupt
|
56
52
|
# Exit Gracefully if CTRL+C is Pressed During Session
|
57
|
-
Cryptum.
|
53
|
+
Cryptum::UI::Exit.gracefully(which_self: self)
|
58
54
|
rescue StandardError => e
|
59
55
|
raise e
|
60
56
|
end
|
@@ -96,7 +92,6 @@ module Cryptum
|
|
96
92
|
|
97
93
|
public_class_method def self.help
|
98
94
|
puts "USAGE:
|
99
|
-
logger = #{self}.create()
|
100
95
|
"
|
101
96
|
end
|
102
97
|
end
|
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eventmachine'
|
4
|
-
require 'json'
|
5
|
-
|
6
3
|
module Cryptum
|
7
4
|
# This plugin is used to Establish a Web
|
8
5
|
# Socket Connection with Coinbase
|
@@ -196,7 +193,7 @@ module Cryptum
|
|
196
193
|
end
|
197
194
|
|
198
195
|
EM.add_periodic_timer(delay_ms_cast_as_decimal) do
|
199
|
-
order_countdown = Cryptum::UI::
|
196
|
+
order_countdown = Cryptum::UI::Order::Timer.refresh(
|
200
197
|
option_choice: option_choice,
|
201
198
|
event_history: event_history,
|
202
199
|
order_timer_win: terminal_win.order_timer_section,
|
@@ -230,7 +227,7 @@ module Cryptum
|
|
230
227
|
terminal_win.key_press_event.key_r = true
|
231
228
|
# IMPORTANT:
|
232
229
|
# Wait for Order Plan recalculation to occur
|
233
|
-
# once Cryptum::UI::
|
230
|
+
# once Cryptum::UI::Order::Plan is refreshed
|
234
231
|
# in Cryptum::Event _BEFORE_ writing the order
|
235
232
|
# book to file.
|
236
233
|
end
|
@@ -255,7 +252,7 @@ module Cryptum
|
|
255
252
|
end
|
256
253
|
rescue Interrupt
|
257
254
|
# Exit Gracefully if CTRL+C is Pressed During Session
|
258
|
-
Cryptum.
|
255
|
+
Cryptum::UI::Exit.gracefully(
|
259
256
|
which_self: self,
|
260
257
|
event_history: event_history,
|
261
258
|
option_choice: option_choice,
|
@@ -268,7 +265,6 @@ module Cryptum
|
|
268
265
|
# Display Usage for this Module
|
269
266
|
public_class_method def self.help
|
270
267
|
puts "USAGE:
|
271
|
-
logger = #{self}.create()
|
272
268
|
"
|
273
269
|
end
|
274
270
|
end
|