cryptum 0.0.262 → 0.0.264
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 +10 -9
- data/lib/cryptum/event/bot_conf.rb +28 -0
- data/lib/cryptum/event/cancel.rb +17 -10
- data/lib/cryptum/event/exit.rb +35 -0
- data/lib/cryptum/event/gtfo.rb +36 -0
- data/lib/cryptum/event/history.rb +1 -1
- data/lib/cryptum/event/key_press.rb +1 -1
- data/lib/cryptum/event/order_book.rb +32 -0
- data/lib/cryptum/event/pane.rb +36 -0
- data/lib/cryptum/event/scroll.rb +160 -0
- data/lib/cryptum/event.rb +7 -4
- data/lib/cryptum/ui/key_press_event.rb +5 -0
- data/lib/cryptum/ui/market_trend.rb +0 -5
- data/lib/cryptum/ui/order_execution.rb +0 -5
- data/lib/cryptum/ui/order_plan.rb +2 -7
- data/lib/cryptum/ui/order_timer.rb +0 -5
- data/lib/cryptum/ui/portfolio.rb +0 -5
- data/lib/cryptum/ui/signal_engine.rb +0 -5
- data/lib/cryptum/ui/ticker.rb +0 -5
- data/lib/cryptum/ui.rb +21 -7
- data/lib/cryptum/version.rb +1 -1
- data/lib/cryptum/web_sock/event_machine.rb +76 -65
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 131cbcaadd202ee2bdcc8f4e23067f6e2c632b7159007a308bcb288ed74748c7
|
4
|
+
data.tar.gz: 9fac19b924a5c594858c84878fef84f570830fcf199d8ceb918b0686537e0f8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bff9d226b9ac00ea28aa072903f107a9f1508e231c0abdc20aa05ce136d6778bb06d884b21ab6096ab0f90eb2f0033c2e7b9b12fa7a33b978134540151258e1
|
7
|
+
data.tar.gz: 2736aa7bca7479be8eda25942e24fedaf689ee4a4ffe99c92e50fe14b4086b4372fbd1a30e2abcf64814e8141f1e8b6b54842a2e13d9d7378b388b1a557c8fd6
|
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-02
|
3
|
+
# on 2022-12-02 23:03:00 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
|
@@ -102,7 +102,7 @@ Layout/TrailingWhitespace:
|
|
102
102
|
- 'lib/cryptum/ui/order_plan.rb'
|
103
103
|
- 'lib/cryptum/ui/order_timer.rb'
|
104
104
|
|
105
|
-
# Offense count:
|
105
|
+
# Offense count: 66
|
106
106
|
Lint/UselessAssignment:
|
107
107
|
Exclude:
|
108
108
|
- 'bin/cryptum-forecast'
|
@@ -110,17 +110,18 @@ Lint/UselessAssignment:
|
|
110
110
|
- 'lib/cryptum/api.rb'
|
111
111
|
- 'lib/cryptum/event.rb'
|
112
112
|
- 'lib/cryptum/event/buy.rb'
|
113
|
-
- 'lib/cryptum/event/
|
113
|
+
- 'lib/cryptum/event/scroll.rb'
|
114
114
|
- 'lib/cryptum/order_book/generate.rb'
|
115
115
|
- 'lib/cryptum/order_book/market_trend.rb'
|
116
116
|
- 'lib/cryptum/ui/market_trend.rb'
|
117
117
|
- 'lib/cryptum/ui/order_execution.rb'
|
118
118
|
- 'lib/cryptum/ui/order_plan.rb'
|
119
|
+
- 'lib/cryptum/ui/order_timer.rb'
|
119
120
|
- 'lib/cryptum/ui/portfolio.rb'
|
120
121
|
- 'lib/cryptum/ui/signal_engine.rb'
|
121
122
|
- 'lib/cryptum/ui/ticker.rb'
|
122
123
|
|
123
|
-
# Offense count:
|
124
|
+
# Offense count: 41
|
124
125
|
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
|
125
126
|
Metrics/AbcSize:
|
126
127
|
Max: 400
|
@@ -129,29 +130,29 @@ Metrics/AbcSize:
|
|
129
130
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
|
130
131
|
# AllowedMethods: refine
|
131
132
|
Metrics/BlockLength:
|
132
|
-
Max:
|
133
|
+
Max: 145
|
133
134
|
|
134
135
|
# Offense count: 4
|
135
136
|
# Configuration parameters: CountBlocks.
|
136
137
|
Metrics/BlockNesting:
|
137
138
|
Max: 4
|
138
139
|
|
139
|
-
# Offense count:
|
140
|
+
# Offense count: 18
|
140
141
|
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
|
141
142
|
Metrics/CyclomaticComplexity:
|
142
143
|
Max: 73
|
143
144
|
|
144
|
-
# Offense count:
|
145
|
+
# Offense count: 60
|
145
146
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
|
146
147
|
Metrics/MethodLength:
|
147
|
-
Max:
|
148
|
+
Max: 383
|
148
149
|
|
149
150
|
# Offense count: 15
|
150
151
|
# Configuration parameters: CountComments, CountAsOne.
|
151
152
|
Metrics/ModuleLength:
|
152
153
|
Max: 538
|
153
154
|
|
154
|
-
# Offense count:
|
155
|
+
# Offense count: 18
|
155
156
|
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
|
156
157
|
Metrics/PerceivedComplexity:
|
157
158
|
Max: 76
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cryptum
|
4
|
+
# This plugin is used to Reload the Bot Conf When the "r" Key is Pressed
|
5
|
+
module Event
|
6
|
+
module BotConf
|
7
|
+
# Supported Method Parameters::
|
8
|
+
# Cryptum::Event::BotConf.reload(
|
9
|
+
# )
|
10
|
+
public_class_method def self.reload(opts = {})
|
11
|
+
terminal_win = opts[:terminal_win]
|
12
|
+
option_choice = opts[:option_choice]
|
13
|
+
|
14
|
+
terminal_win.key_press_event.key_r = false
|
15
|
+
Cryptum.read_bot_conf(option_choice: option_choice)
|
16
|
+
rescue StandardError => e
|
17
|
+
raise e
|
18
|
+
end
|
19
|
+
|
20
|
+
# Display Usage for this Module
|
21
|
+
public_class_method def self.help
|
22
|
+
puts "USAGE:
|
23
|
+
bot_conf = #{self}.reload()
|
24
|
+
"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/cryptum/event/cancel.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Cryptum
|
4
|
-
# This plugin is used to
|
4
|
+
# This plugin is used to Reload the Bot Conf When the "C" Key is Pressed
|
5
5
|
module Event
|
6
6
|
module Cancel
|
7
7
|
# Supported Method Parameters::
|
8
8
|
# Cryptum::Event::Cancel.open_orders(
|
9
9
|
# )
|
10
10
|
public_class_method def self.open_orders(opts = {})
|
11
|
+
terminal_win = opts[:terminal_win]
|
11
12
|
option_choice = opts[:option_choice]
|
12
13
|
env = opts[:env]
|
13
|
-
event_history = opts[:event_history]
|
14
|
-
order_type = opts[:order_type]
|
15
|
-
order_action = opts[:order_action]
|
14
|
+
# event_history = opts[:event_history]
|
15
|
+
# order_type = opts[:order_type]
|
16
|
+
# order_action = opts[:order_action]
|
16
17
|
|
17
18
|
# Consume Latest Order History Justification from
|
18
19
|
# Order Book & cancel orders tagged as pie
|
@@ -25,14 +26,20 @@ module Cryptum
|
|
25
26
|
# )
|
26
27
|
|
27
28
|
# event_history
|
28
|
-
event_history.order_canceled = true
|
29
|
-
event_history.event_notes = "{ \"event_type\": \"#{event_history.event_type}\", \"cancel\": \"#{event_history.order_canceled}\", \"submitted\": \"#{event_history.order_submitted}\" }" if option_choice.proxy
|
29
|
+
# event_history.order_canceled = true
|
30
|
+
# event_history.event_notes = "{ \"event_type\": \"#{event_history.event_type}\", \"cancel\": \"#{event_history.order_canceled}\", \"submitted\": \"#{event_history.order_submitted}\" }" if option_choice.proxy
|
30
31
|
|
32
|
+
# Cryptum::API.cancel_all_open_orders(
|
33
|
+
# env: env,
|
34
|
+
# option_choice: option_choice,
|
35
|
+
# order_type: order_type,
|
36
|
+
# event_notes: event_history.event_notes
|
37
|
+
# )
|
38
|
+
|
39
|
+
terminal_win.key_press_event.key_c = false
|
31
40
|
Cryptum::API.cancel_all_open_orders(
|
32
41
|
env: env,
|
33
|
-
option_choice: option_choice
|
34
|
-
order_type: order_type,
|
35
|
-
event_notes: event_history.event_notes
|
42
|
+
option_choice: option_choice
|
36
43
|
)
|
37
44
|
rescue StandardError => e
|
38
45
|
raise e
|
@@ -41,7 +48,7 @@ module Cryptum
|
|
41
48
|
# Display Usage for this Module
|
42
49
|
public_class_method def self.help
|
43
50
|
puts "USAGE:
|
44
|
-
|
51
|
+
#{self}.open_orders()
|
45
52
|
"
|
46
53
|
end
|
47
54
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cryptum
|
4
|
+
# This plugin is used to Exit Cryptum Gracefully When the "x" Key is Pressed
|
5
|
+
module Event
|
6
|
+
module Exit
|
7
|
+
# Supported Method Parameters::
|
8
|
+
# Cryptum::Event::BotConf.gracefully(
|
9
|
+
# )
|
10
|
+
public_class_method def self.gracefully(opts = {})
|
11
|
+
terminal_win = opts[:terminal_win]
|
12
|
+
event_history = opts[:event_history]
|
13
|
+
option_choice = opts[:option_choice]
|
14
|
+
env = opts[:env]
|
15
|
+
|
16
|
+
terminal_win.key_press_event.key_x = false
|
17
|
+
Cryptum.exit_gracefully(
|
18
|
+
which_self: self,
|
19
|
+
event_history: event_history,
|
20
|
+
option_choice: option_choice,
|
21
|
+
env: env
|
22
|
+
)
|
23
|
+
rescue StandardError => e
|
24
|
+
raise e
|
25
|
+
end
|
26
|
+
|
27
|
+
# Display Usage for this Module
|
28
|
+
public_class_method def self.help
|
29
|
+
puts "USAGE:
|
30
|
+
#{self}.gracefully()
|
31
|
+
"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cryptum
|
4
|
+
# This plugin is used to Get the F* Out (GTFO) when the "G" Key is Pressed
|
5
|
+
module Event
|
6
|
+
module GTFO
|
7
|
+
# Supported Method Parameters::
|
8
|
+
# Cryptum::Event::GTFO.now(
|
9
|
+
# )
|
10
|
+
public_class_method def self.now(opts = {})
|
11
|
+
terminal_win = opts[:terminal_win]
|
12
|
+
option_choice = opts[:option_choice]
|
13
|
+
env = opts[:env]
|
14
|
+
event_history = opts[:event_history]
|
15
|
+
bot_conf = opts[:bot_conf]
|
16
|
+
|
17
|
+
terminal_win.key_press_event.key_g = false
|
18
|
+
Cryptum::API.gtfo(
|
19
|
+
option_choice: option_choice,
|
20
|
+
env: env,
|
21
|
+
event_history: event_history,
|
22
|
+
bot_conf: bot_conf
|
23
|
+
)
|
24
|
+
rescue StandardError => e
|
25
|
+
raise e
|
26
|
+
end
|
27
|
+
|
28
|
+
# Display Usage for this Module
|
29
|
+
public_class_method def self.help
|
30
|
+
puts "USAGE:
|
31
|
+
bot_conf = #{self}.now()
|
32
|
+
"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cryptum
|
4
|
+
# This plugin is used to Write the Order Book from Memory
|
5
|
+
# to File When the "w" Key is Pressed
|
6
|
+
module Event
|
7
|
+
module OrderBook
|
8
|
+
# Supported Method Parameters::
|
9
|
+
# Cryptum::Event::BotConf.write(
|
10
|
+
# )
|
11
|
+
public_class_method def self.write(opts = {})
|
12
|
+
terminal_win = opts[:terminal_win]
|
13
|
+
event_history = opts[:event_history]
|
14
|
+
|
15
|
+
terminal_win.key_press_event.key_w = false
|
16
|
+
order_book_file = event_history.order_book[:path]
|
17
|
+
File.open(order_book_file, 'w') do |f|
|
18
|
+
f.puts event_history.order_book.to_json
|
19
|
+
end
|
20
|
+
rescue StandardError => e
|
21
|
+
raise e
|
22
|
+
end
|
23
|
+
|
24
|
+
# Display Usage for this Module
|
25
|
+
public_class_method def self.help
|
26
|
+
puts "USAGE:
|
27
|
+
#{self}.write()
|
28
|
+
"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cryptum
|
4
|
+
# This plugin is used to Switch through Order Plan / Order History
|
5
|
+
# Window Panes when the TAB Key is Pressed.
|
6
|
+
module Event
|
7
|
+
module Pane
|
8
|
+
# Supported Method Parameters::
|
9
|
+
# Cryptum::Event::Pane.switch(
|
10
|
+
# )
|
11
|
+
public_class_method def self.switch(opts = {})
|
12
|
+
terminal_win = opts[:terminal_win]
|
13
|
+
event_history = opts[:event_history]
|
14
|
+
|
15
|
+
terminal_win.key_press_event.key_tab = false
|
16
|
+
|
17
|
+
if event_history.order_plan_win_active
|
18
|
+
event_history.order_plan_win_active = false
|
19
|
+
event_history.order_execute_win_active = true
|
20
|
+
else
|
21
|
+
event_history.order_plan_win_active = true
|
22
|
+
event_history.order_execute_win_active = false
|
23
|
+
end
|
24
|
+
rescue StandardError => e
|
25
|
+
raise e
|
26
|
+
end
|
27
|
+
|
28
|
+
# Display Usage for this Module
|
29
|
+
public_class_method def self.help
|
30
|
+
puts "USAGE:
|
31
|
+
#{self}.switch()
|
32
|
+
"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cryptum
|
4
|
+
# This plugin is used to Scroll through Order Plan
|
5
|
+
# Order Plan and Order History Window Panes
|
6
|
+
# to File When the "w" Key is Pressed
|
7
|
+
module Event
|
8
|
+
module Scroll
|
9
|
+
# Supported Method Parameters::
|
10
|
+
# Cryptum::Event::Scroll.up(
|
11
|
+
# )
|
12
|
+
public_class_method def self.up(opts = {})
|
13
|
+
terminal_win = opts[:terminal_win]
|
14
|
+
event_history = opts[:event_history]
|
15
|
+
|
16
|
+
terminal_win.key_press_event.key_ansi = false
|
17
|
+
terminal_win.key_press_event.key_esc = false
|
18
|
+
terminal_win.key_press_event.key_up_arrow = false
|
19
|
+
|
20
|
+
if event_history.order_plan_win_active
|
21
|
+
event_history.order_plan_row_to_select -= 1
|
22
|
+
event_history.order_plan_index_offset -= 1 if event_history.order_plan_row_to_select.negative?
|
23
|
+
event_history.order_plan_index_offset = 0 if event_history.order_plan_index_offset.negative?
|
24
|
+
event_history.order_plan_row_to_select = 0 if event_history.order_plan_row_to_select.negative?
|
25
|
+
end
|
26
|
+
|
27
|
+
if event_history.order_execute_win_active
|
28
|
+
event_history.order_execute_row_to_select -= 1
|
29
|
+
event_history.order_execute_index_offset -= 1 if event_history.order_execute_row_to_select.negative?
|
30
|
+
event_history.order_execute_index_offset = 0 if event_history.order_execute_index_offset.negative?
|
31
|
+
event_history.order_execute_row_to_select = 0 if event_history.order_execute_row_to_select.negative?
|
32
|
+
end
|
33
|
+
rescue StandardError => e
|
34
|
+
raise e
|
35
|
+
end
|
36
|
+
|
37
|
+
# Supported Method Parameters::
|
38
|
+
# Cryptum::Event::Scroll.down(
|
39
|
+
# )
|
40
|
+
public_class_method def self.down(opts = {})
|
41
|
+
terminal_win = opts[:terminal_win]
|
42
|
+
event_history = opts[:event_history]
|
43
|
+
|
44
|
+
terminal_win.key_press_event.key_ansi = false
|
45
|
+
terminal_win.key_press_event.key_esc = false
|
46
|
+
terminal_win.key_press_event.key_down_arrow = false
|
47
|
+
|
48
|
+
if event_history.order_plan_win_active
|
49
|
+
event_history.order_plan_row_to_select += 1
|
50
|
+
event_history.order_plan_index_offset += 1 if event_history.order_plan_row_to_select > event_history.order_plan_max_rows_to_display
|
51
|
+
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
|
52
|
+
end
|
53
|
+
|
54
|
+
if event_history.order_execute_win_active
|
55
|
+
event_history.order_execute_row_to_select += 1
|
56
|
+
event_history.order_execute_index_offset += 1 if event_history.order_execute_row_to_select > event_history.order_execute_max_rows_to_display
|
57
|
+
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
|
58
|
+
end
|
59
|
+
rescue StandardError => e
|
60
|
+
raise e
|
61
|
+
end
|
62
|
+
|
63
|
+
# Supported Method Parameters::
|
64
|
+
# Cryptum::Event::Scroll.page_up(
|
65
|
+
# )
|
66
|
+
public_class_method def self.page_up(opts = {})
|
67
|
+
terminal_win = opts[:terminal_win]
|
68
|
+
event_history = opts[:event_history]
|
69
|
+
|
70
|
+
terminal_win.key_press_event.key_ansi = false
|
71
|
+
terminal_win.key_press_event.key_esc = false
|
72
|
+
terminal_win.key_press_event.key_page_up = false
|
73
|
+
|
74
|
+
if event_history.order_plan_win_active
|
75
|
+
event_history.order_plan_row_to_select = 0
|
76
|
+
event_history.order_plan_index_offset -= event_history.order_plan_max_rows_to_display - 1
|
77
|
+
event_history.order_plan_index_offset = 0 if event_history.order_plan_index_offset.negative?
|
78
|
+
event_history.order_plan_row_to_select = 0 if event_history.order_plan_row_to_select.negative?
|
79
|
+
end
|
80
|
+
|
81
|
+
if event_history.order_execute_win_active
|
82
|
+
event_history.order_execute_row_to_select = 0
|
83
|
+
event_history.order_execute_index_offset -= event_history.order_execute_max_rows_to_display - 1
|
84
|
+
event_history.order_execute_index_offset = 0 if event_history.order_execute_index_offset.negative?
|
85
|
+
event_history.order_execute_row_to_select = 0 if event_history.order_execute_row_to_select.negative?
|
86
|
+
end
|
87
|
+
rescue StandardError => e
|
88
|
+
raise e
|
89
|
+
end
|
90
|
+
|
91
|
+
# Supported Method Parameters::
|
92
|
+
# Cryptum::Event::Scroll.page_down(
|
93
|
+
# )
|
94
|
+
public_class_method def self.page_down(opts = {})
|
95
|
+
terminal_win = opts[:terminal_win]
|
96
|
+
event_history = opts[:event_history]
|
97
|
+
|
98
|
+
terminal_win.key_press_event.key_ansi = false
|
99
|
+
terminal_win.key_press_event.key_esc = false
|
100
|
+
terminal_win.key_press_event.key_page_down = false
|
101
|
+
|
102
|
+
if event_history.order_plan_win_active
|
103
|
+
event_history.order_plan_row_to_select = 0
|
104
|
+
event_history.order_plan_index_offset += event_history.order_plan_max_rows_to_display + 1
|
105
|
+
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
|
106
|
+
end
|
107
|
+
|
108
|
+
if event_history.order_execute_win_active
|
109
|
+
event_history.order_execute_row_to_select = 0
|
110
|
+
event_history.order_execute_index_offset += event_history.order_execute_max_rows_to_display + 1
|
111
|
+
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
|
112
|
+
end
|
113
|
+
rescue StandardError => e
|
114
|
+
raise e
|
115
|
+
end
|
116
|
+
|
117
|
+
# Supported Method Parameters::
|
118
|
+
# Cryptum::Event::Scroll.top(
|
119
|
+
# )
|
120
|
+
public_class_method def self.top(opts = {})
|
121
|
+
terminal_win = opts[:terminal_win]
|
122
|
+
event_history = opts[:event_history]
|
123
|
+
|
124
|
+
terminal_win.key_press_event.key_ansi = false
|
125
|
+
terminal_win.key_press_event.key_esc = false
|
126
|
+
terminal_win.key_press_event.key_home = false
|
127
|
+
|
128
|
+
rescue StandardError => e
|
129
|
+
raise e
|
130
|
+
end
|
131
|
+
|
132
|
+
# Supported Method Parameters::
|
133
|
+
# Cryptum::Event::Scroll.bottom(
|
134
|
+
# )
|
135
|
+
public_class_method def self.bottom(opts = {})
|
136
|
+
terminal_win = opts[:terminal_win]
|
137
|
+
event_history = opts[:event_history]
|
138
|
+
|
139
|
+
terminal_win.key_press_event.key_ansi = false
|
140
|
+
terminal_win.key_press_event.key_esc = false
|
141
|
+
terminal_win.key_press_event.key_end = false
|
142
|
+
|
143
|
+
rescue StandardError => e
|
144
|
+
raise e
|
145
|
+
end
|
146
|
+
|
147
|
+
# Display Usage for this Module
|
148
|
+
public_class_method def self.help
|
149
|
+
puts "USAGE:
|
150
|
+
#{self}.up()
|
151
|
+
#{self}.down()
|
152
|
+
#{self}.page_up()
|
153
|
+
#{self}.page_down()
|
154
|
+
#{self}.top()
|
155
|
+
#{self}.bottom()
|
156
|
+
"
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
data/lib/cryptum/event.rb
CHANGED
@@ -5,10 +5,16 @@ require 'logger'
|
|
5
5
|
module Cryptum
|
6
6
|
# This plugin is used to parse Coinbase Pro Web Socket Events in the HTTP Response
|
7
7
|
module Event
|
8
|
+
autoload :BotConf, 'cryptum/event/bot_conf'
|
8
9
|
autoload :Buy, 'cryptum/event/buy'
|
9
|
-
autoload :
|
10
|
+
autoload :Cancel, 'cryptum/event/cancel'
|
11
|
+
autoload :Exit, 'cryptum/event/exit'
|
12
|
+
autoload :GTFO, 'cryptum/event/gtfo'
|
10
13
|
autoload :History, 'cryptum/event/history'
|
11
14
|
autoload :KeyPress, 'cryptum/event/key_press'
|
15
|
+
autoload :OrderBook, 'cryptum/event/order_book'
|
16
|
+
autoload :Pane, 'cryptum/event/pane'
|
17
|
+
autoload :Scroll, 'cryptum/event/scroll'
|
12
18
|
autoload :Sell, 'cryptum/event/sell'
|
13
19
|
|
14
20
|
# Supported Method Parameters::
|
@@ -31,9 +37,6 @@ module Cryptum
|
|
31
37
|
fiat = this_product[:quote_currency]
|
32
38
|
fiat_portfolio_file = "#{option_choice.repo_root}/order_books/#{fiat}_PORTFOLIO.json"
|
33
39
|
|
34
|
-
# Detect Key Press Events
|
35
|
-
Cryptum::Event::KeyPress.detect(terminal_win: terminal_win)
|
36
|
-
|
37
40
|
# Determine if Summary UI needs updated data
|
38
41
|
event_history = Cryptum::Portfolio::Balance.refresh(
|
39
42
|
env: env,
|
@@ -53,11 +53,6 @@ module Cryptum
|
|
53
53
|
col_just3_alt = (Curses.cols - Cryptum::UI.col_third) - 1
|
54
54
|
col_just4 = Curses.cols - Cryptum::UI.col_fourth
|
55
55
|
|
56
|
-
Cryptum::UI.detect_key_press_in_ui(
|
57
|
-
key_press_event: key_press_event,
|
58
|
-
ui_win: market_trend_win
|
59
|
-
)
|
60
|
-
|
61
56
|
# ROW 1
|
62
57
|
out_line_no = 0
|
63
58
|
Cryptum::UI.line(
|
@@ -369,11 +369,6 @@ module Cryptum
|
|
369
369
|
col_just3 = (Curses.cols - Cryptum::UI.col_third) - 1
|
370
370
|
col_just4 = Curses.cols - Cryptum::UI.col_fourth
|
371
371
|
|
372
|
-
Cryptum::UI.detect_key_press_in_ui(
|
373
|
-
key_press_event: key_press_event,
|
374
|
-
ui_win: order_execute_win
|
375
|
-
)
|
376
|
-
|
377
372
|
# ROW 1
|
378
373
|
out_line_no = 0
|
379
374
|
line_color = :white
|
@@ -149,7 +149,7 @@ module Cryptum
|
|
149
149
|
end
|
150
150
|
|
151
151
|
red_pill_alert = '| RED PILL ALERT |'
|
152
|
-
red_pill_msg =
|
152
|
+
red_pill_msg = '- Autotrade % Exhausted -'
|
153
153
|
event_history.red_pill = true if order_plan.empty?
|
154
154
|
|
155
155
|
if event_history.red_pill
|
@@ -193,11 +193,6 @@ module Cryptum
|
|
193
193
|
col_just3 = (Curses.cols - Cryptum::UI.col_third) - 1
|
194
194
|
col_just4 = Curses.cols - Cryptum::UI.col_fourth
|
195
195
|
|
196
|
-
Cryptum::UI.detect_key_press_in_ui(
|
197
|
-
key_press_event: key_press_event,
|
198
|
-
ui_win: order_plan_win
|
199
|
-
)
|
200
|
-
|
201
196
|
# ROW 1
|
202
197
|
out_line_no = 0
|
203
198
|
line_color = :white
|
@@ -227,7 +222,7 @@ module Cryptum
|
|
227
222
|
string: ''.ljust(col_just1, ' ')
|
228
223
|
)
|
229
224
|
|
230
|
-
header_str = "- ORDER PLAN
|
225
|
+
header_str = "- ORDER PLAN | CYCLE ##{order_plan_prefix} -"
|
231
226
|
order_plan_win.setpos(
|
232
227
|
out_line_no,
|
233
228
|
Cryptum::UI.col_center(str: header_str)
|
@@ -20,11 +20,6 @@ module Cryptum
|
|
20
20
|
last_trend_reset_time = event_history.order_book[:last_trend_reset]
|
21
21
|
last_order_exec_time = event_history.order_book[:last_order_exec]
|
22
22
|
|
23
|
-
Cryptum::UI.detect_key_press_in_ui(
|
24
|
-
key_press_event: key_press_event,
|
25
|
-
ui_win: order_timer_win
|
26
|
-
)
|
27
|
-
|
28
23
|
# Market Trend Reset Timer
|
29
24
|
time_between_trend_reset = option_choice.market_trend_reset
|
30
25
|
trend_timer_begin = Time.parse(last_trend_reset_time)
|
data/lib/cryptum/ui/portfolio.rb
CHANGED
@@ -104,11 +104,6 @@ module Cryptum
|
|
104
104
|
# UI
|
105
105
|
col_just3 = (Curses.cols - Cryptum::UI.col_third) - 1
|
106
106
|
|
107
|
-
Cryptum::UI.detect_key_press_in_ui(
|
108
|
-
key_press_event: key_press_event,
|
109
|
-
ui_win: portfolio_win
|
110
|
-
)
|
111
|
-
|
112
107
|
# ROW 1
|
113
108
|
out_line_no = 0
|
114
109
|
Cryptum::UI.line(
|
@@ -51,11 +51,6 @@ module Cryptum
|
|
51
51
|
col_just3 = (Curses.cols - Cryptum::UI.col_third) - 1
|
52
52
|
col_just4 = Curses.cols - Cryptum::UI.col_fourth
|
53
53
|
|
54
|
-
Cryptum::UI.detect_key_press_in_ui(
|
55
|
-
key_press_event: key_press_event,
|
56
|
-
ui_win: signal_engine_win
|
57
|
-
)
|
58
|
-
|
59
54
|
# ROW 1
|
60
55
|
out_line_no = 0
|
61
56
|
Cryptum::UI.line(
|
data/lib/cryptum/ui/ticker.rb
CHANGED
@@ -149,11 +149,6 @@ module Cryptum
|
|
149
149
|
col_just3_alt = (Curses.cols - Cryptum::UI.col_third) - 1
|
150
150
|
col_just4 = (Curses.cols - Cryptum::UI.col_fourth) - 1
|
151
151
|
|
152
|
-
Cryptum::UI.detect_key_press_in_ui(
|
153
|
-
key_press_event: key_press_event,
|
154
|
-
ui_win: ticker_win
|
155
|
-
)
|
156
|
-
|
157
152
|
# ROW 1
|
158
153
|
out_line_no = 0
|
159
154
|
Cryptum::UI.line(
|
data/lib/cryptum/ui.rb
CHANGED
@@ -277,7 +277,7 @@ module Cryptum
|
|
277
277
|
# f.puts key_press.class
|
278
278
|
# f.print key_press.inspect
|
279
279
|
# f.puts "\n\n\n"
|
280
|
-
#
|
280
|
+
# end
|
281
281
|
# end
|
282
282
|
|
283
283
|
case key_press
|
@@ -293,16 +293,30 @@ module Cryptum
|
|
293
293
|
key_press_event.key_w = true
|
294
294
|
when 'x'
|
295
295
|
key_press_event.key_x = true
|
296
|
-
when "\t"
|
297
|
-
key_press_event.key_tab = true
|
298
296
|
when "\e"
|
299
297
|
key_press_event.key_esc = true
|
298
|
+
when "\n"
|
299
|
+
key_press_event.key_enter = true
|
300
|
+
when "\t"
|
301
|
+
key_press_event.key_tab = true
|
300
302
|
end
|
301
303
|
|
302
|
-
# What a hack to detect
|
303
|
-
|
304
|
-
|
305
|
-
|
304
|
+
# What a hack to detect special keys (-.-)
|
305
|
+
if key_press_event.key_esc
|
306
|
+
key_press_event.key_ansi = true if key_press == '['
|
307
|
+
if key_press_event.key_ansi
|
308
|
+
key_press_event.key_up_arrow = true if key_press == 'A'
|
309
|
+
key_press_event.key_down_arrow = true if key_press == 'B'
|
310
|
+
# NOTE: the ~ at the end of these keys are ignored
|
311
|
+
# which may result in other keys working in place of them
|
312
|
+
# e.g. home is \e[1~ but we know it's home as soon as
|
313
|
+
# \e[1 is detected.
|
314
|
+
key_press_event.key_page_up = true if key_press == '5'
|
315
|
+
key_press_event.key_page_down = true if key_press == '6'
|
316
|
+
key_press_event.key_home = true if key_press == '1'
|
317
|
+
key_press_event.key_end = true if key_press == '4'
|
318
|
+
end
|
319
|
+
end
|
306
320
|
|
307
321
|
key_press_event
|
308
322
|
rescue Interrupt
|
data/lib/cryptum/version.rb
CHANGED
@@ -53,6 +53,11 @@ module Cryptum
|
|
53
53
|
end
|
54
54
|
|
55
55
|
ws.on :message do |event|
|
56
|
+
# TODO: The Speed of the UI is dictated by the
|
57
|
+
# Frequency of WebSocket Messages Coming Through.
|
58
|
+
# Explore another way to decouple required events
|
59
|
+
# (such as keypresses) from only being triggered
|
60
|
+
# when messages come through.
|
56
61
|
ai_enabled = bot_conf[:artifical_intelligence]
|
57
62
|
|
58
63
|
event_history.event = JSON.parse(
|
@@ -70,114 +75,120 @@ module Cryptum
|
|
70
75
|
ai_enabled: ai_enabled
|
71
76
|
)
|
72
77
|
|
73
|
-
# Decent for Debugging Events
|
74
|
-
# puts event_history.inspect
|
75
|
-
# Decent for Debugging MACD & RSI History
|
76
|
-
# puts indicator_status.inspect
|
77
|
-
|
78
78
|
# Detect Key Press Events
|
79
79
|
Cryptum::Event::KeyPress.detect(terminal_win: terminal_win)
|
80
80
|
|
81
81
|
# Cancel ALL Open Orders when
|
82
82
|
# C is pressed
|
83
83
|
if terminal_win.key_press_event.key_c
|
84
|
-
Cryptum::
|
85
|
-
|
86
|
-
option_choice: option_choice
|
84
|
+
Cryptum::Event::Cancel.open_orders(
|
85
|
+
terminal_win: terminal_win,
|
86
|
+
option_choice: option_choice,
|
87
|
+
env: env
|
87
88
|
)
|
88
|
-
terminal_win.key_press_event.key_c = false
|
89
89
|
end
|
90
90
|
|
91
91
|
# Get the F* Out (GTFO) when
|
92
92
|
# G is pressed
|
93
93
|
if terminal_win.key_press_event.key_g
|
94
|
-
event_history = Cryptum::
|
94
|
+
event_history = Cryptum::Event::GTFO.now(
|
95
|
+
terminal_win: terminal_win,
|
95
96
|
option_choice: option_choice,
|
96
97
|
env: env,
|
97
98
|
event_history: event_history,
|
98
99
|
bot_conf: bot_conf
|
99
100
|
)
|
100
|
-
terminal_win.key_press_event.key_g = false
|
101
101
|
end
|
102
102
|
|
103
|
-
#
|
104
|
-
# R is Pressed
|
103
|
+
# Reload Bot Conf when r is Pressed
|
105
104
|
if terminal_win.key_press_event.key_r
|
106
|
-
bot_conf = Cryptum.
|
107
|
-
|
105
|
+
bot_conf = Cryptum::Event::BotConf.reload(
|
106
|
+
terminal_win: terminal_win,
|
107
|
+
option_choice: option_choice
|
108
|
+
)
|
108
109
|
end
|
109
110
|
|
110
111
|
# Only Write Order Book to File when
|
111
112
|
# W is Pressed
|
112
113
|
if terminal_win.key_press_event.key_w
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
terminal_win.key_press_event.key_w = false
|
114
|
+
Cryptum::Event::OrderBook.write(
|
115
|
+
terminal_win: terminal_win,
|
116
|
+
event_history: event_history
|
117
|
+
)
|
118
118
|
end
|
119
119
|
|
120
120
|
# Exit if x is Pressed
|
121
121
|
if terminal_win.key_press_event.key_x
|
122
|
-
|
123
|
-
|
124
|
-
which_self: self,
|
122
|
+
Cryptum::Event::Exit.gracefully(
|
123
|
+
terminal_win: terminal_win,
|
125
124
|
event_history: event_history,
|
126
125
|
option_choice: option_choice,
|
127
126
|
env: env
|
128
127
|
)
|
129
128
|
end
|
130
129
|
|
131
|
-
# Scroll Down Order Plan / Order Execution Window Panes
|
132
|
-
if terminal_win.key_press_event.key_down_arrow
|
133
|
-
terminal_win.key_press_event.key_ansi = false
|
134
|
-
terminal_win.key_press_event.key_esc = false
|
135
|
-
terminal_win.key_press_event.key_down_arrow = false
|
136
|
-
if event_history.order_plan_win_active
|
137
|
-
event_history.order_plan_row_to_select += 1
|
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
|
140
|
-
end
|
141
|
-
|
142
|
-
if event_history.order_execute_win_active
|
143
|
-
event_history.order_execute_row_to_select += 1
|
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
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
130
|
# TAB through Order Plan / Order Execution Window Panes
|
150
131
|
if terminal_win.key_press_event.key_tab
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
event_history.order_execute_win_active = true
|
156
|
-
else
|
157
|
-
event_history.order_plan_win_active = true
|
158
|
-
event_history.order_execute_win_active = false
|
159
|
-
end
|
132
|
+
Cryptum::Event::Pane.switch(
|
133
|
+
terminal_win: terminal_win,
|
134
|
+
event_history: event_history
|
135
|
+
)
|
160
136
|
end
|
161
137
|
|
162
138
|
# Scroll Up Order Plan / Order Execution Window Panes
|
163
139
|
if terminal_win.key_press_event.key_up_arrow
|
140
|
+
Cryptum::Event::Scroll.up(
|
141
|
+
terminal_win: terminal_win,
|
142
|
+
event_history: event_history
|
143
|
+
)
|
144
|
+
end
|
145
|
+
|
146
|
+
# Scroll Down Order Plan / Order Execution Window Panes
|
147
|
+
if terminal_win.key_press_event.key_down_arrow
|
148
|
+
Cryptum::Event::Scroll.down(
|
149
|
+
terminal_win: terminal_win,
|
150
|
+
event_history: event_history
|
151
|
+
)
|
152
|
+
end
|
153
|
+
|
154
|
+
# Scroll Up Order Plan / Order Execution Window Panes Faster
|
155
|
+
if terminal_win.key_press_event.key_page_up
|
156
|
+
Cryptum::Event::Scroll.page_up(
|
157
|
+
terminal_win: terminal_win,
|
158
|
+
event_history: event_history
|
159
|
+
)
|
160
|
+
end
|
161
|
+
|
162
|
+
# Scroll Down Order Plan / Order Execution Window Panes Faster
|
163
|
+
if terminal_win.key_press_event.key_page_down
|
164
|
+
Cryptum::Event::Scroll.page_down(
|
165
|
+
terminal_win: terminal_win,
|
166
|
+
event_history: event_history
|
167
|
+
)
|
168
|
+
end
|
169
|
+
|
170
|
+
# Scroll to Top of Order Plan / Order Execution Window Panes
|
171
|
+
if terminal_win.key_press_event.key_home
|
172
|
+
Cryptum::Event::Scroll.top(
|
173
|
+
terminal_win: terminal_win,
|
174
|
+
event_history: event_history
|
175
|
+
)
|
176
|
+
end
|
177
|
+
|
178
|
+
# Scroll to Bottom of Order Plan / Order Execution Window Panes
|
179
|
+
if terminal_win.key_press_event.key_end
|
180
|
+
Cryptum::Event::Scroll.bottom(
|
181
|
+
terminal_win: terminal_win,
|
182
|
+
event_history: event_history
|
183
|
+
)
|
184
|
+
end
|
185
|
+
|
186
|
+
# Open / Close Order Plan / Order Execution Details Window
|
187
|
+
if terminal_win.key_press_event.key_enter
|
164
188
|
terminal_win.key_press_event.key_ansi = false
|
165
189
|
terminal_win.key_press_event.key_esc = false
|
166
|
-
terminal_win.key_press_event.
|
167
|
-
|
168
|
-
if event_history.order_plan_win_active
|
169
|
-
event_history.order_plan_row_to_select -= 1
|
170
|
-
event_history.order_plan_index_offset -= 1 if event_history.order_plan_row_to_select.negative?
|
171
|
-
event_history.order_plan_index_offset = 0 if event_history.order_plan_index_offset.negative?
|
172
|
-
event_history.order_plan_row_to_select = 0 if event_history.order_plan_row_to_select.negative?
|
173
|
-
end
|
174
|
-
|
175
|
-
if event_history.order_execute_win_active
|
176
|
-
event_history.order_execute_row_to_select -= 1
|
177
|
-
event_history.order_execute_index_offset -= 1 if event_history.order_execute_row_to_select.negative?
|
178
|
-
event_history.order_execute_index_offset = 0 if event_history.order_execute_index_offset.negative?
|
179
|
-
event_history.order_execute_row_to_select = 0 if event_history.order_execute_row_to_select.negative?
|
180
|
-
end
|
190
|
+
terminal_win.key_press_event.key_enter = false
|
191
|
+
File.write('/tmp/key_enter.DETECTED', nil)
|
181
192
|
end
|
182
193
|
end
|
183
194
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.264
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 0day Inc.
|
@@ -381,10 +381,16 @@ files:
|
|
381
381
|
- lib/cryptum/api.rb
|
382
382
|
- lib/cryptum/bot_conf.rb
|
383
383
|
- lib/cryptum/event.rb
|
384
|
+
- lib/cryptum/event/bot_conf.rb
|
384
385
|
- lib/cryptum/event/buy.rb
|
385
386
|
- lib/cryptum/event/cancel.rb
|
387
|
+
- lib/cryptum/event/exit.rb
|
388
|
+
- lib/cryptum/event/gtfo.rb
|
386
389
|
- lib/cryptum/event/history.rb
|
387
390
|
- lib/cryptum/event/key_press.rb
|
391
|
+
- lib/cryptum/event/order_book.rb
|
392
|
+
- lib/cryptum/event/pane.rb
|
393
|
+
- lib/cryptum/event/scroll.rb
|
388
394
|
- lib/cryptum/event/sell.rb
|
389
395
|
- lib/cryptum/log.rb
|
390
396
|
- lib/cryptum/matrix.rb
|