cryptum 0.0.372 → 0.0.374

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: 9aa120fa4d511dc9bf69d5a1ab014f6a64a25240c2c82d24e3b5174577f909db
4
- data.tar.gz: 635cd8ee8edc14f8af8fb0e231f93ec56b9ca2ca8ef76c956437545fa2237cd4
3
+ metadata.gz: a78297f3f507363560f8127ddbe5a801975c0d9741d0b06eb255260388cf9393
4
+ data.tar.gz: 49279724c8c8bbda01f2a987f32f94fae70fddaa003941ff3a05dd7fd8bbbe0f
5
5
  SHA512:
6
- metadata.gz: 95e9e47b4ed784434434e59d26ce36d6390570800f2121d69062afefe9a7b298c2b5efb672454541ea7d8341f2221a1a6e8e0ad10105fc764a0117b9d1149376
7
- data.tar.gz: d8c64d255c32e4f7c93e0dd9bf6266001c1d4d3c8f8753ca8e5db88ec8821c65661dafc0654e22e474c5df39fde6460fcf896c41e0206b1f62b749580aba6dbd
6
+ metadata.gz: da4280d0b8c0d77526d999437e1643828cf00510722186d3c6408a679e1577c905956fb27ba2550ada2505af3baebd11f9242b73cf331467876f8589517b80fb
7
+ data.tar.gz: f52c1f848a9fe79f6861c989e985e73d5797b90a860288d49d7f68a249e923872fffc7446545f46220eea8c1a20f6adccada401c97cb81fa1cf91dd8edb3af36
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2023-01-10 17:06:46 UTC using RuboCop version 1.43.0.
3
+ # on 2023-03-29 14:29:26 UTC using RuboCop version 1.48.1.
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
@@ -15,6 +15,11 @@ Lint/UselessAssignment:
15
15
  Lint/UselessRescue:
16
16
  Enabled: false
17
17
 
18
+ # Offense count: 1
19
+ # Configuration parameters: CountComments, CountAsOne.
20
+ Metrics/ClassLength:
21
+ Max: 131
22
+
18
23
  # Offense count: 4
19
24
  # This cop supports safe autocorrection (--autocorrect).
20
25
  # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
@@ -24,7 +29,7 @@ Style/ConditionalAssignment:
24
29
  - 'lib/cryptum/event/pane.rb'
25
30
  - 'lib/cryptum/ui/order_execute_details.rb'
26
31
 
27
- # Offense count: 22
32
+ # Offense count: 23
28
33
  # Configuration parameters: AllowedConstants.
29
34
  Style/Documentation:
30
35
  Enabled: false
data/Gemfile CHANGED
@@ -12,7 +12,7 @@ gemspec
12
12
  # to build appropriately. Defer to ./reinstall_coinbot_gemset.sh
13
13
  # to review these custom flags
14
14
  gem 'addressable', '2.8.1'
15
- gem 'bundler', '>=2.4.9'
15
+ gem 'bundler', '>=2.4.10'
16
16
  gem 'bundler-audit', '0.9.1'
17
17
  gem 'curses', '1.4.4'
18
18
  gem 'eventmachine', '1.2.7'
@@ -44,7 +44,7 @@ module Cryptum
44
44
  :recalculate_order_plan
45
45
 
46
46
  def initialize(opts = {})
47
- # option_choice = opts[:option_choice]
47
+ option_choice = opts[:option_choice]
48
48
  start_time = opts[:start_time]
49
49
  order_book = opts[:order_book]
50
50
 
@@ -78,20 +78,119 @@ module Cryptum
78
78
  self.start_time = start_time
79
79
 
80
80
  # -------------------------------------------------- #
81
- # SAUCE 4
82
- # TODO: develop algorithm to calculate
83
- # FAST BUY && SLOW BUY values taking
84
- # market_trend_reset values into account
81
+ # SAUCE 3 (SAUCE 4 RELATES TO SAUCE 3)
82
+ case option_choice.market_trend_reset_label
83
+ when '1W'
84
+ # SLOW BUY = 1 day
85
+ self.time_between_orders_max = 86_400
85
86
 
86
- # FAST BUY = 4 hours
87
- self.time_between_orders = 14_400
88
- self.time_between_orders_reset = time_between_orders
87
+ # FAST BUY = 4 hours
88
+ self.time_between_orders = 14_400
89
+ self.time_between_orders_reset = time_between_orders
89
90
 
