cryptum 0.0.268 → 0.0.270

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: d384463e4c37155226e6cedb4a2156b77d7a9df8660f420acb15fc04de7875f0
4
- data.tar.gz: 82e3e395beb272f6634ae1335093cee1ffa10504229720fe5a5821c5d811d6e9
3
+ metadata.gz: 1f112246033a05eecb95d6b71d0ce96e7206d9aaef1cf7b675ddd453baafd8de
4
+ data.tar.gz: 399946d0c1100458ef8adcf300c190271af2cd936181c5f259153310c52e1eff
5
5
  SHA512:
6
- metadata.gz: d60b522b67253efd740f0fb41943f3fcdc9c76ec0441c0880c0e409b9769d5d30544857573fe42411bf4e0ebac89808348e8ba34b9d274521dfb75e16c93edc6
7
- data.tar.gz: a4edd8b79853a7d59135b4e9d136a2f4556a8de663adf9c926f1bd7f1491aa1a655095216845543e5d0d9c0996155f525b3659b236c460de54dfc97e23e65695
6
+ metadata.gz: d6d3a544bcbca635371547cf272a051f24585c0d8530f7356c5c466fb5202ca2c03cd75fde6ca42baafd410fd03c1ebc6f315e4666942cab00769e5982f568e9
7
+ data.tar.gz: af57efd0263bb5ead63ddb9a8e5b5c9e289d234a71183a727ee56f10cbb2139df62df7858335379f487208dd7a5d8a5f8d0d5b1b345d9efc2ce73b6d07550b72
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 18:21:06 UTC using RuboCop version 1.39.0.
3
+ # on 2022-12-05 22:19:37 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: 81
90
+ # Offense count: 84
91
91
  Lint/UselessAssignment:
92
92
  Enabled: false
93
93
 
94
- # Offense count: 49
94
+ # Offense count: 48
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: 20
110
+ # Offense count: 19
111
111
  # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
112
112
  Metrics/CyclomaticComplexity:
113
113
  Max: 73
@@ -117,7 +117,7 @@ Metrics/CyclomaticComplexity:
117
117
  Metrics/MethodLength:
118
118
  Max: 389
119
119
 
120
- # Offense count: 17
120
+ # Offense count: 18
121
121
  # Configuration parameters: CountComments, CountAsOne.
122
122
  Metrics/ModuleLength:
123
123
  Max: 538
@@ -127,12 +127,13 @@ Metrics/ModuleLength:
127
127
  Metrics/PerceivedComplexity:
128
128
  Max: 76
129
129
 
130
- # Offense count: 1
130
+ # Offense count: 3
131
131
  # This cop supports safe autocorrection (--autocorrect).
132
132
  # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
133
133
  # SupportedStyles: assign_to_condition, assign_inside_condition
134
134
  Style/ConditionalAssignment:
135
135
  Exclude:
136
+ - 'lib/cryptum/event/pane.rb'
136
137
  - 'lib/cryptum/option.rb'
137
138
 
138
139
  # Offense count: 1
@@ -179,12 +180,6 @@ Style/RedundantAssignment:
179
180
  Exclude:
180
181
  - 'lib/cryptum/api.rb'
181
182
 
182
- # Offense count: 1
183
- # This cop supports unsafe autocorrection (--autocorrect-all).
184
- Style/RedundantInterpolation:
185
- Exclude:
186
- - 'lib/cryptum/ui/order_execute_details.rb'
187
-
188
183
  # Offense count: 1
189
184
  # This cop supports safe autocorrection (--autocorrect).
190
185
  # Configuration parameters: AllowMultipleReturnValues.
@@ -222,9 +217,9 @@ Style/TrailingCommaInArrayLiteral:
222
217
  Exclude:
223
218
  - 'lib/cryptum/matrix.rb'
224
219
 
225
- # Offense count: 18
220
+ # Offense count: 21
226
221
  # This cop supports safe autocorrection (--autocorrect).
227
222
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
228
223
  # URISchemes: http, https
229
224
  Layout/LineLength:
230
- Max: 216
225
+ Max: 221
@@ -34,32 +34,18 @@ module Cryptum
34
34
 
35
35
  terminal_win.key_press_event.key_enter = false
36
36
 
37
- if event_history.order_plan_win_active &&
38
- !event_history.order_plan_details_win_active &&
39
- !event_history.order_execute_win_active
40
-
41
- event_history.order_plan_win_active = false
42
- event_history.order_plan_details_win_active = true
43
- elsif !event_history.order_plan_win_active &&
44
- event_history.order_plan_details_win_active &&
45
- !event_history.order_execute_win_active
46
-
47
- event_history.order_plan_win_active = true
48
- event_history.order_plan_details_win_active = false
49
- end
50
-
51
- if event_history.order_execute_win_active &&
52
- !event_history.order_execute_details_win_active &&
53
- !event_history.order_plan_win_active
54
-
55
- event_history.order_execute_win_active = false
56
- event_history.order_execute_details_win_active = true
57
- elsif !event_history.order_execute_win_active &&
58
- event_history.order_execute_details_win_active &&
59
- !event_history.order_plan_win_active
60
-
61
- event_history.order_execute_win_active = true
62
- event_history.order_execute_details_win_active = false
37
+ if event_history.order_plan_win_active
38
+ if event_history.order_plan_details_win_active
39
+ event_history.order_plan_details_win_active = false
40
+ else
41
+ event_history.order_plan_details_win_active = true
42
+ end
43
+ elsif event_history.order_execute_win_active
44
+ if event_history.order_execute_details_win_active
45
+ event_history.order_execute_details_win_active = false
46
+ else
47
+ event_history.order_execute_details_win_active = true
48
+ end
63
49
  end
64
50
  rescue StandardError => e
65
51
  raise e
@@ -53,7 +53,7 @@ module Cryptum
53
53
  string: ''.ljust(col_just1, ' ')
54
54
  )
55
55
 
56
- header_str = "- ##{order[:plan_no]} ORDER HISTORY DETAILS -"
56
+ header_str = "- ORDER ##{order[:plan_no]} DETAILS -"
57
57
  order_execute_details_win.setpos(
58
58
  out_line_no,
59
59
  Cryptum::UI.col_center(str: header_str)
@@ -62,7 +62,7 @@ module Cryptum
62
62
  Cryptum::UI.colorize(
63
63
  ui_win: order_execute_details_win,
64
64
  color: order_color,
65
- style: :bold,
65
+ style: header_style,
66
66
  string: header_str
67
67
  )
68
68
 
@@ -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
@@ -53,7 +79,7 @@ module Cryptum
53
79
  string: ''.ljust(col_just1, ' ')
54
80
  )
55
81
 
56
- header_str = "- ##{order[:plan_no]} ORDER SLICE DETAILS -"
82
+ header_str = "- ORDER SLICE ##{order[:plan_no]} DETAILS -"
57
83
  order_plan_details_win.setpos(
58
84
  out_line_no,
59
85
  Cryptum::UI.col_center(str: header_str)
@@ -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.268'
4
+ VERSION = '0.0.270'
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.268
4
+ version: 0.0.270
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.