cryptum 0.0.327 → 0.0.328
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/lib/cryptum/event/parse.rb +181 -0
- data/lib/cryptum/event.rb +1 -0
- data/lib/cryptum/ui/command.rb +2 -0
- data/lib/cryptum/ui/market_trend.rb +0 -8
- data/lib/cryptum/ui/order_execute_details.rb +0 -15
- data/lib/cryptum/ui/order_execution.rb +0 -32
- data/lib/cryptum/ui/order_plan_details.rb +0 -5
- data/lib/cryptum/ui/order_timer.rb +0 -1
- data/lib/cryptum/ui/portfolio.rb +0 -11
- data/lib/cryptum/ui/signal_engine.rb +0 -8
- data/lib/cryptum/ui/ticker.rb +0 -2
- data/lib/cryptum/version.rb +1 -1
- data/lib/cryptum/web_sock/event_machine.rb +2 -137
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d537b32fc50af720ce0cc67974757c859bc0806c61e08b67767965b8c09c6a07
|
4
|
+
data.tar.gz: ea661892420f9088b105fa0b17bfd823066de3659b16dbd046f5b4944308a691
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c227a272ba47900bc0edb859270adeeb4eef3e1673155660f7334ebb0c0ba2a0c55a1ba9bd03b6ef36a519360169d9c8e90fcc27346f7c36337fedcf329b2d7
|
7
|
+
data.tar.gz: 3ae326daa9912a53cf8570fc205e3e7d9522d1efd08fa9a6ac9c35423e478fcc18039ee0ce6ae17574ad118b22c8e60300b4a34c0cbc8f31ccb19f62ac61fa67
|
@@ -0,0 +1,181 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cryptum
|
4
|
+
# This plugin is used to parse Coinbase Pro Web Socket Events in the HTTP Response
|
5
|
+
module Event
|
6
|
+
module Parse
|
7
|
+
# Supported Method Parameters::
|
8
|
+
# Cryptum::Event::Pane.websocket_msg(
|
9
|
+
# )
|
10
|
+
public_class_method def self.websocket_msg(opts = {})
|
11
|
+
env = opts[:env]
|
12
|
+
terminal_win = opts[:terminal_win]
|
13
|
+
option_choice = opts[:option_choice]
|
14
|
+
event_history = opts[:event_history]
|
15
|
+
indicator_status = opts[:indicator_status]
|
16
|
+
bot_conf = opts[:bot_conf]
|
17
|
+
|
18
|
+
this_product = event_history.order_book[:this_product]
|
19
|
+
fiat = this_product[:quote_currency]
|
20
|
+
fiat_portfolio_file = "#{option_choice.session_root}/order_books/#{fiat}_PORTFOLIO.json"
|
21
|
+
|
22
|
+
# Determine if Summary UI needs updated data
|
23
|
+
event_history = Cryptum::Portfolio::Balance.refresh(
|
24
|
+
env: env,
|
25
|
+
option_choice: option_choice,
|
26
|
+
terminal_win: terminal_win,
|
27
|
+
event_history: event_history,
|
28
|
+
fiat_portfolio_file: fiat_portfolio_file
|
29
|
+
)
|
30
|
+
|
31
|
+
# If the Terminal Window has been Resized, Resize the UI
|
32
|
+
if Curses.cols != terminal_win.cols
|
33
|
+
terminal_win.cols = Curses.cols
|
34
|
+
terminal_win.ticker_ui_resize = true
|
35
|
+
terminal_win.market_trend_ui_resize = true
|
36
|
+
end
|
37
|
+
|
38
|
+
event_history = Cryptum::UI::Portfolio.refresh(
|
39
|
+
option_choice: option_choice,
|
40
|
+
portfolio_win: terminal_win.portfolio_section,
|
41
|
+
event_history: event_history,
|
42
|
+
key_press_event: terminal_win.key_press_event,
|
43
|
+
indicator_status: indicator_status,
|
44
|
+
bot_conf: bot_conf,
|
45
|
+
fiat_portfolio_file: fiat_portfolio_file
|
46
|
+
)
|
47
|
+
|
48
|
+
if event_history.event_type == :ticker ||
|
49
|
+
terminal_win.ticker_ui_resize
|
50
|
+
|
51
|
+
ticker_event = event_history.ticker_event = event_history.event if event_history.event_type == :ticker
|
52
|
+
ticker_event = event_history.ticker_event if terminal_win.ticker_ui_resize
|
53
|
+
event_history = Cryptum::UI::Ticker.refresh(
|
54
|
+
option_choice: option_choice,
|
55
|
+
start_time: event_history.start_time,
|
56
|
+
ticker_win: terminal_win.ticker_section,
|
57
|
+
key_press_event: terminal_win.key_press_event,
|
58
|
+
event_history: event_history,
|
59
|
+
event: ticker_event
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
Cryptum::UI::OrderTimer.refresh(
|
64
|
+
option_choice: option_choice,
|
65
|
+
event_history: event_history,
|
66
|
+
order_timer_win: terminal_win.order_timer_section,
|
67
|
+
indicator_status: indicator_status,
|
68
|
+
key_press_event: terminal_win.key_press_event
|
69
|
+
)
|
70
|
+
|
71
|
+
if event_history.event_type == :l2update ||
|
72
|
+
terminal_win.market_trend_ui_resize
|
73
|
+
|
74
|
+
market_trend_event = event_history.market_trend_event = event_history.event if event_history.event_type == :l2update
|
75
|
+
market_trend_event = event_history.market_trend_event if terminal_win.market_trend_ui_resize
|
76
|
+
event_history = Cryptum::UI::MarketTrend.refresh(
|
77
|
+
option_choice: option_choice,
|
78
|
+
market_trend_win: terminal_win.market_trend_section,
|
79
|
+
event_history: event_history,
|
80
|
+
key_press_event: terminal_win.key_press_event,
|
81
|
+
event: market_trend_event,
|
82
|
+
indicator_status: indicator_status,
|
83
|
+
bot_conf: bot_conf
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
indicator_status = Cryptum::UI::SignalEngine.refresh(
|
88
|
+
option_choice: option_choice,
|
89
|
+
signal_engine_win: terminal_win.signal_engine_section,
|
90
|
+
event_history: event_history,
|
91
|
+
key_press_event: terminal_win.key_press_event,
|
92
|
+
indicator_status: indicator_status,
|
93
|
+
bot_conf: bot_conf,
|
94
|
+
fiat_portfolio_file: fiat_portfolio_file
|
95
|
+
)
|
96
|
+
|
97
|
+
unless event_history.order_plan_details_win_active
|
98
|
+
event_history = Cryptum::UI::OrderPlan.refresh(
|
99
|
+
option_choice: option_choice,
|
100
|
+
order_plan_win: terminal_win.order_plan_section,
|
101
|
+
env: env,
|
102
|
+
event_history: event_history,
|
103
|
+
key_press_event: terminal_win.key_press_event,
|
104
|
+
indicator_status: indicator_status,
|
105
|
+
bot_conf: bot_conf,
|
106
|
+
fiat_portfolio_file: fiat_portfolio_file
|
107
|
+
)
|
108
|
+
recalc_op = event_history.recalculate_order_plan
|
109
|
+
order_plan = event_history.order_book[:order_plan]
|
110
|
+
terminal_win.key_press_event.key_w = true if (recalc_op || order_plan.empty?) &&
|
111
|
+
!event_history.red_pill
|
112
|
+
event_history.recalculate_order_plan = false
|
113
|
+
end
|
114
|
+
|
115
|
+
if event_history.order_plan_details_win_active
|
116
|
+
event_history = Cryptum::UI::OrderPlanDetails.refresh(
|
117
|
+
option_choice: option_choice,
|
118
|
+
order_plan_details_win: terminal_win.order_plan_details_section,
|
119
|
+
event_history: event_history,
|
120
|
+
key_press_event: terminal_win.key_press_event
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
124
|
+
unless event_history.order_execute_details_win_active
|
125
|
+
event_history = Cryptum::UI::OrderExecution.refresh(
|
126
|
+
option_choice: option_choice,
|
127
|
+
order_execute_win: terminal_win.order_execute_section,
|
128
|
+
env: env,
|
129
|
+
event_history: event_history,
|
130
|
+
key_press_event: terminal_win.key_press_event,
|
131
|
+
indicator_status: indicator_status,
|
132
|
+
bot_conf: bot_conf,
|
133
|
+
fiat_portfolio_file: fiat_portfolio_file
|
134
|
+
)
|
135
|
+
end
|
136
|
+
|
137
|
+
if event_history.order_execute_details_win_active
|
138
|
+
event_history = Cryptum::UI::OrderExecuteDetails.refresh(
|
139
|
+
option_choice: option_choice,
|
140
|
+
order_execute_details_win: terminal_win.order_execute_details_section,
|
141
|
+
event_history: event_history,
|
142
|
+
key_press_event: terminal_win.key_press_event
|
143
|
+
)
|
144
|
+
end
|
145
|
+
|
146
|
+
# Refresh Command Section for Cryptum Session Usage
|
147
|
+
Cryptum::UI::Command.refresh(
|
148
|
+
command_win: terminal_win.command_section,
|
149
|
+
key_press_event: terminal_win.key_press_event
|
150
|
+
)
|
151
|
+
|
152
|
+
event_history
|
153
|
+
rescue Interrupt
|
154
|
+
# Exit Gracefully if CTRL+C is Pressed During Session
|
155
|
+
Cryptum.exit_gracefully(
|
156
|
+
which_self: self,
|
157
|
+
event_history: event_history,
|
158
|
+
option_choice: option_choice,
|
159
|
+
env: env
|
160
|
+
)
|
161
|
+
rescue StandardError => e
|
162
|
+
raise e
|
163
|
+
end
|
164
|
+
|
165
|
+
# Display Usage for this Module
|
166
|
+
public_class_method def self.help
|
167
|
+
puts "USAGE:
|
168
|
+
#{self}.websocket_msg(
|
169
|
+
env: env,
|
170
|
+
terminal_win: terminal_win,
|
171
|
+
option_choice: option_choice,
|
172
|
+
event_history: event_history,
|
173
|
+
indicator_status: indicator_status,
|
174
|
+
bot_conf: bot_conf,
|
175
|
+
ai_enabled: ai_enabled
|
176
|
+
)
|
177
|
+
"
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
data/lib/cryptum/event.rb
CHANGED
@@ -14,6 +14,7 @@ module Cryptum
|
|
14
14
|
autoload :KeyPress, 'cryptum/event/key_press'
|
15
15
|
autoload :OrderBook, 'cryptum/event/order_book'
|
16
16
|
autoload :Pane, 'cryptum/event/pane'
|
17
|
+
autoload :Parse, 'cryptum/event/parse'
|
17
18
|
autoload :Scroll, 'cryptum/event/scroll'
|
18
19
|
autoload :Sell, 'cryptum/event/sell'
|
19
20
|
|
data/lib/cryptum/ui/command.rb
CHANGED
@@ -158,6 +158,7 @@ module Cryptum
|
|
158
158
|
Cryptum::UI.colorize(
|
159
159
|
ui_win: command_win,
|
160
160
|
color: key_g_color,
|
161
|
+
style: key_g_style,
|
161
162
|
string: command_str_r2_arr[7]
|
162
163
|
)
|
163
164
|
|
@@ -202,6 +203,7 @@ module Cryptum
|
|
202
203
|
Cryptum::UI.colorize(
|
203
204
|
ui_win: command_win,
|
204
205
|
color: key_u_color,
|
206
|
+
style: key_u_style,
|
205
207
|
string: command_str_r3_arr.first
|
206
208
|
)
|
207
209
|
|
@@ -13,14 +13,10 @@ module Cryptum
|
|
13
13
|
# )
|
14
14
|
|
15
15
|
public_class_method def self.refresh(opts = {})
|
16
|
-
# option_choice = opts[:option_choice]
|
17
16
|
market_trend_win = opts[:market_trend_win]
|
18
17
|
event_history = opts[:event_history]
|
19
|
-
# key_press_event = opts[:key_press_event]
|
20
18
|
event = opts[:event]
|
21
19
|
indicator_status = opts[:indicator_status]
|
22
|
-
# bot_conf = opts[:bot_conf]
|
23
|
-
# reset_counter = opts[:reset_counter]
|
24
20
|
|
25
21
|
indicator_hash = Cryptum::OrderBook::MarketTrend.status(
|
26
22
|
event_history: event_history,
|
@@ -46,11 +42,7 @@ module Cryptum
|
|
46
42
|
market_trend_out = "Market Trend #{trend_arrow} | #{order_trend_out}"
|
47
43
|
|
48
44
|
# UI
|
49
|
-
# col_just1 = 12
|
50
45
|
col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
|
51
|
-
# col_just2 = 14
|
52
|
-
# col_just3 = 21
|
53
|
-
# col_just3_alt = (Curses.cols - Cryptum::UI.col_third) - 1
|
54
46
|
col_just4 = Curses.cols - Cryptum::UI.col_fourth
|
55
47
|
|
56
48
|
# ROW 1
|
@@ -12,16 +12,10 @@ module Cryptum
|
|
12
12
|
# )
|
13
13
|
|
14
14
|
public_class_method def self.refresh(opts = {})
|
15
|
-
# option_choice = opts[:option_choice]
|
16
15
|
event_history = opts[:event_history]
|
17
16
|
order_execute_details_win = opts[:order_execute_details_win]
|
18
|
-
# indicator_status = opts[:indicator_status]
|
19
|
-
# key_press_event = opts[:key_press_event]
|
20
17
|
|
21
18
|
order_meta_data = event_history.order_execute_selected_data
|
22
|
-
# tpm = order_meta_data[:tpm]
|
23
|
-
# autotrade_percent = order_meta_data[:autotrade_percent]
|
24
|
-
# order_plan_no = order_meta_data[:plan_no]
|
25
19
|
|
26
20
|
order_color = order_meta_data[:color].to_sym
|
27
21
|
case order_color
|
@@ -94,9 +88,6 @@ module Cryptum
|
|
94
88
|
order_hist_created_finished_ln = '- Creation Date: N/A | Finished Date: N/A'
|
95
89
|
end
|
96
90
|
|
97
|
-
# risk_alloc_out = Cryptum.beautify_large_number(
|
98
|
-
# value: order_meta_data[:risk_alloc]
|
99
|
-
# )
|
100
91
|
invest_out = Cryptum.beautify_large_number(
|
101
92
|
value: order_meta_data[:invest]
|
102
93
|
)
|
@@ -109,10 +100,6 @@ module Cryptum
|
|
109
100
|
target_price_out = Cryptum.beautify_large_number(
|
110
101
|
value: order_meta_data[:target_price]
|
111
102
|
)
|
112
|
-
# profit_out = Cryptum.beautify_large_number(
|
113
|
-
# value: order_meta_data[:profit]
|
114
|
-
# )
|
115
|
-
# plan_no = "#{order_meta_data[:plan_no]}|"
|
116
103
|
|
117
104
|
invest = "$#{invest_out} @ "
|
118
105
|
tick = "$#{price_out} = "
|
@@ -127,8 +114,6 @@ module Cryptum
|
|
127
114
|
|
128
115
|
# UI
|
129
116
|
col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
|
130
|
-
# col_just3 = (Curses.cols - Cryptum::UI.col_third) - 1
|
131
|
-
# col_just4 = Curses.cols - Cryptum::UI.col_fourth
|
132
117
|
|
133
118
|
# ROW 1
|
134
119
|
out_line_no = 0
|
@@ -17,10 +17,8 @@ module Cryptum
|
|
17
17
|
order_execute_win = opts[:order_execute_win]
|
18
18
|
env = opts[:env]
|
19
19
|
event_history = opts[:event_history]
|
20
|
-
# key_press_event = opts[:key_press_event]
|
21
20
|
indicator_status = opts[:indicator_status]
|
22
21
|
bot_conf = opts[:bot_conf]
|
23
|
-
# fiat_portfolio_file = opts[:fiat_portfolio_file]
|
24
22
|
|
25
23
|
event_type = event_history.event_type if option_choice.autotrade
|
26
24
|
event_side = event_history.event[:side].to_s.to_sym if option_choice.autotrade
|
@@ -29,18 +27,11 @@ module Cryptum
|
|
29
27
|
ticker_price = event_history.order_book[:ticker_price].to_f
|
30
28
|
open_24h = event_history.order_book[:open_24h].to_f
|
31
29
|
this_product = event_history.order_book[:this_product]
|
32
|
-
# base_min_size = this_product[:base_min_size]
|
33
30
|
min_market_funds = this_product[:min_market_funds]
|
34
31
|
base_increment = this_product[:base_increment]
|
35
32
|
quote_increment = this_product[:quote_increment]
|
36
|
-
# crypto_smallest_size_to_buy = base_min_size.to_s.split('.')[-1].length
|
37
33
|
crypto_smallest_decimal = base_increment.to_s.split('.')[-1].length
|
38
34
|
fiat_smallest_decimal = quote_increment.to_s.split('.')[-1].length
|
39
|
-
# crypto_smallest_size_to_buy = format(
|
40
|
-
# "%0.#{crypto_smallest_decimal}f",
|
41
|
-
# min_market_funds.to_f / ticker_price
|
42
|
-
# )
|
43
|
-
# crypto_smallest_size_to_buy = crypto_smallest_size_to_buy.to_s.split('.')[-1].length
|
44
35
|
|
45
36
|
last_three_prices_arr = []
|
46
37
|
last_ticker_price = event_history.order_book[:ticker_price].to_f
|
@@ -107,15 +98,9 @@ module Cryptum
|
|
107
98
|
size
|
108
99
|
)
|
109
100
|
|
110
|
-
# size = size.to_i.floor if base_increment.to_i >= 1
|
111
|
-
|
112
|
-
# size = base_min_size if size.to_f < base_min_size.to_f
|
113
|
-
# size = min_market_funds if size.to_f < min_market_funds.to_f
|
114
|
-
|
115
101
|
fiat_invested_this_order = size.to_f * price.to_f
|
116
102
|
|
117
103
|
fiat_portfolio = event_history.order_book[:fiat_portfolio]
|
118
|
-
# fiat_balance = format('%0.2f', fiat_portfolio.first[:balance])
|
119
104
|
fiat_avail_for_trade = format('%0.2f', fiat_portfolio.first[:available])
|
120
105
|
|
121
106
|
event_history.red_pill = true if fiat_invested_this_order > fiat_avail_for_trade.to_f
|
@@ -214,9 +199,6 @@ module Cryptum
|
|
214
199
|
order_history_meta.each do |meta|
|
215
200
|
next unless meta[:buy_order_id] == buy_order_id
|
216
201
|
|
217
|
-
# buy_done_at_hash_arr = order_history.select do |oh|
|
218
|
-
# oh[:id] == meta[:buy_order_id]
|
219
|
-
# end
|
220
202
|
meta[:done_at] = Time.now.strftime('%Y-%m-%d %H:%M:%S.%N%z')
|
221
203
|
meta[:color] = :white
|
222
204
|
end
|
@@ -286,9 +268,6 @@ module Cryptum
|
|
286
268
|
order_history_meta.each do |meta|
|
287
269
|
next unless meta[:sell_order_id] == sell_order_id
|
288
270
|
|
289
|
-
# sell_done_at_hash_arr = order_history.select do |oh|
|
290
|
-
# oh[:id] == meta[:sell_order_id]
|
291
|
-
# end
|
292
271
|
meta[:done_at] = Time.now.strftime('%Y-%m-%d %H:%M:%S.%N%z')
|
293
272
|
|
294
273
|
# TODO: Retry sell order if the original sell order expires.
|
@@ -309,11 +288,7 @@ module Cryptum
|
|
309
288
|
order_history_meta.each do |meta|
|
310
289
|
next unless meta[:sell_order_id] == sell_order_id
|
311
290
|
|
312
|
-
# sell_done_at_hash_arr = order_history.select do |oh|
|
313
|
-
# oh[:id] == meta[:sell_order_id]
|
314
|
-
# end
|
315
291
|
meta[:done_at] = Time.now.strftime('%Y-%m-%d %H:%M:%S.%N%z')
|
316
|
-
# meta[:done_at] = sell_done_at_hash_arr.first[:done_at] unless sell_done_at_hash_arr.empty?
|
317
292
|
meta[:color] = :green
|
318
293
|
end
|
319
294
|
end
|
@@ -374,7 +349,6 @@ module Cryptum
|
|
374
349
|
|
375
350
|
# UI
|
376
351
|
col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
|
377
|
-
# col_just3 = (Curses.cols - Cryptum::UI.col_third) - 1
|
378
352
|
col_just4 = Curses.cols - Cryptum::UI.col_fourth
|
379
353
|
|
380
354
|
# ROW 1
|
@@ -455,9 +429,6 @@ module Cryptum
|
|
455
429
|
selected_order[:color] = meta[:color]
|
456
430
|
end
|
457
431
|
|
458
|
-
# risk_alloc_out = Cryptum.beautify_large_number(
|
459
|
-
# value: meta[:risk_alloc]
|
460
|
-
# )
|
461
432
|
invest_out = Cryptum.beautify_large_number(
|
462
433
|
value: meta[:invest]
|
463
434
|
)
|
@@ -470,9 +441,6 @@ module Cryptum
|
|
470
441
|
target_price_out = Cryptum.beautify_large_number(
|
471
442
|
value: meta[:target_price]
|
472
443
|
)
|
473
|
-
# profit_out = Cryptum.beautify_large_number(
|
474
|
-
# value: meta[:profit]
|
475
|
-
# )
|
476
444
|
plan_no = meta[:plan_no]
|
477
445
|
|
478
446
|
buy_created_at_hash_arr = order_history.select do |oh|
|
@@ -12,11 +12,8 @@ module Cryptum
|
|
12
12
|
# )
|
13
13
|
|
14
14
|
public_class_method def self.refresh(opts = {})
|
15
|
-
# option_choice = opts[:option_choice]
|
16
15
|
event_history = opts[:event_history]
|
17
16
|
order_plan_details_win = opts[:order_plan_details_win]
|
18
|
-
# indicator_status = opts[:indicator_status]
|
19
|
-
# key_press_event = opts[:key_press_event]
|
20
17
|
|
21
18
|
order = event_history.order_plan_selected_data
|
22
19
|
tpm = order[:tpm]
|
@@ -60,8 +57,6 @@ module Cryptum
|
|
60
57
|
|
61
58
|
# UI
|
62
59
|
col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
|
63
|
-
# col_just3 = (Curses.cols - Cryptum::UI.col_third) - 1
|
64
|
-
# col_just4 = Curses.cols - Cryptum::UI.col_fourth
|
65
60
|
|
66
61
|
# ROW 1
|
67
62
|
out_line_no = 0
|
@@ -15,7 +15,6 @@ module Cryptum
|
|
15
15
|
event_history = opts[:event_history]
|
16
16
|
order_timer_win = opts[:order_timer_win]
|
17
17
|
indicator_status = opts[:indicator_status]
|
18
|
-
# key_press_event = opts[:key_press_event]
|
19
18
|
|
20
19
|
last_trend_reset_time = event_history.order_book[:last_trend_reset]
|
21
20
|
last_order_exec_time = event_history.order_book[:last_order_exec]
|
data/lib/cryptum/ui/portfolio.rb
CHANGED
@@ -16,18 +16,13 @@ module Cryptum
|
|
16
16
|
option_choice = opts[:option_choice]
|
17
17
|
portfolio_win = opts[:portfolio_win]
|
18
18
|
event_history = opts[:event_history]
|
19
|
-
# key_press_event = opts[:key_press_event]
|
20
|
-
# indicator_status = opts[:indicator_status]
|
21
19
|
bot_conf = opts[:bot_conf]
|
22
|
-
# fiat_portfolio_file = opts[:fiat_portfolio_file]
|
23
20
|
|
24
21
|
ticker_price = event_history.order_book[:ticker_price].to_f
|
25
22
|
this_product = event_history.order_book[:this_product]
|
26
23
|
symbol_out = this_product[:id]
|
27
|
-
# quote_increment = this_product[:quote_increment]
|
28
24
|
base_increment = this_product[:base_increment]
|
29
25
|
|
30
|
-
# fiat_smallest_decimal = quote_increment.to_s.split('.')[-1].length
|
31
26
|
crypto_smallest_decimal = base_increment.to_s.split('.')[-1].length
|
32
27
|
|
33
28
|
autotrade_percent = format(
|
@@ -40,8 +35,6 @@ module Cryptum
|
|
40
35
|
bot_conf[:target_profit_margin_percent]
|
41
36
|
)
|
42
37
|
|
43
|
-
# tpm_cast_as_decimal = tpm.to_f / 100
|
44
|
-
|
45
38
|
crypto_currency = option_choice.symbol.to_s.upcase.split('_').first.to_sym
|
46
39
|
portfolio = event_history.order_book[:portfolio]
|
47
40
|
this_account = portfolio.select do |account|
|
@@ -95,10 +88,6 @@ module Cryptum
|
|
95
88
|
(1 - (fiat_budget / total_holdings.to_f)) * 100
|
96
89
|
)
|
97
90
|
|
98
|
-
# crypto_invested_percent = format(
|
99
|
-
# '%0.2f',
|
100
|
-
# (current_crypto_fiat_value.to_f / total_holdings.to_f) * 100
|
101
|
-
# )
|
102
91
|
crypto_invested_percent = format(
|
103
92
|
'%0.2f',
|
104
93
|
current_crypto_fiat_value.to_f.fdiv(total_holdings.to_f) * 100
|
@@ -13,13 +13,8 @@ module Cryptum
|
|
13
13
|
# )
|
14
14
|
|
15
15
|
public_class_method def self.refresh(opts = {})
|
16
|
-
# option_choice = opts[:option_choice]
|
17
16
|
signal_engine_win = opts[:signal_engine_win]
|
18
|
-
# event_history = opts[:event_history]
|
19
|
-
# key_press_event = opts[:key_press_event]
|
20
17
|
indicator_status = opts[:indicator_status]
|
21
|
-
# bot_conf = opts[:bot_conf]
|
22
|
-
# fiat_portfolio_file = opts[:fiat_portfolio_file]
|
23
18
|
|
24
19
|
color = :white
|
25
20
|
color = indicator_status.market_trend[:color] if indicator_status.market_trend
|
@@ -46,9 +41,6 @@ module Cryptum
|
|
46
41
|
|
47
42
|
# UI
|
48
43
|
col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
|
49
|
-
# col_just1 = 12
|
50
|
-
# col_just2 = 14
|
51
|
-
# col_just3 = (Curses.cols - Cryptum::UI.col_third) - 1
|
52
44
|
col_just4 = Curses.cols - Cryptum::UI.col_fourth
|
53
45
|
|
54
46
|
# ROW 1
|
data/lib/cryptum/ui/ticker.rb
CHANGED
@@ -110,8 +110,6 @@ module Cryptum
|
|
110
110
|
margin_percent_open_24h_out = "#{Cryptum.flat_arrow} #{beautify_margin_percent_open_24h}% (#{trend})"
|
111
111
|
end
|
112
112
|
|
113
|
-
# current_time_out = Time.now.strftime('%Y-%m-%d %H:%M:%S%z')
|
114
|
-
|
115
113
|
order_history = order_book[:order_history]
|
116
114
|
open_sell_orders = order_history.select do |order|
|
117
115
|
order[:status] == 'open' && order[:side] == 'sell'
|
data/lib/cryptum/version.rb
CHANGED
@@ -62,150 +62,15 @@ module Cryptum
|
|
62
62
|
)
|
63
63
|
event_history.event_type = event_history.event[:type].to_s.to_sym
|
64
64
|
|
65
|
-
|
66
|
-
fiat = this_product[:quote_currency]
|
67
|
-
fiat_portfolio_file = "#{option_choice.session_root}/order_books/#{fiat}_PORTFOLIO.json"
|
68
|
-
|
69
|
-
# Determine if Summary UI needs updated data
|
70
|
-
event_history = Cryptum::Portfolio::Balance.refresh(
|
65
|
+
event_history = Cryptum::Event::Parse.websocket_msg(
|
71
66
|
env: env,
|
72
|
-
option_choice: option_choice,
|
73
67
|
terminal_win: terminal_win,
|
74
|
-
event_history: event_history,
|
75
|
-
fiat_portfolio_file: fiat_portfolio_file
|
76
|
-
)
|
77
|
-
|
78
|
-
# If the Terminal Window has been Resized, Resize the UI
|
79
|
-
if Curses.cols != terminal_win.cols
|
80
|
-
terminal_win.cols = Curses.cols
|
81
|
-
terminal_win.ticker_ui_resize = true
|
82
|
-
terminal_win.market_trend_ui_resize = true
|
83
|
-
end
|
84
|
-
|
85
|
-
event_history = Cryptum::UI::Portfolio.refresh(
|
86
|
-
option_choice: option_choice,
|
87
|
-
portfolio_win: terminal_win.portfolio_section,
|
88
|
-
event_history: event_history,
|
89
|
-
key_press_event: terminal_win.key_press_event,
|
90
|
-
indicator_status: indicator_status,
|
91
|
-
bot_conf: bot_conf,
|
92
|
-
fiat_portfolio_file: fiat_portfolio_file
|
93
|
-
)
|
94
|
-
|
95
|
-
if event_history.event_type == :ticker ||
|
96
|
-
terminal_win.ticker_ui_resize
|
97
|
-
|
98
|
-
ticker_event = event_history.ticker_event = event_history.event if event_history.event_type == :ticker
|
99
|
-
ticker_event = event_history.ticker_event if terminal_win.ticker_ui_resize
|
100
|
-
event_history = Cryptum::UI::Ticker.refresh(
|
101
|
-
option_choice: option_choice,
|
102
|
-
start_time: event_history.start_time,
|
103
|
-
ticker_win: terminal_win.ticker_section,
|
104
|
-
key_press_event: terminal_win.key_press_event,
|
105
|
-
event_history: event_history,
|
106
|
-
event: ticker_event
|
107
|
-
)
|
108
|
-
end
|
109
|
-
|
110
|
-
Cryptum::UI::OrderTimer.refresh(
|
111
|
-
option_choice: option_choice,
|
112
|
-
event_history: event_history,
|
113
|
-
order_timer_win: terminal_win.order_timer_section,
|
114
|
-
indicator_status: indicator_status,
|
115
|
-
key_press_event: terminal_win.key_press_event
|
116
|
-
)
|
117
|
-
|
118
|
-
if event_history.event_type == :l2update ||
|
119
|
-
terminal_win.market_trend_ui_resize
|
120
|
-
|
121
|
-
market_trend_event = event_history.market_trend_event = event_history.event if event_history.event_type == :l2update
|
122
|
-
market_trend_event = event_history.market_trend_event if terminal_win.market_trend_ui_resize
|
123
|
-
event_history = Cryptum::UI::MarketTrend.refresh(
|
124
|
-
option_choice: option_choice,
|
125
|
-
market_trend_win: terminal_win.market_trend_section,
|
126
|
-
event_history: event_history,
|
127
|
-
key_press_event: terminal_win.key_press_event,
|
128
|
-
event: market_trend_event,
|
129
|
-
indicator_status: indicator_status,
|
130
|
-
bot_conf: bot_conf
|
131
|
-
)
|
132
|
-
end
|
133
|
-
|
134
|
-
indicator_status = Cryptum::UI::SignalEngine.refresh(
|
135
68
|
option_choice: option_choice,
|
136
|
-
signal_engine_win: terminal_win.signal_engine_section,
|
137
69
|
event_history: event_history,
|
138
|
-
key_press_event: terminal_win.key_press_event,
|
139
70
|
indicator_status: indicator_status,
|
140
|
-
bot_conf: bot_conf
|
141
|
-
fiat_portfolio_file: fiat_portfolio_file
|
71
|
+
bot_conf: bot_conf
|
142
72
|
)
|
143
73
|
|
144
|
-
unless event_history.order_plan_details_win_active
|
145
|
-
event_history = Cryptum::UI::OrderPlan.refresh(
|
146
|
-
option_choice: option_choice,
|
147
|
-
order_plan_win: terminal_win.order_plan_section,
|
148
|
-
env: env,
|
149
|
-
event_history: event_history,
|
150
|
-
key_press_event: terminal_win.key_press_event,
|
151
|
-
indicator_status: indicator_status,
|
152
|
-
bot_conf: bot_conf,
|
153
|
-
fiat_portfolio_file: fiat_portfolio_file
|
154
|
-
)
|
155
|
-
recalc_op = event_history.recalculate_order_plan
|
156
|
-
order_plan = event_history.order_book[:order_plan]
|
157
|
-
terminal_win.key_press_event.key_w = true if (recalc_op || order_plan.empty?) &&
|
158
|
-
!event_history.red_pill
|
159
|
-
event_history.recalculate_order_plan = false
|
160
|
-
end
|
161
|
-
|
162
|
-
if event_history.order_plan_details_win_active
|
163
|
-
event_history = Cryptum::UI::OrderPlanDetails.refresh(
|
164
|
-
option_choice: option_choice,
|
165
|
-
order_plan_details_win: terminal_win.order_plan_details_section,
|
166
|
-
event_history: event_history,
|
167
|
-
key_press_event: terminal_win.key_press_event
|
168
|
-
)
|
169
|
-
end
|
170
|
-
|
171
|
-
unless event_history.order_execute_details_win_active
|
172
|
-
event_history = Cryptum::UI::OrderExecution.refresh(
|
173
|
-
option_choice: option_choice,
|
174
|
-
order_execute_win: terminal_win.order_execute_section,
|
175
|
-
env: env,
|
176
|
-
event_history: event_history,
|
177
|
-
key_press_event: terminal_win.key_press_event,
|
178
|
-
indicator_status: indicator_status,
|
179
|
-
bot_conf: bot_conf,
|
180
|
-
fiat_portfolio_file: fiat_portfolio_file
|
181
|
-
)
|
182
|
-
end
|
183
|
-
|
184
|
-
if event_history.order_execute_details_win_active
|
185
|
-
event_history = Cryptum::UI::OrderExecuteDetails.refresh(
|
186
|
-
option_choice: option_choice,
|
187
|
-
order_execute_details_win: terminal_win.order_execute_details_section,
|
188
|
-
event_history: event_history,
|
189
|
-
key_press_event: terminal_win.key_press_event
|
190
|
-
)
|
191
|
-
end
|
192
|
-
|
193
|
-
# Refresh Command Section for Cryptum Session Usage
|
194
|
-
Cryptum::UI::Command.refresh(
|
195
|
-
command_win: terminal_win.command_section,
|
196
|
-
key_press_event: terminal_win.key_press_event
|
197
|
-
)
|
198
|
-
|
199
|
-
# event_history = Cryptum::Event.parse(
|
200
|
-
# env: env,
|
201
|
-
# terminal_win: terminal_win,
|
202
|
-
# option_choice: option_choice,
|
203
|
-
# event_history: event_history,
|
204
|
-
# indicator_status: indicator_status,
|
205
|
-
# bot_conf: bot_conf,
|
206
|
-
# ai_enabled: ai_enabled
|
207
|
-
# )
|
208
|
-
|
209
74
|
# Detect Key Press Events
|
210
75
|
Cryptum::Event::KeyPress.detect(terminal_win: terminal_win)
|
211
76
|
|
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.328
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 0day Inc.
|
@@ -390,6 +390,7 @@ files:
|
|
390
390
|
- lib/cryptum/event/key_press.rb
|
391
391
|
- lib/cryptum/event/order_book.rb
|
392
392
|
- lib/cryptum/event/pane.rb
|
393
|
+
- lib/cryptum/event/parse.rb
|
393
394
|
- lib/cryptum/event/scroll.rb
|
394
395
|
- lib/cryptum/event/sell.rb
|
395
396
|
- lib/cryptum/log.rb
|