90
- # SLOW BUY = 1 day
91
- self.time_between_orders_max = 86_400
91
+ # 1 hour
92
+ self.time_between_orders_min = 3_600
93
+ when '1D'
94
+ # SLOW BUY = 4 hours
95
+ self.time_between_orders_max = 14_400
92
96
 
93
- # 1 hour
94
- self.time_between_orders_min = 3_600
97
+ # FAST BUY = 3 hours
98
+ self.time_between_orders = 10_800
99
+ self.time_between_orders_reset = time_between_orders
100
+
101
+ # 45 minutes
102
+ self.time_between_orders_min = 2_700
103
+ when '4h'
104
+ # SLOW BUY = 3 hours
105
+ self.time_between_orders_max = 10_800
106
+
107
+ # FAST BUY = 2 hours
108
+ self.time_between_orders = 7_200
109
+ self.time_between_orders_reset = time_between_orders
110
+
111
+ # 30 minutes
112
+ self.time_between_orders_min = 1_800
113
+ when '3h'
114
+ # SLOW BUY = 2 hours
115
+ self.time_between_orders_max = 7_200
116
+
117
+ # FAST BUY = 1 hour
118
+ self.time_between_orders = 3_600
119
+ self.time_between_orders_reset = time_between_orders
120
+
121
+ # 15 minutes
122
+ self.time_between_orders_min = 900
123
+ when '2h'
124
+ # SLOW BUY = 1 hour
125
+ self.time_between_orders_max = 3_600
126
+
127
+ # FAST BUY = 45 minutes
128
+ self.time_between_orders = 2_700
129
+ self.time_between_orders_reset = time_between_orders
130
+
131
+ # 5 minutes
132
+ self.time_between_orders_min = 300
133
+ when '1h'
134
+ # SLOW BUY = 45 minutes
135
+ self.time_between_orders_max = 2_700
136
+
137
+ # FAST BUY = 30 minutes
138
+ self.time_between_orders = 1_800
139
+ self.time_between_orders_reset = time_between_orders
140
+
141
+ # 3 minutes
142
+ self.time_between_orders_min = 180
143
+ when '45m'
144
+ # SLOW BUY = 30 minutes
145
+ self.time_between_orders_max = 1_800
146
+
147
+ # FAST BUY = 15 minutes
148
+ self.time_between_orders = 900
149
+ self.time_between_orders_reset = time_between_orders
150
+
151
+ # 1 minute
152
+ self.time_between_orders_min = 60
153
+ when '30m'
154
+ # SLOW BUY = 15 minutes
155
+ self.time_between_orders_max = 900
156
+
157
+ # FAST BUY = 5 minutes
158
+ self.time_between_orders = 300
159
+ self.time_between_orders_reset = time_between_orders
160
+
161
+ # 1 minute
162
+ self.time_between_orders_min = 60
163
+ when '15m'
164
+ # SLOW BUY = 5 minutes
165
+ self.time_between_orders_max = 300
166
+
167
+ # FAST BUY = 3 minutes
168
+ self.time_between_orders = 180
169
+ self.time_between_orders_reset = time_between_orders
170
+
171
+ # 1 minute
172
+ self.time_between_orders_min = 60
173
+ when '5m'
174
+ # SLOW BUY = 3 minutes
175
+ self.time_between_orders_max = 180
176
+
177
+ # FAST BUY = 1 minute
178
+ self.time_between_orders = 60
179
+ self.time_between_orders_reset = time_between_orders
180
+
181
+ # 1 minute
182
+ self.time_between_orders_min = 60
183
+ when '3m', '1m'
184
+ # SLOW BUY = 1 minute
185
+ self.time_between_orders_max = 60
186
+
187
+ # FAST BUY = 1 minute
188
+ self.time_between_orders = 60
189
+ self.time_between_orders_reset = time_between_orders
190
+
191
+ # 1 minute
192
+ self.time_between_orders_min = 60
193
+ end
95
194
  # -------------------------------------------------- #
96
195
  end
97
196
  rescue Interrupt
@@ -88,11 +88,20 @@ module Cryptum
88
88
  last_order = order_history_meta.select do |order|
89
89
  order if order[:color] == 'yellow'
90
90
  end.last
91
+
91
92
  last_purchase_price = 0.0
92
93
  last_purchase_price = last_order[:price].to_f if last_order
93
94
 
94
95
  limit_price = last_purchase_price - quote_increment.to_f if last_purchase_price.positive? && last_purchase_price < limit_price
95
96
 
