cryptum 0.0.272 → 0.0.274

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33789e9885b695c15c6910051688172381d800d5621266ff531d0b7445478b2a
4
- data.tar.gz: 84ec9383263bb2e98d4aa9b7e53535581e8c1a879062ff6cbef25f98fb19d475
3
+ metadata.gz: 456e40a2bee690096338d88ddc7add455131802b7b272d799ac626f8e616d6e3
4
+ data.tar.gz: a7e8ab91160b716cdc4f210ec90682cb37114fa408b7e5885dfd8a5c29e9d8c3
5
5
  SHA512:
6
- metadata.gz: 6ffa742a34ef7e6bd05bc1464c469d2e0767657d30957ff87a4b8762b248fdfe6b619f1c2f6b04f1e3c2c48f70002cf6b4b833bfd4df867496036c0d5c60bab6
7
- data.tar.gz: b4986392cfdfffd83b09e17ca37515fb5264521cc2c5f0d64695e344c793e99947e065cd11c6fe2f250d24159a84877c9503d81371a14de27b26d6281545475b
6
+ metadata.gz: a12cd5a525df52d7a401b862ad784a723526ab180330a43120a8db4707d97f7eff0bf01ea02d6b46945e0d5a0967d15196a16e99a837729da0e5a5fd056757a6
7
+ data.tar.gz: c9ad2167536a5d44878d1b293d59da200ee6b7620da04d21a7ad8ae05275effd458a8a090a06d2823d12144bee86d0eff8ba300ba9601b0316b4638276d69fd4
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-06 15:52:44 UTC using RuboCop version 1.39.0.
3
+ # on 2022-12-06 22:57:28 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
@@ -87,11 +87,11 @@ Layout/TrailingWhitespace:
87
87
  - 'lib/cryptum/ui/order_plan.rb'
88
88
  - 'lib/cryptum/ui/order_timer.rb'
89
89
 
90
- # Offense count: 85
90
+ # Offense count: 87
91
91
  Lint/UselessAssignment:
92
92
  Enabled: false
93
93
 
94
- # Offense count: 48
94
+ # Offense count: 47
95
95
  # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
96
96
  Metrics/AbcSize:
97
97
  Max: 405
@@ -107,7 +107,7 @@ Metrics/BlockLength:
107
107
  Metrics/BlockNesting:
108
108
  Max: 4
109
109
 
110
- # Offense count: 19
110
+ # Offense count: 20
111
111
  # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
112
112
  Metrics/CyclomaticComplexity:
113
113
  Max: 73
@@ -122,12 +122,12 @@ Metrics/MethodLength:
122
122
  Metrics/ModuleLength:
123
123
  Max: 538
124
124
 
125
- # Offense count: 19
125
+ # Offense count: 20
126
126
  # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
127
127
  Metrics/PerceivedComplexity:
128
128
  Max: 76
129
129
 
130
- # Offense count: 3
130
+ # Offense count: 4
131
131
  # This cop supports safe autocorrection (--autocorrect).
132
132
  # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
133
133
  # SupportedStyles: assign_to_condition, assign_inside_condition
@@ -135,6 +135,7 @@ Style/ConditionalAssignment:
135
135
  Exclude:
136
136
  - 'lib/cryptum/event/pane.rb'
137
137
  - 'lib/cryptum/option.rb'
138
+ - 'lib/cryptum/ui/order_execute_details.rb'
138
139
 
139
140
  # Offense count: 1
140
141
  # Configuration parameters: AllowedConstants.
data/bin/cryptum CHANGED
@@ -43,6 +43,7 @@ begin
43
43
  bot_conf: bot_conf,
44
44
  terminal_win: terminal_win
45
45
  )
46
+ terminal_win.key_press_event.key_w = true
46
47
 
47
48
  # Connect to WebSocket
48
49
  # Trigger Events as Event Data
@@ -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 3_600 i.e. 1 hour)>'
59
+ '<Optional - Seconds Between Market Trend Reset (Default 60 i.e. 1 hour)>'
60
60
  ) { |t| option_choice.market_trend_reset = t.to_i }
