cryptum 0.0.359 → 0.0.360
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +16 -0
- data/.gitignore +30 -0
- data/.rspec +3 -0
- data/.rspec_status +0 -0
- data/.rubocop.yml +31 -0
- data/.rubocop_todo.yml +36 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +38 -0
- data/LICENSE +674 -0
- data/README.md +87 -0
- data/Rakefile +19 -0
- data/bin/cryptum +73 -0
- data/bin/cryptum-forecast +200 -0
- data/bin/cryptum-repl +73 -0
- data/bin/cryptum_autoinc_version +38 -0
- data/build_cryptum_gem.sh +58 -0
- data/cryptum.gemspec +52 -0
- data/cryptum_container.sh +1 -0
- data/docker/cryptum.json +60 -0
- data/docker/cryptum_container.sh +59 -0
- data/docker/packer_secrets.json.EXAMPLE +7 -0
- data/docker/provisioners/cryptum.sh +11 -0
- data/docker/provisioners/docker_bashrc.sh +2 -0
- data/docker/provisioners/docker_rvm.sh +22 -0
- data/docker/provisioners/init_image.sh +28 -0
- data/docker/provisioners/post_install.sh +6 -0
- data/docker/provisioners/ruby.sh +16 -0
- data/docker/provisioners/upload_globals.sh +49 -0
- data/etc/bot_confs/.gitkeep +0 -0
- data/etc/bot_confs/BOT_CONF.TEMPLATE +10 -0
- data/etc/coinbase_pro.yaml.EXAMPLE +8 -0
- data/etc/open_ai.yaml.EXAMPLE +1 -0
- data/git_commit.sh +22 -0
- data/lib/cryptum/api.rb +688 -0
- data/lib/cryptum/bot_conf.rb +197 -0
- data/lib/cryptum/event/bot_conf.rb +34 -0
- data/lib/cryptum/event/buy.rb +145 -0
- data/lib/cryptum/event/cancel.rb +35 -0
- data/lib/cryptum/event/exit.rb +35 -0
- data/lib/cryptum/event/gtfo.rb +36 -0
- data/lib/cryptum/event/history.rb +108 -0
- data/lib/cryptum/event/key_press.rb +64 -0
- data/lib/cryptum/event/order_book.rb +34 -0
- data/lib/cryptum/event/pane.rb +65 -0
- data/lib/cryptum/event/parse.rb +181 -0
- data/lib/cryptum/event/scroll.rb +200 -0
- data/lib/cryptum/event/sell.rb +124 -0
- data/lib/cryptum/event.rb +27 -0
- data/lib/cryptum/log.rb +34 -0
- data/lib/cryptum/matrix.rb +181 -0
- data/lib/cryptum/open_ai.rb +156 -0
- data/lib/cryptum/option/choice.rb +28 -0
- data/lib/cryptum/option.rb +206 -0
- data/lib/cryptum/order_book/generate.rb +114 -0
- data/lib/cryptum/order_book/indicator.rb +15 -0
- data/lib/cryptum/order_book/market_trend.rb +137 -0
- data/lib/cryptum/order_book/profit_margin.rb +55 -0
- data/lib/cryptum/order_book.rb +19 -0
- data/lib/cryptum/portfolio/balance.rb +123 -0
- data/lib/cryptum/portfolio.rb +15 -0
- data/lib/cryptum/ui/command.rb +314 -0
- data/lib/cryptum/ui/key_press_event.rb +33 -0
- data/lib/cryptum/ui/market_trend.rb +77 -0
- data/lib/cryptum/ui/order_execute_details.rb +297 -0
- data/lib/cryptum/ui/order_execution.rb +573 -0
- data/lib/cryptum/ui/order_plan.rb +512 -0
- data/lib/cryptum/ui/order_plan_details.rb +240 -0
- data/lib/cryptum/ui/order_timer.rb +136 -0
- data/lib/cryptum/ui/portfolio.rb +221 -0
- data/lib/cryptum/ui/signal_engine.rb +109 -0
- data/lib/cryptum/ui/terminal_window.rb +111 -0
- data/lib/cryptum/ui/ticker.rb +319 -0
- data/lib/cryptum/ui.rb +343 -0
- data/lib/cryptum/version.rb +5 -0
- data/lib/cryptum/web_sock/coinbase.rb +104 -0
- data/lib/cryptum/web_sock/event_machine.rb +276 -0
- data/lib/cryptum/web_sock.rb +16 -0
- data/lib/cryptum.rb +120 -0
- data/order_books/.gitkeep +0 -0
- data/reinstall_cryptum_gemset.sh +29 -0
- data/spec/lib/cryptum/api_spec.rb +10 -0
- data/spec/lib/cryptum/event_spec.rb +10 -0
- data/spec/lib/cryptum/log_spec.rb +10 -0
- data/spec/lib/cryptum/option_spec.rb +10 -0
- data/spec/lib/cryptum/order_book/generate_spec.rb +10 -0
- data/spec/lib/cryptum/order_book/market_trend_spec.rb +10 -0
- data/spec/lib/cryptum/order_book_spec.rb +10 -0
- data/spec/lib/cryptum/ui/command_spec.rb +10 -0
- data/spec/lib/cryptum/ui/ticker_spec.rb +10 -0
- data/spec/lib/cryptum/ui_spec.rb +10 -0
- data/spec/lib/cryptum/web_sock_spec.rb +10 -0
- data/spec/lib/cryptum_spec.rb +10 -0
- data/spec/spec_helper.rb +3 -0
- data/upgrade_Gemfile_gems.sh +20 -0
- data/upgrade_cryptum.sh +13 -0
- data/upgrade_gem.sh +4 -0
- data/upgrade_ruby.sh +45 -0
- metadata +112 -9
@@ -0,0 +1,77 @@
|
|
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 MarketTrend
|
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
|
+
market_trend_win = opts[:market_trend_win]
|
17
|
+
event_history = opts[:event_history]
|
18
|
+
event = opts[:event]
|
19
|
+
indicator_status = opts[:indicator_status]
|
20
|
+
|
21
|
+
indicator_hash = Cryptum::OrderBook::MarketTrend.status(
|
22
|
+
event_history: event_history,
|
23
|
+
event: event,
|
24
|
+
indicator_status: indicator_status
|
25
|
+
)
|
26
|
+
|
27
|
+
market_trend_color = indicator_hash[:color]
|
28
|
+
market_trend_out = indicator_hash[:ui]
|
29
|
+
|
30
|
+
# UI
|
31
|
+
# ROW 1
|
32
|
+
out_line_no = 0
|
33
|
+
Cryptum::UI.line(
|
34
|
+
ui_win: market_trend_win,
|
35
|
+
out_line_no: out_line_no
|
36
|
+
)
|
37
|
+
|
38
|
+
# ROW 2
|
39
|
+
out_line_no += 1
|
40
|
+
market_trend_win.setpos(out_line_no, Cryptum::UI.col_first)
|
41
|
+
market_trend_win.clrtoeol
|
42
|
+
|
43
|
+
market_trend_win.setpos(
|
44
|
+
out_line_no,
|
45
|
+
Cryptum::UI.col_center(str: market_trend_out)
|
46
|
+
)
|
47
|
+
|
48
|
+
Cryptum::UI.colorize(
|
49
|
+
ui_win: market_trend_win,
|
50
|
+
color: market_trend_color,
|
51
|
+
style: :bold,
|
52
|
+
string: market_trend_out
|
53
|
+
)
|
54
|
+
|
55
|
+
market_trend_win.refresh
|
56
|
+
|
57
|
+
event_history
|
58
|
+
rescue Interrupt
|
59
|
+
# Exit Gracefully if CTRL+C is Pressed During Session
|
60
|
+
Cryptum.exit_gracefully(which_self: self)
|
61
|
+
rescue StandardError => e
|
62
|
+
raise e
|
63
|
+
end
|
64
|
+
|
65
|
+
# Display Usage for this Module
|
66
|
+
|
67
|
+
public_class_method def self.help
|
68
|
+
puts "USAGE:
|
69
|
+
#{self}.refresh(
|
70
|
+
order_book: 'required - Order Book Data Structure',
|
71
|
+
event: 'required - Event from Coinbase Web Socket'
|
72
|
+
)
|
73
|
+
"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,297 @@
|
|
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
|
+
event_history = opts[:event_history]
|
16
|
+
order_execute_details_win = opts[:order_execute_details_win]
|
17
|
+
|
18
|
+
order_meta_data = event_history.order_execute_selected_data
|
19
|
+
|
20
|
+
order_color = order_meta_data[:color].to_sym
|
21
|
+
case order_color
|
22
|
+
when :cyan, :red
|
23
|
+
order_id = order_meta_data[:buy_order_id]
|
24
|
+
when :green, :magenta, :yellow
|
25
|
+
order_id = order_meta_data[:sell_order_id]
|
26
|
+
when :white
|
27
|
+
order_id = 'Expired'
|
28
|
+
else
|
29
|
+
order_id = 'N/A'
|
30
|
+
end
|
31
|
+
|
32
|
+
order_id_details = "- ID: #{order_id}"
|
33
|
+
|
34
|
+
order_history_arr = event_history.order_book[:order_history].select do |order|
|
35
|
+
order if order[:id] == order_id
|
36
|
+
end
|
37
|
+
|
38
|
+
if order_history_arr.empty? && order_color == :yellow
|
39
|
+
order_meta_data.delete(:sell_order_id)
|
40
|
+
order_id = order_meta_data[:buy_order_id]
|
41
|
+
order_meta_data[:color] = :cyan
|
42
|
+
order_history_arr = event_history.order_book[:order_history].select do |order|
|
43
|
+
order if order[:id] == order_id
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
order_type_ln = '- Type: N/A'
|
48
|
+
order_status_ln = '- Status: N/A'
|
49
|
+
fill_fees = 'N/A'
|
50
|
+
fill_size = 'N/A'
|
51
|
+
executed_value = 'N/A'
|
52
|
+
market_type = 'N/A'
|
53
|
+
settled = 'N/A'
|
54
|
+
unless order_history_arr.empty?
|
55
|
+
order_history = order_history_arr.first
|
56
|
+
order_type = order_history[:type].capitalize
|
57
|
+
time_in_force = order_history[:time_in_force].upcase
|
58
|
+
order_status = order_history[:status].upcase
|
59
|
+
created_at = order_history[:created_at]
|
60
|
+
fill_fees = order_history[:fill_fees]
|
61
|
+
fill_size = order_history[:filled_size]
|
62
|
+
executed_value = order_history[:executed_value]
|
63
|
+
market_type = order_history[:market_type]
|
64
|
+
settled = order_history[:settled]
|
65
|
+
|
66
|
+
order_side = order_history[:side].capitalize
|
67
|
+
case order_side.to_sym
|
68
|
+
when :Buy
|
69
|
+
expire_time = order_history[:expire_time]
|
70
|
+
done_at = order_history[:done_at]
|
71
|
+
order_meta_data[:color] = :cyan if done_at
|
72
|
+
when :Sell
|
73
|
+
done_at = order_history[:done_at]
|
74
|
+
end
|
75
|
+
|
76
|
+
order_type_ln = "- Type: #{order_type} #{order_side} #{time_in_force}"
|
77
|
+
order_type_ln = "- Type: #{order_type} #{order_side} #{time_in_force} 1m" if time_in_force == 'GTT'
|
78
|
+
order_status_ln = "- Status: #{order_status}"
|
79
|
+
end
|
80
|
+
|
81
|
+
if created_at && (!expire_time || !done_at)
|
82
|
+
order_hist_created_finished_ln = "- Creation Date: #{created_at} | Finished Date: N/A"
|
83
|
+
elsif created_at && expire_time && !done_at
|
84
|
+
order_hist_created_finished_ln = "- Creation Date: #{created_at} | Expiring Date: #{expire_time}"
|
85
|
+
elsif created_at && done_at
|
86
|
+
order_hist_created_finished_ln = "- Creation Date: #{created_at} | Finished Date: #{done_at}"
|
87
|
+
else
|
88
|
+
order_hist_created_finished_ln = '- Creation Date: N/A | Finished Date: N/A'
|
89
|
+
end
|
90
|
+
|
91
|
+
invest_out = Cryptum.beautify_large_number(
|
92
|
+
value: order_meta_data[:invest]
|
93
|
+
)
|
94
|
+
price_out = Cryptum.beautify_large_number(
|
95
|
+
value: order_meta_data[:price]
|
96
|
+
)
|
97
|
+
size_out = Cryptum.beautify_large_number(
|
98
|
+
value: order_meta_data[:size]
|
99
|
+
)
|
100
|
+
target_price_out = Cryptum.beautify_large_number(
|
101
|
+
value: order_meta_data[:target_price]
|
102
|
+
)
|
103
|
+
|
104
|
+
invest = "$#{invest_out} @ "
|
105
|
+
tick = "$#{price_out} = "
|
106
|
+
size = "*#{size_out} + "
|
107
|
+
tpm_out = "#{order_meta_data[:tpm]}% = "
|
108
|
+
targ_tick = "$#{target_price_out}"
|
109
|
+
profit = " | Profit: $#{order_meta_data[:profit]}"
|
110
|
+
|
111
|
+
details_ln1 = "- Slice Plan: #{invest}#{tick}#{size}#{tpm_out}#{targ_tick}#{profit}"
|
112
|
+
details_ln2 = "- Fees: $#{fill_fees} | Fill Size: *#{fill_size}"
|
113
|
+
details_ln3 = "- Executed Value: $#{executed_value} | Market Type: #{market_type} | Settled: #{settled}"
|
114
|
+
|
115
|
+
# UI
|
116
|
+
col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
|
117
|
+
|
118
|
+
# ROW 1
|
119
|
+
out_line_no = 0
|
120
|
+
line_color = order_color
|
121
|
+
header_color = order_color
|
122
|
+
header_style = :bold
|
123
|
+
style = :bold
|
124
|
+
header_style = :reverse if event_history.order_execute_details_win_active
|
125
|
+
|
126
|
+
Cryptum::UI.line(
|
127
|
+
ui_win: order_execute_details_win,
|
128
|
+
out_line_no: out_line_no,
|
129
|
+
color: line_color
|
130
|
+
)
|
131
|
+
|
132
|
+
# ROW 2
|
133
|
+
out_line_no += 1
|
134
|
+
order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
135
|
+
order_execute_details_win.clrtoeol
|
136
|
+
Cryptum::UI.colorize(
|
137
|
+
ui_win: order_execute_details_win,
|
138
|
+
color: header_color,
|
139
|
+
style: header_style,
|
140
|
+
string: ''.ljust(col_just1, ' ')
|
141
|
+
)
|
142
|
+
|
143
|
+
header_str = "- ORDER ##{order_meta_data[:plan_no]} DETAILS -"
|
144
|
+
order_execute_details_win.setpos(
|
145
|
+
out_line_no,
|
146
|
+
Cryptum::UI.col_center(str: header_str)
|
147
|
+
)
|
148
|
+
|
149
|
+
Cryptum::UI.colorize(
|
150
|
+
ui_win: order_execute_details_win,
|
151
|
+
color: order_color,
|
152
|
+
style: header_style,
|
153
|
+
string: header_str
|
154
|
+
)
|
155
|
+
|
156
|
+
# ROW 3
|
157
|
+
out_line_no += 1
|
158
|
+
order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
159
|
+
order_execute_details_win.clrtoeol
|
160
|
+
|
161
|
+
Cryptum::UI.colorize(
|
162
|
+
ui_win: order_execute_details_win,
|
163
|
+
color: order_color,
|
164
|
+
style: style,
|
165
|
+
string: order_id_details.ljust(col_just1, ' ')
|
166
|
+
)
|
167
|
+
|
168
|
+
# ROW 4
|
169
|
+
out_line_no += 1
|
170
|
+
order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
171
|
+
order_execute_details_win.clrtoeol
|
172
|
+
|
173
|
+
Cryptum::UI.colorize(
|
174
|
+
ui_win: order_execute_details_win,
|
175
|
+
color: order_color,
|
176
|
+
style: style,
|
177
|
+
string: order_type_ln.ljust(col_just1, ' ')
|
178
|
+
)
|
179
|
+
|
180
|
+
# ROW 5
|
181
|
+
out_line_no += 1
|
182
|
+
order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
183
|
+
order_execute_details_win.clrtoeol
|
184
|
+
|
185
|
+
Cryptum::UI.colorize(
|
186
|
+
ui_win: order_execute_details_win,
|
187
|
+
color: order_color,
|
188
|
+
style: style,
|
189
|
+
string: order_status_ln.ljust(col_just1, ' ')
|
190
|
+
)
|
191
|
+
|
192
|
+
# ROW 6
|
193
|
+
out_line_no += 1
|
194
|
+
order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
195
|
+
order_execute_details_win.clrtoeol
|
196
|
+
|
197
|
+
Cryptum::UI.colorize(
|
198
|
+
ui_win: order_execute_details_win,
|
199
|
+
color: order_color,
|
200
|
+
style: style,
|
201
|
+
string: order_hist_created_finished_ln.ljust(col_just1, ' ')
|
202
|
+
)
|
203
|
+
|
204
|
+
# ROW 7
|
205
|
+
out_line_no += 1
|
206
|
+
order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
207
|
+
order_execute_details_win.clrtoeol
|
208
|
+
|
209
|
+
Cryptum::UI.colorize(
|
210
|
+
ui_win: order_execute_details_win,
|
211
|
+
color: order_color,
|
212
|
+
style: style,
|
213
|
+
string: details_ln1.ljust(col_just1, ' ')
|
214
|
+
)
|
215
|
+
|
216
|
+
# ROW 8
|
217
|
+
out_line_no += 1
|
218
|
+
order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
219
|
+
order_execute_details_win.clrtoeol
|
220
|
+
|
221
|
+
Cryptum::UI.colorize(
|
222
|
+
ui_win: order_execute_details_win,
|
223
|
+
color: order_color,
|
224
|
+
style: style,
|
225
|
+
string: details_ln2.ljust(col_just1, ' ')
|
226
|
+
)
|
227
|
+
|
228
|
+
# ROW 9
|
229
|
+
out_line_no += 1
|
230
|
+
order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
231
|
+
order_execute_details_win.clrtoeol
|
232
|
+
|
233
|
+
Cryptum::UI.colorize(
|
234
|
+
ui_win: order_execute_details_win,
|
235
|
+
color: order_color,
|
236
|
+
style: style,
|
237
|
+
string: details_ln3.ljust(col_just1, ' ')
|
238
|
+
)
|
239
|
+
|
240
|
+
# Clear to OK ROW
|
241
|
+
ok_row = 9
|
242
|
+
out_line_no += 1
|
243
|
+
to_ok_row = ok_row - 1
|
244
|
+
(out_line_no..to_ok_row).each do |clr_line|
|
245
|
+
order_execute_details_win.setpos(clr_line, Cryptum::UI.col_first)
|
246
|
+
Cryptum::UI.colorize(
|
247
|
+
ui_win: order_execute_details_win,
|
248
|
+
color: order_color,
|
249
|
+
style: :normal,
|
250
|
+
string: ''.ljust(col_just1, ' ')
|
251
|
+
)
|
252
|
+
end
|
253
|
+
|
254
|
+
# OK ROW
|
255
|
+
out_line_no = ok_row
|
256
|
+
order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
257
|
+
order_execute_details_win.clrtoeol
|
258
|
+
Cryptum::UI.colorize(
|
259
|
+
ui_win: order_execute_details_win,
|
260
|
+
color: order_color,
|
261
|
+
string: ''.ljust(col_just1, ' ')
|
262
|
+
)
|
263
|
+
|
264
|
+
header_str = '- OK -'
|
265
|
+
order_execute_details_win.setpos(
|
266
|
+
out_line_no,
|
267
|
+
Cryptum::UI.col_center(str: header_str)
|
268
|
+
)
|
269
|
+
|
270
|
+
Cryptum::UI.colorize(
|
271
|
+
ui_win: order_execute_details_win,
|
272
|
+
color: order_color,
|
273
|
+
style: :reverse,
|
274
|
+
string: header_str
|
275
|
+
)
|
276
|
+
|
277
|
+
order_execute_details_win.refresh
|
278
|
+
|
279
|
+
event_history
|
280
|
+
rescue Interrupt
|
281
|
+
# Exit Gracefully if CTRL+C is Pressed During Session
|
282
|
+
Cryptum.exit_gracefully(which_self: self)
|
283
|
+
rescue StandardError => e
|
284
|
+
raise e
|
285
|
+
end
|
286
|
+
|
287
|
+
# Display Usage for this Module
|
288
|
+
|
289
|
+
public_class_method def self.help
|
290
|
+
puts "USAGE:
|
291
|
+
#{self}.refresh(
|
292
|
+
)
|
293
|
+
"
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|