97
+ # Debug last order
98
+ File.open('/tmp/cryptum-errors.txt', 'a') do |f|
99
+ f.puts "Last Order: #{last_order}"
100
+ f.puts "Last Purchase Price: #{last_purchase_price}"
101
+ f.puts "Limit Price (Should be <= quote_increment-- ^): #{limit_price}"
102
+ f.puts "\n\n\n"
103
+ end
104
+
96
105
  price = format(
97
106
  "%0.#{fiat_smallest_decimal}f",
98
107
  limit_price
@@ -155,7 +164,7 @@ module Cryptum
155
164
  order_history_meta.push(this_order)
156
165
  end
157
166
 
158
- # SAUCE 3
167
+ # SAUCE 4 (SAUCE 3 RELATES TO SAUCE 4)
159
168
  # Time between orders
160
169
  # Increment n Seconds between buys to
161
170
  # account for bearish and bullish trends
@@ -312,6 +321,7 @@ module Cryptum
312
321
  oh_meta_sold_arr = order_history_meta.select do |ohm|
313
322
  ohm[:color].to_sym == :green && ohm.key?(:done_at)
314
323
  end
324
+ order_hist_meta_sold = oh_meta_sold_arr.length
315
325
 
316
326
  # Snag all sold orders within past 24 hrs
317
327
  ohm_sold_twenty_four_arr = []
@@ -320,12 +330,13 @@ module Cryptum
320
330
  Time.parse(o[:done_at]) >= twenty_four_hrs_ago
321
331
  end
322
332
  end
323
- order_hist_meta_sold = ohm_sold_twenty_four_arr.length
333
+ order_hist_meta_sold_twenty_four = ohm_sold_twenty_four_arr.length
324
334
 
325
335
  # Snag all expired orders
326
336
  oh_meta_expired_arr = order_history_meta.select do |ohm|
327
337
  ohm[:color].to_sym == :white && ohm.key?(:done_at)
328
338
  end
339
+ order_hist_meta_expired = oh_meta_expired_arr.length
329
340
 
330
341
  # Snag all expired orders within past 24 hrs
331
342
  ohm_expire_twenty_four_arr = []
@@ -334,9 +345,20 @@ module Cryptum
334
345
  Time.parse(o[:done_at]) >= twenty_four_hrs_ago
335
346
  end
336
347
  end
337
- order_hist_meta_expired = ohm_expire_twenty_four_arr.length
348
+ order_hist_meta_24h_expired = ohm_expire_twenty_four_arr.length
349
+
350
+ # Calculate total gains and gains within past 24 hrs
351
+ gains_sum = oh_meta_sold_arr.map do |ohms|
352
+ ohms[:profit].to_f
353
+ end.sum
354
+
355
+ gains_out = Cryptum.beautify_large_number(
356
+ value: format(
357
+ '%0.2f',
358
+ gains_sum
359
+ )
360
+ )
338
361
 
339
- # Calculate gains within past 24 hrs
340
362
  gains_24h_sum = ohm_sold_twenty_four_arr.map do |ohms|
341
363
  ohms[:profit].to_f
342
364
  end.sum
@@ -351,7 +373,23 @@ module Cryptum
351
373
  total_to_sell = order_history.select do |oh|
352
374
  oh[:status].to_sym == :open && oh[:side].to_sym == :sell
353
375
  end.length
376
+
354
377
  event_history.open_sell_orders = total_to_sell
378
+ oh_meta_total_selling_profit_arr = order_history_meta.select do |ohm|
379
+ ohm[:color].to_sym == :yellow
380
+ end
381
+
382
+ total_selling_profit = oh_meta_total_selling_profit_arr.map do |ohms|
383
+ ohms[:profit].to_f
384
+ end.sum
385
+
386
+ total_selling_profit_out = Cryptum.beautify_large_number(
387
+ value: format(
388
+ '%0.2f',
389
+ total_selling_profit
390
+ )
391
+ )
392
+
355
393
  # TODO: when event_history.open_sell_orders > event_history.open_sell_orders_max
356
394
  # Capture highest amount to sell, cancel all orders, and create _one_ limit sell
357
395
  # order set to a price of the previously captured highest amount to sell.
@@ -524,7 +562,10 @@ module Cryptum
524
562
  string: ''.ljust(col_just1, ' ')
525
563
  )
526
564
 
