cryptum 0.0.269 → 0.0.271

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: d40a387e6624886030d8bdaf44ffc1fe19d7d776810f6b369d4e0bc06f658b36
4
- data.tar.gz: 26f2281e64fbfac162390bcc25be978e7e58498dd7fb4c6fa67e0e7c1d0f4e5e
3
+ metadata.gz: a2a99684100eded0f7b6ca6e94cd2b7afa4f1a46f4d173fcf8f6d23929f412ed
4
+ data.tar.gz: d01f3f8a7de3c65f295785f5fb38d781e0e3f2c4694eb8fe90e9a9e792442bf7
5
5
  SHA512:
6
- metadata.gz: 62511617e610526d54b285f2fb8ae2b450ed9042c382edfcb7eaea4e88b60ea346c7401ba5ecba563b12e48cfba63ac51c6cbdede6097c67d78abf0c672369d9
7
- data.tar.gz: f31542bfaa39f3a6d8c16b0362285bfc9cd79f6f36deec22957c1774348660f4a8a4cc8d6981b6490970403e4032bec28e82bf470c5d28129934f4fb4dcc6164
6
+ metadata.gz: 3323a2fd4c747bb7daf655eff588ab7bf2e5010eb9cc707e1f44157f62b328a9ee3866beb4785e1423eae08ff82adb8dfb0771c3fc733ce6f3baf775948d4e12
7
+ data.tar.gz: c6de579395b53f951f12ef615aca7540b647d7d13a5bab05a27115ec88c8636a47b13df6e44edce7b8fd908ab81e889aeee6611e32529df9d0f2a8cbcebc0826
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-05 19:21:30 UTC using RuboCop version 1.39.0.
3
+ # on 2022-12-05 23:34:03 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
@@ -127,7 +127,7 @@ Metrics/ModuleLength:
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.
@@ -217,7 +218,7 @@ Style/TrailingCommaInArrayLiteral:
217
218
  Exclude:
218
219
  - 'lib/cryptum/matrix.rb'
219
220
 
220
- # Offense count: 18
221
+ # Offense count: 22
221
222
  # This cop supports safe autocorrection (--autocorrect).
222
223
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
223
224
  # URISchemes: http, https
@@ -21,7 +21,56 @@ module Cryptum
21
21
  order = event_history.order_execute_selected_data
22
22
  tpm = order[:tpm]
23
23
  autotrade_percent = order[:autotrade_percent]
24
- order_color = order[:color]
24
+ order_color = order[:color].to_sym
25
+
26
+ order_plan_no = order[:plan_no]
27
+ case order_color
28
+ when :cyan, :red
29
+ order_id = order[:buy_order_id]
30
+ order_type = 'Buy'
31
+ when :green, :magenta, :yellow
32
+ order_id = order[:sell_order_id]
33
+ order_type = 'Sell'
34
+ when :black
35
+ order_id = 'Expired'
36
+ order_type = 'Expired'
37
+ else
38
+ order_id = 'N/A'
39
+ order_type = 'N/A'
40
+ end
41
+
42
+ risk_alloc_out = Cryptum.beautify_large_number(
43
+ value: order[:risk_alloc]
44
+ )
45
+ invest_out = Cryptum.beautify_large_number(
46
+ value: order[:invest]
47
+ )
48
+ price_out = Cryptum.beautify_large_number(
49
+ value: order[:price]
50
+ )
51
+ size_out = Cryptum.beautify_large_number(
52
+ value: order[:size]
53
+ )
54
+ target_price_out = Cryptum.beautify_large_number(
55
+ value: order[:target_price]
56
+ )
57
+ profit_out = Cryptum.beautify_large_number(
58
+ value: order[:profit]
59
+ )
60
+ plan_no = "#{order[:plan_no]}|"
61
+
62
+ created_at = order[:created_at]
63
+
64
+ invest = "$#{invest_out} @ "
65
+ tick = "$#{price_out} = "
66
+ size = "*#{size_out} + "
67
+ tpm_out = "#{order[:tpm]}% = "
68
+ targ_tick = "$#{target_price_out}"
69
+ profit = "|Profit: $#{order[:profit]}"
70
+
71
+ order_id_details = "#{order_type} Order ID: #{order_id}"
72
+ order_plan_details = "Order Slice #: #{order_plan_no}"
73
+ order_exec_ln = "Details: #{created_at}|#{invest}#{tick}#{size}#{tpm_out}#{targ_tick}#{profit}"
25
74
 
