cryptum 0.0.392 → 0.0.393
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cryptum/option/choice.rb +1 -2
- data/lib/cryptum/option/parser.rb +0 -6
- data/lib/cryptum/ui/order/execute.rb +64 -130
- data/lib/cryptum/version.rb +1 -1
- 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: ca637e5a3a716df2681e8b1b5596c179eef4a83664d387edfc71d19a088dc4d0
|
4
|
+
data.tar.gz: ee4e852ed2cbaccfc985f9f0ac5b1fab3e0e9e9e028da55e315476163e51e1f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 004ea17a91df64ef33f9aef8a62cce6b9d558a06f8f46b98ccd473cc4ec4e81ee306ba9734149bbabac7078a59773eb104d1baef1dd76dda566b89a0aebc1ffe
|
7
|
+
data.tar.gz: 269567118f7ff64cc9ed35d615b7fe65598a8b3f82bea963241b293132558523c6005794823093ed6bc00cb80adea516a97c06c7af299a73490deb3d21df9d28
|
@@ -19,12 +19,6 @@ module Cryptum
|
|
19
19
|
'<Required - Crypto Symbol.(e.g. btc-usd, eth-usd, etc.)'
|
20
20
|
) { |s| option_choice.symbol = s.to_s.gsub('-', '_').downcase.to_sym }
|
21
21
|
|
22
|
-
options.on(
|
23
|
-
'-A',
|
24
|
-
'--[no-]autotrade',
|
25
|
-
'<Optional - Automatically Buy and Sell Crypto>'
|
26
|
-
) { |a| option_choice.autotrade = a }
|
27
|
-
|
28
22
|
options.on(
|
29
23
|
'-l',
|
30
24
|
'--[no-]list-products',
|
@@ -19,9 +19,9 @@ module Cryptum
|
|
19
19
|
indicator_status = opts[:indicator_status]
|
20
20
|
bot_conf = opts[:bot_conf]
|
21
21
|
|
22
|
-
event_type = event_history.event_type
|
23
|
-
event_side = event_history.event[:side].to_s.to_sym
|
24
|
-
event_reason = event_history.event[:reason].to_s.to_sym
|
22
|
+
event_type = event_history.event_type
|
23
|
+
event_side = event_history.event[:side].to_s.to_sym
|
24
|
+
event_reason = event_history.event[:reason].to_s.to_sym
|
25
25
|
|
26
26
|
ticker_price = event_history.order_book[:ticker_price].to_f
|
27
27
|
open_24h = event_history.order_book[:open_24h].to_f
|
@@ -42,11 +42,11 @@ module Cryptum
|
|
42
42
|
limit_price = last_three_prices_arr.sort[1]
|
43
43
|
return event_history unless limit_price.positive?
|
44
44
|
|
45
|
-
tpm = bot_conf[:target_profit_margin_percent].to_f
|
46
|
-
tpm_cast_as_decimal = tpm / 100
|
45
|
+
# tpm = bot_conf[:target_profit_margin_percent].to_f
|
46
|
+
# tpm_cast_as_decimal = tpm / 100
|
47
47
|
|
48
48
|
order_history_meta = event_history.order_book[:order_history_meta]
|
49
|
-
order_history = event_history.order_book[:order_history]
|
49
|
+
order_history = event_history.order_book[:order_history]
|
50
50
|
|
51
51
|
margin_percent_open_24h = (1 - (open_24h / ticker_price)) * 100
|
52
52
|
cast_margin_to_sec = margin_percent_open_24h * 0.1
|
@@ -79,87 +79,60 @@ module Cryptum
|
|
79
79
|
indicator_status.action_signal == :buy &&
|
80
80
|
!event_history.red_pill
|
81
81
|
|
82
|
-
|
83
|
-
this_order = event_history.order_book[:order_plan].first
|
82
|
+
this_order = event_history.order_book[:order_plan].first
|
84
83
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
84
|
+
# If price is greater than the previous order,
|
85
|
+
# force it to be slightly less
|
86
|
+
last_order = order_history_meta.select do |order|
|
87
|
+
order if order[:color] == 'yellow'
|
88
|
+
end.last
|
90
89
|
|
91
|
-
|
92
|
-
|
90
|
+
last_purchase_price = 0.0
|
91
|
+
last_purchase_price = last_order[:price].to_f if last_order
|
93
92
|
|
94
|
-
|
93
|
+
limit_price = last_purchase_price - quote_increment.to_f if last_purchase_price.positive? && last_purchase_price < limit_price
|
95
94
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
95
|
+
# Debug last order
|
96
|
+
File.open('/tmp/cryptum-errors.txt', 'a') do |f|
|
97
|
+
f.puts "Last Order: #{last_order}"
|
98
|
+
f.puts "Last Purchase Price: #{last_purchase_price}"
|
99
|
+
f.puts "Limit Price (Should be <= quote_increment-- ^): #{limit_price}"
|
100
|
+
f.puts "\n\n\n"
|
101
|
+
end
|
103
102
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
103
|
+
price = format(
|
104
|
+
"%0.#{fiat_smallest_decimal}f",
|
105
|
+
limit_price
|
106
|
+
)
|
108
107
|
|
109
|
-
|
108
|
+
size = this_order[:invest].to_f / limit_price
|
110
109
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
110
|
+
loop do
|
111
|
+
size = size.to_f + base_increment.to_f
|
112
|
+
break if (size.to_f * price.to_f) > min_market_funds.to_f
|
113
|
+
end
|
115
114
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
115
|
+
size = format(
|
116
|
+
"%0.#{crypto_smallest_decimal}f",
|
117
|
+
size
|
118
|
+
)
|
120
119
|
|
121
|
-
|
122
|
-
|
123
|
-
fiat_portfolio = event_history.order_book[:fiat_portfolio]
|
124
|
-
fiat_avail_to_trade = format('%0.2f', fiat_portfolio.first[:available])
|
125
|
-
|
126
|
-
event_history.red_pill = true if fiat_invested_this_order > fiat_avail_to_trade.to_f
|
127
|
-
|
128
|
-
unless event_history.red_pill
|
129
|
-
event_history = Cryptum::Event::Buy.crypto(
|
130
|
-
option_choice: option_choice,
|
131
|
-
env: env,
|
132
|
-
price: price,
|
133
|
-
size: size,
|
134
|
-
event_history: event_history,
|
135
|
-
bot_conf: bot_conf
|
136
|
-
)
|
137
|
-
end
|
138
|
-
else
|
139
|
-
this_order = event_history.order_book[:order_plan].shift
|
140
|
-
# Mock Order ID
|
141
|
-
this_order[:buy_order_id] = format(
|
142
|
-
'%0.6i',
|
143
|
-
Random.rand(0..999_999)
|
144
|
-
)
|
120
|
+
fiat_invested_this_order = size.to_f * price.to_f
|
145
121
|
|
146
|
-
|
147
|
-
|
148
|
-
"%0.#{crypto_smallest_decimal}f",
|
149
|
-
this_order[:invest].to_f / limit_price
|
150
|
-
)
|
122
|
+
fiat_portfolio = event_history.order_book[:fiat_portfolio]
|
123
|
+
fiat_avail_to_trade = format('%0.2f', fiat_portfolio.first[:available])
|
151
124
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
125
|
+
event_history.red_pill = true if fiat_invested_this_order > fiat_avail_to_trade.to_f
|
126
|
+
|
127
|
+
unless event_history.red_pill
|
128
|
+
event_history = Cryptum::Event::Buy.crypto(
|
129
|
+
option_choice: option_choice,
|
130
|
+
env: env,
|
131
|
+
price: price,
|
132
|
+
size: size,
|
133
|
+
event_history: event_history,
|
134
|
+
bot_conf: bot_conf
|
160
135
|
)
|
161
|
-
this_order[:color] = :cyan
|
162
|
-
order_history_meta.push(this_order)
|
163
136
|
end
|
164
137
|
|
165
138
|
# SAUCE 4 (SAUCE 3 RELATES TO SAUCE 4)
|
@@ -181,23 +154,6 @@ module Cryptum
|
|
181
154
|
# be more than event_history.time_between_orders_max
|
182
155
|
event_history.time_between_orders = event_history.time_between_orders_max if event_history.time_between_orders > event_history.time_between_orders_max
|
183
156
|
end
|
184
|
-
|
185
|
-
# SELL
|
186
|
-
# Once buy arders are fulfilled submit a
|
187
|
-
# limit sell order for fulfillment
|
188
|
-
unless option_choice.autotrade
|
189
|
-
# Testing logic via Mock
|
190
|
-
event_type_arr = %i[received open done]
|
191
|
-
last_et_index = event_type_arr.length - 1
|
192
|
-
rand_et_index = Random.rand(0..last_et_index)
|
193
|
-
event_type = event_type_arr[rand_et_index]
|
194
|
-
|
195
|
-
event_side_arr = %i[buy sell]
|
196
|
-
last_es_index = event_side_arr.length - 1
|
197
|
-
rand_es_index = Random.rand(0..last_es_index)
|
198
|
-
event_side = event_type_arr[rand_es_index].to_s.to_sym
|
199
|
-
event_reason = 'mock'
|
200
|
-
end
|
201
157
|
end
|
202
158
|
|
203
159
|
# Update Completed Sell Orders w/ Green
|
@@ -227,52 +183,30 @@ module Cryptum
|
|
227
183
|
event_side == :buy &&
|
228
184
|
event_reason != :canceled
|
229
185
|
|
230
|
-
|
231
|
-
|
232
|
-
meta[:buy_order_id] == event_history.event[:order_id]
|
233
|
-
end
|
234
|
-
else
|
235
|
-
last_index = order_history_meta.length - 1
|
236
|
-
rand_index = Random.rand(0..last_index)
|
237
|
-
order_ready_to_sell_arr = [
|
238
|
-
order_history_meta[rand_index]
|
239
|
-
]
|
186
|
+
order_ready_to_sell_arr = order_history_meta.select do |meta|
|
187
|
+
meta[:buy_order_id] == event_history.event[:order_id]
|
240
188
|
end
|
241
189
|
|
242
190
|
if order_ready_to_sell_arr.length.positive?
|
243
191
|
order_ready_to_sell = order_ready_to_sell_arr.first
|
244
192
|
buy_order_id = order_ready_to_sell[:buy_order_id]
|
245
193
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
)
|
194
|
+
price = format(
|
195
|
+
"%0.#{fiat_smallest_decimal}f",
|
196
|
+
order_ready_to_sell[:target_price]
|
197
|
+
)
|
251
198
|
|
252
|
-
|
199
|
+
size = order_ready_to_sell[:size]
|
253
200
|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
else
|
264
|
-
sell_order_id = format(
|
265
|
-
'%0.2i',
|
266
|
-
Random.rand(0..999_999)
|
267
|
-
)
|
268
|
-
|
269
|
-
event_history.order_book[:order_history_meta].each do |meta|
|
270
|
-
if meta[:buy_order_id] == buy_order_id
|
271
|
-
meta[:sell_order_id] = sell_order_id
|
272
|
-
meta[:color] = :yellow
|
273
|
-
end
|
274
|
-
end
|
275
|
-
end
|
201
|
+
event_history = Cryptum::Event::Sell.crypto(
|
202
|
+
option_choice: option_choice,
|
203
|
+
env: env,
|
204
|
+
price: price,
|
205
|
+
size: size,
|
206
|
+
event_history: event_history,
|
207
|
+
bot_conf: bot_conf,
|
208
|
+
buy_order_id: buy_order_id
|
209
|
+
)
|
276
210
|
end
|
277
211
|
end
|
278
212
|
|
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.393
|
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-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|