cryptum 0.0.428 → 0.0.430
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -5
- data/Gemfile +1 -1
- data/lib/cryptum/order_book/market_trend.rb +32 -51
- data/lib/cryptum/ui/order/execute.rb +35 -10
- data/lib/cryptum/version.rb +1 -1
- data/lib/cryptum/web_sock/event_machine.rb +6 -5
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a529bc6041458959ded98c7d5a487f978a1ca4da216ef27006daa74b4882fdf
|
4
|
+
data.tar.gz: be3358d93281401821f0192b837717d343872a58c1b0eb759056ce8d00387a00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f1cad0e69a09e9754340649c6457e9bb7abbac52b6a6f2e15158ad7b6b8f1a2a667ad4afacdc9b460b30828bfa9a44a0cd4d1bdce40dd25446d39c71b1d95d8
|
7
|
+
data.tar.gz: 002ad29184c1b14f4dd6a6ea6bd04fd836a9d08d3db03d76e401353f4ade3acf9c05edae3045c61f104975fbc1fd536d9217ae90f3da486098699c338f1e26bf
|
data/.rubocop.yml
CHANGED
@@ -6,7 +6,7 @@ Layout/LineLength:
|
|
6
6
|
Lint/UselessRescue:
|
7
7
|
Enabled: false
|
8
8
|
Metrics/AbcSize:
|
9
|
-
Max:
|
9
|
+
Max: 436.3
|
10
10
|
Metrics/BlockLength:
|
11
11
|
Max: 138
|
12
12
|
Metrics/BlockNesting:
|
@@ -14,13 +14,13 @@ Metrics/BlockNesting:
|
|
14
14
|
Metrics/ClassLength:
|
15
15
|
Max: 128
|
16
16
|
Metrics/CyclomaticComplexity:
|
17
|
-
Max:
|
17
|
+
Max: 86
|
18
18
|
Metrics/MethodLength:
|
19
|
-
Max:
|
19
|
+
Max: 418
|
20
20
|
Metrics/ModuleLength:
|
21
|
-
Max:
|
21
|
+
Max: 428
|
22
22
|
Metrics/PerceivedComplexity:
|
23
|
-
Max:
|
23
|
+
Max: 84
|
24
24
|
Style/HashSyntax:
|
25
25
|
EnforcedShorthandSyntax: never
|
26
26
|
|
data/Gemfile
CHANGED
@@ -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
|
|
@@ -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
|
|
@@ -451,15 +457,34 @@ module Cryptum
|
|
451
457
|
)
|
452
458
|
plan_no = meta[:plan_no]
|
453
459
|
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
460
|
+
order_exec_last_ln = '____-__-__ __:__:__-____'
|
461
|
+
case meta[:color].to_sym
|
462
|
+
when :cyan, :red
|
463
|
+
buy_created_at_hash_arr = order_history.select do |oh|
|
464
|
+
oh[:id] == meta[:buy_order_id]
|
465
|
+
end
|
466
|
+
|
467
|
+
unless buy_created_at_hash_arr.empty?
|
468
|
+
order_exec_last_ln = Time.parse(
|
469
|
+
buy_created_at_hash_arr.first[:created_at]
|
470
|
+
).strftime('%Y-%m-%d %H:%M:%S%z')
|
471
|
+
end
|
472
|
+
when :green, :white
|
473
|
+
if meta[:done_at]
|
474
|
+
order_exec_last_ln = Time.parse(
|
475
|
+
meta[:done_at]
|
476
|
+
).strftime('%Y-%m-%d %H:%M:%S%z')
|
477
|
+
end
|
478
|
+
when :magenta, :yellow
|
479
|
+
sell_created_at_hash_arr = order_history.select do |oh|
|
480
|
+
oh[:id] == meta[:sell_order_id]
|
481
|
+
end
|
482
|
+
|
483
|
+
unless sell_created_at_hash_arr.empty?
|
484
|
+
order_exec_last_ln = Time.parse(
|
485
|
+
sell_created_at_hash_arr.first[:created_at]
|
486
|
+
).strftime('%Y-%m-%d %H:%M:%S%z')
|
487
|
+
end
|
463
488
|
end
|
464
489
|
|
465
490
|
invest = "$#{invest_out} @ "
|
@@ -469,7 +494,7 @@ module Cryptum
|
|
469
494
|
targ_tick = "$#{target_price_out}"
|
470
495
|
profit = "|Profit: $#{meta[:profit]}"
|
471
496
|
|
472
|
-
order_exec_ln = "#{
|
497
|
+
order_exec_ln = "#{order_exec_last_ln}|#{invest}#{tick}#{size}#{tpm_out}#{targ_tick}#{profit}|#{plan_no}"
|
473
498
|
|
474
499
|
order_execute_win.setpos(out_line_no, Cryptum::UI.col_first)
|
475
500
|
order_execute_win.clrtoeol
|
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.430
|
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-27 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.
|
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
|