cryptum 0.0.272 → 0.0.273

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33789e9885b695c15c6910051688172381d800d5621266ff531d0b7445478b2a
4
- data.tar.gz: 84ec9383263bb2e98d4aa9b7e53535581e8c1a879062ff6cbef25f98fb19d475
3
+ metadata.gz: 448c1b3f990829ef87c5adc398ddcaea4b46c62acee1723785bf79572c6d2b89
4
+ data.tar.gz: 76fdd8d8e3258291eb3644417d9094a926cfa425c126ff7b3a2f7bb37d7fb31b
5
5
  SHA512:
6
- metadata.gz: 6ffa742a34ef7e6bd05bc1464c469d2e0767657d30957ff87a4b8762b248fdfe6b619f1c2f6b04f1e3c2c48f70002cf6b4b833bfd4df867496036c0d5c60bab6
7
- data.tar.gz: b4986392cfdfffd83b09e17ca37515fb5264521cc2c5f0d64695e344c793e99947e065cd11c6fe2f250d24159a84877c9503d81371a14de27b26d6281545475b
6
+ metadata.gz: 92418c47f83fe60acf22473eff5d72516e41d903f03f4484b6e67943287102758d24a1c08299f8a832136658a48876efdbc293b03adb323c10d2dcec0d2c4eed
7
+ data.tar.gz: 6150d6bdf97804e728a707cbdb06a93f174fae0da0f18a7883a0abbded5a6ba615377eff28dc68ace6004406a2867282b70dc3b1bdc641acd90cc6d0788fde3e
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,86 @@ 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
+ order_type_ln = '- Type: N/A'
45
+ order_status_ln = '- Status: N/A'
46
+ order_hist_created_ln = '- Creation Date: N/A'
47
+ order_hist_finished_ln = '- Finished Date: N/A'
48
+ if order_history_arr.any?
49
+ order_history = order_history_arr.first
50
+ order_type = order_history[:type].capitalize
51
+ time_in_force = order_history[:time_in_force].upcase
52
+ order_status = order_history[:status].upcase
53
+ created_at = order_history[:created_at]
54
+ order_hist_created_ln = "- Creation Date: #{created_at}"
55
+
56
+ order_side = order_history[:side].capitalize
57
+ case order_side.to_sym
58
+ when :Buy
59
+ expire_time = order_history[:expire_time]
60
+ done_at = order_history[:done_at]
61
+ order_hist_finished_ln = "- Expiring Date: #{expire_time}"
62
+ when :Sell
63
+ done_at = order_history[:done_at]
64
+ end
65
+ order_hist_finished_ln = "- Finished Date: #{done_at}" if done_at
66
+
67
+ order_type_ln = "- Type: #{order_type} #{order_side} #{time_in_force}"
68
+ order_status_ln = "- Status: #{order_status}"
40
69
  end
41
70
 
42
71
  risk_alloc_out = Cryptum.beautify_large_number(
43
- value: order[:risk_alloc]
72
+ value: order_meta_data[:risk_alloc]
44
73
  )
45
74
  invest_out = Cryptum.beautify_large_number(
46
- value: order[:invest]
75
+ value: order_meta_data[:invest]
47
76
  )
48
77
  price_out = Cryptum.beautify_large_number(
49
- value: order[:price]
78
+ value: order_meta_data[:price]
50
79
  )
51
80
  size_out = Cryptum.beautify_large_number(
52
- value: order[:size]
81
+ value: order_meta_data[:size]
53
82
  )
54
83
  target_price_out = Cryptum.beautify_large_number(
55
- value: order[:target_price]
84
+ value: order_meta_data[:target_price]
56
85
  )
57
86
  profit_out = Cryptum.beautify_large_number(
58
- value: order[:profit]
87
+ value: order_meta_data[:profit]
59
88
  )