61
61
  end.parse!
62
62
 
@@ -89,7 +89,7 @@ module Cryptum
89
89
  reason = :repo_root
90
90
  end
91
91
 
92
- option_choice.market_trend_reset = 3_600 if option_choice.market_trend_reset.to_i.zero?
92
+ option_choice.market_trend_reset = 60 if option_choice.market_trend_reset.to_i.zero?
93
93
  unless option_choice.market_trend_reset.to_i >= 60 &&
94
94
  option_choice.market_trend_reset <= 86_400
95
95
  usage = true
@@ -20,7 +20,6 @@ module Cryptum
20
20
  option_choice = opts[:option_choice]
21
21
  env = opts[:env]
22
22
  bot_conf = opts[:bot_conf]
23
- terminal_win = opts[:terminal_win]
24
23
 
25
24
  order_book_file = "#{option_choice.repo_root}/order_books/#{option_choice.symbol}.ORDER_BOOK.json"
26
25
 
@@ -41,7 +40,7 @@ module Cryptum
41
40
  this_product_arr = products.select do |product|
42
41
  product if product[:id] == option_choice.symbol.to_s.gsub('_', '-').upcase
43
42
  end
44
- this_product = this_product_arr.first
43
+ this_product = this_product_arr.last
45
44
 
46
45
  order_book = {
47
46
  path: order_book_file,
@@ -85,17 +84,8 @@ module Cryptum
85
84
  order_book: order_book
86
85
  )
87
86
 
88
- # Write order_book to file at session initiation
89
- # File.open(order_book_file, 'w') do |f|
90
- # f.puts order_book.to_json
91
- # end
92
87
  event_history.order_book = order_book
93
88
 
94
- Cryptum::Event::OrderBook.write(
95
- terminal_win: terminal_win,
96
- event_history: event_history
97
- )
98
-
99
89
  event_history
100
90
  rescue StandardError => e
101
91
  raise e
@@ -18,58 +18,112 @@ module Cryptum
18
18
  indicator_status = opts[:indicator_status]
19
19
  key_press_event = opts[:key_press_event]
20
20
 
21
- order = event_history.order_execute_selected_data
22
- tpm = order[:tpm]
23
- autotrade_percent = order[:autotrade_percent]
24
- order_color = order[:color].to_sym
21
+ 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_color = order_meta_data[:color].to_sym
25
25
 
26
- order_plan_no = order[:plan_no]
26
+ order_plan_no = order_meta_data[:plan_no]
27
27
  case order_color
28
28
  when :cyan, :red
29
- order_id = order[:buy_order_id]
30
- order_type = 'Buy'
29
+ order_id = order_meta_data[:buy_order_id]
31
30
  when :green, :magenta, :yellow
32
- order_id = order[:sell_order_id]
33
- order_type = 'Sell'
31
+ order_id = order_meta_data[:sell_order_id]
34
32
  when :black
35
33
  order_id = 'Expired'
36
- order_type = 'Expired'
37
34
  else
38
35
  order_id = 'N/A'
