cryptum 0.0.354 → 0.0.356
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +13 -116
- data/.github/workflows/main.yml +0 -16
- data/.gitignore +0 -30
- data/.rspec +0 -3
- data/.rspec_status +0 -0
- data/.rubocop.yml +0 -31
- data/.rubocop_todo.yml +0 -32
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/CODE_OF_CONDUCT.md +0 -84
- data/Gemfile +0 -38
- data/LICENSE +0 -674
- data/README.md +0 -75
- data/Rakefile +0 -19
- data/bin/cryptum +0 -73
- data/bin/cryptum-forecast +0 -200
- data/bin/cryptum-repl +0 -73
- data/bin/cryptum_autoinc_version +0 -38
- data/build_cryptum_gem.sh +0 -58
- data/cryptum.gemspec +0 -52
- data/cryptum_container.sh +0 -1
- data/docker/cryptum.json +0 -60
- data/docker/cryptum_container.sh +0 -59
- data/docker/packer_secrets.json.EXAMPLE +0 -7
- data/docker/provisioners/cryptum.sh +0 -11
- data/docker/provisioners/docker_bashrc.sh +0 -2
- data/docker/provisioners/docker_rvm.sh +0 -22
- data/docker/provisioners/init_image.sh +0 -28
- data/docker/provisioners/post_install.sh +0 -6
- data/docker/provisioners/ruby.sh +0 -16
- data/docker/provisioners/upload_globals.sh +0 -49
- data/etc/bot_confs/.gitkeep +0 -0
- data/etc/bot_confs/BOT_CONF.TEMPLATE +0 -10
- data/etc/coinbase_pro.yaml.EXAMPLE +0 -8
- data/etc/open_ai.yaml.EXAMPLE +0 -1
- data/git_commit.sh +0 -22
- data/lib/cryptum/api.rb +0 -688
- data/lib/cryptum/bot_conf.rb +0 -197
- data/lib/cryptum/event/bot_conf.rb +0 -34
- data/lib/cryptum/event/buy.rb +0 -145
- data/lib/cryptum/event/cancel.rb +0 -35
- data/lib/cryptum/event/exit.rb +0 -35
- data/lib/cryptum/event/gtfo.rb +0 -36
- data/lib/cryptum/event/history.rb +0 -105
- data/lib/cryptum/event/key_press.rb +0 -64
- data/lib/cryptum/event/order_book.rb +0 -34
- data/lib/cryptum/event/pane.rb +0 -65
- data/lib/cryptum/event/parse.rb +0 -181
- data/lib/cryptum/event/scroll.rb +0 -200
- data/lib/cryptum/event/sell.rb +0 -124
- data/lib/cryptum/event.rb +0 -27
- data/lib/cryptum/log.rb +0 -34
- data/lib/cryptum/matrix.rb +0 -181
- data/lib/cryptum/open_ai.rb +0 -156
- data/lib/cryptum/option/choice.rb +0 -28
- data/lib/cryptum/option.rb +0 -206
- data/lib/cryptum/order_book/generate.rb +0 -114
- data/lib/cryptum/order_book/indicator.rb +0 -15
- data/lib/cryptum/order_book/market_trend.rb +0 -137
- data/lib/cryptum/order_book/profit_margin.rb +0 -55
- data/lib/cryptum/order_book.rb +0 -19
- data/lib/cryptum/portfolio/balance.rb +0 -123
- data/lib/cryptum/portfolio.rb +0 -15
- data/lib/cryptum/ui/command.rb +0 -314
- data/lib/cryptum/ui/key_press_event.rb +0 -33
- data/lib/cryptum/ui/market_trend.rb +0 -74
- data/lib/cryptum/ui/order_execute_details.rb +0 -297
- data/lib/cryptum/ui/order_execution.rb +0 -573
- data/lib/cryptum/ui/order_plan.rb +0 -503
- data/lib/cryptum/ui/order_plan_details.rb +0 -240
- data/lib/cryptum/ui/order_timer.rb +0 -121
- data/lib/cryptum/ui/portfolio.rb +0 -221
- data/lib/cryptum/ui/signal_engine.rb +0 -109
- data/lib/cryptum/ui/terminal_window.rb +0 -111
- data/lib/cryptum/ui/ticker.rb +0 -319
- data/lib/cryptum/ui.rb +0 -343
- data/lib/cryptum/version.rb +0 -5
- data/lib/cryptum/web_sock/coinbase.rb +0 -102
- data/lib/cryptum/web_sock/event_machine.rb +0 -274
- data/lib/cryptum/web_sock.rb +0 -16
- data/lib/cryptum.rb +0 -120
- data/order_books/.gitkeep +0 -0
- data/reinstall_cryptum_gemset.sh +0 -29
- data/spec/lib/cryptum/api_spec.rb +0 -10
- data/spec/lib/cryptum/event_spec.rb +0 -10
- data/spec/lib/cryptum/log_spec.rb +0 -10
- data/spec/lib/cryptum/option_spec.rb +0 -10
- data/spec/lib/cryptum/order_book/generate_spec.rb +0 -10
- data/spec/lib/cryptum/order_book/market_trend_spec.rb +0 -10
- data/spec/lib/cryptum/order_book_spec.rb +0 -10
- data/spec/lib/cryptum/ui/command_spec.rb +0 -10
- data/spec/lib/cryptum/ui/ticker_spec.rb +0 -10
- data/spec/lib/cryptum/ui_spec.rb +0 -10
- data/spec/lib/cryptum/web_sock_spec.rb +0 -10
- data/spec/lib/cryptum_spec.rb +0 -10
- data/spec/spec_helper.rb +0 -3
- data/upgrade_Gemfile_gems.sh +0 -20
- data/upgrade_cryptum.sh +0 -13
- data/upgrade_gem.sh +0 -4
- data/upgrade_ruby.sh +0 -45
@@ -1,240 +0,0 @@
|
|
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
|
-
event_history = opts[:event_history]
|
16
|
-
order_plan_details_win = opts[:order_plan_details_win]
|
17
|
-
|
18
|
-
order = event_history.order_plan_selected_data
|
19
|
-
tpm = order[:tpm]
|
20
|
-
autotrade_percent = order[:autotrade_percent]
|
21
|
-
order_color = order[:color]
|
22
|
-
|
23
|
-
fiat_avail_out = Cryptum.beautify_large_number(
|
24
|
-
value: order[:fiat_available]
|
25
|
-
)
|
26
|
-
risk_alloc_out = Cryptum.beautify_large_number(
|
27
|
-
value: order[:risk_alloc]
|
28
|
-
)
|
29
|
-
slice_alloc_out = Cryptum.beautify_large_number(
|
30
|
-
value: order[:slice_alloc]
|
31
|
-
)
|
32
|
-
previous_slice_invest_out = Cryptum.beautify_large_number(
|
33
|
-
value: order[:previous_slice_invest]
|
34
|
-
)
|
35
|
-
invest_out = Cryptum.beautify_large_number(
|
36
|
-
value: order[:invest]
|
37
|
-
)
|
38
|
-
profit_out = Cryptum.beautify_large_number(
|
39
|
-
value: order[:profit]
|
40
|
-
)
|
41
|
-
tpm_out = format('%0.2f', tpm)
|
42
|
-
return_out = Cryptum.beautify_large_number(
|
43
|
-
value: order[:return]
|
44
|
-
)
|
45
|
-
autotrade_ln1_details = "1. Autotrade is set to #{autotrade_percent}% of $#{fiat_avail_out}, making $#{risk_alloc_out} available for this slice in"
|
46
|
-
autotrade_ln2_details = ' the order plan.'
|
47
|
-
if order[:last_slice]
|
48
|
-
slice_alloc_ln1_details = "2. Since $#{risk_alloc_out} is the remaining amount within the criteria defined in the Autotrade % above,"
|
49
|
-
slice_alloc_ln2_details = " $#{invest_out} will be allocated for this slice."
|
50
|
-
else
|
51
|
-
slice_alloc_ln1_details = "2. With $#{risk_alloc_out} available and a slice allocation of #{order[:allocation_percent]}%, $#{slice_alloc_out} plus the previous"
|
52
|
-
slice_alloc_ln2_details = " slice of $#{previous_slice_invest_out} results in $#{invest_out} being allocated for this slice."
|
53
|
-
end
|
54
|
-
profit_ln1_details = "3. With a slice allocation of $#{invest_out}, plus a TPM equal to #{tpm_out}%, $#{return_out} will be returned"
|
55
|
-
profit_ln2_details = " once sold. With $#{invest_out} invested, the gross profit equals $#{profit_out}, minus any Maker &"
|
56
|
-
profit_ln3_details = ' Taker (transaction) fees.'
|
57
|
-
|
58
|
-
# UI
|
59
|
-
col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
|
60
|
-
|
61
|
-
# ROW 1
|
62
|
-
out_line_no = 0
|
63
|
-
line_color = order_color
|
64
|
-
header_color = order_color
|
65
|
-
header_style = :bold
|
66
|
-
style = :bold
|
67
|
-
header_style = :reverse if event_history.order_plan_details_win_active
|
68
|
-
|
69
|
-
Cryptum::UI.line(
|
70
|
-
ui_win: order_plan_details_win,
|
71
|
-
out_line_no: out_line_no,
|
72
|
-
color: line_color
|
73
|
-
)
|
74
|
-
|
75
|
-
# ROW 2
|
76
|
-
out_line_no += 1
|
77
|
-
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
78
|
-
order_plan_details_win.clrtoeol
|
79
|
-
Cryptum::UI.colorize(
|
80
|
-
ui_win: order_plan_details_win,
|
81
|
-
color: header_color,
|
82
|
-
style: header_style,
|
83
|
-
string: ''.ljust(col_just1, ' ')
|
84
|
-
)
|
85
|
-
|
86
|
-
header_str = "- ORDER SLICE ##{order[:plan_no]} DETAILS -"
|
87
|
-
order_plan_details_win.setpos(
|
88
|
-
out_line_no,
|
89
|
-
Cryptum::UI.col_center(str: header_str)
|
90
|
-
)
|
91
|
-
|
92
|
-
Cryptum::UI.colorize(
|
93
|
-
ui_win: order_plan_details_win,
|
94
|
-
color: order_color,
|
95
|
-
style: header_style,
|
96
|
-
string: header_str
|
97
|
-
)
|
98
|
-
|
99
|
-
# ROW 3
|
100
|
-
out_line_no += 1
|
101
|
-
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
102
|
-
order_plan_details_win.clrtoeol
|
103
|
-
|
104
|
-
Cryptum::UI.colorize(
|
105
|
-
ui_win: order_plan_details_win,
|
106
|
-
color: order_color,
|
107
|
-
style: style,
|
108
|
-
string: autotrade_ln1_details.ljust(col_just1, ' ')
|
109
|
-
)
|
110
|
-
|
111
|
-
# ROW 4
|
112
|
-
out_line_no += 1
|
113
|
-
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
114
|
-
order_plan_details_win.clrtoeol
|
115
|
-
|
116
|
-
Cryptum::UI.colorize(
|
117
|
-
ui_win: order_plan_details_win,
|
118
|
-
color: order_color,
|
119
|
-
style: style,
|
120
|
-
string: autotrade_ln2_details.ljust(col_just1, ' ')
|
121
|
-
)
|
122
|
-
|
123
|
-
# ROW 5
|
124
|
-
out_line_no += 1
|
125
|
-
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
126
|
-
order_plan_details_win.clrtoeol
|
127
|
-
|
128
|
-
Cryptum::UI.colorize(
|
129
|
-
ui_win: order_plan_details_win,
|
130
|
-
color: order_color,
|
131
|
-
style: style,
|
132
|
-
string: slice_alloc_ln1_details.ljust(col_just1, ' ')
|
133
|
-
)
|
134
|
-
|
135
|
-
# ROW 6
|
136
|
-
out_line_no += 1
|
137
|
-
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
138
|
-
order_plan_details_win.clrtoeol
|
139
|
-
|
140
|
-
Cryptum::UI.colorize(
|
141
|
-
ui_win: order_plan_details_win,
|
142
|
-
color: order_color,
|
143
|
-
style: style,
|
144
|
-
string: slice_alloc_ln2_details.ljust(col_just1, ' ')
|
145
|
-
)
|
146
|
-
|
147
|
-
# ROW 7
|
148
|
-
out_line_no += 1
|
149
|
-
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
150
|
-
order_plan_details_win.clrtoeol
|
151
|
-
|
152
|
-
Cryptum::UI.colorize(
|
153
|
-
ui_win: order_plan_details_win,
|
154
|
-
color: order_color,
|
155
|
-
style: style,
|
156
|
-
string: profit_ln1_details.ljust(col_just1, ' ')
|
157
|
-
)
|
158
|
-
|
159
|
-
# ROW 8
|
160
|
-
out_line_no += 1
|
161
|
-
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
162
|
-
order_plan_details_win.clrtoeol
|
163
|
-
|
164
|
-
Cryptum::UI.colorize(
|
165
|
-
ui_win: order_plan_details_win,
|
166
|
-
color: order_color,
|
167
|
-
style: style,
|
168
|
-
string: profit_ln2_details.ljust(col_just1, ' ')
|
169
|
-
)
|
170
|
-
|
171
|
-
# ROW 9
|
172
|
-
out_line_no += 1
|
173
|
-
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
174
|
-
order_plan_details_win.clrtoeol
|
175
|
-
|
176
|
-
Cryptum::UI.colorize(
|
177
|
-
ui_win: order_plan_details_win,
|
178
|
-
color: order_color,
|
179
|
-
style: style,
|
180
|
-
string: profit_ln3_details.ljust(col_just1, ' ')
|
181
|
-
)
|
182
|
-
|
183
|
-
# Clear to OK ROW
|
184
|
-
ok_row = 9
|
185
|
-
out_line_no += 1
|
186
|
-
to_ok_row = ok_row - 1
|
187
|
-
(out_line_no..to_ok_row).each do |clr_line|
|
188
|
-
order_plan_details_win.setpos(clr_line, Cryptum::UI.col_first)
|
189
|
-
Cryptum::UI.colorize(
|
190
|
-
ui_win: order_plan_details_win,
|
191
|
-
color: order_color,
|
192
|
-
style: :normal,
|
193
|
-
string: ''.ljust(col_just1, ' ')
|
194
|
-
)
|
195
|
-
end
|
196
|
-
|
197
|
-
# OK ROW
|
198
|
-
out_line_no = ok_row
|
199
|
-
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
200
|
-
order_plan_details_win.clrtoeol
|
201
|
-
Cryptum::UI.colorize(
|
202
|
-
ui_win: order_plan_details_win,
|
203
|
-
color: order_color,
|
204
|
-
string: ''.ljust(col_just1, ' ')
|
205
|
-
)
|
206
|
-
|
207
|
-
header_str = '- OK -'
|
208
|
-
order_plan_details_win.setpos(
|
209
|
-
out_line_no,
|
210
|
-
Cryptum::UI.col_center(str: header_str)
|
211
|
-
)
|
212
|
-
|
213
|
-
Cryptum::UI.colorize(
|
214
|
-
ui_win: order_plan_details_win,
|
215
|
-
color: order_color,
|
216
|
-
style: :reverse,
|
217
|
-
string: header_str
|
218
|
-
)
|
219
|
-
|
220
|
-
order_plan_details_win.refresh
|
221
|
-
|
222
|
-
event_history
|
223
|
-
rescue Interrupt
|
224
|
-
# Exit Gracefully if CTRL+C is Pressed During Session
|
225
|
-
Cryptum.exit_gracefully(which_self: self)
|
226
|
-
rescue StandardError => e
|
227
|
-
raise e
|
228
|
-
end
|
229
|
-
|
230
|
-
# Display Usage for this Module
|
231
|
-
|
232
|
-
public_class_method def self.help
|
233
|
-
puts "USAGE:
|
234
|
-
#{self}.refresh(
|
235
|
-
)
|
236
|
-
"
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
@@ -1,121 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'logger'
|
4
|
-
|
5
|
-
module Cryptum
|
6
|
-
module UI
|
7
|
-
# This plugin is used to Refresh the Cryptum Status Section UI
|
8
|
-
module OrderTimer
|
9
|
-
# Supported Method Parameters::
|
10
|
-
# Cryptum::UI::Timer.refresh(
|
11
|
-
# )
|
12
|
-
|
13
|
-
public_class_method def self.refresh(opts = {})
|
14
|
-
option_choice = opts[:option_choice]
|
15
|
-
event_history = opts[:event_history]
|
16
|
-
order_timer_win = opts[:order_timer_win]
|
17
|
-
indicator_status = opts[:indicator_status]
|
18
|
-
|
19
|
-
last_trend_reset_time = event_history.order_book[:last_trend_reset]
|
20
|
-
last_order_exec_time = event_history.order_book[:last_order_exec]
|
21
|
-
|
22
|
-
# Market Trend Reset Timer
|
23
|
-
time_between_trend_reset = option_choice.market_trend_reset
|
24
|
-
trend_timer_begin = Time.parse(last_trend_reset_time)
|
25
|
-
trend_timer_end = trend_timer_begin + time_between_trend_reset
|
26
|
-
trend_time_remaining = trend_timer_end - Time.now
|
27
|
-
trend_countdown = Cryptum.beautify_large_number(
|
28
|
-
value: format('%0.2f', trend_time_remaining)
|
29
|
-
)
|
30
|
-
|
31
|
-
# Market Trend Reset Timer
|
32
|
-
time_between_order_exec = event_history.time_between_orders
|
33
|
-
time_between_order_exec_out = Cryptum.beautify_large_number(
|
34
|
-
value: format('%0.2f', time_between_order_exec)
|
35
|
-
)
|
36
|
-
order_begin_time = Time.parse(last_order_exec_time)
|
37
|
-
order_end_time = order_begin_time + time_between_order_exec
|
38
|
-
order_exec_time_remaining = order_end_time - Time.now
|
39
|
-
order_countdown = Cryptum.beautify_large_number(
|
40
|
-
value: format('%0.2f', order_exec_time_remaining)
|
41
|
-
)
|
42
|
-
|
43
|
-
buy_total = event_history.order_book[:market_trend][:buy].to_i
|
44
|
-
sell_total = event_history.order_book[:market_trend][:sell].to_i
|
45
|
-
|
46
|
-
color = :white
|
47
|
-
color = indicator_status.market_trend[:color] if indicator_status.market_trend
|
48
|
-
case color
|
49
|
-
when :green
|
50
|
-
# TODO: add condition to check if open sell orders exist.
|
51
|
-
# If so intent should be something like, "- SEE ORDER HISTORY -"
|
52
|
-
# Otherwise, intent should be something like, "- WAIT FOR MARKET TREND SHIFT -"
|
53
|
-
intent = "- SEE ORDER HISTORY #{Cryptum.down_arrow} -"
|
54
|
-
else
|
55
|
-
speed = 'FAST'
|
56
|
-
speed = 'SLOW' if buy_total >= sell_total
|
57
|
-
|
58
|
-
intent = "- #{speed} BUY: #{order_countdown} of #{time_between_order_exec_out} -"
|
59
|
-
intent = '- BUYING PAUSED -' if event_history.red_pill
|
60
|
-
end
|
61
|
-
|
62
|
-
# Have a Clock
|
63
|
-
clock = Time.now.strftime('%Y-%m-%d %H:%M:%S%z')
|
64
|
-
|
65
|
-
# UI
|
66
|
-
col_just4 = (Curses.cols - Cryptum::UI.col_fourth) - 1
|
67
|
-
|
68
|
-
# ROW 1
|
69
|
-
# COLUMN 1
|
70
|
-
out_line_no = 0
|
71
|
-
order_timer_win.setpos(out_line_no, Cryptum::UI.col_first)
|
72
|
-
order_timer_win.clrtoeol
|
73
|
-
Cryptum::UI.colorize(
|
74
|
-
ui_win: order_timer_win,
|
75
|
-
color: :white,
|
76
|
-
style: :bold,
|
77
|
-
string: "#{option_choice.market_trend_reset_label} M. Trend Rst: #{trend_countdown}"
|
78
|
-
)
|
79
|
-
|
80
|
-
# COLUMN 2
|
81
|
-
order_timer_win.setpos(
|
82
|
-
out_line_no,
|
83
|
-
Cryptum::UI.col_center(str: intent)
|
84
|
-
)
|
85
|
-
Cryptum::UI.colorize(
|
86
|
-
ui_win: order_timer_win,
|
87
|
-
color: :white,
|
88
|
-
style: :bold,
|
89
|
-
string: intent
|
90
|
-
)
|
91
|
-
|
92
|
-
# COLUMN 3
|
93
|
-
order_timer_win.setpos(out_line_no, Cryptum::UI.col_fourth)
|
94
|
-
Cryptum::UI.colorize(
|
95
|
-
ui_win: order_timer_win,
|
96
|
-
color: :white,
|
97
|
-
style: :bold,
|
98
|
-
string: clock.rjust(col_just4)
|
99
|
-
)
|
100
|
-
|
101
|
-
order_timer_win.refresh
|
102
|
-
|
103
|
-
order_countdown.to_f
|
104
|
-
rescue Interrupt
|
105
|
-
# Exit Gracefully if CTRL+C is Pressed During Session
|
106
|
-
Cryptum.exit_gracefully(which_self: self)
|
107
|
-
rescue StandardError => e
|
108
|
-
raise e
|
109
|
-
end
|
110
|
-
|
111
|
-
# Display Usage for this Module
|
112
|
-
|
113
|
-
public_class_method def self.help
|
114
|
-
puts "USAGE:
|
115
|
-
#{self}.refresh(
|
116
|
-
)
|
117
|
-
"
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
data/lib/cryptum/ui/portfolio.rb
DELETED
@@ -1,221 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'logger'
|
4
|
-
|
5
|
-
module Cryptum
|
6
|
-
# This plugin is used to Refresh the Cryptum console UI
|
7
|
-
module UI
|
8
|
-
module Portfolio
|
9
|
-
# Supported Method Parameters::
|
10
|
-
# Cryptum::UI::Candle.refresh(
|
11
|
-
# order_book: 'required - Order Book Data Structure',
|
12
|
-
# event: 'required - Event from Coinbase Web Socket'
|
13
|
-
# )
|
14
|
-
|
15
|
-
public_class_method def self.refresh(opts = {})
|
16
|
-
option_choice = opts[:option_choice]
|
17
|
-
portfolio_win = opts[:portfolio_win]
|
18
|
-
event_history = opts[:event_history]
|
19
|
-
bot_conf = opts[:bot_conf]
|
20
|
-
|
21
|
-
ticker_price = event_history.order_book[:ticker_price].to_f
|
22
|
-
this_product = event_history.order_book[:this_product]
|
23
|
-
symbol_out = this_product[:id]
|
24
|
-
base_increment = this_product[:base_increment]
|
25
|
-
|
26
|
-
crypto_smallest_decimal = base_increment.to_s.split('.')[-1].length
|
27
|
-
|
28
|
-
autotrade_percent = format(
|
29
|
-
'%0.2f',
|
30
|
-
bot_conf[:autotrade_portfolio_percent].to_f
|
31
|
-
)
|
32
|
-
|
33
|
-
tpm = format(
|
34
|
-
'%0.2f',
|
35
|
-
bot_conf[:target_profit_margin_percent]
|
36
|
-
)
|
37
|
-
|
38
|
-
crypto_currency = option_choice.symbol.to_s.upcase.split('_').first.to_sym
|
39
|
-
portfolio = event_history.order_book[:portfolio]
|
40
|
-
this_account = portfolio.select do |account|
|
41
|
-
account[:currency] == crypto_currency.to_s
|
42
|
-
end
|
43
|
-
raise "ID for Crypto Currency, #{crypto_currency} Not Found" if this_account.empty?
|
44
|
-
|
45
|
-
balance = format("%0.#{crypto_smallest_decimal}f", this_account.first[:balance])
|
46
|
-
balance_out = Cryptum.beautify_large_number(
|
47
|
-
value: balance
|
48
|
-
)
|
49
|
-
avail_for_trade = format("%0.#{crypto_smallest_decimal}f", this_account.first[:available])
|
50
|
-
avail_for_trade_out = Cryptum.beautify_large_number(
|
51
|
-
value: avail_for_trade
|
52
|
-
)
|
53
|
-
|
54
|
-
fiat_portfolio = event_history.order_book[:fiat_portfolio]
|
55
|
-
fiat = option_choice.symbol.to_s.upcase.split('_').last.to_sym
|
56
|
-
total_holdings = format('%0.2f', fiat_portfolio.first[:total_holdings])
|
57
|
-
total_holdings_out = Cryptum.beautify_large_number(
|
58
|
-
value: total_holdings
|
59
|
-
)
|
60
|
-
fiat_balance = format('%0.2f', fiat_portfolio.first[:balance])
|
61
|
-
fiat_balance_out = Cryptum.beautify_large_number(
|
62
|
-
value: fiat_balance
|
63
|
-
)
|
64
|
-
fiat_avail_for_trade = format('%0.2f', fiat_portfolio.first[:available])
|
65
|
-
fiat_avail_for_trade_out = Cryptum.beautify_large_number(
|
66
|
-
value: fiat_avail_for_trade
|
67
|
-
)
|
68
|
-
|
69
|
-
fees = event_history.order_book[:fees]
|
70
|
-
maker_fee = format('%0.2f', fees[:maker_fee_rate].to_f * 100)
|
71
|
-
taker_fee = format('%0.2f', fees[:taker_fee_rate].to_f * 100)
|
72
|
-
volume_tier = format('%0.2f', fees[:usd_volume].to_f)
|
73
|
-
volume_tier_out = Cryptum.beautify_large_number(
|
74
|
-
value: volume_tier
|
75
|
-
)
|
76
|
-
|
77
|
-
current_crypto_fiat_value = format(
|
78
|
-
'%0.2f',
|
79
|
-
balance.to_f * ticker_price
|
80
|
-
)
|
81
|
-
current_crypto_fiat_value_out = Cryptum.beautify_large_number(
|
82
|
-
value: current_crypto_fiat_value
|
83
|
-
)
|
84
|
-
|
85
|
-
fiat_budget = fiat_avail_for_trade.to_f
|
86
|
-
current_fiat_invested_percent = format(
|
87
|
-
'%0.2f',
|
88
|
-
(1 - (fiat_budget / total_holdings.to_f)) * 100
|
89
|
-
)
|
90
|
-
|
91
|
-
crypto_invested_percent = format(
|
92
|
-
'%0.2f',
|
93
|
-
current_crypto_fiat_value.to_f.fdiv(total_holdings.to_f) * 100
|
94
|
-
)
|
95
|
-
# TODO: Everything Above this Line Needs to be Indicators ^
|
96
|
-
|
97
|
-
# UI
|
98
|
-
col_just3 = (Curses.cols - Cryptum::UI.col_third) - 1
|
99
|
-
|
100
|
-
# ROW 1
|
101
|
-
out_line_no = 0
|
102
|
-
Cryptum::UI.line(
|
103
|
-
ui_win: portfolio_win,
|
104
|
-
out_line_no: out_line_no
|
105
|
-
)
|
106
|
-
|
107
|
-
# ROW 2
|
108
|
-
out_line_no += 1
|
109
|
-
portfolio_win.setpos(out_line_no, Cryptum::UI.col_first)
|
110
|
-
portfolio_win.clrtoeol
|
111
|
-
Cryptum::UI.colorize(
|
112
|
-
ui_win: portfolio_win,
|
113
|
-
color: :white,
|
114
|
-
style: :bold,
|
115
|
-
string: "Portfolio | % Tied Up | % #{symbol_out}:"
|
116
|
-
)
|
117
|
-
|
118
|
-
portfolio_win.setpos(out_line_no, Cryptum::UI.col_third)
|
119
|
-
Cryptum::UI.colorize(
|
120
|
-
ui_win: portfolio_win,
|
121
|
-
color: :white,
|
122
|
-
string: "$#{total_holdings_out} | #{current_fiat_invested_percent}% | #{crypto_invested_percent}%".rjust(col_just3, '.')
|
123
|
-
)
|
124
|
-
|
125
|
-
# ROW 3
|
126
|
-
out_line_no += 1
|
127
|
-
portfolio_win.setpos(out_line_no, Cryptum::UI.col_first)
|
128
|
-
portfolio_win.clrtoeol
|
129
|
-
Cryptum::UI.colorize(
|
130
|
-
ui_win: portfolio_win,
|
131
|
-
color: :cyan,
|
132
|
-
string: 'TPM % | Autotrade %:'
|
133
|
-
)
|
134
|
-
|
135
|
-
portfolio_win.setpos(out_line_no, Cryptum::UI.col_third)
|
136
|
-
Cryptum::UI.colorize(
|
137
|
-
ui_win: portfolio_win,
|
138
|
-
color: :cyan,
|
139
|
-
string: "#{tpm}% | #{autotrade_percent}%".rjust(col_just3, '.')
|
140
|
-
)
|
141
|
-
|
142
|
-
# ROW 4
|
143
|
-
out_line_no += 1
|
144
|
-
portfolio_win.setpos(out_line_no, Cryptum::UI.col_first)
|
145
|
-
portfolio_win.clrtoeol
|
146
|
-
Cryptum::UI.colorize(
|
147
|
-
ui_win: portfolio_win,
|
148
|
-
color: :green,
|
149
|
-
style: :bold,
|
150
|
-
string: "#{fiat} Bal | Tradeable:"
|
151
|
-
)
|
152
|
-
|
153
|
-
portfolio_win.setpos(out_line_no, Cryptum::UI.col_third)
|
154
|
-
Cryptum::UI.colorize(
|
155
|
-
ui_win: portfolio_win,
|
156
|
-
color: :green,
|
157
|
-
string: "$#{fiat_balance_out} | $#{fiat_avail_for_trade_out}".rjust(
|
158
|
-
col_just3,
|
159
|
-
'.'
|
160
|
-
)
|
161
|
-
)
|
162
|
-
|
163
|
-
# ROW 5
|
164
|
-
out_line_no += 1
|
165
|
-
portfolio_win.setpos(out_line_no, Cryptum::UI.col_first)
|
166
|
-
portfolio_win.clrtoeol
|
167
|
-
Cryptum::UI.colorize(
|
168
|
-
ui_win: portfolio_win,
|
169
|
-
color: :yellow,
|
170
|
-
style: :bold,
|
171
|
-
string: 'Crypto Val | Bal | Tradeable:'
|
172
|
-
)
|
173
|
-
|
174
|
-
portfolio_win.setpos(out_line_no, Cryptum::UI.col_third)
|
175
|
-
Cryptum::UI.colorize(
|
176
|
-
ui_win: portfolio_win,
|
177
|
-
color: :yellow,
|
178
|
-
string: "$#{current_crypto_fiat_value_out} | *#{balance_out} | *#{avail_for_trade_out}".rjust(col_just3, '.')
|
179
|
-
)
|
180
|
-
|
181
|
-
# ROW 6
|
182
|
-
out_line_no += 1
|
183
|
-
portfolio_win.setpos(out_line_no, Cryptum::UI.col_first)
|
184
|
-
portfolio_win.clrtoeol
|
185
|
-
Cryptum::UI.colorize(
|
186
|
-
ui_win: portfolio_win,
|
187
|
-
color: :red,
|
188
|
-
style: :bold,
|
189
|
-
string: 'Maker & Taker Fees | My Volume:'
|
190
|
-
)
|
191
|
-
|
192
|
-
portfolio_win.setpos(out_line_no, Cryptum::UI.col_third)
|
193
|
-
Cryptum::UI.colorize(
|
194
|
-
ui_win: portfolio_win,
|
195
|
-
color: :red,
|
196
|
-
string: "#{maker_fee}% & #{taker_fee}% | $#{volume_tier_out}".rjust(col_just3, '.')
|
197
|
-
)
|
198
|
-
|
199
|
-
portfolio_win.refresh
|
200
|
-
|
201
|
-
event_history
|
202
|
-
rescue Interrupt
|
203
|
-
# Exit Gracefully if CTRL+C is Pressed During Session
|
204
|
-
Cryptum.exit_gracefully(which_self: self)
|
205
|
-
rescue StandardError => e
|
206
|
-
raise e
|
207
|
-
end
|
208
|
-
|
209
|
-
# Display Usage for this Module
|
210
|
-
|
211
|
-
public_class_method def self.help
|
212
|
-
puts "USAGE:
|
213
|
-
#{self}.refresh(
|
214
|
-
order_book: 'required - Order Book Data Structure',
|
215
|
-
event: 'required - Event from Coinbase Web Socket'
|
216
|
-
)
|
217
|
-
"
|
218
|
-
end
|
219
|
-
end
|
220
|
-
end
|
221
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'logger'
|
4
|
-
|
5
|
-
module Cryptum
|
6
|
-
# This plugin is used to Refresh the Cryptum console UI
|
7
|
-
module UI
|
8
|
-
module SignalEngine
|
9
|
-
# Supported Method Parameters::
|
10
|
-
# Cryptum::UI::Candle.refresh(
|
11
|
-
# order_book: 'required - Order Book Data Structure',
|
12
|
-
# event: 'required - Event from Coinbase Web Socket'
|
13
|
-
# )
|
14
|
-
|
15
|
-
public_class_method def self.refresh(opts = {})
|
16
|
-
signal_engine_win = opts[:signal_engine_win]
|
17
|
-
indicator_status = opts[:indicator_status]
|
18
|
-
|
19
|
-
color = :white
|
20
|
-
color = indicator_status.market_trend[:color] if indicator_status.market_trend
|
21
|
-
|
22
|
-
indicator_status.last_action_signal = indicator_status.action_signal
|
23
|
-
|
24
|
-
case color
|
25
|
-
when :green
|
26
|
-
signal_color = :green
|
27
|
-
action_signal = :sell
|
28
|
-
when :yellow
|
29
|
-
signal_color = :yellow
|
30
|
-
action_signal = :hold
|
31
|
-
when :red
|
32
|
-
signal_color = :cyan
|
33
|
-
action_signal = :buy
|
34
|
-
else
|
35
|
-
signal_color = :white
|
36
|
-
action_signal = :skip
|
37
|
-
end
|
38
|
-
|
39
|
-
action_signal_out = "SIGNAL >>> #{action_signal.to_s.upcase} <<< ENGINE"
|
40
|
-
# TODO: Everything Above this Line Needs to be Indicators ^
|
41
|
-
|
42
|
-
# UI
|
43
|
-
col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
|
44
|
-
col_just4 = Curses.cols - Cryptum::UI.col_fourth
|
45
|
-
|
46
|
-
# ROW 1
|
47
|
-
out_line_no = 0
|
48
|
-
Cryptum::UI.line(
|
49
|
-
ui_win: signal_engine_win,
|
50
|
-
out_line_no: out_line_no
|
51
|
-
)
|
52
|
-
|
53
|
-
# ROW 2
|
54
|
-
out_line_no += 1
|
55
|
-
signal_engine_win.setpos(out_line_no, Cryptum::UI.col_first)
|
56
|
-
signal_engine_win.clrtoeol
|
57
|
-
|
58
|
-
Cryptum::UI.colorize(
|
59
|
-
ui_win: signal_engine_win,
|
60
|
-
color: signal_color,
|
61
|
-
style: :reverse,
|
62
|
-
string: ''.ljust(col_just1, ' ')
|
63
|
-
)
|
64
|
-
|
65
|
-
signal_engine_win.setpos(
|
66
|
-
out_line_no,
|
67
|
-
Cryptum::UI.col_center(str: action_signal_out)
|
68
|
-
)
|
69
|
-
|
70
|
-
Cryptum::UI.colorize(
|
71
|
-
ui_win: signal_engine_win,
|
72
|
-
color: signal_color,
|
73
|
-
style: :reverse,
|
74
|
-
string: action_signal_out
|
75
|
-
)
|
76
|
-
|
77
|
-
signal_engine_win.setpos(out_line_no, Cryptum::UI.col_fourth)
|
78
|
-
Cryptum::UI.colorize(
|
79
|
-
ui_win: signal_engine_win,
|
80
|
-
color: signal_color,
|
81
|
-
style: :reverse,
|
82
|
-
string: ''.ljust(col_just4, ' ')
|
83
|
-
)
|
84
|
-
|
85
|
-
signal_engine_win.refresh
|
86
|
-
|
87
|
-
indicator_status.action_signal = action_signal
|
88
|
-
|
89
|
-
indicator_status
|
90
|
-
rescue Interrupt
|
91
|
-
# Exit Gracefully if CTRL+C is Pressed During Session
|
92
|
-
Cryptum.exit_gracefully(which_self: self)
|
93
|
-
rescue StandardError => e
|
94
|
-
raise e
|
95
|
-
end
|
96
|
-
|
97
|
-
# Display Usage for this Module
|
98
|
-
|
99
|
-
public_class_method def self.help
|
100
|
-
puts "USAGE:
|
101
|
-
#{self}.refresh(
|
102
|
-
order_book: 'required - Order Book Data Structure',
|
103
|
-
event: 'required - Event from Coinbase Web Socket'
|
104
|
-
)
|
105
|
-
"
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|