527
- header_str = "24 HR SUMMARY | Open Sell Orders: #{total_to_sell} | Sold: #{order_hist_meta_sold} | Gains: $#{gains_24h_out} | Expired: #{order_hist_meta_expired}"
565
+ header_str = "SELLING: #{total_to_sell} w tProf: $#{total_selling_profit_out} | "
566
+ header_str += "SOLD 24h: #{order_hist_meta_sold_twenty_four} Tot: #{order_hist_meta_sold} | "
567
+ header_str += "GAINS 24h: $#{gains_24h_out} Tot: $#{gains_out} | "
568
+ header_str += "EXPIRED 24h: #{order_hist_meta_24h_expired} Tot: #{order_hist_meta_expired}"
528
569
  order_execute_win.setpos(
529
570
  out_line_no,
530
571
  Cryptum::UI.col_center(str: header_str)
@@ -537,14 +578,14 @@ module Cryptum
537
578
  string: header_str
538
579
  )
539
580
 
540
- order_execute_win.setpos(out_line_no, Cryptum::UI.col_fourth)
541
- order_execute_win.clrtoeol
542
- Cryptum::UI.colorize(
543
- ui_win: order_execute_win,
544
- color: header_color,
545
- style: header_style,
546
- string: ''.ljust(col_just4, ' ')
547
- )
581
+ # order_execute_win.setpos(out_line_no, Cryptum::UI.col_fourth)
582
+ # order_execute_win.clrtoeol
583
+ # Cryptum::UI.colorize(
584
+ # ui_win: order_execute_win,
585
+ # color: header_color,
586
+ # style: header_style,
587
+ # string: ''.ljust(col_just4, ' ')
588
+ # )
548
589
 
549
590
  # ROW 11
550
591
  out_line_no += 1
@@ -456,7 +456,9 @@ module Cryptum
456
456
  string: ''.ljust(col_just1, ' ')
457
457
  )
458
458
 
459
- header_str = "CYCLE SUMMARY | Risk Allocated: $#{order_plan_volume_out} | Profit: $#{order_plan_profit_sum_out} | #{order_plan_exec_percent}% Done"
459
+ header_str = "RISK ALLOCATED: $#{order_plan_volume_out} | "
460
+ header_str += "PROJECTED PROFIT: $#{order_plan_profit_sum_out} | "
461
+ header_str += "#{order_plan_exec_percent}% DONE"
460
462
  order_plan_win.setpos(
461
463
  out_line_no,
462
464
  Cryptum::UI.col_center(str: header_str)
@@ -469,14 +471,14 @@ module Cryptum
469
471
  string: header_str
470
472
  )
471
473
 
472
- order_plan_win.setpos(out_line_no, Cryptum::UI.col_fourth)
473
- order_plan_win.clrtoeol
474
- Cryptum::UI.colorize(
475
- ui_win: order_plan_win,
476
- color: header_color,
477
- style: header_style,
478
- string: ''.ljust(col_just4, ' ')
479
- )
474
+ # order_plan_win.setpos(out_line_no, Cryptum::UI.col_fourth)
475
+ # order_plan_win.clrtoeol
476
+ # Cryptum::UI.colorize(
477
+ # ui_win: order_plan_win,
478
+ # color: header_color,
479
+ # style: header_style,
480
+ # string: ''.ljust(col_just4, ' ')
481
+ # )
480
482
  end
481
483
 
482
484
  # ROW 11
@@ -65,7 +65,7 @@ module Cryptum
65
65
  # TODO: add condition to check if open sell orders exist.
66
66
  # If so intent should be something like, "- SEE ORDER HISTORY -"
67
67
  # Otherwise, intent should be something like, "- WAIT FOR MARKET TREND SHIFT -"
68
- intent = "- SEE ORDER HISTORY #{Cryptum.down_arrow} -"
68
+ intent = "- #{Cryptum.down_arrow} SEE ORDER HISTORY #{Cryptum.down_arrow} -"
69
69
  else
70
70
  speed = 'FAST'
71
71
  speed = 'SLOW' if buy_total >= sell_total
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptum
4
- VERSION = '0.0.372'
4
+ VERSION = '0.0.374'
5
5
  end
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.372
4
+ version: 0.0.374
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-23 00:00:00.000000000 Z
11
+ date: 2023-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.4.9
33
+ version: 2.4.10
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 2.4.9
40
+ version: 2.4.10
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler-audit
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -523,7 +523,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
523
523
  - !ruby/object:Gem::Version
524
524
  version: '0'
525
525
  requirements: []
526
- rubygems_version: 3.4.9
526
+ rubygems_version: 3.4.10
527
527
  signing_key:
528
528
  specification_version: 4
529
529
  summary: Coinbase Pro High-Frequency Trading Bot