60
- plan_no = "#{order[:plan_no]}|"
61
-
62
- created_at = order[:created_at]
89
+ plan_no = "#{order_meta_data[:plan_no]}|"
63
90
 
64
91
  invest = "$#{invest_out} @ "
65
92
  tick = "$#{price_out} = "
66
93
  size = "*#{size_out} + "
67
- tpm_out = "#{order[:tpm]}% = "
94
+ tpm_out = "#{order_meta_data[:tpm]}% = "
68
95
  targ_tick = "$#{target_price_out}"
69
- profit = "|Profit: $#{order[:profit]}"
96
+ profit = "|Profit: $#{order_meta_data[:profit]}"
70
97
 
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}"
98
+ meta_ln = "- Metadata: #{invest}#{tick}#{size}#{tpm_out}#{targ_tick}#{profit}"
99
+ meta_ln = '- Metadata:'
100
+ meta_color_ln = " - Color: #{order_color}"
73
101
 
74
102
  # UI
75
103
  col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
@@ -101,7 +129,7 @@ module Cryptum
101
129
  string: ''.ljust(col_just1, ' ')
102
130
  )
103
131
 
104
- header_str = "- ORDER ##{order[:plan_no]} DETAILS -"
132
+ header_str = "- ORDER ##{order_meta_data[:plan_no]} DETAILS -"
105
133
  order_execute_details_win.setpos(
106
134
  out_line_no,
107
135
  Cryptum::UI.col_center(str: header_str)
@@ -126,6 +154,18 @@ module Cryptum
126
154
  string: order_id_details.ljust(col_just1, ' ')
127
155
  )
128
156
 
157
+ # ROW 4
158
+ out_line_no += 1
159
+ order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
160
+ order_execute_details_win.clrtoeol
161
+
162
+ Cryptum::UI.colorize(
163
+ ui_win: order_execute_details_win,
164
+ color: order_color,
165
+ style: style,
166
+ string: order_type_ln.ljust(col_just1, ' ')
167
+ )
168
+
129
169
  # ROW 5
130
170
  out_line_no += 1
131
171
  order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
@@ -135,7 +175,55 @@ module Cryptum
135
175
  ui_win: order_execute_details_win,
136
176
  color: order_color,
137
177
  style: style,
138
- string: order_exec_ln.ljust(col_just1, ' ')
178
+ string: order_status_ln.ljust(col_just1, ' ')
179
+ )
180
+
181
+ # ROW 6
182
+ out_line_no += 1
183
+ order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
184
+ order_execute_details_win.clrtoeol
185
+
186
+ Cryptum::UI.colorize(
187
+ ui_win: order_execute_details_win,
188
+ color: order_color,
189
+ style: style,
190
+ string: order_hist_created_ln.ljust(col_just1, ' ')
191
+ )
192
+
193
+ # ROW 7
194
+ out_line_no += 1
195
+ order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
196
+ order_execute_details_win.clrtoeol
197
+
198
+ Cryptum::UI.colorize(
199
+ ui_win: order_execute_details_win,
200
+ color: order_color,
201
+ style: style,
202
+ string: order_hist_finished_ln.ljust(col_just1, ' ')
203
+ )
204
+
205
+ # ROW 8
206
+ out_line_no += 1
207
+ order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
208
+ order_execute_details_win.clrtoeol
209
+
210
+ Cryptum::UI.colorize(
211
+ ui_win: order_execute_details_win,
212
+ color: order_color,
213
+ style: style,
214
+ string: meta_ln.ljust(col_just1, ' ')
215
+ )
216
+
217
+ # ROW 9
218
+ out_line_no += 1
219
+ order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
220
+ order_execute_details_win.clrtoeol
221
+
222
+ Cryptum::UI.colorize(
223
+ ui_win: order_execute_details_win,
224
+ color: order_color,
225
+ style: style,
226
+ string: meta_color_ln.ljust(col_just1, ' ')
139
227
  )
140
228
 
141
229
  # 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.273'
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.273
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