cryptum 0.0.428 → 0.0.429

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: fe0b02adbb5ffcbdb8065a6f1736db690d68311c3e951827a28931b9c7a4c1f2
4
- data.tar.gz: 3add711462fc12b4f22e80f1883a8559cec2929bbb16a8a10c3c8c9a19a674a3
3
+ metadata.gz: 2380db0865bfa954a012a595702a708c13fe6bf18cfd0958d510239addf00186
4
+ data.tar.gz: fc72a86ba6f45138bf5171e766581ccf3e0fc970eb3eeda90c456d9aaecc9306
5
5
  SHA512:
6
- metadata.gz: 7d70cdf414221746b8fd55fd6c16e9072287dae88b4e0c6bc6a76273df5e40685cdd5f417b625fd5440cebd8c73d463c70de29b4b48b19ea9eaa6bdab5904b0c
7
- data.tar.gz: 9bc168b1a91812b2f7b68dfc4594eba6ab24a628daa7f04df123023f46e86bd94ac08e380fe46c4f154f066229036003910162f01f0a0c489a4ec2953ef03f77
6
+ metadata.gz: c76b40bba10f43ff918eae4f8fce19368a92d2e20e3c4baf7b29da3a0165f4c8a8c05bb2ef45a34d088c0f1ae7ca28acc09c1538cd211a70c6c774d3db1ed5a1
7
+ data.tar.gz: 4394275cfa271f7cace9ed98b905fedf42eabafba11a292a2eb23af927f184c095c08ce487fbf0aacc22fb029a3ada517468bebe08090390613347b744e027a3
data/.rubocop.yml CHANGED
@@ -6,7 +6,7 @@ Layout/LineLength:
6
6
  Lint/UselessRescue:
7
7
  Enabled: false
8
8
  Metrics/AbcSize:
9
- Max: 410
9
+ Max: 417.7
10
10
  Metrics/BlockLength:
11
11
  Max: 138
12
12
  Metrics/BlockNesting:
data/Gemfile CHANGED
@@ -29,7 +29,7 @@ gem 'rspec', '3.12.0'
29
29
  gem 'rubocop', '1.50.2'
30
30
  gem 'rubocop-rake', '0.6.0'
31
31
  gem 'rubocop-rspec', '2.20.0'
32
- gem 'ruby-prof', '1.6.2'
32
+ gem 'ruby-prof', '1.6.3'
33
33
  gem 'rvm', '1.11.3.9'
34
34
  gem 'sinatra', '3.0.6'
35
35
  gem 'thin', '1.8.2'
@@ -62,57 +62,38 @@ module Cryptum
62
62
  Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
63
63
  end
64
64
 
65
- # public_class_method def self.reset(opts = {})
66
- # # IT IS ABSOLUTELY CRITICAL THIS METHOD IS AS FAST AS POSSIBLE
67
- # # TO AVOID TICKER PRICE SYNCING ISSUES.
68
- # event_history = opts[:event_history]
69
-
70
- # # order_history = event_history.order_book[:order_history]
71
- # # order_history_meta = event_history.order_book[:order_history_meta]
72
-
73
- # # Only retain past 24 hours of
74
- # # order history meta for bought, sold, and expired
75
- # # keep open limit sell orders indefintely
76
- # # before_twenty_four_hrs_ago = Time.now - 86_400
77
- # # order_history_meta.delete_if do |ohm|
78
- # # order_history.find do |oh|
79
- # # next unless oh[:done_at]
80
-
81
- # # Time.parse(oh[:done_at]) < before_twenty_four_hrs_ago && (
82
- # # oh[:id] == ohm[:buy_order_id] ||
83
- # # oh[:id] == ohm[:sell_order_id]
84
- # # ) && (
85
- # # ohm[:color].to_sym == :white ||
86
- # # ohm[:color].to_sym == :green ||
87
- # # ohm[:color].to_sym == :cyan ||
88
- # # ohm[:color].to_sym == :red
89
- # # )
90
- # # end
91
- # # end
92
-
93
- # # Only keep order history meta for those
94
- # # hashes that exist in the last order history
95
- # # response
96
- # # order_history_meta.keep_if do |ohm|
97
- # # order_history.find do |oh|
98
- # # (oh[:id] == ohm[:buy_order_id] || oh[:id] == ohm[:sell_order_id]) && (
99
- # # ohm[:color].to_sym == :white ||
100
- # # ohm[:color].to_sym == :green ||
101
- # # ohm[:color].to_sym == :yellow
102
- # # )
103
- # # end
104
- # # end
105
- # # event_history.order_book[:order_history_meta] = order_history_meta
106
-
107
- # # Reset Market Trend Counter
108
- # event_history.order_book[:market_trend][:buy] = 0
109
- # event_history.order_book[:market_trend][:sell] = 0
110
- # event_history.order_book[:last_trend_reset] = Time.now.strftime(
111
- # '%Y-%m-%d %H:%M:%S.%N%z'
112
- # )
113
- # rescue Interrupt, StandardError => e
114
- # Cryptum::Log.append(level: :error, msg: e, which_self: self)
115
- # end
65
+ public_class_method def self.reset(opts = {})
66
+ # IT IS ABSOLUTELY CRITICAL THIS METHOD IS AS FAST AS POSSIBLE
67
+ # TO AVOID TICKER PRICE SYNCING ISSUES.
68
+ event_history = opts[:event_history]
69
+
70
+ # order_history = event_history.order_book[:order_history]
71
+ order_history_meta = event_history.order_book[:order_history_meta]
72
+
73
+ # Only retain past 24 hours of
74
+ # order history meta for expired
75
+ # keep open limit sell orders indefintely
76
+ before_twenty_four_hrs_ago = Time.now - 86_400
77
+ order_history_meta.delete_if do |ohm|
78
+ next unless ohm[:color] == 'white'
79
+
80
+ Time.parse(ohm[:done_at]) < before_twenty_four_hrs_ago
81
+ end
82
+
83
+ # Write order_history_meta back to event_history object
84
+ event_history.order_book[:order_history_meta] = order_history_meta
85
+
86
+ # Reset Market Trend Counter
87
+ event_history.order_book[:market_trend][:buy] = 0
88
+ event_history.order_book[:market_trend][:sell] = 0
89
+ event_history.order_book[:last_trend_reset] = Time.now.strftime(
90
+ '%Y-%m-%d %H:%M:%S.%N%z'
91
+ )
92
+
93
+ event_history
94
+ rescue Interrupt, StandardError => e
95
+ Cryptum::Log.append(level: :error, msg: e, which_self: self)
96
+ end
116
97
 
