cryptum 0.0.266 → 0.0.268
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 -41
- data/Gemfile +1 -1
- data/lib/cryptum/event/history.rb +9 -1
- data/lib/cryptum/event/pane.rb +41 -0
- data/lib/cryptum/event.rb +41 -19
- data/lib/cryptum/option.rb +5 -4
- data/lib/cryptum/order_book/market_trend.rb +6 -4
- data/lib/cryptum/order_execute_details.rb +56 -0
- data/lib/cryptum/ui/order_execute_details.rb +167 -0
- data/lib/cryptum/ui/order_execution.rb +8 -1
- data/lib/cryptum/ui/order_plan.rb +12 -5
- data/lib/cryptum/ui/order_plan_details.rb +163 -0
- data/lib/cryptum/ui/terminal_window.rb +16 -0
- data/lib/cryptum/ui.rb +2 -0
- data/lib/cryptum/version.rb +1 -1
- data/lib/cryptum/web_sock/event_machine.rb +4 -4
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d384463e4c37155226e6cedb4a2156b77d7a9df8660f420acb15fc04de7875f0
|
4
|
+
data.tar.gz: 82e3e395beb272f6634ae1335093cee1ffa10504229720fe5a5821c5d811d6e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d60b522b67253efd740f0fb41943f3fcdc9c76ec0441c0880c0e409b9769d5d30544857573fe42411bf4e0ebac89808348e8ba34b9d274521dfb75e16c93edc6
|
7
|
+
data.tar.gz: a4edd8b79853a7d59135b4e9d136a2f4556a8de663adf9c926f1bd7f1491aa1a655095216845543e5d0d9c0996155f525b3659b236c460de54dfc97e23e65695
|
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-05 18:21:06 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
|
@@ -41,13 +41,6 @@ Layout/EmptyLines:
|
|
41
41
|
Exclude:
|
42
42
|
- 'lib/cryptum/api.rb'
|
43
43
|
|
44
|
-
# Offense count: 1
|
45
|
-
# This cop supports safe autocorrection (--autocorrect).
|
46
|
-
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
|
47
|
-
Layout/ExtraSpacing:
|
48
|
-
Exclude:
|
49
|
-
- 'lib/cryptum/ui/order_plan.rb'
|
50
|
-
|
51
44
|
# Offense count: 1
|
52
45
|
# This cop supports safe autocorrection (--autocorrect).
|
53
46
|
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
@@ -82,14 +75,6 @@ Layout/MultilineOperationIndentation:
|
|
82
75
|
- 'lib/cryptum/ui/order_execution.rb'
|
83
76
|
- 'lib/cryptum/ui/ticker.rb'
|
84
77
|
|
85
|
-
# Offense count: 1
|
86
|
-
# This cop supports safe autocorrection (--autocorrect).
|
87
|
-
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
|
88
|
-
# SupportedStylesForExponentOperator: space, no_space
|
89
|
-
Layout/SpaceAroundOperators:
|
90
|
-
Exclude:
|
91
|
-
- 'lib/cryptum/ui/order_plan.rb'
|
92
|
-
|
93
78
|
# Offense count: 13
|
94
79
|
# This cop supports safe autocorrection (--autocorrect).
|
95
80
|
# Configuration parameters: AllowInHeredoc.
|
@@ -102,29 +87,14 @@ Layout/TrailingWhitespace:
|
|
102
87
|
- 'lib/cryptum/ui/order_plan.rb'
|
103
88
|
- 'lib/cryptum/ui/order_timer.rb'
|
104
89
|
|
105
|
-
# Offense count:
|
90
|
+
# Offense count: 81
|
106
91
|
Lint/UselessAssignment:
|
107
|
-
|
108
|
-
- 'bin/cryptum-forecast'
|
109
|
-
- 'lib/cryptum.rb'
|
110
|
-
- 'lib/cryptum/api.rb'
|
111
|
-
- 'lib/cryptum/event.rb'
|
112
|
-
- 'lib/cryptum/event/buy.rb'
|
113
|
-
- 'lib/cryptum/event/scroll.rb'
|
114
|
-
- 'lib/cryptum/order_book/generate.rb'
|
115
|
-
- 'lib/cryptum/order_book/market_trend.rb'
|
116
|
-
- 'lib/cryptum/ui/market_trend.rb'
|
117
|
-
- 'lib/cryptum/ui/order_execution.rb'
|
118
|
-
- 'lib/cryptum/ui/order_plan.rb'
|
119
|
-
- 'lib/cryptum/ui/order_timer.rb'
|
120
|
-
- 'lib/cryptum/ui/portfolio.rb'
|
121
|
-
- 'lib/cryptum/ui/signal_engine.rb'
|
122
|
-
- 'lib/cryptum/ui/ticker.rb'
|
92
|
+
Enabled: false
|
123
93
|
|
124
|
-
# Offense count:
|
94
|
+
# Offense count: 49
|
125
95
|
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
|
126
96
|
Metrics/AbcSize:
|
127
|
-
Max:
|
97
|
+
Max: 405
|
128
98
|
|
129
99
|
# Offense count: 7
|
130
100
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
|
@@ -137,22 +107,22 @@ Metrics/BlockLength:
|
|
137
107
|
Metrics/BlockNesting:
|
138
108
|
Max: 4
|
139
109
|
|
140
|
-
# Offense count:
|
110
|
+
# Offense count: 20
|
141
111
|
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
|
142
112
|
Metrics/CyclomaticComplexity:
|
143
113
|
Max: 73
|
144
114
|
|
145
|
-
# Offense count:
|
115
|
+
# Offense count: 68
|
146
116
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
|
147
117
|
Metrics/MethodLength:
|
148
|
-
Max:
|
118
|
+
Max: 389
|
149
119
|
|
150
|
-
# Offense count:
|
120
|
+
# Offense count: 17
|
151
121
|
# Configuration parameters: CountComments, CountAsOne.
|
152
122
|
Metrics/ModuleLength:
|
153
123
|
Max: 538
|
154
124
|
|
155
|
-
# Offense count:
|
125
|
+
# Offense count: 19
|
156
126
|
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
|
157
127
|
Metrics/PerceivedComplexity:
|
158
128
|
Max: 76
|
@@ -209,6 +179,12 @@ Style/RedundantAssignment:
|
|
209
179
|
Exclude:
|
210
180
|
- 'lib/cryptum/api.rb'
|
211
181
|
|
182
|
+
# Offense count: 1
|
183
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
184
|
+
Style/RedundantInterpolation:
|
185
|
+
Exclude:
|
186
|
+
- 'lib/cryptum/ui/order_execute_details.rb'
|
187
|
+
|
212
188
|
# Offense count: 1
|
213
189
|
# This cop supports safe autocorrection (--autocorrect).
|
214
190
|
# Configuration parameters: AllowMultipleReturnValues.
|
@@ -246,7 +222,7 @@ Style/TrailingCommaInArrayLiteral:
|
|
246
222
|
Exclude:
|
247
223
|
- 'lib/cryptum/matrix.rb'
|
248
224
|
|
249
|
-
# Offense count:
|
225
|
+
# Offense count: 18
|
250
226
|
# This cop supports safe autocorrection (--autocorrect).
|
251
227
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
|
252
228
|
# URISchemes: http, https
|
data/Gemfile
CHANGED
@@ -25,13 +25,17 @@ module Cryptum
|
|
25
25
|
:time_between_orders_min,
|
26
26
|
:time_between_orders_reset,
|
27
27
|
:order_plan_win_active,
|
28
|
+
:order_plan_details_win_active,
|
28
29
|
:order_plan_index_offset,
|
29
30
|
:order_plan_max_rows_to_display,
|
30
31
|
:order_plan_row_to_select,
|
32
|
+
:order_plan_selected_data,
|
31
33
|
:order_execute_win_active,
|
34
|
+
:order_execute_details_win_active,
|
32
35
|
:order_execute_index_offset,
|
33
36
|
:order_execute_max_rows_to_display,
|
34
|
-
:order_execute_row_to_select
|
37
|
+
:order_execute_row_to_select,
|
38
|
+
:order_execute_selected_data
|
35
39
|
|
36
40
|
def initialize(opts = {})
|
37
41
|
# option_choice = opts[:option_choice]
|
@@ -49,13 +53,17 @@ module Cryptum
|
|
49
53
|
self.reconnected = false
|
50
54
|
self.red_pill = false
|
51
55
|
self.order_plan_win_active = true
|
56
|
+
self.order_plan_details_win_active = false
|
52
57
|
self.order_plan_index_offset = 0
|
53
58
|
self.order_plan_max_rows_to_display = 6
|
54
59
|
self.order_plan_row_to_select = order_plan_index_offset
|
60
|
+
self.order_plan_selected_data = { color: :white }
|
55
61
|
self.order_execute_win_active = false
|
62
|
+
self.order_execute_details_win_active = false
|
56
63
|
self.order_execute_index_offset = 0
|
57
64
|
self.order_execute_max_rows_to_display = 6
|
58
65
|
self.order_execute_row_to_select = order_execute_index_offset
|
66
|
+
self.order_execute_selected_data = { color: :white }
|
59
67
|
|
60
68
|
# TODO: Implement market_trend_reset / 144
|
61
69
|
# Default = 10 minutes
|
data/lib/cryptum/event/pane.rb
CHANGED
@@ -25,10 +25,51 @@ module Cryptum
|
|
25
25
|
raise e
|
26
26
|
end
|
27
27
|
|
28
|
+
# Supported Method Parameters::
|
29
|
+
# Cryptum::Event::Pane.toggle_details(
|
30
|
+
# )
|
31
|
+
public_class_method def self.toggle_details(opts = {})
|
32
|
+
terminal_win = opts[:terminal_win]
|
33
|
+
event_history = opts[:event_history]
|
34
|
+
|
35
|
+
terminal_win.key_press_event.key_enter = false
|
36
|
+
|
37
|
+
if event_history.order_plan_win_active &&
|
38
|
+
!event_history.order_plan_details_win_active &&
|
39
|
+
!event_history.order_execute_win_active
|
40
|
+
|
41
|
+
event_history.order_plan_win_active = false
|
42
|
+
event_history.order_plan_details_win_active = true
|
43
|
+
elsif !event_history.order_plan_win_active &&
|
44
|
+
event_history.order_plan_details_win_active &&
|
45
|
+
!event_history.order_execute_win_active
|
46
|
+
|
47
|
+
event_history.order_plan_win_active = true
|
48
|
+
event_history.order_plan_details_win_active = false
|
49
|
+
end
|
50
|
+
|
51
|
+
if event_history.order_execute_win_active &&
|
52
|
+
!event_history.order_execute_details_win_active &&
|
53
|
+
!event_history.order_plan_win_active
|
54
|
+
|
55
|
+
event_history.order_execute_win_active = false
|
56
|
+
event_history.order_execute_details_win_active = true
|
57
|
+
elsif !event_history.order_execute_win_active &&
|
58
|
+
event_history.order_execute_details_win_active &&
|
59
|
+
!event_history.order_plan_win_active
|
60
|
+
|
61
|
+
event_history.order_execute_win_active = true
|
62
|
+
event_history.order_execute_details_win_active = false
|
63
|
+
end
|
64
|
+
rescue StandardError => e
|
65
|
+
raise e
|
66
|
+
end
|
67
|
+
|
28
68
|
# Display Usage for this Module
|
29
69
|
public_class_method def self.help
|
30
70
|
puts "USAGE:
|
31
71
|
#{self}.switch()
|
72
|
+
#{self}.toggle_details()
|
32
73
|
"
|
33
74
|
end
|
34
75
|
end
|
data/lib/cryptum/event.rb
CHANGED
@@ -112,26 +112,48 @@ module Cryptum
|
|
112
112
|
fiat_portfolio_file: fiat_portfolio_file
|
113
113
|
)
|
114
114
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
115
|
+
unless event_history.order_plan_details_win_active
|
116
|
+
Cryptum::UI::OrderPlan.refresh(
|
117
|
+
option_choice: option_choice,
|
118
|
+
order_plan_win: terminal_win.order_plan_section,
|
119
|
+
event_history: event_history,
|
120
|
+
key_press_event: terminal_win.key_press_event,
|
121
|
+
indicator_status: indicator_status,
|
122
|
+
bot_conf: bot_conf,
|
123
|
+
fiat_portfolio_file: fiat_portfolio_file
|
124
|
+
)
|
125
|
+
end
|
124
126
|
|
125
|
-
event_history
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
127
|
+
if event_history.order_plan_details_win_active
|
128
|
+
Cryptum::UI::OrderPlanDetails.refresh(
|
129
|
+
option_choice: option_choice,
|
130
|
+
order_plan_details_win: terminal_win.order_plan_details_section,
|
131
|
+
event_history: event_history,
|
132
|
+
key_press_event: terminal_win.key_press_event
|
133
|
+
)
|
134
|
+
end
|
135
|
+
|
136
|
+
unless event_history.order_execute_details_win_active
|
137
|
+
event_history = Cryptum::UI::OrderExecution.refresh(
|
138
|
+
option_choice: option_choice,
|
139
|
+
order_execute_win: terminal_win.order_execute_section,
|
140
|
+
env: env,
|
141
|
+
event_history: event_history,
|
142
|
+
key_press_event: terminal_win.key_press_event,
|
143
|
+
indicator_status: indicator_status,
|
144
|
+
bot_conf: bot_conf,
|
145
|
+
fiat_portfolio_file: fiat_portfolio_file
|
146
|
+
)
|
147
|
+
end
|
148
|
+
|
149
|
+
if event_history.order_execute_details_win_active
|
150
|
+
Cryptum::UI::OrderExecuteDetails.refresh(
|
151
|
+
option_choice: option_choice,
|
152
|
+
order_execute_details_win: terminal_win.order_execute_details_section,
|
153
|
+
event_history: event_history,
|
154
|
+
key_press_event: terminal_win.key_press_event
|
155
|
+
)
|
156
|
+
end
|
135
157
|
|
136
158
|
# Refresh Command Section for Cryptum Session Usage
|
137
159
|
Cryptum::UI::Command.refresh(
|
data/lib/cryptum/option.rb
CHANGED
@@ -56,7 +56,7 @@ module Cryptum
|
|
56
56
|
options.on(
|
57
57
|
'-tSECONDS',
|
58
58
|
'--time-between-market-trend-reset=SECONDS',
|
59
|
-
'<Optional - Seconds Between Market Trend Reset (Default
|
59
|
+
'<Optional - Seconds Between Market Trend Reset (Default 3_600 i.e. 1 hour)>'
|
60
60
|
) { |t| option_choice.market_trend_reset = t.to_i }
|
61
61
|
end.parse!
|
62
62
|
|
@@ -89,8 +89,9 @@ module Cryptum
|
|
89
89
|
reason = :repo_root
|
90
90
|
end
|
91
91
|
|
92
|
-
option_choice.market_trend_reset =
|
93
|
-
unless option_choice.market_trend_reset.to_i
|
92
|
+
option_choice.market_trend_reset = 3_600 if option_choice.market_trend_reset.to_i.zero?
|
93
|
+
unless option_choice.market_trend_reset.to_i >= 60 &&
|
94
|
+
option_choice.market_trend_reset <= 86_400
|
94
95
|
usage = true
|
95
96
|
reason = :market_trend_reset
|
96
97
|
end
|
@@ -113,7 +114,7 @@ module Cryptum
|
|
113
114
|
when :repo_root
|
114
115
|
puts "ERROR: #{option_choice.repo_root} does not exist.\n\n"
|
115
116
|
when :market_trend_reset
|
116
|
-
puts "ERROR: #{option_choice.market_trend_reset} Must be a positive
|
117
|
+
puts "ERROR: #{option_choice.market_trend_reset} Must be a positive integer between 60-86_400.\n\n"
|
117
118
|
end
|
118
119
|
|
119
120
|
puts `#{option_choice.driver_name} --help`
|
@@ -33,11 +33,13 @@ module Cryptum
|
|
33
33
|
|
34
34
|
# order_difference = 0
|
35
35
|
if buy_total > sell_total
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
# Too expensive
|
37
|
+
# order_difference = Cryptum.beautify_large_number(
|
38
|
+
# value: buy_total - sell_total
|
39
|
+
# ).to_i
|
40
|
+
order_difference = buy_total - sell_total
|
39
41
|
indicator_hash[:color] = :green
|
40
|
-
indicator_hash[:ui] = "BUYS UP BY #{order_difference}"
|
42
|
+
indicator_hash[:ui] = "BUYS UP BY #{order_difference.to_i}"
|
41
43
|
indicator_hash[:status] = "B#{Cryptum.up_arrow}"
|
42
44
|
elsif buy_total < sell_total
|
43
45
|
order_difference = Cryptum.beautify_large_number(
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
module Cryptum
|
6
|
+
module UI
|
7
|
+
# This plugin is used to Display Order Execute Details
|
8
|
+
# selected from the Order Execute Window Pane.
|
9
|
+
module OrderExecuteDetails
|
10
|
+
# Supported Method Parameters::
|
11
|
+
# Cryptum::UI::OrderExecuteDetails.refresh(
|
12
|
+
# )
|
13
|
+
|
14
|
+
public_class_method def self.refresh(opts = {})
|
15
|
+
option_choice = opts[:option_choice]
|
16
|
+
event_history = opts[:event_history]
|
17
|
+
order_execute_details_win = opts[:order_execute_details_win]
|
18
|
+
indicator_status = opts[:indicator_status]
|
19
|
+
key_press_event = opts[:key_press_event]
|
20
|
+
|
21
|
+
color = :white
|
22
|
+
|
23
|
+
# UI
|
24
|
+
col_just4 = (Curses.cols - Cryptum::UI.col_fourth) - 1
|
25
|
+
|
26
|
+
# ROW 1
|
27
|
+
# COLUMN 1
|
28
|
+
out_line_no = 0
|
29
|
+
order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
30
|
+
order_execute_details_win.clrtoeol
|
31
|
+
Cryptum::UI.colorize(
|
32
|
+
ui_win: order_execute_details_win,
|
33
|
+
color: :white,
|
34
|
+
style: :bold,
|
35
|
+
string: 'Order Details'
|
36
|
+
)
|
37
|
+
|
38
|
+
order_execute_details_win.refresh
|
39
|
+
rescue Interrupt
|
40
|
+
# Exit Gracefully if CTRL+C is Pressed During Session
|
41
|
+
Cryptum.exit_gracefully(which_self: self)
|
42
|
+
rescue StandardError => e
|
43
|
+
raise e
|
44
|
+
end
|
45
|
+
|
46
|
+
# Display Usage for this Module
|
47
|
+
|
48
|
+
public_class_method def self.help
|
49
|
+
puts "USAGE:
|
50
|
+
#{self}.refresh(
|
51
|
+
)
|
52
|
+
"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
module Cryptum
|
6
|
+
module UI
|
7
|
+
# This plugin is used to Display Order Execute Details
|
8
|
+
# selected from the Order Execute Window Pane.
|
9
|
+
module OrderExecuteDetails
|
10
|
+
# Supported Method Parameters::
|
11
|
+
# Cryptum::UI::OrderExecuteDetails.refresh(
|
12
|
+
# )
|
13
|
+
|
14
|
+
public_class_method def self.refresh(opts = {})
|
15
|
+
option_choice = opts[:option_choice]
|
16
|
+
event_history = opts[:event_history]
|
17
|
+
order_execute_details_win = opts[:order_execute_details_win]
|
18
|
+
indicator_status = opts[:indicator_status]
|
19
|
+
key_press_event = opts[:key_press_event]
|
20
|
+
|
21
|
+
order = event_history.order_execute_selected_data
|
22
|
+
tpm = order[:tpm]
|
23
|
+
autotrade_percent = order[:autotrade_percent]
|
24
|
+
order_color = order[:color]
|
25
|
+
|
26
|
+
# UI
|
27
|
+
col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
|
28
|
+
col_just3 = (Curses.cols - Cryptum::UI.col_third) - 1
|
29
|
+
col_just4 = Curses.cols - Cryptum::UI.col_fourth
|
30
|
+
|
31
|
+
# ROW 1
|
32
|
+
out_line_no = 0
|
33
|
+
line_color = order_color
|
34
|
+
header_color = order_color
|
35
|
+
header_style = :bold
|
36
|
+
style = :bold
|
37
|
+
header_style = :reverse if event_history.order_execute_details_win_active
|
38
|
+
|
39
|
+
Cryptum::UI.line(
|
40
|
+
ui_win: order_execute_details_win,
|
41
|
+
out_line_no: out_line_no,
|
42
|
+
color: line_color
|
43
|
+
)
|
44
|
+
|
45
|
+
# ROW 2
|
46
|
+
out_line_no += 1
|
47
|
+
order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
48
|
+
order_execute_details_win.clrtoeol
|
49
|
+
Cryptum::UI.colorize(
|
50
|
+
ui_win: order_execute_details_win,
|
51
|
+
color: header_color,
|
52
|
+
style: header_style,
|
53
|
+
string: ''.ljust(col_just1, ' ')
|
54
|
+
)
|
55
|
+
|
56
|
+
header_str = "- ##{order[:plan_no]} ORDER HISTORY DETAILS -"
|
57
|
+
order_execute_details_win.setpos(
|
58
|
+
out_line_no,
|
59
|
+
Cryptum::UI.col_center(str: header_str)
|
60
|
+
)
|
61
|
+
|
62
|
+
Cryptum::UI.colorize(
|
63
|
+
ui_win: order_execute_details_win,
|
64
|
+
color: order_color,
|
65
|
+
style: :bold,
|
66
|
+
string: header_str
|
67
|
+
)
|
68
|
+
|
69
|
+
# ROW 3
|
70
|
+
out_line_no += 1
|
71
|
+
order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
72
|
+
order_execute_details_win.clrtoeol
|
73
|
+
|
74
|
+
risk_alloc_out = Cryptum.beautify_large_number(
|
75
|
+
value: order[:risk_alloc]
|
76
|
+
)
|
77
|
+
invest_out = Cryptum.beautify_large_number(
|
78
|
+
value: order[:invest]
|
79
|
+
)
|
80
|
+
price_out = Cryptum.beautify_large_number(
|
81
|
+
value: order[:price]
|
82
|
+
)
|
83
|
+
size_out = Cryptum.beautify_large_number(
|
84
|
+
value: order[:size]
|
85
|
+
)
|
86
|
+
target_price_out = Cryptum.beautify_large_number(
|
87
|
+
value: order[:target_price]
|
88
|
+
)
|
89
|
+
profit_out = Cryptum.beautify_large_number(
|
90
|
+
value: order[:profit]
|
91
|
+
)
|
92
|
+
plan_no = "#{order[:plan_no]}|"
|
93
|
+
|
94
|
+
created_at = order[:created_at]
|
95
|
+
|
96
|
+
invest = "$#{invest_out} @ "
|
97
|
+
tick = "$#{price_out} = "
|
98
|
+
size = "*#{size_out} + "
|
99
|
+
tpm_out = "#{order[:tpm]}% = "
|
100
|
+
targ_tick = "$#{target_price_out}"
|
101
|
+
profit = "|Profit: $#{order[:profit]}"
|
102
|
+
|
103
|
+
order_exec_ln = "#{created_at}|#{invest}#{tick}#{size}#{tpm_out}#{targ_tick}#{profit}"
|
104
|
+
|
105
|
+
Cryptum::UI.colorize(
|
106
|
+
ui_win: order_execute_details_win,
|
107
|
+
color: order_color,
|
108
|
+
style: style,
|
109
|
+
string: order_exec_ln.ljust(col_just1, '.')
|
110
|
+
)
|
111
|
+
|
112
|
+
# Clear to OK ROW
|
113
|
+
ok_row = 9
|
114
|
+
out_line_no += 1
|
115
|
+
to_ok_row = ok_row - 1
|
116
|
+
(out_line_no..to_ok_row).each do |clr_line|
|
117
|
+
order_execute_details_win.setpos(clr_line, Cryptum::UI.col_first)
|
118
|
+
Cryptum::UI.colorize(
|
119
|
+
ui_win: order_execute_details_win,
|
120
|
+
color: order_color,
|
121
|
+
style: :normal,
|
122
|
+
string: ''.ljust(col_just1, ' ')
|
123
|
+
)
|
124
|
+
end
|
125
|
+
|
126
|
+
# OK ROW
|
127
|
+
out_line_no = ok_row
|
128
|
+
order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
129
|
+
order_execute_details_win.clrtoeol
|
130
|
+
Cryptum::UI.colorize(
|
131
|
+
ui_win: order_execute_details_win,
|
132
|
+
color: order_color,
|
133
|
+
string: ''.ljust(col_just1, ' ')
|
134
|
+
)
|
135
|
+
|
136
|
+
header_str = '- OK -'
|
137
|
+
order_execute_details_win.setpos(
|
138
|
+
out_line_no,
|
139
|
+
Cryptum::UI.col_center(str: header_str)
|
140
|
+
)
|
141
|
+
|
142
|
+
Cryptum::UI.colorize(
|
143
|
+
ui_win: order_execute_details_win,
|
144
|
+
color: order_color,
|
145
|
+
style: :reverse,
|
146
|
+
string: header_str
|
147
|
+
)
|
148
|
+
|
149
|
+
order_execute_details_win.refresh
|
150
|
+
rescue Interrupt
|
151
|
+
# Exit Gracefully if CTRL+C is Pressed During Session
|
152
|
+
Cryptum.exit_gracefully(which_self: self)
|
153
|
+
rescue StandardError => e
|
154
|
+
raise e
|
155
|
+
end
|
156
|
+
|
157
|
+
# Display Usage for this Module
|
158
|
+
|
159
|
+
public_class_method def self.help
|
160
|
+
puts "USAGE:
|
161
|
+
#{self}.refresh(
|
162
|
+
)
|
163
|
+
"
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
@@ -421,12 +421,18 @@ module Cryptum
|
|
421
421
|
end
|
422
422
|
|
423
423
|
if order_history_meta.any?
|
424
|
+
selected_order = event_history.order_execute_selected_data
|
424
425
|
order_history_meta.reverse[first_row..last_row].each do |meta|
|
425
426
|
out_line_no += 1
|
426
427
|
current_line = out_line_no - 2
|
427
428
|
|
428
429
|
style = :normal
|
429
|
-
|
430
|
+
if event_history.order_execute_row_to_select == current_line
|
431
|
+
style = :highlight
|
432
|
+
selected_order = meta
|
433
|
+
selected_order[:color] = meta[:color]
|
434
|
+
end
|
435
|
+
|
430
436
|
risk_alloc_out = Cryptum.beautify_large_number(
|
431
437
|
value: meta[:risk_alloc]
|
432
438
|
)
|
@@ -476,6 +482,7 @@ module Cryptum
|
|
476
482
|
string: order_exec_ln.ljust(col_just1, '.')
|
477
483
|
)
|
478
484
|
end
|
485
|
+
event_history.order_execute_selected_data = selected_order
|
479
486
|
end
|
480
487
|
|
481
488
|
# ROW 10
|
@@ -321,12 +321,20 @@ module Cryptum
|
|
321
321
|
event_history.order_plan_index_offset = first_row
|
322
322
|
end
|
323
323
|
|
324
|
+
selected_order = event_history.order_plan_selected_data
|
324
325
|
order_plan[first_row..last_row].each do |order|
|
325
326
|
out_line_no += 1
|
326
327
|
current_line = out_line_no - 2
|
327
328
|
|
328
329
|
style = :normal
|
329
|
-
|
330
|
+
if event_history.order_plan_row_to_select == current_line
|
331
|
+
style = :highlight
|
332
|
+
selected_order = order
|
333
|
+
selected_order[:tpm] = tpm
|
334
|
+
selected_order[:autotrade_percent] = autotrade_percent
|
335
|
+
selected_order[:color] = plan_color
|
336
|
+
end
|
337
|
+
|
330
338
|
fiat_avail_out = Cryptum.beautify_large_number(
|
331
339
|
value: order[:fiat_available]
|
332
340
|
)
|
@@ -348,11 +356,11 @@ module Cryptum
|
|
348
356
|
alloc = "$#{risk_alloc_out} @ #{order[:allocation_percent]}% = "
|
349
357
|
invest = "$#{invest_out} + #{tpm_out}% = "
|
350
358
|
|
351
|
-
returns
|
359
|
+
returns = "$#{return_out}|"
|
352
360
|
profit = "Profit: $#{profit_out}"
|
353
361
|
|
354
362
|
order_plan_invest = "#{plan_no}#{fiat}#{alloc}#{invest}"
|
355
|
-
order_plan_return
|
363
|
+
order_plan_return = "#{returns}#{profit}"
|
356
364
|
|
357
365
|
order_plan_win.setpos(out_line_no, Cryptum::UI.col_first)
|
358
366
|
order_plan_win.clrtoeol
|
@@ -363,6 +371,7 @@ module Cryptum
|
|
363
371
|
string: "#{order_plan_invest}#{order_plan_return}".ljust(col_just1, '.')
|
364
372
|
)
|
365
373
|
end
|
374
|
+
event_history.order_plan_selected_data = selected_order
|
366
375
|
|
367
376
|
if order_plan.length < 9
|
368
377
|
lines_to_clear = 9 - order_plan.length
|
@@ -407,8 +416,6 @@ module Cryptum
|
|
407
416
|
)
|
408
417
|
|
409
418
|
order_plan_win.refresh
|
410
|
-
|
411
|
-
# event_history
|
412
419
|
rescue Interrupt
|
413
420
|
# Exit Gracefully if CTRL+C is Pressed During Session
|
414
421
|
Cryptum.exit_gracefully(which_self: self)
|
@@ -0,0 +1,163 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
module Cryptum
|
6
|
+
module UI
|
7
|
+
# This plugin is used to Display Order Plan Details
|
8
|
+
# selected from the Order Plan Window Pane.
|
9
|
+
module OrderPlanDetails
|
10
|
+
# Supported Method Parameters::
|
11
|
+
# Cryptum::UI::OrderPlanDetails.refresh(
|
12
|
+
# )
|
13
|
+
|
14
|
+
public_class_method def self.refresh(opts = {})
|
15
|
+
option_choice = opts[:option_choice]
|
16
|
+
event_history = opts[:event_history]
|
17
|
+
order_plan_details_win = opts[:order_plan_details_win]
|
18
|
+
indicator_status = opts[:indicator_status]
|
19
|
+
key_press_event = opts[:key_press_event]
|
20
|
+
|
21
|
+
order = event_history.order_plan_selected_data
|
22
|
+
tpm = order[:tpm]
|
23
|
+
autotrade_percent = order[:autotrade_percent]
|
24
|
+
order_color = order[:color]
|
25
|
+
|
26
|
+
# UI
|
27
|
+
col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
|
28
|
+
col_just3 = (Curses.cols - Cryptum::UI.col_third) - 1
|
29
|
+
col_just4 = Curses.cols - Cryptum::UI.col_fourth
|
30
|
+
|
31
|
+
# ROW 1
|
32
|
+
out_line_no = 0
|
33
|
+
line_color = order_color
|
34
|
+
header_color = order_color
|
35
|
+
header_style = :bold
|
36
|
+
style = :bold
|
37
|
+
header_style = :reverse if event_history.order_plan_details_win_active
|
38
|
+
|
39
|
+
Cryptum::UI.line(
|
40
|
+
ui_win: order_plan_details_win,
|
41
|
+
out_line_no: out_line_no,
|
42
|
+
color: line_color
|
43
|
+
)
|
44
|
+
|
45
|
+
# ROW 2
|
46
|
+
out_line_no += 1
|
47
|
+
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
48
|
+
order_plan_details_win.clrtoeol
|
49
|
+
Cryptum::UI.colorize(
|
50
|
+
ui_win: order_plan_details_win,
|
51
|
+
color: header_color,
|
52
|
+
style: header_style,
|
53
|
+
string: ''.ljust(col_just1, ' ')
|
54
|
+
)
|
55
|
+
|
56
|
+
header_str = "- ##{order[:plan_no]} ORDER SLICE DETAILS -"
|
57
|
+
order_plan_details_win.setpos(
|
58
|
+
out_line_no,
|
59
|
+
Cryptum::UI.col_center(str: header_str)
|
60
|
+
)
|
61
|
+
|
62
|
+
Cryptum::UI.colorize(
|
63
|
+
ui_win: order_plan_details_win,
|
64
|
+
color: order_color,
|
65
|
+
style: :bold,
|
66
|
+
string: header_str
|
67
|
+
)
|
68
|
+
|
69
|
+
# ROW 3
|
70
|
+
out_line_no += 1
|
71
|
+
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
72
|
+
order_plan_details_win.clrtoeol
|
73
|
+
|
74
|
+
fiat_avail_out = Cryptum.beautify_large_number(
|
75
|
+
value: order[:fiat_available]
|
76
|
+
)
|
77
|
+
risk_alloc_out = Cryptum.beautify_large_number(
|
78
|
+
value: order[:risk_alloc]
|
79
|
+
)
|
80
|
+
invest_out = Cryptum.beautify_large_number(
|
81
|
+
value: order[:invest]
|
82
|
+
)
|
83
|
+
profit_out = Cryptum.beautify_large_number(
|
84
|
+
value: order[:profit]
|
85
|
+
)
|
86
|
+
tpm_out = format('%0.2f', tpm)
|
87
|
+
return_out = Cryptum.beautify_large_number(
|
88
|
+
value: order[:return]
|
89
|
+
)
|
90
|
+
plan_no = "#{order[:plan_no]}|"
|
91
|
+
fiat = "#{autotrade_percent}% of $#{fiat_avail_out} = "
|
92
|
+
alloc = "$#{risk_alloc_out} @ #{order[:allocation_percent]}% = "
|
93
|
+
invest = "$#{invest_out} + #{tpm_out}% = "
|
94
|
+
|
95
|
+
returns = "$#{return_out}|"
|
96
|
+
profit = "Profit: $#{profit_out}"
|
97
|
+
|
98
|
+
order_plan_invest = "#{plan_no}#{fiat}#{alloc}#{invest}"
|
99
|
+
order_plan_return = "#{returns}#{profit}"
|
100
|
+
|
101
|
+
Cryptum::UI.colorize(
|
102
|
+
ui_win: order_plan_details_win,
|
103
|
+
color: order_color,
|
104
|
+
style: style,
|
105
|
+
string: "#{order_plan_invest}#{order_plan_return}".ljust(col_just1, '.')
|
106
|
+
)
|
107
|
+
|
108
|
+
# Clear to OK ROW
|
109
|
+
ok_row = 9
|
110
|
+
out_line_no += 1
|
111
|
+
to_ok_row = ok_row - 1
|
112
|
+
(out_line_no..to_ok_row).each do |clr_line|
|
113
|
+
order_plan_details_win.setpos(clr_line, Cryptum::UI.col_first)
|
114
|
+
Cryptum::UI.colorize(
|
115
|
+
ui_win: order_plan_details_win,
|
116
|
+
color: order_color,
|
117
|
+
style: :normal,
|
118
|
+
string: ''.ljust(col_just1, ' ')
|
119
|
+
)
|
120
|
+
end
|
121
|
+
|
122
|
+
# OK ROW
|
123
|
+
out_line_no = ok_row
|
124
|
+
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
125
|
+
order_plan_details_win.clrtoeol
|
126
|
+
Cryptum::UI.colorize(
|
127
|
+
ui_win: order_plan_details_win,
|
128
|
+
color: order_color,
|
129
|
+
string: ''.ljust(col_just1, ' ')
|
130
|
+
)
|
131
|
+
|
132
|
+
header_str = '- OK -'
|
133
|
+
order_plan_details_win.setpos(
|
134
|
+
out_line_no,
|
135
|
+
Cryptum::UI.col_center(str: header_str)
|
136
|
+
)
|
137
|
+
|
138
|
+
Cryptum::UI.colorize(
|
139
|
+
ui_win: order_plan_details_win,
|
140
|
+
color: order_color,
|
141
|
+
style: :reverse,
|
142
|
+
string: header_str
|
143
|
+
)
|
144
|
+
|
145
|
+
order_plan_details_win.refresh
|
146
|
+
rescue Interrupt
|
147
|
+
# Exit Gracefully if CTRL+C is Pressed During Session
|
148
|
+
Cryptum.exit_gracefully(which_self: self)
|
149
|
+
rescue StandardError => e
|
150
|
+
raise e
|
151
|
+
end
|
152
|
+
|
153
|
+
# Display Usage for this Module
|
154
|
+
|
155
|
+
public_class_method def self.help
|
156
|
+
puts "USAGE:
|
157
|
+
#{self}.refresh(
|
158
|
+
)
|
159
|
+
"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
@@ -13,11 +13,13 @@ module Cryptum
|
|
13
13
|
:ticker_section,
|
14
14
|
:portfolio_section,
|
15
15
|
:order_plan_section,
|
16
|
+
:order_plan_details_section,
|
16
17
|
:order_timer_section,
|
17
18
|
:market_trend_section,
|
18
19
|
:market_trend_ui_resize,
|
19
20
|
:signal_engine_section,
|
20
21
|
:order_execute_section,
|
22
|
+
:order_execute_details_section,
|
21
23
|
:command_section
|
22
24
|
|
23
25
|
def initialize
|
@@ -48,6 +50,13 @@ module Cryptum
|
|
48
50
|
left: 0
|
49
51
|
)
|
50
52
|
|
53
|
+
self.order_plan_details_section = Cryptum::UI.window(
|
54
|
+
height: 11,
|
55
|
+
width: 0,
|
56
|
+
top: 13,
|
57
|
+
left: 0
|
58
|
+
)
|
59
|
+
|
51
60
|
self.order_timer_section = Cryptum::UI.window(
|
52
61
|
height: 1,
|
53
62
|
width: 0,
|
@@ -76,6 +85,13 @@ module Cryptum
|
|
76
85
|
left: 0
|
77
86
|
)
|
78
87
|
|
88
|
+
self.order_execute_details_section = Cryptum::UI.window(
|
89
|
+
height: 11,
|
90
|
+
width: 0,
|
91
|
+
top: 29,
|
92
|
+
left: 0
|
93
|
+
)
|
94
|
+
|
79
95
|
self.command_section = Cryptum::UI.window(
|
80
96
|
height: 3,
|
81
97
|
width: 0,
|
data/lib/cryptum/ui.rb
CHANGED
@@ -12,10 +12,12 @@ module Cryptum
|
|
12
12
|
autoload :Ticker, 'cryptum/ui/ticker'
|
13
13
|
autoload :Portfolio, 'cryptum/ui/portfolio'
|
14
14
|
autoload :OrderPlan, 'cryptum/ui/order_plan'
|
15
|
+
autoload :OrderPlanDetails, 'cryptum/ui/order_plan_details'
|
15
16
|
autoload :OrderTimer, 'cryptum/ui/order_timer'
|
16
17
|
autoload :MarketTrend, 'cryptum/ui/market_trend'
|
17
18
|
autoload :SignalEngine, 'cryptum/ui/signal_engine'
|
18
19
|
autoload :OrderExecution, 'cryptum/ui/order_execution'
|
20
|
+
autoload :OrderExecuteDetails, 'cryptum/ui/order_execute_details'
|
19
21
|
autoload :Command, 'cryptum/ui/command'
|
20
22
|
|
21
23
|
# Initialize the UI
|
data/lib/cryptum/version.rb
CHANGED
@@ -185,10 +185,10 @@ module Cryptum
|
|
185
185
|
|
186
186
|
# Open / Close Order Plan / Order Execution Details Window
|
187
187
|
if terminal_win.key_press_event.key_enter
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
188
|
+
Cryptum::Event::Pane.toggle_details(
|
189
|
+
terminal_win: terminal_win,
|
190
|
+
event_history: event_history
|
191
|
+
)
|
192
192
|
end
|
193
193
|
end
|
194
194
|
|
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.268
|
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-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - '='
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 6.
|
159
|
+
version: 6.5.0
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - '='
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 6.
|
166
|
+
version: 6.5.0
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: require_all
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -402,14 +402,17 @@ files:
|
|
402
402
|
- lib/cryptum/order_book/market_trend.rb
|
403
403
|
- lib/cryptum/order_book/profit_margin.rb
|
404
404
|
- lib/cryptum/order_book/weighted_avg.rb
|
405
|
+
- lib/cryptum/order_execute_details.rb
|
405
406
|
- lib/cryptum/portfolio.rb
|
406
407
|
- lib/cryptum/portfolio/balance.rb
|
407
408
|
- lib/cryptum/ui.rb
|
408
409
|
- lib/cryptum/ui/command.rb
|
409
410
|
- lib/cryptum/ui/key_press_event.rb
|
410
411
|
- lib/cryptum/ui/market_trend.rb
|
412
|
+
- lib/cryptum/ui/order_execute_details.rb
|
411
413
|
- lib/cryptum/ui/order_execution.rb
|
412
414
|
- lib/cryptum/ui/order_plan.rb
|
415
|
+
- lib/cryptum/ui/order_plan_details.rb
|
413
416
|
- lib/cryptum/ui/order_timer.rb
|
414
417
|
- lib/cryptum/ui/portfolio.rb
|
415
418
|
- lib/cryptum/ui/signal_engine.rb
|