39
- order_type = 'N/A'
36
+ end
37
+
38
+ order_id_details = "- ID: #{order_id}"
39
+
40
+ order_history_arr = event_history.order_book[:order_history].select do |order|
41
+ order if order[:id] == order_id
42
+ end
43
+
44
+ if order_history_arr.empty? && order_color == :yellow
45
+ order_id = order_meta_data[:buy_order_id]
46
+ order_meta_data[:color] = :cyan
47
+ order_meta_data[:sell_order_id] = nil
48
+ order_history_arr = event_history.order_book[:order_history].select do |order|
49
+ order if order[:id] == order_id
50
+ end
51
+ end
52
+
53
+ order_type_ln = '- Type: N/A'
54
+ order_status_ln = '- Status: N/A'
55
+ fill_fees = 'N/A'
56
+ fill_size = 'N/A'
57
+ executed_value = 'N/A'
58
+ market_type = 'N/A'
59
+ settled = 'N/A'
60
+ if order_history_arr.any?
61
+ order_history = order_history_arr.first
62
+ order_type = order_history[:type].capitalize
63
+ time_in_force = order_history[:time_in_force].upcase
64
+ order_status = order_history[:status].upcase
65
+ created_at = order_history[:created_at]
66
+ fill_fees = order_history[:fill_fees]
67
+ fill_size = order_history[:filled_size]
68
+ executed_value = order_history[:executed_value]
69
+ market_type = order_history[:market_type]
70
+ settled = order_history[:settled]
71
+
72
+ order_side = order_history[:side].capitalize
73
+ case order_side.to_sym
74
+ when :Buy
75
+ expire_time = order_history[:expire_time]
76
+ done_at = order_history[:done_at]
77
+ order_meta_data[:color] = :cyan if done_at
78
+ when :Sell
79
+ done_at = order_history[:done_at]
80
+ end
81
+
82
+ order_type_ln = "- Type: #{order_type} #{order_side} #{time_in_force}"
83
+ order_type_ln = "- Type: #{order_type} #{order_side} #{time_in_force} 1m" if time_in_force == 'GTT'
84
+ order_status_ln = "- Status: #{order_status}"
85
+ end
86
+
87
+ if created_at && (!expire_time || !done_at)
88
+ order_hist_created_finished_ln = "- Creation Date: #{created_at} | Finished Date: N/A"
89
+ elsif created_at && expire_time && !done_at
90
+ order_hist_created_finished_ln = "- Creation Date: #{created_at} | Expiring Date: #{expire_time}"
91
+ elsif created_at && done_at
92
+ order_hist_created_finished_ln = "- Creation Date: #{created_at} | Finished Date: #{done_at}"
93
+ else
94
+ order_hist_created_finished_ln = '- Creation Date: N/A | Finished Date: N/A'
40
95
  end
41
96
 
42
97
  risk_alloc_out = Cryptum.beautify_large_number(
43
- value: order[:risk_alloc]
98
+ value: order_meta_data[:risk_alloc]
44
99
  )
45
100
  invest_out = Cryptum.beautify_large_number(
46
- value: order[:invest]
101
+ value: order_meta_data[:invest]
47
102
  )
48
103
  price_out = Cryptum.beautify_large_number(
49
- value: order[:price]
104
+ value: order_meta_data[:price]
50
105
  )
51
106
  size_out = Cryptum.beautify_large_number(
52
- value: order[:size]
107
+ value: order_meta_data[:size]
53
108
  )
54
109
  target_price_out = Cryptum.beautify_large_number(
55
- value: order[:target_price]
110
+ value: order_meta_data[:target_price]
56
111
  )
57
112
  profit_out = Cryptum.beautify_large_number(
58
- value: order[:profit]
113
+ value: order_meta_data[:profit]
59
114
  )
60
- plan_no = "#{order[:plan_no]}|"
61
-
62
- created_at = order[:created_at]
115
+ plan_no = "#{order_meta_data[:plan_no]}|"
63
116
 
64
117
  invest = "$#{invest_out} @ "
65
118
  tick = "$#{price_out} = "
66
119
  size = "*#{size_out} + "
67
- tpm_out = "#{order[:tpm]}% = "
120
+ tpm_out = "#{order_meta_data[:tpm]}% = "
68
121
  targ_tick = "$#{target_price_out}"
69
- profit = "|Profit: $#{order[:profit]}"
122
+ profit = " | Profit: $#{order_meta_data[:profit]}"
70
123
 
71
- order_id_details = "#{order_type} Order ID: #{order_id}"
72
- order_exec_ln = "Details: #{created_at}|#{invest}#{tick}#{size}#{tpm_out}#{targ_tick}#{profit}"
124
+ details_ln1 = "- Slice Plan: #{invest}#{tick}#{size}#{tpm_out}#{targ_tick}#{profit}"
125
+ details_ln2 = "- Fees: $#{fill_fees} | Fill Size: *#{fill_size}"
126
+ details_ln3 = "- Executed Value: $#{executed_value} | Market Type: #{market_type} | Settled: #{settled}"
73
127
 