117
98
  # Display Usage for this Module
118
99
 
@@ -101,6 +101,8 @@ module Cryptum
101
101
  )
102
102
 
103
103
  # Debug last order -------------------------------#
104
+ # TODO: if the order attempt is unsucessful at the adjusted price,
105
+ # the order plan needs to be reset.
104
106
  debug_last_order = "Last Order: #{last_order}\n"
105
107
  debug_last_order += "Last Purchase Price: #{last_purchase_price}\n"
106
108
  debug_last_order += "Limit Price (Should be <= #{last_purchase_price}): #{price}"
@@ -142,6 +144,8 @@ module Cryptum
142
144
  event_history: event_history,
143
145
  bot_conf: bot_conf
144
146
  )
147
+ order_history = event_history.order_book[:order_history]
148
+ order_history_meta = event_history.order_book[:order_history_meta]
145
149
  end
146
150
 
147
151
  # SAUCE 4 (SAUCE 3 RELATES TO SAUCE 4)
@@ -216,6 +220,8 @@ module Cryptum
216
220
  bot_conf: bot_conf,
217
221
  buy_order_id: buy_order_id
218
222
  )
223
+ order_history = event_history.order_book[:order_history]
224
+ order_history_meta = event_history.order_book[:order_history_meta]
219
225
  end
220
226
  end
221
227
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptum
4
- VERSION = '0.0.428'
4
+ VERSION = '0.0.429'
5
5
  end
@@ -216,11 +216,12 @@ module Cryptum
216
216
  EM.add_periodic_timer(option_choice.market_trend_reset) do
217
217
  # NOTE: To ensure the integrity of event_history is maintained,
218
218
  # changes to its contents _MUST_ stay in this block.
219
- event_history.order_book[:market_trend][:buy] = 0
220
- event_history.order_book[:market_trend][:sell] = 0
221
- event_history.order_book[:last_trend_reset] = Time.now.strftime(
222
- '%Y-%m-%d %H:%M:%S.%N%z'
223
- )
219
+ # event_history.order_book[:market_trend][:buy] = 0
220
+ # event_history.order_book[:market_trend][:sell] = 0
221
+ # event_history.order_book[:last_trend_reset] = Time.now.strftime(
222
+ # '%Y-%m-%d %H:%M:%S.%N%z'
223
+ # )
224
+ event_history = Cryptum::OrderBook::MarketTrend.reset(event_history: event_history)
224
225
 
225
226
  # Reload Bot Conf (i.e. Risk Allocation)
226
227
  # Recalculate Order Plan, and Write to File
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.428
4
+ version: 0.0.429
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-04-19 00:00:00.000000000 Z
11
+ date: 2023-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -268,14 +268,14 @@ dependencies:
268
268
  requirements:
269
269
  - - '='
270
270
  - !ruby/object:Gem::Version
271
- version: 1.6.2
271
+ version: 1.6.3
272
272
  type: :runtime
273
273
  prerelease: false
274
274
  version_requirements: !ruby/object:Gem::Requirement
275
275
  requirements:
276
276
  - - '='
277
277
  - !ruby/object:Gem::Version
278
- version: 1.6.2
278
+ version: 1.6.3
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: rvm
281
281
  requirement: !ruby/object:Gem::Requirement