cryptum 0.0.429 → 0.0.431

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: 2380db0865bfa954a012a595702a708c13fe6bf18cfd0958d510239addf00186
4
- data.tar.gz: fc72a86ba6f45138bf5171e766581ccf3e0fc970eb3eeda90c456d9aaecc9306
3
+ metadata.gz: efc9ac08fc48ca7aa7674359ea95d662af6cade3fc2a0249b19ce03bc996f3fb
4
+ data.tar.gz: 3b6ddc0e658f076ee6f80f2f4a399d9192292c2ce090a7056b26c51a0cb7fd2a
5
5
  SHA512:
6
- metadata.gz: c76b40bba10f43ff918eae4f8fce19368a92d2e20e3c4baf7b29da3a0165f4c8a8c05bb2ef45a34d088c0f1ae7ca28acc09c1538cd211a70c6c774d3db1ed5a1
7
- data.tar.gz: 4394275cfa271f7cace9ed98b905fedf42eabafba11a292a2eb23af927f184c095c08ce487fbf0aacc22fb029a3ada517468bebe08090390613347b744e027a3
6
+ metadata.gz: aff4e41fe11057b9d0b401c78b27dae432a8756ec6a02b265b5b1eb580999954d0ae8ace3390804544920f89eeed141467d240f346603582a100ba6b1885ed61
7
+ data.tar.gz: da014125c73aba67a997bb76b2a9476a1074b35ae51973b4b6a44833ab3bc5c410c572d249ddfae3116f1e75581c18ec74daf6254a2610c56bdd4b632322fe43
data/.rubocop.yml CHANGED
@@ -6,7 +6,7 @@ Layout/LineLength:
6
6
  Lint/UselessRescue:
7
7
  Enabled: false
8
8
  Metrics/AbcSize:
9
- Max: 417.7
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: 80
17
+ Max: 86
18
18
  Metrics/MethodLength:
19
- Max: 397
19
+ Max: 418
20
20
  Metrics/ModuleLength:
21
- Max: 407
21
+ Max: 428
22
22
  Metrics/PerceivedComplexity:
23
- Max: 80
23
+ Max: 84
24
24
  Style/HashSyntax:
25
25
  EnforcedShorthandSyntax: never
26
26
 
data/lib/cryptum/log.rb CHANGED
@@ -68,7 +68,7 @@ module Cryptum
68
68
  logger.level = Logger::WARN
69
69
  else
70
70
  level_error = "ERROR: Invalid log level. Valid options are:\n"
71
- level_error += ":info\n:warn\n:unknown\n:fatal\n:error\n:debug"
71
+ level_error += ":debug\n:error\n:fatal\n:info\n:learning\n:unknown\n:warn\n"
72
72
  raise level_error
73
73
  end
74
74
 
@@ -70,6 +70,24 @@ module Cryptum
70
70
  File.read(order_book_file),
71
71
  symbolize_names: true
72
72
  )
73
+
74
+ # Only keep order history meta for those hashes
75
+ # that exist in the last order history response
76
+ # :white ones will be kept for 24 hrs and handled
77
+ # via Cryptum::OrderBook::MarketTrend.reset
78
+ # This exist primarily to clean up meta data if the
79
+ # bot crashes.
80
+ order_book[:order_history_meta].keep_if do |ohm|
81
+ order_book[:order_history].find do |oh|
82
+ (oh[:id] == ohm[:buy_order_id] || oh[:id] == ohm[:sell_order_id]) && (
83
+ ohm[:color].to_sym == :cyan ||
84
+ ohm[:color].to_sym == :green ||
85
+ ohm[:color].to_sym == :magenta ||
86
+ ohm[:color].to_sym == :red ||
87
+ ohm[:color].to_sym == :yellow
88
+ )
89
+ end
90
+ end
73
91
  end
74
92
 
75
93
  event_history = Cryptum::Event::History.new(
@@ -67,22 +67,16 @@ module Cryptum
67
67
  # TO AVOID TICKER PRICE SYNCING ISSUES.
68
68
  event_history = opts[:event_history]
69
69
 
70
- # order_history = event_history.order_book[:order_history]
71
- order_history_meta = event_history.order_book[:order_history_meta]
72
-
73
70
  # Only retain past 24 hours of
74
71
  # order history meta for expired
75
72
  # keep open limit sell orders indefintely
76
73
  before_twenty_four_hrs_ago = Time.now - 86_400
77
- order_history_meta.delete_if do |ohm|
74
+ event_history.order_book[:order_history_meta].delete_if do |ohm|
78
75
  next unless ohm[:color] == 'white'
79
76
 
80
77
  Time.parse(ohm[:done_at]) < before_twenty_four_hrs_ago
81
78
  end
82
79
 
83
- # Write order_history_meta back to event_history object
84
- event_history.order_book[:order_history_meta] = order_history_meta
85
-
86
80
  # Reset Market Trend Counter
87
81
  event_history.order_book[:market_trend][:buy] = 0
88
82
  event_history.order_book[:market_trend][:sell] = 0
@@ -457,15 +457,34 @@ module Cryptum
457
457
  )
458
458
  plan_no = meta[:plan_no]
459
459
 
460
- buy_created_at_hash_arr = order_history.select do |oh|
461
- oh[:id] == meta[:buy_order_id]
462
- end
463
-
464
- buy_created_at = '____-__-__ __:__:__-____'
465
- unless buy_created_at_hash_arr.empty?
466
- buy_created_at = Time.parse(
467
- buy_created_at_hash_arr.first[:created_at]
468
- ).strftime('%Y-%m-%d %H:%M:%S%z')
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
469
488
  end
470
489
 
471
490
  invest = "$#{invest_out} @ "
@@ -475,7 +494,7 @@ module Cryptum
475
494
  targ_tick = "$#{target_price_out}"
476
495
  profit = "|Profit: $#{meta[:profit]}"
477
496
 
478
- order_exec_ln = "#{buy_created_at}|#{invest}#{tick}#{size}#{tpm_out}#{targ_tick}#{profit}|#{plan_no}"
497
+ order_exec_ln = "#{order_exec_last_ln}|#{invest}#{tick}#{size}#{tpm_out}#{targ_tick}#{profit}|#{plan_no}"
479
498
 
480
499
  order_execute_win.setpos(out_line_no, Cryptum::UI.col_first)
481
500
  order_execute_win.clrtoeol
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptum
4
- VERSION = '0.0.429'
4
+ VERSION = '0.0.431'
5
5
  end
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.429
4
+ version: 0.0.431
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-26 00:00:00.000000000 Z
11
+ date: 2023-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable