cryptum 0.0.427 → 0.0.429
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile +2 -2
- data/lib/cryptum/order_book/market_trend.rb +32 -51
- data/lib/cryptum/ui/order/execute.rb +14 -8
- data/lib/cryptum/version.rb +1 -1
- data/lib/cryptum/web_sock/event_machine.rb +6 -5
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2380db0865bfa954a012a595702a708c13fe6bf18cfd0958d510239addf00186
|
4
|
+
data.tar.gz: fc72a86ba6f45138bf5171e766581ccf3e0fc970eb3eeda90c456d9aaecc9306
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c76b40bba10f43ff918eae4f8fce19368a92d2e20e3c4baf7b29da3a0165f4c8a8c05bb2ef45a34d088c0f1ae7ca28acc09c1538cd211a70c6c774d3db1ed5a1
|
7
|
+
data.tar.gz: 4394275cfa271f7cace9ed98b905fedf42eabafba11a292a2eb23af927f184c095c08ce487fbf0aacc22fb029a3ada517468bebe08090390613347b744e027a3
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
@@ -28,8 +28,8 @@ gem 'rest-client', '2.1.0'
|
|
28
28
|
gem 'rspec', '3.12.0'
|
29
29
|
gem 'rubocop', '1.50.2'
|
30
30
|
gem 'rubocop-rake', '0.6.0'
|
31
|
-
gem 'rubocop-rspec', '2.
|
32
|
-
gem 'ruby-prof', '1.6.
|
31
|
+
gem 'rubocop-rspec', '2.20.0'
|
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
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
|
@@ -95,10 +95,17 @@ module Cryptum
|
|
95
95
|
|
96
96
|
limit_price = last_purchase_price - quote_increment.to_f if last_purchase_price.positive? && last_purchase_price < limit_price
|
97
97
|
|
98
|
+
price = format(
|
99
|
+
"%0.#{fiat_smallest_decimal}f",
|
100
|
+
limit_price
|
101
|
+
)
|
102
|
+
|
98
103
|
# Debug last order -------------------------------#
|
99
|
-
|
100
|
-
|
101
|
-
debug_last_order
|
104
|
+
# TODO: if the order attempt is unsucessful at the adjusted price,
|
105
|
+
# the order plan needs to be reset.
|
106
|
+
debug_last_order = "Last Order: #{last_order}\n"
|
107
|
+
debug_last_order += "Last Purchase Price: #{last_purchase_price}\n"
|
108
|
+
debug_last_order += "Limit Price (Should be <= #{last_purchase_price}): #{price}"
|
102
109
|
debug_last_order += "\n\n\n"
|
103
110
|
|
104
111
|
Cryptum::Log.append(
|
@@ -109,11 +116,6 @@ module Cryptum
|
|
109
116
|
)
|
110
117
|
#-------------------------------------------------#
|
111
118
|
|
112
|
-
price = format(
|
113
|
-
"%0.#{fiat_smallest_decimal}f",
|
114
|
-
limit_price
|
115
|
-
)
|
116
|
-
|
117
119
|
size = this_order[:invest].to_f / limit_price
|
118
120
|
|
119
121
|
loop do
|
@@ -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
|
|
data/lib/cryptum/version.rb
CHANGED
@@ -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
|
-
|
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.
|
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-
|
11
|
+
date: 2023-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -254,28 +254,28 @@ dependencies:
|
|
254
254
|
requirements:
|
255
255
|
- - '='
|
256
256
|
- !ruby/object:Gem::Version
|
257
|
-
version: 2.
|
257
|
+
version: 2.20.0
|
258
258
|
type: :runtime
|
259
259
|
prerelease: false
|
260
260
|
version_requirements: !ruby/object:Gem::Requirement
|
261
261
|
requirements:
|
262
262
|
- - '='
|
263
263
|
- !ruby/object:Gem::Version
|
264
|
-
version: 2.
|
264
|
+
version: 2.20.0
|
265
265
|
- !ruby/object:Gem::Dependency
|
266
266
|
name: ruby-prof
|
267
267
|
requirement: !ruby/object:Gem::Requirement
|
268
268
|
requirements:
|
269
269
|
- - '='
|
270
270
|
- !ruby/object:Gem::Version
|
271
|
-
version: 1.6.
|
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.
|
278
|
+
version: 1.6.3
|
279
279
|
- !ruby/object:Gem::Dependency
|
280
280
|
name: rvm
|
281
281
|
requirement: !ruby/object:Gem::Requirement
|