cryptum 0.0.424 → 0.0.426

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6be55cd7655b11bf979acce2ea8273e8dc7ffb299379c2382f48732cd0538bfe
4
- data.tar.gz: d1c2de61701aa0d65fc2ae4cd1cd697d30af6e90ed2a2f09c0e9559da01ba02c
3
+ metadata.gz: 127ea736102e9f1d3ef7223fba59992eefc164f9f91cb63888503794925ae11b
4
+ data.tar.gz: a95b0a42d443aa539127bf0b17c2fb80eabc64a0d6d17a025c558ddb75b90488
5
5
  SHA512:
6
- metadata.gz: 3fcfb5f5457e240a8f16415218f0261dd1f2fd6833862e45be3936278231738ae267139f83c3d1ab3f166eebd9d3d7fce6159a59feb059ea0046266560c0bcfd
7
- data.tar.gz: 0c671eca62a2e26ff352228d6bc2002b94b480c87eae5e8621a90534945f2750e1a87a48d8cf20e76d2ca9e66e9232630e7c2321d8ae773ddc2ff98d0ff2b961
6
+ metadata.gz: 24834242320b3db874db4377bfd80cf3e6cab555fb7fb50635a1b084699e845eb4e7ec8c5170fcb4920bd8c0897bee1915a52a3e450ea712ba9bb6505a357c50
7
+ data.tar.gz: d2778232f88959d84424dc921edab4a41786656f568a3bdf367e68c7de667d6e1c4a9d3d81b129974db60b3e6206aa5d33c4869274694d3e14d65dd1e904b520
data/.rubocop.yml CHANGED
@@ -6,7 +6,7 @@ Layout/LineLength:
6
6
  Lint/UselessRescue:
7
7
  Enabled: false
8
8
  Metrics/AbcSize:
9
- Max: 393
9
+ Max: 410
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: 77
17
+ Max: 80
18
18
  Metrics/MethodLength:
19
19
  Max: 397
20
20
  Metrics/ModuleLength:
21
21
  Max: 407
22
22
  Metrics/PerceivedComplexity:
23
- Max: 77
23
+ Max: 80
24
24
  Style/HashSyntax:
25
25
  EnforcedShorthandSyntax: never
26
26
 
data/lib/cryptum/log.rb CHANGED
@@ -26,9 +26,13 @@ module Cryptum
26
26
  datetime_str = '%Y-%m-%d %H:%M:%S.%N%z'
27
27
 
28
28
  # Always append to log file
29
- log_file_path = '/tmp/cryptum.log'
30
- log_file_path = "/tmp/cryptum-ai-#{session}-#{symbol}.json" if level == :learning
31
- log_file = File.open(log_file_path, 'a')
29
+ if level == :learning
30
+ log_file_path = "/tmp/cryptum-ai-#{session}-#{symbol}.json" if level == :learning
31
+ log_file = File.open(log_file_path, 'w')
32
+ else
33
+ log_file_path = '/tmp/cryptum.log'
34
+ log_file = File.open(log_file_path, 'a')
35
+ end
32
36
 
33
37
  # Leave 10 "old" log files where
34
38
  # each file is ~ 1,024,000 bytes
@@ -69,17 +73,12 @@ module Cryptum
69
73
  end
70
74
 
71
75
  if level == :learning
72
- logger.formatter = proc do |_severity, datetime, progname, json_msg|
73
- date = datetime.strftime(datetime_str)
76
+ log_event = msg
77
+ logger.formatter = proc do |_severity, _datetime, _progname, learning_arr|
74
78
  JSON.pretty_generate(
75
- date: date,
76
- session: session,
77
- symbol: symbol,
78
- progname: progname,
79
- msg: json_msg
79
+ learning_data: learning_arr
80
80
  )
81
81
  end
82
- log_event = msg
83
82
  else
84
83
  log_event = "driver: #{driver_name}"
85
84
  if event_history.respond_to?('order_book')
@@ -237,6 +237,12 @@ module Cryptum
237
237
  end
238
238
  end
239
239
 
240
+ # Snag all sold orders
241
+ oh_meta_sold_arr = order_history_meta.select do |ohm|
242
+ ohm[:color].to_sym == :green && ohm.key?(:done_at)
243
+ end
244
+ order_hist_meta_sold = oh_meta_sold_arr.length
245
+
240
246
  # Update Completed Sell Orders w/ Green &&
241
247
  # Include done_at Timestamp for 24h gain calc
242
248
  if event_type == :done &&
@@ -247,6 +253,18 @@ module Cryptum
247
253
  order_history_meta.each do |meta|
248
254
  next unless meta[:sell_order_id] == sell_order_id
249
255
 
256
+ learning_arr = []
257
+ oh_meta_sold_arr.each do |ohm|
258
+ learning = ohm
259
+ buy_order_id = ohm[:buy_order_id]
260
+ sell_order_id = ohm[:sell_order_id]
261
+ order_history_buy_details = order_history.select { |oh| oh[:id] == buy_order_id }
262
+ order_history_sell_details = order_history.select { |oh| oh[:id] == sell_order_id }
263
+ learning[:buy_details] = order_history_buy_details.first
264
+ learning[:sell_details] = order_history_sell_details.first
265
+ learning_arr.push(learning)
266
+ end
267
+
250
268
  meta[:done_at] = Time.now.strftime('%Y-%m-%d %H:%M:%S.%N%z')
251
269
  meta[:color] = :green
252
270
 
@@ -259,9 +277,11 @@ module Cryptum
259
277
  order_history_sell_details = order_history.select { |oh| oh[:id] == sell_order_id }
260
278
  learning[:buy_details] = order_history_buy_details.first
261
279
  learning[:sell_details] = order_history_sell_details.first
280
+ learning_arr.push(learning)
281
+
262
282
  Cryptum::Log.append(
263
283
  level: :learning,
264
- msg: learning,
284
+ msg: learning_arr,
265
285
  which_self: self,
266
286
  event_history: event_history
267
287
  )
@@ -271,12 +291,6 @@ module Cryptum
271
291
  # OK, now let's tally up everything...
272
292
  twenty_four_hrs_ago = Time.now - 86_400
273
293
 
274
- # Snag all sold orders
275
- oh_meta_sold_arr = order_history_meta.select do |ohm|
276
- ohm[:color].to_sym == :green && ohm.key?(:done_at)
277
- end
278
- order_hist_meta_sold = oh_meta_sold_arr.length
279
-
280
294
  # Snag all sold orders within past 24 hrs
281
295
  ohm_sold_twenty_four_arr = []
282
296
  unless oh_meta_sold_arr.empty?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptum
4
- VERSION = '0.0.424'
4
+ VERSION = '0.0.426'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.424
4
+ version: 0.0.426
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.
@@ -537,7 +537,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
537
537
  - !ruby/object:Gem::Version
538
538
  version: '0'
539
539
  requirements: []
540
- rubygems_version: 3.4.10
540
+ rubygems_version: 3.4.11
541
541
  signing_key:
542
542
  specification_version: 4
543
543
  summary: Coinbase Pro High-Frequency Trading Bot