cryptum 0.0.271 → 0.0.272
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 +4 -4
- data/.rubocop_todo.yml +5 -6
- data/bin/cryptum +5 -4
- data/lib/cryptum/event/bot_conf.rb +2 -0
- data/lib/cryptum/event/history.rb +4 -2
- data/lib/cryptum/event/order_book.rb +5 -3
- data/lib/cryptum/event.rb +1 -0
- data/lib/cryptum/order_book/generate.rb +9 -4
- data/lib/cryptum/ui/order_execute_details.rb +0 -13
- data/lib/cryptum/ui/order_plan.rb +25 -12
- data/lib/cryptum/ui/order_plan_details.rb +5 -18
- data/lib/cryptum/version.rb +1 -1
- data/lib/cryptum/web_sock/event_machine.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33789e9885b695c15c6910051688172381d800d5621266ff531d0b7445478b2a
|
4
|
+
data.tar.gz: 84ec9383263bb2e98d4aa9b7e53535581e8c1a879062ff6cbef25f98fb19d475
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ffa742a34ef7e6bd05bc1464c469d2e0767657d30957ff87a4b8762b248fdfe6b619f1c2f6b04f1e3c2c48f70002cf6b4b833bfd4df867496036c0d5c60bab6
|
7
|
+
data.tar.gz: b4986392cfdfffd83b09e17ca37515fb5264521cc2c5f0d64695e344c793e99947e065cd11c6fe2f250d24159a84877c9503d81371a14de27b26d6281545475b
|
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-
|
3
|
+
# on 2022-12-06 15:52:44 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,7 +87,7 @@ Layout/TrailingWhitespace:
|
|
87
87
|
- 'lib/cryptum/ui/order_plan.rb'
|
88
88
|
- 'lib/cryptum/ui/order_timer.rb'
|
89
89
|
|
90
|
-
# Offense count:
|
90
|
+
# Offense count: 85
|
91
91
|
Lint/UselessAssignment:
|
92
92
|
Enabled: false
|
93
93
|
|
@@ -100,7 +100,7 @@ Metrics/AbcSize:
|
|
100
100
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
|
101
101
|
# AllowedMethods: refine
|
102
102
|
Metrics/BlockLength:
|
103
|
-
Max:
|
103
|
+
Max: 146
|
104
104
|
|
105
105
|
# Offense count: 4
|
106
106
|
# Configuration parameters: CountBlocks.
|
@@ -127,7 +127,7 @@ Metrics/ModuleLength:
|
|
127
127
|
Metrics/PerceivedComplexity:
|
128
128
|
Max: 76
|
129
129
|
|
130
|
-
# Offense count:
|
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
|
@@ -135,7 +135,6 @@ Style/ConditionalAssignment:
|
|
135
135
|
Exclude:
|
136
136
|
- 'lib/cryptum/event/pane.rb'
|
137
137
|
- 'lib/cryptum/option.rb'
|
138
|
-
- 'lib/cryptum/ui/order_execute_details.rb'
|
139
138
|
|
140
139
|
# Offense count: 1
|
141
140
|
# Configuration parameters: AllowedConstants.
|
@@ -218,7 +217,7 @@ Style/TrailingCommaInArrayLiteral:
|
|
218
217
|
Exclude:
|
219
218
|
- 'lib/cryptum/matrix.rb'
|
220
219
|
|
221
|
-
# Offense count:
|
220
|
+
# Offense count: 21
|
222
221
|
# This cop supports safe autocorrection (--autocorrect).
|
223
222
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
|
224
223
|
# URISchemes: http, https
|
data/bin/cryptum
CHANGED
@@ -28,6 +28,9 @@ begin
|
|
28
28
|
# Exist and Initialize Automated Trading Parameters
|
29
29
|
bot_conf = Cryptum::BotConf.read(option_choice: option_choice)
|
30
30
|
|
31
|
+
# Initialize Curses UI
|
32
|
+
terminal_win = Cryptum::UI.init
|
33
|
+
|
31
34
|
# Generate an Order Book for Session Tracking
|
32
35
|
# Load previous order_book_justification from
|
33
36
|
# Order Book File (if it exists) to preserve
|
@@ -37,12 +40,10 @@ begin
|
|
37
40
|
start_time: start_time,
|
38
41
|
option_choice: option_choice,
|
39
42
|
env: env,
|
40
|
-
bot_conf: bot_conf
|
43
|
+
bot_conf: bot_conf,
|
44
|
+
terminal_win: terminal_win
|
41
45
|
)
|
42
46
|
|
43
|
-
# Initialize Curses UI
|
44
|
-
terminal_win = Cryptum::UI.init
|
45
|
-
|
46
47
|
# Connect to WebSocket
|
47
48
|
# Trigger Events as Event Data
|
48
49
|
# is Generated via Coinbase Pro
|
@@ -9,8 +9,10 @@ module Cryptum
|
|
9
9
|
# )
|
10
10
|
public_class_method def self.reload(opts = {})
|
11
11
|
terminal_win = opts[:terminal_win]
|
12
|
+
event_history = opts[:event_history]
|
12
13
|
option_choice = opts[:option_choice]
|
13
14
|
|
15
|
+
event_history.recalculate_order_plan = true
|
14
16
|
terminal_win.key_press_event.key_r = false
|
15
17
|
Cryptum.read_bot_conf(option_choice: option_choice)
|
16
18
|
rescue StandardError => e
|
@@ -35,7 +35,8 @@ module Cryptum
|
|
35
35
|
:order_execute_index_offset,
|
36
36
|
:order_execute_max_rows_to_display,
|
37
37
|
:order_execute_row_to_select,
|
38
|
-
:order_execute_selected_data
|
38
|
+
:order_execute_selected_data,
|
39
|
+
:recalculate_order_plan
|
39
40
|
|
40
41
|
def initialize(opts = {})
|
41
42
|
# option_choice = opts[:option_choice]
|
@@ -48,7 +49,7 @@ module Cryptum
|
|
48
49
|
self.order_submitted = false
|
49
50
|
self.order_ready = false
|
50
51
|
self.order_book = order_book
|
51
|
-
self.plan_no =
|
52
|
+
self.plan_no = 1
|
52
53
|
self.start_time = start_time
|
53
54
|
self.reconnected = false
|
54
55
|
self.red_pill = false
|
@@ -64,6 +65,7 @@ module Cryptum
|
|
64
65
|
self.order_execute_max_rows_to_display = 6
|
65
66
|
self.order_execute_row_to_select = order_execute_index_offset
|
66
67
|
self.order_execute_selected_data = { color: :white }
|
68
|
+
self.recalculate_order_plan = false
|
67
69
|
|
68
70
|
# TODO: Implement market_trend_reset / 144
|
69
71
|
# Default = 10 minutes
|
@@ -14,9 +14,11 @@ module Cryptum
|
|
14
14
|
|
15
15
|
terminal_win.key_press_event.key_w = false
|
16
16
|
order_book_file = event_history.order_book[:path]
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
|
18
|
+
File.write(
|
19
|
+
order_book_file,
|
20
|
+
JSON.pretty_generate(event_history.order_book)
|
21
|
+
)
|
20
22
|
rescue StandardError => e
|
21
23
|
raise e
|
22
24
|
end
|
data/lib/cryptum/event.rb
CHANGED
@@ -20,6 +20,7 @@ module Cryptum
|
|
20
20
|
option_choice = opts[:option_choice]
|
21
21
|
env = opts[:env]
|
22
22
|
bot_conf = opts[:bot_conf]
|
23
|
+
terminal_win = opts[:terminal_win]
|
23
24
|
|
24
25
|
order_book_file = "#{option_choice.repo_root}/order_books/#{option_choice.symbol}.ORDER_BOOK.json"
|
25
26
|
|
@@ -85,12 +86,16 @@ module Cryptum
|
|
85
86
|
)
|
86
87
|
|
87
88
|
# Write order_book to file at session initiation
|
88
|
-
File.open(order_book_file, 'w') do |f|
|
89
|
-
|
90
|
-
end
|
91
|
-
|
89
|
+
# File.open(order_book_file, 'w') do |f|
|
90
|
+
# f.puts order_book.to_json
|
91
|
+
# end
|
92
92
|
event_history.order_book = order_book
|
93
93
|
|
94
|
+
Cryptum::Event::OrderBook.write(
|
95
|
+
terminal_win: terminal_win,
|
96
|
+
event_history: event_history
|
97
|
+
)
|
98
|
+
|
94
99
|
event_history
|
95
100
|
rescue StandardError => e
|
96
101
|
raise e
|
@@ -69,7 +69,6 @@ module Cryptum
|
|
69
69
|
profit = "|Profit: $#{order[:profit]}"
|
70
70
|
|
71
71
|
order_id_details = "#{order_type} Order ID: #{order_id}"
|
72
|
-
order_plan_details = "Order Slice #: #{order_plan_no}"
|
73
72
|
order_exec_ln = "Details: #{created_at}|#{invest}#{tick}#{size}#{tpm_out}#{targ_tick}#{profit}"
|
74
73
|
|
75
74
|
# UI
|
@@ -132,18 +131,6 @@ module Cryptum
|
|
132
131
|
order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
133
132
|
order_execute_details_win.clrtoeol
|
134
133
|
|
135
|
-
Cryptum::UI.colorize(
|
136
|
-
ui_win: order_execute_details_win,
|
137
|
-
color: order_color,
|
138
|
-
style: style,
|
139
|
-
string: order_plan_details.ljust(col_just1, ' ')
|
140
|
-
)
|
141
|
-
|
142
|
-
# ROW 4
|
143
|
-
out_line_no += 1
|
144
|
-
order_execute_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
145
|
-
order_execute_details_win.clrtoeol
|
146
|
-
|
147
134
|
Cryptum::UI.colorize(
|
148
135
|
ui_win: order_execute_details_win,
|
149
136
|
color: order_color,
|
@@ -80,21 +80,27 @@ module Cryptum
|
|
80
80
|
|
81
81
|
event_history.red_pill = true if crypto_invested_percent.to_f > autotrade_percent
|
82
82
|
|
83
|
-
if
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
83
|
+
if event_history.recalculate_order_plan || (
|
84
|
+
crypto_invested_percent.to_f <= autotrade_percent &&
|
85
|
+
autotrade_percent.positive? && (
|
86
|
+
order_plan.empty? || (
|
87
|
+
indicator_status.action_signal == :buy &&
|
88
|
+
indicator_status.last_action_signal == :sell
|
89
|
+
)
|
88
90
|
)
|
89
91
|
)
|
90
92
|
|
91
93
|
event_history.red_pill = false
|
92
|
-
|
93
|
-
|
94
|
+
if indicator_status.action_signal == :buy &&
|
95
|
+
indicator_status.last_action_signal == :sell
|
96
|
+
|
97
|
+
order_plan = []
|
98
|
+
# Reset time between orders
|
99
|
+
event_history.time_between_orders = event_history.time_between_orders_reset
|
100
|
+
event_history.plan_no += 1
|
101
|
+
end
|
94
102
|
|
95
|
-
order_plan = []
|
96
103
|
plan_no_slice = 1
|
97
|
-
event_history.plan_no += 1
|
98
104
|
plan_no = event_history.plan_no
|
99
105
|
# Sum up currently invested amount so we don't
|
100
106
|
# exceed autotrade % for next order plan generation
|
@@ -124,8 +130,14 @@ module Cryptum
|
|
124
130
|
next unless fiat_budget >= min_market_funds.to_f
|
125
131
|
|
126
132
|
slice_alloc = risk_alloc * allocation_decimal
|
127
|
-
|
128
|
-
|
133
|
+
this_plan_no = "#{plan_no}.#{plan_no_slice}"
|
134
|
+
if event_history.recalculate_order_plan
|
135
|
+
order_slice = order_plan.find do |order|
|
136
|
+
order[:plan_no] == this_plan_no
|
137
|
+
end
|
138
|
+
end
|
139
|
+
order_slice ||= {}
|
140
|
+
order_slice[:plan_no] = this_plan_no
|
129
141
|
order_slice[:fiat_available] = format('%0.2f', fiat_budget)
|
130
142
|
order_slice[:risk_alloc] = format('%0.2f', risk_alloc)
|
131
143
|
order_slice[:allocation_decimal] = format(
|
@@ -142,11 +154,12 @@ module Cryptum
|
|
142
154
|
order_slice[:return] = format('%0.2f', fiat_returning)
|
143
155
|
order_slice[:profit] = format('%0.2f', profit)
|
144
156
|
|
145
|
-
order_plan.push(order_slice)
|
157
|
+
order_plan.push(order_slice) unless event_history.recalculate_order_plan
|
146
158
|
fiat_budget -= fiat_investing
|
147
159
|
plan_no_slice += 1
|
148
160
|
end
|
149
161
|
event_history.order_book[:order_plan] = order_plan
|
162
|
+
event_history.recalculate_order_plan = false
|
150
163
|
end
|
151
164
|
|
152
165
|
red_pill_alert = '| RED PILL ALERT |'
|
@@ -42,12 +42,11 @@ module Cryptum
|
|
42
42
|
return_out = Cryptum.beautify_large_number(
|
43
43
|
value: order[:return]
|
44
44
|
)
|
45
|
-
autotrade_details = "1.
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
profit = " equal to #{tpm_out}% $#{return_out} will be returned. With $#{invest_out} invested the profit equals $#{profit_out}."
|
45
|
+
autotrade_details = "1. Autotrade is set to #{autotrade_percent}% of $#{fiat_avail_out}, making $#{risk_alloc_out} available for this slice in the order plan."
|
46
|
+
slice_alloc_details = "2. With $#{risk_alloc_out} available and a slice allocation of #{order[:allocation_percent]}%, $#{slice_alloc_out} OR AN ORDER MINIMUM of $#{invest_out} will"
|
47
|
+
invest_details = ' be allocated for this slice (whichever is highest).'
|
48
|
+
tpm_details = "3. With a slice allocation of $#{invest_out}, plus a TPM equal to #{tpm_out}%, $#{return_out} will be returned once sold."
|
49
|
+
profit = " With $#{invest_out} invested the gross profit equals $#{profit_out}, minus any transaction fees."
|
51
50
|
|
52
51
|
# UI
|
53
52
|
col_just1 = (Curses.cols - Cryptum::UI.col_first) - 1
|
@@ -104,18 +103,6 @@ module Cryptum
|
|
104
103
|
string: autotrade_details.ljust(col_just1, ' ')
|
105
104
|
)
|
106
105
|
|
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, ' ')
|
117
|
-
)
|
118
|
-
|
119
106
|
# ROW 5
|
120
107
|
out_line_no += 1
|
121
108
|
order_plan_details_win.setpos(out_line_no, Cryptum::UI.col_first)
|
data/lib/cryptum/version.rb
CHANGED
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.272
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 0day Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|