74
128
  # UI
75
129
  col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
@@ -101,7 +155,7 @@ module Cryptum
101
155
  string: ''.ljust(col_just1, ' ')
102
156
  )
103
157
 
104
- header_str = "- ORDER ##{order[:plan_no]} DETAILS -"
158
+ header_str = "- ORDER ##{order_meta_data[:plan_no]} DETAILS -"
105
159
  order_execute_details_win.setpos(
106
160
  out_line_no,
107
161
  Cryptum::UI.col_center(str: header_str)
@@ -126,6 +180,18 @@ module Cryptum
126
180
  string: order_id_details.ljust(col_just1, ' ')
127
181
  )
128
182
 
183
+ # ROW 4
184
+ out_line_no += 1
185
+ order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
186
+ order_execute_details_win.clrtoeol
187
+
188
+ Cryptum::UI.colorize(
189
+ ui_win: order_execute_details_win,
190
+ color: order_color,
191
+ style: style,
192
+ string: order_type_ln.ljust(col_just1, ' ')
193
+ )
194
+
129
195
  # ROW 5
130
196
  out_line_no += 1
131
197
  order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
@@ -135,7 +201,55 @@ module Cryptum
135
201
  ui_win: order_execute_details_win,
136
202
  color: order_color,
137
203
  style: style,
138
- string: order_exec_ln.ljust(col_just1, ' ')
204
+ string: order_status_ln.ljust(col_just1, ' ')
205
+ )
206
+
207
+ # ROW 6
208
+ out_line_no += 1
209
+ order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
210
+ order_execute_details_win.clrtoeol
211
+
212
+ Cryptum::UI.colorize(
213
+ ui_win: order_execute_details_win,
214
+ color: order_color,
215
+ style: style,
216
+ string: order_hist_created_finished_ln.ljust(col_just1, ' ')
217
+ )
218
+
219
+ # ROW 7
220
+ out_line_no += 1
221
+ order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
222
+ order_execute_details_win.clrtoeol
223
+
224
+ Cryptum::UI.colorize(
225
+ ui_win: order_execute_details_win,
226
+ color: order_color,
227
+ style: style,
228
+ string: details_ln1.ljust(col_just1, ' ')
229
+ )
230
+
231
+ # ROW 8
232
+ out_line_no += 1
233
+ order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
234
+ order_execute_details_win.clrtoeol
235
+
236
+ Cryptum::UI.colorize(
237
+ ui_win: order_execute_details_win,
238
+ color: order_color,
239
+ style: style,
240
+ string: details_ln2.ljust(col_just1, ' ')
241
+ )
242
+
243
+ # ROW 9
244
+ out_line_no += 1
245
+ order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
246
+ order_execute_details_win.clrtoeol
247
+
248
+ Cryptum::UI.colorize(
249
+ ui_win: order_execute_details_win,
250
+ color: order_color,
251
+ style: style,
252
+ string: details_ln3.ljust(col_just1, ' ')
139
253
  )
140
254
 
141
255
  # Clear to OK ROW
@@ -42,11 +42,13 @@ module Cryptum
42
42
  return_out = Cryptum.beautify_large_number(
43
43
  value: order[:return]
44
44
  )
45
- autotrade_details = "1. Autotrade is set to #{autotrade_percent}% of $#{fiat_avail_out}, making $#{risk_alloc_out} available for this slice in the order plan."
46
- slice_alloc_details = "2. With $#{risk_alloc_out} available and a slice allocation of #{order[:allocation_percent]}%, $#{slice_alloc_out} OR AN ORDER MINIMUM of $#{invest_out} will"
47
- invest_details = ' be allocated for this slice (whichever is highest).'
48
- tpm_details = "3. With a slice allocation of $#{invest_out}, plus a TPM equal to #{tpm_out}%, $#{return_out} will be returned once sold."
49
- profit = " With $#{invest_out} invested the gross profit equals $#{profit_out}, minus any transaction fees."
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
+ slice_alloc_ln1_details = "2. With $#{risk_alloc_out} available and a slice allocation of #{order[:allocation_percent]}%, $#{slice_alloc_out} OR AN ORDER MINIMUM"
48
+ slice_alloc_ln2_details = " of $#{invest_out} will be allocated for this slice (whichever is highest)."
49
+ profit_ln1_details = "3. With a slice allocation of $#{invest_out}, plus a TPM equal to #{tpm_out}%, $#{return_out} will be returned"
50
+ profit_ln2_details = " once sold. With $#{invest_out} invested, the gross profit equals $#{profit_out}, minus any Maker &"
51
+ profit_ln3_details = ' Taker (transaction) fees.'
50
52
 
