cryptum 0.0.255 → 0.0.257
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_todo.yml +6 -6
- data/lib/cryptum/event/history.rb +18 -10
- data/lib/cryptum/ui/key_press_event.rb +2 -2
- data/lib/cryptum/ui/order_execution.rb +8 -6
- data/lib/cryptum/ui/order_plan.rb +8 -6
- data/lib/cryptum/ui/order_timer.rb +2 -6
- data/lib/cryptum/ui/ticker.rb +6 -3
- data/lib/cryptum/ui.rb +2 -2
- data/lib/cryptum/version.rb +1 -1
- data/lib/cryptum/web_sock/event_machine.rb +33 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 700e1a1a2785e98e2ba35546de12c8920716951d891439f37ddb67d44d11ac45
|
4
|
+
data.tar.gz: e0ba8ec4ce2dea089fe9e58aafc93258d02593029875636e20c0edee0f7a068d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81f138f0d93da609436879479b61fb59750b2b6c013a921df87de1bbb566bb86e0a38f37067ecc3e8d4409c43db3102596afe17910b3770dcadaad8d0c66c04c
|
7
|
+
data.tar.gz: a94ad89f104b2dab9d0cef42de733b0211271e9ef5bed7788949e203b3f44d85e859dd40c4598befb341bed192f336f8f50c4376f654f238ea9195545d3fcb45
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2022-12-01
|
3
|
+
# on 2022-12-01 19:02:17 UTC using RuboCop version 1.39.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -123,13 +123,13 @@ Lint/UselessAssignment:
|
|
123
123
|
# Offense count: 39
|
124
124
|
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
|
125
125
|
Metrics/AbcSize:
|
126
|
-
Max:
|
126
|
+
Max: 388
|
127
127
|
|
128
128
|
# Offense count: 7
|
129
129
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
|
130
130
|
# AllowedMethods: refine
|
131
131
|
Metrics/BlockLength:
|
132
|
-
Max:
|
132
|
+
Max: 135
|
133
133
|
|
134
134
|
# Offense count: 4
|
135
135
|
# Configuration parameters: CountBlocks.
|
@@ -144,7 +144,7 @@ Metrics/CyclomaticComplexity:
|
|
144
144
|
# Offense count: 56
|
145
145
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
|
146
146
|
Metrics/MethodLength:
|
147
|
-
Max:
|
147
|
+
Max: 362
|
148
148
|
|
149
149
|
# Offense count: 15
|
150
150
|
# Configuration parameters: CountComments, CountAsOne.
|
@@ -207,7 +207,7 @@ Style/RedundantReturn:
|
|
207
207
|
Exclude:
|
208
208
|
- 'lib/cryptum.rb'
|
209
209
|
|
210
|
-
# Offense count:
|
210
|
+
# Offense count: 4
|
211
211
|
# This cop supports safe autocorrection (--autocorrect).
|
212
212
|
Style/RedundantSelf:
|
213
213
|
Exclude:
|
@@ -244,7 +244,7 @@ Style/TrailingCommaInArrayLiteral:
|
|
244
244
|
Exclude:
|
245
245
|
- 'lib/cryptum/matrix.rb'
|
246
246
|
|
247
|
-
# Offense count:
|
247
|
+
# Offense count: 16
|
248
248
|
# This cop supports safe autocorrection (--autocorrect).
|
249
249
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
|
250
250
|
# URISchemes: http, https
|
@@ -25,10 +25,14 @@ module Cryptum
|
|
25
25
|
:time_between_orders_max,
|
26
26
|
:time_between_orders_min,
|
27
27
|
:time_between_orders_reset,
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
28
|
+
:order_plan_win_active,
|
29
|
+
:order_plan_index_offset,
|
30
|
+
:order_plan_max_rows_to_display,
|
31
|
+
:order_plan_row_to_select,
|
32
|
+
:order_execute_win_active,
|
33
|
+
:order_execute_index_offset,
|
34
|
+
:order_execute_max_rows_to_display,
|
35
|
+
:order_execute_row_to_select
|
32
36
|
|
33
37
|
def initialize(opts = {})
|
34
38
|
# option_choice = opts[:option_choice]
|
@@ -46,17 +50,21 @@ module Cryptum
|
|
46
50
|
self.reconnected = false
|
47
51
|
self.red_pill = false
|
48
52
|
self.reset_market_trend = false
|
49
|
-
self.
|
50
|
-
self.
|
51
|
-
self.
|
52
|
-
self.
|
53
|
+
self.order_plan_win_active = true
|
54
|
+
self.order_plan_index_offset = 0
|
55
|
+
self.order_plan_max_rows_to_display = 7
|
56
|
+
self.order_plan_row_to_select = self.order_plan_index_offset
|
57
|
+
self.order_execute_win_active = false
|
58
|
+
self.order_execute_index_offset = 0
|
59
|
+
self.order_execute_max_rows_to_display = 6
|
60
|
+
self.order_execute_row_to_select = self.order_execute_index_offset
|
53
61
|
|
54
62
|
# 10 minutes
|
55
63
|
self.time_between_orders = 600
|
56
64
|
self.time_between_orders_reset = self.time_between_orders
|
57
65
|
|
58
|
-
#
|
59
|
-
self.time_between_orders_max =
|
66
|
+
# 1 hour
|
67
|
+
self.time_between_orders_max = 3_600
|
60
68
|
|
61
69
|
# 5 seconds
|
62
70
|
self.time_between_orders_min = 5
|
@@ -377,7 +377,7 @@ module Cryptum
|
|
377
377
|
out_line_no = 0
|
378
378
|
line_color = :white
|
379
379
|
style = :bold
|
380
|
-
line_color = :red if event_history.
|
380
|
+
line_color = :red if event_history.order_execute_win_active
|
381
381
|
|
382
382
|
Cryptum::UI.line(
|
383
383
|
ui_win: order_execute_win,
|
@@ -417,18 +417,20 @@ module Cryptum
|
|
417
417
|
|
418
418
|
|
419
419
|
# ROWS 4-10
|
420
|
-
first_row = event_history.
|
421
|
-
last_row = first_row +
|
420
|
+
first_row = event_history.order_execute_index_offset
|
421
|
+
last_row = first_row + event_history.order_execute_max_rows_to_display
|
422
422
|
if last_row >= order_history_meta.length
|
423
423
|
last_row = order_history_meta.length - 1
|
424
|
-
first_row = last_row -
|
425
|
-
event_history.
|
424
|
+
first_row = last_row - event_history.order_execute_max_rows_to_display
|
425
|
+
event_history.order_execute_index_offset = first_row
|
426
426
|
end
|
427
427
|
|
428
428
|
order_history_meta.reverse[first_row..last_row].each do |meta|
|
429
429
|
out_line_no += 1
|
430
|
+
current_line = out_line_no - 3
|
431
|
+
|
430
432
|
style = :normal
|
431
|
-
style = :highlight if event_history.
|
433
|
+
style = :highlight if event_history.order_execute_row_to_select == current_line
|
432
434
|
risk_alloc_out = Cryptum.beautify_large_number(
|
433
435
|
value: meta[:risk_alloc]
|
434
436
|
)
|
@@ -201,7 +201,7 @@ module Cryptum
|
|
201
201
|
out_line_no = 0
|
202
202
|
line_color = :white
|
203
203
|
style = :bold
|
204
|
-
line_color = :red if event_history.
|
204
|
+
line_color = :red if event_history.order_plan_win_active
|
205
205
|
|
206
206
|
Cryptum::UI.line(
|
207
207
|
ui_win: order_plan_win,
|
@@ -317,18 +317,20 @@ module Cryptum
|
|
317
317
|
plan_color = :cyan if color == :red
|
318
318
|
plan_color = :green if color == :green
|
319
319
|
|
320
|
-
first_row = event_history.
|
321
|
-
last_row = first_row +
|
320
|
+
first_row = event_history.order_plan_index_offset
|
321
|
+
last_row = first_row + event_history.order_plan_max_rows_to_display
|
322
322
|
if last_row >= order_plan.length
|
323
323
|
last_row = order_plan.length - 1
|
324
|
-
first_row = last_row -
|
325
|
-
event_history.
|
324
|
+
first_row = last_row - event_history.order_plan_max_rows_to_display
|
325
|
+
event_history.order_plan_index_offset = first_row
|
326
326
|
end
|
327
327
|
|
328
328
|
order_plan[first_row..last_row].each do |order|
|
329
329
|
out_line_no += 1
|
330
|
+
current_line = out_line_no - 3
|
331
|
+
|
330
332
|
style = :normal
|
331
|
-
style = :highlight if event_history.
|
333
|
+
style = :highlight if event_history.order_plan_row_to_select == current_line
|
332
334
|
fiat_avail_out = Cryptum.beautify_large_number(
|
333
335
|
value: order[:fiat_available]
|
334
336
|
)
|
@@ -55,14 +55,10 @@ module Cryptum
|
|
55
55
|
# Otherwise, intent should be something like, "- WAIT FOR MARKET TREND SHIFT -"
|
56
56
|
intent = "- SEE LIMIT SELL ORDERS -"
|
57
57
|
else
|
58
|
-
trend = 'BEAR'
|
59
58
|
speed = 'FAST'
|
60
|
-
if event_history.bullish_trend
|
61
|
-
trend = 'BULL'
|
62
|
-
speed = 'SLOW'
|
63
|
-
end
|
59
|
+
speed = 'SLOW' if event_history.bullish_trend
|
64
60
|
|
65
|
-
intent = "
|
61
|
+
intent = "- #{speed} BUY: #{order_countdown} of #{time_between_order_exec_out} -"
|
66
62
|
intent = '- BUYING PAUSED -' if event_history.red_pill
|
67
63
|
end
|
68
64
|
|
data/lib/cryptum/ui/ticker.rb
CHANGED
@@ -98,14 +98,17 @@ module Cryptum
|
|
98
98
|
)
|
99
99
|
if margin_percent_open_24h.positive?
|
100
100
|
margin_percent_open_24h_color = :green
|
101
|
-
|
101
|
+
trend = 'BULL'
|
102
|
+
margin_percent_open_24h_out = "#{Cryptum.up_arrow} #{beautify_margin_percent_open_24h}% (#{trend})"
|
102
103
|
elsif margin_percent_open_24h.negative?
|
103
104
|
# Space removed to account for negative number.
|
104
105
|
margin_percent_open_24h_color = :red
|
105
|
-
|
106
|
+
trend = 'BEAR'
|
107
|
+
margin_percent_open_24h_out = "#{Cryptum.down_arrow}#{beautify_margin_percent_open_24h}% (#{trend})"
|
106
108
|
else
|
109
|
+
trend = 'FLAT'
|
107
110
|
margin_percent_open_24h_color = :yellow
|
108
|
-
margin_percent_open_24h_out = "#{Cryptum.flat_arrow} #{beautify_margin_percent_open_24h}%"
|
111
|
+
margin_percent_open_24h_out = "#{Cryptum.flat_arrow} #{beautify_margin_percent_open_24h}% (#{trend})"
|
109
112
|
end
|
110
113
|
|
111
114
|
current_time_out = Time.now.strftime('%Y-%m-%d %H:%M:%S%z')
|
data/lib/cryptum/ui.rb
CHANGED
@@ -301,8 +301,8 @@ module Cryptum
|
|
301
301
|
|
302
302
|
# What a hack to detect up / down arrow key presses.
|
303
303
|
key_press_event.key_ansi = true if key_press_event.key_esc && key_press == '['
|
304
|
-
key_press_event.
|
305
|
-
key_press_event.
|
304
|
+
key_press_event.key_up_arrow = true if key_press_event.key_ansi && key_press == 'A'
|
305
|
+
key_press_event.key_down_arrow = true if key_press_event.key_ansi && key_press == 'B'
|
306
306
|
|
307
307
|
key_press_event
|
308
308
|
rescue Interrupt
|
data/lib/cryptum/version.rb
CHANGED
@@ -129,40 +129,58 @@ module Cryptum
|
|
129
129
|
end
|
130
130
|
|
131
131
|
# Scroll Down Order Plan / Order Execution Window Panes
|
132
|
-
if terminal_win.key_press_event.
|
132
|
+
if terminal_win.key_press_event.key_down_arrow
|
133
133
|
terminal_win.key_press_event.key_ansi = false
|
134
134
|
terminal_win.key_press_event.key_esc = false
|
135
|
-
terminal_win.key_press_event.
|
135
|
+
terminal_win.key_press_event.key_down_arrow = false
|
136
|
+
if event_history.order_plan_win_active
|
137
|
+
order_plan_max_row_index = event_history.order_plan_max_rows_to_display - 1
|
138
|
+
event_history.order_plan_row_to_select += 1
|
139
|
+
event_history.order_plan_index_offset += 1 if event_history.order_plan_row_to_select > order_plan_max_row_index
|
140
|
+
event_history.order_plan_row_to_select = order_plan_max_row_index if event_history.order_plan_row_to_select > order_plan_max_row_index
|
141
|
+
end
|
136
142
|
|
137
|
-
|
143
|
+
if event_history.order_execute_win_active
|
144
|
+
order_execute_max_row_index = event_history.order_execute_max_rows_to_display - 1
|
145
|
+
event_history.order_execute_row_to_select += 1
|
146
|
+
event_history.order_execute_index_offset += 1 if event_history.order_execute_row_to_select > order_execute_max_row_index
|
147
|
+
event_history.order_execute_row_to_select = order_execute_max_row_index if event_history.order_execute_row_to_select > order_execute_max_row_index
|
138
148
|
|
139
|
-
|
149
|
+
end
|
140
150
|
end
|
141
151
|
|
142
152
|
# TAB through Order Plan / Order Execution Window Panes
|
143
153
|
if terminal_win.key_press_event.key_tab
|
144
154
|
terminal_win.key_press_event.key_tab = false
|
145
155
|
|
146
|
-
if event_history.
|
147
|
-
event_history.
|
148
|
-
event_history.
|
156
|
+
if event_history.order_plan_win_active
|
157
|
+
event_history.order_plan_win_active = false
|
158
|
+
event_history.order_execute_win_active = true
|
149
159
|
else
|
150
|
-
event_history.
|
151
|
-
event_history.
|
160
|
+
event_history.order_plan_win_active = true
|
161
|
+
event_history.order_execute_win_active = false
|
152
162
|
end
|
153
163
|
end
|
154
164
|
|
155
165
|
# Scroll Up Order Plan / Order Execution Window Panes
|
156
|
-
if terminal_win.key_press_event.
|
166
|
+
if terminal_win.key_press_event.key_up_arrow
|
157
167
|
terminal_win.key_press_event.key_ansi = false
|
158
168
|
terminal_win.key_press_event.key_esc = false
|
159
|
-
terminal_win.key_press_event.
|
169
|
+
terminal_win.key_press_event.key_up_arrow = false
|
160
170
|
|
161
|
-
|
162
|
-
|
171
|
+
if event_history.order_plan_win_active
|
172
|
+
event_history.order_plan_row_to_select -= 1
|
173
|
+
event_history.order_plan_index_offset -= 1 if event_history.order_plan_row_to_select.negative?
|
174
|
+
event_history.order_plan_index_offset = 0 if event_history.order_plan_index_offset.negative?
|
175
|
+
event_history.order_plan_row_to_select = 0 if event_history.order_plan_row_to_select.negative?
|
176
|
+
end
|
163
177
|
|
164
|
-
|
165
|
-
|
178
|
+
if event_history.order_execute_win_active
|
179
|
+
event_history.order_execute_row_to_select -= 1
|
180
|
+
event_history.order_execute_index_offset -= 1 if event_history.order_execute_row_to_select.negative?
|
181
|
+
event_history.order_execute_index_offset = 0 if event_history.order_execute_index_offset.negative?
|
182
|
+
event_history.order_execute_row_to_select = 0 if event_history.order_execute_row_to_select.negative?
|
183
|
+
end
|
166
184
|
end
|
167
185
|
end
|
168
186
|
|