aga-money 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 985d910b923d6d96300ef35356028e1a5314c76c65103adba8a9cf76953331fa
4
- data.tar.gz: e21714d8f50f0411e2ea79f3eb9bd993ff560962b88e6a2f0069d9d30fb17cd0
3
+ metadata.gz: adb2de788b6d5aaff7c6b9f816aa85f061352a6a90c771b193c72be96a7b1811
4
+ data.tar.gz: f06107519ddf0d7a37e094ad05303df0694c1935d655a734ccde8c4753b90dd6
5
5
  SHA512:
6
- metadata.gz: 4f6d89ee5eb55ae2489bee5906bfe55022e418f927e9c24a455526550db1e13fd9b84e82b508161b80d9bbb2746b7b71385055f5823b774c8ed4bb08ad0dd71a
7
- data.tar.gz: 35b4fd8ac2cfe1379e40d534b5ec4ccb7b6b5717589d6044a663a52f6df852ee0f534f01888f3b11bbf8e58d0de5f128ae2a534a5c865eee1560b980b42f10dc
6
+ metadata.gz: ba0590138088e6ffb0af19aee7eb08f340f94a6f9f35eea0f3ebfc6d15d98a454467d857e4a2d15a059d293f55feab38279e9ebd8fef358502a3a920618dad15
7
+ data.tar.gz: b12b563691cb0e01e0a1d6975f9aa8e4b04b45c03af8ac7962001b2861a9b942d1b5800c19e9cae49843dba4c0c9ce6ef8b411da09b56efff116aebb351a09b9
@@ -49,5 +49,7 @@ module Money
49
49
 
50
50
  payload
51
51
  end
52
+
53
+ attr_accessor :start
52
54
  end
53
55
  end
@@ -29,12 +29,12 @@ module Money
29
29
  percentage(detection).round(3) >= computation_percentage(price).round(3)
30
30
  end
31
31
 
32
- # rubocop: disable Metrics/CyclomaticComplexity, Lint/MissingCopEnableDirective
32
+ # rubocop: disable Lint/MissingCopEnableDirective
33
33
  def discriminate_pairs
34
34
  return nil if @pairs.nil?
35
35
 
36
- max = @pairs&.map { |pair| pair[:price] }&.max
37
- min = @pairs&.map { |pair| pair[:price] }&.min
36
+ max = @pairs&.max_by { |pair| pair[:price] }
37
+ min = @pairs&.min_by { |pair| pair[:price] }
38
38
 
39
39
  detection = select_max_pairs(max: max, min: min)
40
40
  gain = compare(detection)
@@ -52,15 +52,16 @@ module Money
52
52
  end
53
53
 
54
54
  def select_exchange_names(data)
55
- data&.map { |pair| { exchange: pair[:exchange], price: pair[:price] } }&.sort_by { |pair| pair[:price] }
55
+ data&.sort_by { |e| e[:price] }
56
56
  end
57
57
 
58
58
  def select_max_pairs(max:, min:)
59
- data = @pairs&.select { |pair| pair[:price] == max || pair[:price] == min }
59
+ data = [min, max]
60
+
60
61
  exchanges = select_exchange_names(data)
61
- diff = max - min
62
+ diff = max[:price] - min[:price]
62
63
 
63
- { payload: { max_diff: diff, exchanges: exchanges, price: min } }
64
+ { payload: { max_diff: diff, exchanges: exchanges, price: min[:price] } }
64
65
  end
65
66
  end
66
67
  end
@@ -16,7 +16,9 @@ module Money
16
16
  @data = data
17
17
  end
18
18
 
19
+ # rubocop: disable Metrics/MethodLength, Lint/MissingCopEnableDirective
19
20
  def gain
21
+ cryptos = []
20
22
  @data&.map do |item|
21
23
  exchanges = item[:exchanges]
22
24
  @gainer = Money::Helpers::Controls::Gain.new(exchanges)
@@ -27,10 +29,10 @@ module Money
27
29
  item[:exchanges] = potential.dig(:payload, :exchanges)
28
30
  item.each { |i| i.delete(:price) }
29
31
 
30
- item
32
+ cryptos << item
31
33
  end&.compact
32
34
 
33
- @data
35
+ cryptos
34
36
  end
35
37
 
36
38
  def liquidity
data/lib/money/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Money
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aga-money
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Baldazzi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-07 00:00:00.000000000 Z
11
+ date: 2023-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -262,5 +262,5 @@ requirements: []
262
262
  rubygems_version: 3.3.24
263
263
  signing_key:
264
264
  specification_version: 4
265
- summary: aga-money0.0.1
265
+ summary: aga-money0.0.2
266
266
  test_files: []