51
53
  # UI
52
54
  col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
@@ -100,7 +102,19 @@ module Cryptum
100
102
  ui_win: order_plan_details_win,
101
103
  color: order_color,
102
104
  style: style,
103
- string: autotrade_details.ljust(col_just1, ' ')
105
+ string: autotrade_ln1_details.ljust(col_just1, ' ')
106
+ )
107
+
108
+ # ROW 4
109
+ out_line_no += 1
110
+ order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
111
+ order_plan_details_win.clrtoeol
112
+
113
+ Cryptum::UI.colorize(
114
+ ui_win: order_plan_details_win,
115
+ color: order_color,
116
+ style: style,
117
+ string: autotrade_ln2_details.ljust(col_just1, ' ')
104
118
  )
105
119
 
106
120
  # ROW 5
@@ -112,7 +126,7 @@ module Cryptum
112
126
  ui_win: order_plan_details_win,
113
127
  color: order_color,
114
128
  style: style,
115
- string: slice_alloc_details.ljust(col_just1, ' ')
129
+ string: slice_alloc_ln1_details.ljust(col_just1, ' ')
116
130
  )
117
131
 
118
132
  # ROW 6
@@ -124,7 +138,7 @@ module Cryptum
124
138
  ui_win: order_plan_details_win,
125
139
  color: order_color,
126
140
  style: style,
127
- string: invest_details.ljust(col_just1, ' ')
141
+ string: slice_alloc_ln2_details.ljust(col_just1, ' ')
128
142
  )
129
143
 
130
144
  # ROW 7
@@ -136,7 +150,7 @@ module Cryptum
136
150
  ui_win: order_plan_details_win,
137
151
  color: order_color,
138
152
  style: style,
139
- string: tpm_details.ljust(col_just1, ' ')
153
+ string: profit_ln1_details.ljust(col_just1, ' ')
140
154
  )
141
155
 
142
156
  # ROW 8
@@ -148,7 +162,19 @@ module Cryptum
148
162
  ui_win: order_plan_details_win,
149
163
  color: order_color,
150
164
  style: style,
151
- string: profit.ljust(col_just1, ' ')
165
+ string: profit_ln2_details.ljust(col_just1, ' ')
166
+ )
167
+
168
+ # ROW 9
169
+ out_line_no += 1
170
+ order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
171
+ order_plan_details_win.clrtoeol
172
+
173
+ Cryptum::UI.colorize(
174
+ ui_win: order_plan_details_win,
175
+ color: order_color,
176
+ style: style,
177
+ string: profit_ln3_details.ljust(col_just1, ' ')
152
178
  )
153
179
 
154
180
  # Clear to OK ROW
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptum
4
- VERSION = '0.0.272'
4
+ VERSION = '0.0.274'
5
5
  end
data/lib/cryptum.rb CHANGED
@@ -158,10 +158,10 @@ module Cryptum
158
158
  # Cryptum Statistics Only Apply to
159
159
  # Live Sessions
160
160
  if event_history
161
- order_book_file = event_history.order_book[:path]
162
- File.open(order_book_file, 'w') do |f|
163
- f.puts event_history.order_book.to_json
164
- end
161
+ File.write(
162
+ order_book_file,
163
+ JSON.pretty_generate(event_history.order_book)
164
+ )
165
165
  end
166
166
 
167
167
  Curses.close_screen
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.272
4
+ version: 0.0.274
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-06 00:00:00.000000000 Z
11
+ date: 2022-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable