cryptum 0.0.258 → 0.0.260
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +17 -9
- data/lib/cryptum/event/history.rb +2 -1
- data/lib/cryptum/option.rb +10 -4
- data/lib/cryptum/order_book/market_trend.rb +6 -2
- data/lib/cryptum/ui/order_execution.rb +47 -21
- data/lib/cryptum/ui/order_plan.rb +47 -21
- data/lib/cryptum/ui/order_timer.rb +5 -2
- data/lib/cryptum/ui/terminal_window.rb +2 -2
- data/lib/cryptum/version.rb +1 -1
- data/lib/cryptum/web_sock/event_machine.rb +4 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d516fc49952990a6873f6e2533dbc7853cc5a7b759bd36ecc9146635efd19e5
|
4
|
+
data.tar.gz: af1d4ff1fdefc57021edb8894a54c932d1e28618b7fd7001eea8b73ef22fd7ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87b2644569e9931c657c9788fd4f8de94ad3ad4f79b0101db8c8a457fb243f3762db38cf5af780ad47e853c866bf675cef479569cc9782a0f9706bf1d73b7500
|
7
|
+
data.tar.gz: db4817a4d481ec036126f5e7d69f4bc5d186c0eb0d9def78e2a2addcf08e86ab2907b3199ffd945ee564ed6e9a47f098d5a6ada396cc4db69e5e4f1a2cfdd7f3
|
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-
|
3
|
+
# on 2022-12-02 18:49:14 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
|
@@ -35,12 +35,11 @@ Layout/EmptyLineAfterGuardClause:
|
|
35
35
|
- 'lib/cryptum/order_book/market_trend.rb'
|
36
36
|
- 'lib/cryptum/ui/order_execution.rb'
|
37
37
|
|
38
|
-
# Offense count:
|
38
|
+
# Offense count: 1
|
39
39
|
# This cop supports safe autocorrection (--autocorrect).
|
40
40
|
Layout/EmptyLines:
|
41
41
|
Exclude:
|
42
42
|
- 'lib/cryptum/api.rb'
|
43
|
-
- 'lib/cryptum/ui/order_execution.rb'
|
44
43
|
|
45
44
|
# Offense count: 1
|
46
45
|
# This cop supports safe autocorrection (--autocorrect).
|
@@ -91,7 +90,7 @@ Layout/SpaceAroundOperators:
|
|
91
90
|
Exclude:
|
92
91
|
- 'lib/cryptum/ui/order_plan.rb'
|
93
92
|
|
94
|
-
# Offense count:
|
93
|
+
# Offense count: 13
|
95
94
|
# This cop supports safe autocorrection (--autocorrect).
|
96
95
|
# Configuration parameters: AllowInHeredoc.
|
97
96
|
Layout/TrailingWhitespace:
|
@@ -103,7 +102,7 @@ Layout/TrailingWhitespace:
|
|
103
102
|
- 'lib/cryptum/ui/order_plan.rb'
|
104
103
|
- 'lib/cryptum/ui/order_timer.rb'
|
105
104
|
|
106
|
-
# Offense count:
|
105
|
+
# Offense count: 54
|
107
106
|
Lint/UselessAssignment:
|
108
107
|
Exclude:
|
109
108
|
- 'bin/cryptum-forecast'
|
@@ -124,13 +123,13 @@ Lint/UselessAssignment:
|
|
124
123
|
# Offense count: 39
|
125
124
|
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
|
126
125
|
Metrics/AbcSize:
|
127
|
-
Max:
|
126
|
+
Max: 401
|
128
127
|
|
129
128
|
# Offense count: 7
|
130
129
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
|
131
130
|
# AllowedMethods: refine
|
132
131
|
Metrics/BlockLength:
|
133
|
-
Max:
|
132
|
+
Max: 139
|
134
133
|
|
135
134
|
# Offense count: 4
|
136
135
|
# Configuration parameters: CountBlocks.
|
@@ -145,7 +144,7 @@ Metrics/CyclomaticComplexity:
|
|
145
144
|
# Offense count: 56
|
146
145
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
|
147
146
|
Metrics/MethodLength:
|
148
|
-
Max:
|
147
|
+
Max: 391
|
149
148
|
|
150
149
|
# Offense count: 15
|
151
150
|
# Configuration parameters: CountComments, CountAsOne.
|
@@ -157,6 +156,14 @@ Metrics/ModuleLength:
|
|
157
156
|
Metrics/PerceivedComplexity:
|
158
157
|
Max: 75
|
159
158
|
|
159
|
+
# Offense count: 1
|
160
|
+
# This cop supports safe autocorrection (--autocorrect).
|
161
|
+
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
|
162
|
+
# SupportedStyles: assign_to_condition, assign_inside_condition
|
163
|
+
Style/ConditionalAssignment:
|
164
|
+
Exclude:
|
165
|
+
- 'lib/cryptum/option.rb'
|
166
|
+
|
160
167
|
# Offense count: 1
|
161
168
|
# Configuration parameters: AllowedConstants.
|
162
169
|
Style/Documentation:
|
@@ -214,12 +221,13 @@ Style/StringChars:
|
|
214
221
|
Exclude:
|
215
222
|
- 'lib/cryptum.rb'
|
216
223
|
|
217
|
-
# Offense count:
|
224
|
+
# Offense count: 3
|
218
225
|
# This cop supports safe autocorrection (--autocorrect).
|
219
226
|
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
220
227
|
# SupportedStyles: single_quotes, double_quotes
|
221
228
|
Style/StringLiterals:
|
222
229
|
Exclude:
|
230
|
+
- 'lib/cryptum/ui/order_execution.rb'
|
223
231
|
- 'lib/cryptum/ui/order_timer.rb'
|
224
232
|
- 'lib/cryptum/ui/portfolio.rb'
|
225
233
|
|
@@ -50,13 +50,14 @@ module Cryptum
|
|
50
50
|
self.red_pill = false
|
51
51
|
self.order_plan_win_active = true
|
52
52
|
self.order_plan_index_offset = 0
|
53
|
-
self.order_plan_max_rows_to_display =
|
53
|
+
self.order_plan_max_rows_to_display = 6
|
54
54
|
self.order_plan_row_to_select = order_plan_index_offset
|
55
55
|
self.order_execute_win_active = false
|
56
56
|
self.order_execute_index_offset = 0
|
57
57
|
self.order_execute_max_rows_to_display = 6
|
58
58
|
self.order_execute_row_to_select = order_execute_index_offset
|
59
59
|
|
60
|
+
# TODO: Implement market_trend_reset / 144
|
60
61
|
# Default = 10 minutes
|
61
62
|
self.time_between_orders = 600
|
62
63
|
self.time_between_orders_reset = time_between_orders
|
data/lib/cryptum/option.rb
CHANGED
@@ -95,10 +95,16 @@ module Cryptum
|
|
95
95
|
reason = :market_trend_reset
|
96
96
|
end
|
97
97
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
98
|
+
case option_choice.market_trend_reset
|
99
|
+
when 86_400
|
100
|
+
option_choice.market_trend_reset_label = 'D'
|
101
|
+
when 3_600
|
102
|
+
option_choice.market_trend_reset_label = '1h'
|
103
|
+
when 60
|
104
|
+
option_choice.market_trend_reset_label = '1m'
|
105
|
+
else
|
106
|
+
option_choice.market_trend_reset_label = option_choice.market_trend_reset
|
107
|
+
end
|
102
108
|
|
103
109
|
if usage
|
104
110
|
case reason
|
@@ -33,12 +33,16 @@ module Cryptum
|
|
33
33
|
|
34
34
|
# order_difference = 0
|
35
35
|
if buy_total > sell_total
|
36
|
-
order_difference =
|
36
|
+
order_difference = Cryptum.beautify_large_number(
|
37
|
+
value: buy_total - sell_total
|
38
|
+
).to_i
|
37
39
|
indicator_hash[:color] = :green
|
38
40
|
indicator_hash[:ui] = "BUYS UP BY #{order_difference}"
|
39
41
|
indicator_hash[:status] = "B#{Cryptum.up_arrow}"
|
40
42
|
elsif buy_total < sell_total
|
41
|
-
order_difference =
|
43
|
+
order_difference = Cryptum.beautify_large_number(
|
44
|
+
value: sell_total - buy_total
|
45
|
+
).to_i
|
42
46
|
indicator_hash[:color] = :red
|
43
47
|
indicator_hash[:ui] = "SELLS UP BY #{order_difference}"
|
44
48
|
indicator_hash[:status] = "S#{Cryptum.up_arrow}"
|
@@ -367,6 +367,7 @@ module Cryptum
|
|
367
367
|
# UI
|
368
368
|
col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
|
369
369
|
col_just3 = (Curses.cols - Cryptum::UI.col_third) - 1
|
370
|
+
col_just4 = Curses.cols - Cryptum::UI.col_fourth
|
370
371
|
|
371
372
|
Cryptum::UI.detect_key_press_in_ui(
|
372
373
|
key_press_event: key_press_event,
|
@@ -376,8 +377,14 @@ module Cryptum
|
|
376
377
|
# ROW 1
|
377
378
|
out_line_no = 0
|
378
379
|
line_color = :white
|
380
|
+
header_color = :white
|
381
|
+
header_style = :bold
|
379
382
|
style = :bold
|
380
|
-
|
383
|
+
if event_history.order_execute_win_active
|
384
|
+
line_color = :blue
|
385
|
+
header_color = :yellow
|
386
|
+
header_style = :reverse
|
387
|
+
end
|
381
388
|
|
382
389
|
Cryptum::UI.line(
|
383
390
|
ui_win: order_execute_win,
|
@@ -391,32 +398,25 @@ module Cryptum
|
|
391
398
|
order_execute_win.clrtoeol
|
392
399
|
Cryptum::UI.colorize(
|
393
400
|
ui_win: order_execute_win,
|
394
|
-
color:
|
395
|
-
style:
|
396
|
-
string: '
|
401
|
+
color: header_color,
|
402
|
+
style: header_style,
|
403
|
+
string: ''.ljust(col_just1, ' ')
|
397
404
|
)
|
398
405
|
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
style: style,
|
404
|
-
string: "#{total_to_sell} | #{order_hist_meta_expired} Expired | #{order_hist_meta_sold} Sold | $#{gains_24h_out} Gained".rjust(
|
405
|
-
col_just3,
|
406
|
-
'.'
|
407
|
-
)
|
406
|
+
header_str = '- ORDER HISTORY -'
|
407
|
+
order_execute_win.setpos(
|
408
|
+
out_line_no,
|
409
|
+
Cryptum::UI.col_center(str: header_str)
|
408
410
|
)
|
409
411
|
|
410
|
-
|
411
|
-
out_line_no += 1
|
412
|
-
Cryptum::UI.line(
|
412
|
+
Cryptum::UI.colorize(
|
413
413
|
ui_win: order_execute_win,
|
414
|
-
|
415
|
-
|
414
|
+
color: header_color,
|
415
|
+
style: header_style,
|
416
|
+
string: header_str
|
416
417
|
)
|
417
418
|
|
418
|
-
|
419
|
-
# ROWS 4-10
|
419
|
+
# ROWS 3-10
|
420
420
|
first_row = event_history.order_execute_index_offset
|
421
421
|
last_row = first_row + event_history.order_execute_max_rows_to_display
|
422
422
|
if last_row >= order_history_meta.length
|
@@ -427,7 +427,7 @@ module Cryptum
|
|
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 -
|
430
|
+
current_line = out_line_no - 2
|
431
431
|
|
432
432
|
style = :normal
|
433
433
|
style = :highlight if event_history.order_execute_row_to_select == current_line
|
@@ -481,6 +481,32 @@ module Cryptum
|
|
481
481
|
)
|
482
482
|
end
|
483
483
|
|
484
|
+
# ROW 10
|
485
|
+
out_line_no += 1
|
486
|
+
order_execute_win.setpos(out_line_no, Cryptum::UI.col_first)
|
487
|
+
order_execute_win.clrtoeol
|
488
|
+
Cryptum::UI.colorize(
|
489
|
+
ui_win: order_execute_win,
|
490
|
+
color: header_color,
|
491
|
+
style: header_style,
|
492
|
+
string: ''.ljust(col_just1, ' ')
|
493
|
+
)
|
494
|
+
|
495
|
+
header_str = "SUMMARY: #{total_to_sell} | #{order_hist_meta_expired} Expired | #{order_hist_meta_sold} Sold | $#{gains_24h_out} Gained"
|
496
|
+
order_execute_win.setpos(
|
497
|
+
out_line_no,
|
498
|
+
Cryptum::UI.col_center(str: header_str)
|
499
|
+
)
|
500
|
+
|
501
|
+
Cryptum::UI.colorize(
|
502
|
+
ui_win: order_execute_win,
|
503
|
+
color: header_color,
|
504
|
+
style: header_style,
|
505
|
+
string: header_str
|
506
|
+
)
|
507
|
+
|
508
|
+
# ROW 11
|
509
|
+
out_line_no += 1
|
484
510
|
Cryptum::UI.line(
|
485
511
|
ui_win: order_execute_win,
|
486
512
|
out_line_no: out_line_no,
|
@@ -200,8 +200,14 @@ module Cryptum
|
|
200
200
|
# ROW 1
|
201
201
|
out_line_no = 0
|
202
202
|
line_color = :white
|
203
|
+
header_color = :white
|
204
|
+
header_style = :bold
|
203
205
|
style = :bold
|
204
|
-
|
206
|
+
if event_history.order_plan_win_active
|
207
|
+
line_color = :blue
|
208
|
+
header_color = :yellow
|
209
|
+
header_style = :reverse
|
210
|
+
end
|
205
211
|
|
206
212
|
Cryptum::UI.line(
|
207
213
|
ui_win: order_plan_win,
|
@@ -215,31 +221,25 @@ module Cryptum
|
|
215
221
|
order_plan_win.clrtoeol
|
216
222
|
Cryptum::UI.colorize(
|
217
223
|
ui_win: order_plan_win,
|
218
|
-
color:
|
219
|
-
style:
|
220
|
-
string:
|
224
|
+
color: header_color,
|
225
|
+
style: header_style,
|
226
|
+
string: ''.ljust(col_just1, ' ')
|
227
|
+
)
|
228
|
+
|
229
|
+
header_str = "- ORDER PLAN: Cycle ##{order_plan_prefix} -"
|
230
|
+
order_plan_win.setpos(
|
231
|
+
out_line_no,
|
232
|
+
Cryptum::UI.col_center(str: header_str)
|
221
233
|
)
|
222
234
|
|
223
|
-
order_plan_win.setpos(out_line_no, Cryptum::UI.col_third)
|
224
235
|
Cryptum::UI.colorize(
|
225
236
|
ui_win: order_plan_win,
|
226
|
-
color:
|
227
|
-
style:
|
228
|
-
string:
|
229
|
-
col_just3,
|
230
|
-
'.'
|
231
|
-
)
|
232
|
-
)
|
233
|
-
|
234
|
-
# ROW 3
|
235
|
-
out_line_no += 1
|
236
|
-
Cryptum::UI.line(
|
237
|
-
ui_win: order_plan_win,
|
238
|
-
out_line_no: out_line_no,
|
239
|
-
color: line_color
|
237
|
+
color: header_color,
|
238
|
+
style: header_style,
|
239
|
+
string: header_str
|
240
240
|
)
|
241
241
|
|
242
|
-
# ROWS
|
242
|
+
# ROWS 3-10
|
243
243
|
if event_history.red_pill
|
244
244
|
out_line_no += 1
|
245
245
|
order_plan_win.setpos(out_line_no, Cryptum::UI.col_first)
|
@@ -327,7 +327,7 @@ module Cryptum
|
|
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 -
|
330
|
+
current_line = out_line_no - 2
|
331
331
|
|
332
332
|
style = :normal
|
333
333
|
style = :highlight if event_history.order_plan_row_to_select == current_line
|
@@ -378,6 +378,32 @@ module Cryptum
|
|
378
378
|
end
|
379
379
|
end
|
380
380
|
|
381
|
+
# ROW 10
|
382
|
+
out_line_no += 1
|
383
|
+
order_plan_win.setpos(out_line_no, Cryptum::UI.col_first)
|
384
|
+
order_plan_win.clrtoeol
|
385
|
+
Cryptum::UI.colorize(
|
386
|
+
ui_win: order_plan_win,
|
387
|
+
color: header_color,
|
388
|
+
style: header_style,
|
389
|
+
string: ''.ljust(col_just1, ' ')
|
390
|
+
)
|
391
|
+
|
392
|
+
header_str = "SUMMARY: $#{order_plan_volume_out} w #{max_order_plan_slices} Slices | $#{order_plan_profit_sum_out} 2 Gain | #{order_plan_exec_percent}% Done"
|
393
|
+
order_plan_win.setpos(
|
394
|
+
out_line_no,
|
395
|
+
Cryptum::UI.col_center(str: header_str)
|
396
|
+
)
|
397
|
+
|
398
|
+
Cryptum::UI.colorize(
|
399
|
+
ui_win: order_plan_win,
|
400
|
+
color: header_color,
|
401
|
+
style: header_style,
|
402
|
+
string: header_str
|
403
|
+
)
|
404
|
+
|
405
|
+
# ROW 11
|
406
|
+
out_line_no += 1
|
381
407
|
Cryptum::UI.line(
|
382
408
|
ui_win: order_plan_win,
|
383
409
|
out_line_no: out_line_no,
|
@@ -51,9 +51,9 @@ module Cryptum
|
|
51
51
|
case color
|
52
52
|
when :green
|
53
53
|
# TODO: add condition to check if open sell orders exist.
|
54
|
-
# If so intent should be something like, "- SEE
|
54
|
+
# If so intent should be something like, "- SEE ORDER HISTORY -"
|
55
55
|
# Otherwise, intent should be something like, "- WAIT FOR MARKET TREND SHIFT -"
|
56
|
-
intent = "- SEE
|
56
|
+
intent = "- SEE ORDER HISTORY #{Cryptum.down_arrow} -"
|
57
57
|
else
|
58
58
|
speed = 'FAST'
|
59
59
|
speed = 'SLOW' if event_history.bullish_trend
|
@@ -69,6 +69,7 @@ module Cryptum
|
|
69
69
|
col_just4 = (Curses.cols - Cryptum::UI.col_fourth) - 1
|
70
70
|
|
71
71
|
# ROW 1
|
72
|
+
# COLUMN 1
|
72
73
|
out_line_no = 0
|
73
74
|
order_timer_win.setpos(out_line_no, Cryptum::UI.col_first)
|
74
75
|
order_timer_win.clrtoeol
|
@@ -79,6 +80,7 @@ module Cryptum
|
|
79
80
|
string: "Market Trend Reset: #{trend_countdown}"
|
80
81
|
)
|
81
82
|
|
83
|
+
# COLUMN 2
|
82
84
|
order_timer_win.setpos(
|
83
85
|
out_line_no,
|
84
86
|
Cryptum::UI.col_center(str: intent)
|
@@ -90,6 +92,7 @@ module Cryptum
|
|
90
92
|
string: intent
|
91
93
|
)
|
92
94
|
|
95
|
+
# COLUMN 3
|
93
96
|
order_timer_win.setpos(out_line_no, Cryptum::UI.col_fourth)
|
94
97
|
Cryptum::UI.colorize(
|
95
98
|
ui_win: order_timer_win,
|
@@ -42,7 +42,7 @@ module Cryptum
|
|
42
42
|
)
|
43
43
|
|
44
44
|
self.order_plan_section = Cryptum::UI.window(
|
45
|
-
height:
|
45
|
+
height: 11,
|
46
46
|
width: 0,
|
47
47
|
top: 13,
|
48
48
|
left: 0
|
@@ -79,7 +79,7 @@ module Cryptum
|
|
79
79
|
self.command_section = Cryptum::UI.window(
|
80
80
|
height: 3,
|
81
81
|
width: 0,
|
82
|
-
top:
|
82
|
+
top: 40,
|
83
83
|
left: 0
|
84
84
|
)
|
85
85
|
end
|
data/lib/cryptum/version.rb
CHANGED
@@ -134,18 +134,15 @@ module Cryptum
|
|
134
134
|
terminal_win.key_press_event.key_esc = false
|
135
135
|
terminal_win.key_press_event.key_down_arrow = false
|
136
136
|
if event_history.order_plan_win_active
|
137
|
-
order_plan_max_row_index = event_history.order_plan_max_rows_to_display - 1
|
138
137
|
event_history.order_plan_row_to_select += 1
|
139
|
-
event_history.order_plan_index_offset += 1 if event_history.order_plan_row_to_select >
|
140
|
-
event_history.order_plan_row_to_select =
|
138
|
+
event_history.order_plan_index_offset += 1 if event_history.order_plan_row_to_select > event_history.order_plan_max_rows_to_display
|
139
|
+
event_history.order_plan_row_to_select = event_history.order_plan_max_rows_to_display if event_history.order_plan_row_to_select > event_history.order_plan_max_rows_to_display
|
141
140
|
end
|
142
141
|
|
143
142
|
if event_history.order_execute_win_active
|
144
|
-
order_execute_max_row_index = event_history.order_execute_max_rows_to_display - 1
|
145
143
|
event_history.order_execute_row_to_select += 1
|
146
|
-
event_history.order_execute_index_offset += 1 if event_history.order_execute_row_to_select >
|
147
|
-
event_history.order_execute_row_to_select =
|
148
|
-
|
144
|
+
event_history.order_execute_index_offset += 1 if event_history.order_execute_row_to_select > event_history.order_execute_max_rows_to_display
|
145
|
+
event_history.order_execute_row_to_select = event_history.order_execute_max_rows_to_display if event_history.order_execute_row_to_select > event_history.order_execute_max_rows_to_display
|
149
146
|
end
|
150
147
|
end
|
151
148
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cryptum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.260
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 0day Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|