26
75
  # UI
27
76
  col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
@@ -53,7 +102,7 @@ module Cryptum
53
102
  string: ''.ljust(col_just1, ' ')
54
103
  )
55
104
 
56
- header_str = "- ##{order[:plan_no]} ORDER HISTORY DETAILS -"
105
+ header_str = "- ORDER ##{order[:plan_no]} DETAILS -"
57
106
  order_execute_details_win.setpos(
58
107
  out_line_no,
59
108
  Cryptum::UI.col_center(str: header_str)
@@ -62,7 +111,7 @@ module Cryptum
62
111
  Cryptum::UI.colorize(
63
112
  ui_win: order_execute_details_win,
64
113
  color: order_color,
65
- style: :bold,
114
+ style: header_style,
66
115
  string: header_str
67
116
  )
68
117
 
@@ -71,42 +120,35 @@ module Cryptum
71
120
  order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
72
121
  order_execute_details_win.clrtoeol
73
122
 
74
- risk_alloc_out = Cryptum.beautify_large_number(
75
- value: order[:risk_alloc]
76
- )
77
- invest_out = Cryptum.beautify_large_number(
78
- value: order[:invest]
79
- )
80
- price_out = Cryptum.beautify_large_number(
81
- value: order[:price]
82
- )
83
- size_out = Cryptum.beautify_large_number(
84
- value: order[:size]
85
- )
86
- target_price_out = Cryptum.beautify_large_number(
87
- value: order[:target_price]
88
- )
89
- profit_out = Cryptum.beautify_large_number(
90
- value: order[:profit]
123
+ Cryptum::UI.colorize(
124
+ ui_win: order_execute_details_win,
125
+ color: order_color,
126
+ style: style,
127
+ string: order_id_details.ljust(col_just1, ' ')
91
128
  )
92
- plan_no = "#{order[:plan_no]}|"
93
129
 
94
- created_at = order[:created_at]
130
+ # ROW 5
131
+ out_line_no += 1
132
+ order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
133
+ order_execute_details_win.clrtoeol
95
134
 
96
- invest = "$#{invest_out} @ "
97
- tick = "$#{price_out} = "
98
- size = "*#{size_out} + "
99
- tpm_out = "#{order[:tpm]}% = "
100
- targ_tick = "$#{target_price_out}"
101
- profit = "|Profit: $#{order[:profit]}"
135
+ Cryptum::UI.colorize(
136
+ ui_win: order_execute_details_win,
137
+ color: order_color,
138
+ style: style,
139
+ string: order_plan_details.ljust(col_just1, ' ')
140
+ )
102
141
 
103
- order_exec_ln = "#{created_at}|#{invest}#{tick}#{size}#{tpm_out}#{targ_tick}#{profit}"
142
+ # ROW 4
143
+ out_line_no += 1
144
+ order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
145
+ order_execute_details_win.clrtoeol
104
146
 
105
147
  Cryptum::UI.colorize(
106
148
  ui_win: order_execute_details_win,
107
149
  color: order_color,
108
150
  style: style,
109
- string: order_exec_ln.ljust(col_just1, '.')
151
+ string: order_exec_ln.ljust(col_just1, ' ')
110
152
  )
111
153
 
112
154
  # Clear to OK ROW
@@ -109,9 +109,6 @@ module Cryptum
109
109
 
110
110
  next unless fiat_investing > min_market_funds.to_f
111
111
 
112
- # fiat_investing = min_market_funds.to_f
113
- # allocation_decimal = fiat_investing / ticker_price
114
-
115
112
  risk_alloc = fiat_budget * autotrade_cast_as_decimal
116
113
  allocation_percent = allocation_decimal * 100
117
114
  fiat_returning = fiat_investing + (
@@ -119,12 +116,14 @@ module Cryptum
119
116
  )
120
117
  profit = fiat_returning - fiat_investing
121
118
 
122
- # Implemented a bugfix here to avoid a bogus single order when Tradeable
123
- # Balances are low. Ensure everything still works as expected when
124
- # balances are higher.
125
119
  break if order_plan.map { |op| op[:invest].to_f }.sum > risk_target ||
126
120
  allocation_percent > 100
127
121
 
122
+ # Avoid a bogus single order at the end when tradeable balances are low.
123
+ # TODO: Add remaining amount to last order
124
+ next unless fiat_budget >= min_market_funds.to_f
125
+
126
+ slice_alloc = risk_alloc * allocation_decimal
128
127
  order_slice = {}
129
128
  order_slice[:plan_no] = "#{plan_no}.#{plan_no_slice}"
130
129
  order_slice[:fiat_available] = format('%0.2f', fiat_budget)
@@ -137,6 +136,8 @@ module Cryptum
137
136
  '%0.2f',
138
137
  allocation_percent
139
138
  )
139
+ order_slice[:slice_alloc] = format('%0.2f', slice_alloc)
140
+ order_slice[:risk_target] = format('%0.2f', risk_target)
140
141
  order_slice[:invest] = format('%0.2f', fiat_investing)
141
142
  order_slice[:return] = format('%0.2f', fiat_returning)
142
143
  order_slice[:profit] = format('%0.2f', profit)
@@ -341,6 +342,9 @@ module Cryptum
341
342
  risk_alloc_out = Cryptum.beautify_large_number(
342
343
  value: order[:risk_alloc]
343
344
  )
345
+ slice_alloc_out = Cryptum.beautify_large_number(
346
+ value: order[:slice_alloc]
347
+ )
344
348
  invest_out = Cryptum.beautify_large_number(
345
349
  value: order[:invest]
346
350
  )
@@ -354,7 +358,7 @@ module Cryptum
354
358
  plan_no = "#{order[:plan_no]}|"
355
359
  fiat = "#{autotrade_percent}% of $#{fiat_avail_out} = "
356
360
  alloc = "$#{risk_alloc_out} @ #{order[:allocation_percent]}% = "
357
- invest = "$#{invest_out} + #{tpm_out}% = "
361
+ invest = "$#{slice_alloc_out} OR MIN OF $#{invest_out} + #{tpm_out}% = "
358
362
 
359
363
  returns = "$#{return_out}|"
360
364
  profit = "Profit: $#{profit_out}"
@@ -23,6 +23,32 @@ module Cryptum
23
23
  autotrade_percent = order[:autotrade_percent]
24
24
  order_color = order[:color]
25
25
 
26
+ fiat_avail_out = Cryptum.beautify_large_number(
27
+ value: order[:fiat_available]
28
+ )
29
+ risk_alloc_out = Cryptum.beautify_large_number(
30
+ value: order[:risk_alloc]
31
+ )
32
+ slice_alloc_out = Cryptum.beautify_large_number(
33
+ value: order[:slice_alloc]
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_details = "1. bot_conf[:autotrade_portfolio_percent] is set to #{autotrade_percent}% of $#{fiat_avail_out},"
46
+ risk_alloc_details = " making $#{risk_alloc_out} available for this slice in the order plan cycle."
47
+ slice_alloc_details = "2. With $#{risk_alloc_out} available and a slice allocation of #{order[:allocation_percent]}%, $#{slice_alloc_out} OR AN ORDER MINIMUM"
48
+ invest_details = " of $#{invest_out} will be allocated for this slice (whichever is highest)."
49
+ tpm_details = "3. With a slice allocation of $#{invest_out} plus bot_conf[:target_profit_margin_percent] (TPM)"
50
+ profit = " equal to #{tpm_out}% $#{return_out} will be returned. With $#{invest_out} invested the profit equals $#{profit_out}."
51
+
26
52
  # UI
27
53
  col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
28
54
  col_just3 = (Curses.cols - Cryptum::UI.col_third) - 1
@@ -62,7 +88,7 @@ module Cryptum
62
88
  Cryptum::UI.colorize(
63
89
  ui_win: order_plan_details_win,
64
90
  color: order_color,
65
- style: :bold,
91
+ style: header_style,
66
92
  string: header_str
67
93
  )
68
94
 
@@ -71,38 +97,71 @@ module Cryptum
71
97
  order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
72
98
  order_plan_details_win.clrtoeol
73
99
 
74
- fiat_avail_out = Cryptum.beautify_large_number(
75
- value: order[:fiat_available]
76
- )
77
- risk_alloc_out = Cryptum.beautify_large_number(
78
- value: order[:risk_alloc]
100
+ Cryptum::UI.colorize(
101
+ ui_win: order_plan_details_win,
102
+ color: order_color,
103
+ style: style,
104
+ string: autotrade_details.ljust(col_just1, ' ')
79
105
  )
80
- invest_out = Cryptum.beautify_large_number(
81
- value: order[:invest]
106
+
107
+ # ROW 4
108
+ out_line_no += 1
109
+ order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
110
+ order_plan_details_win.clrtoeol
111
+
112
+ Cryptum::UI.colorize(
113
+ ui_win: order_plan_details_win,
114
+ color: order_color,
115
+ style: style,
116
+ string: risk_alloc_details.ljust(col_just1, ' ')
82
117
  )
83
- profit_out = Cryptum.beautify_large_number(
84
- value: order[:profit]
118
+
119
+ # ROW 5
120
+ out_line_no += 1
121
+ order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
122
+ order_plan_details_win.clrtoeol
123
+
124
+ Cryptum::UI.colorize(
125
+ ui_win: order_plan_details_win,
126
+ color: order_color,
127
+ style: style,
128
+ string: slice_alloc_details.ljust(col_just1, ' ')
85
129
  )
86
- tpm_out = format('%0.2f', tpm)
87
- return_out = Cryptum.beautify_large_number(
88
- value: order[:return]
130
+
131
+ # ROW 6
132
+ out_line_no += 1
133
+ order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
134
+ order_plan_details_win.clrtoeol
135
+
136
+ Cryptum::UI.colorize(
137
+ ui_win: order_plan_details_win,
138
+ color: order_color,
139
+ style: style,
140
+ string: invest_details.ljust(col_just1, ' ')
89
141
  )
90
- plan_no = "#{order[:plan_no]}|"
91
- fiat = "#{autotrade_percent}% of $#{fiat_avail_out} = "
92
- alloc = "$#{risk_alloc_out} @ #{order[:allocation_percent]}% = "
93
- invest = "$#{invest_out} + #{tpm_out}% = "
94
142
 
95
- returns = "$#{return_out}|"
96
- profit = "Profit: $#{profit_out}"
143
+ # ROW 7
144
+ out_line_no += 1
145
+ order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
146
+ order_plan_details_win.clrtoeol
147
+
148
+ Cryptum::UI.colorize(
149
+ ui_win: order_plan_details_win,
150
+ color: order_color,
151
+ style: style,
152
+ string: tpm_details.ljust(col_just1, ' ')
153
+ )
97
154
 
98
- order_plan_invest = "#{plan_no}#{fiat}#{alloc}#{invest}"
99
- order_plan_return = "#{returns}#{profit}"
155
+ # ROW 8
156
+ out_line_no += 1
157
+ order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
158
+ order_plan_details_win.clrtoeol
100
159
 
101
160
  Cryptum::UI.colorize(
102
161
  ui_win: order_plan_details_win,
103
162
  color: order_color,
104
163
  style: style,
105
- string: "#{order_plan_invest}#{order_plan_return}".ljust(col_just1, '.')
164
+ string: profit.ljust(col_just1, ' ')
106
165
  )
107
166
 
108
167
  # Clear to OK ROW
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptum
4
- VERSION = '0.0.269'
4
+ VERSION = '0.0.271'
5
5
  end
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.269
4
+ version: 0.0.271
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.