aga-money 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/money/base.rb +2 -1
- data/lib/money/resources/arbitrage.rb +3 -1
- data/lib/money/resources/helpers/controls/gain.rb +6 -1
- data/lib/money/resources/helpers/controls/validator.rb +12 -0
- data/lib/money/resources/helpers/request_app.rb +34 -0
- data/lib/money/version.rb +1 -1
- data/lib/money.rb +4 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ffcf6cd9a1fe3b6f4fe4ddbadd06dde77ea4ab32b1e3f1239dad736c4d88a60
|
4
|
+
data.tar.gz: cfb43bd3975d8899c32f02a99e8f4d5ba2fcdf638cae896304854717874ee454
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 492b8b649c0b69eb2e7bd504eb8ae09bc680b331a0caaf8a9f4be4fc3f962a4f59d38aa1a128f71069a75d77854185f57d617bdfe0405d1fbfc64f12876b78de
|
7
|
+
data.tar.gz: '08e44da44aaf9209ac9ea57b8d0c7caa296b9685a4c8ce8d6b3002d4bea762e0749a7cf54dcdcb41e3a9ae84fc79eaccb4058b90e901d57d2dc080fa91affa7d'
|
data/lib/money/base.rb
CHANGED
@@ -3,9 +3,10 @@
|
|
3
3
|
module Money
|
4
4
|
class Base
|
5
5
|
class << self
|
6
|
-
attr_accessor :app_info
|
6
|
+
attr_accessor :app_info, :path_prefix
|
7
7
|
end
|
8
8
|
|
9
9
|
self.app_info = ::ENV['APP_INFO'] || "#{::Money::NAME} V#{::Money.version}"
|
10
|
+
self.path_prefix = 'http://localhost:3000/api/v1/'
|
10
11
|
end
|
11
12
|
end
|
@@ -10,6 +10,8 @@ module Money
|
|
10
10
|
MIN_NUMBER = 0.0000000001
|
11
11
|
MAX_PERC = 0.1
|
12
12
|
|
13
|
+
SET_PERC = 1.0
|
14
|
+
|
13
15
|
def initialize(pairs)
|
14
16
|
@pairs = pairs
|
15
17
|
end
|
@@ -26,7 +28,10 @@ module Money
|
|
26
28
|
price = detection.dig(:payload, :price)
|
27
29
|
return {} if price.nil?
|
28
30
|
|
29
|
-
percentage
|
31
|
+
percentage = percentage(detection).round(3)
|
32
|
+
return {} if percentage < SET_PERC
|
33
|
+
|
34
|
+
percentage >= computation_percentage(price).round(3)
|
30
35
|
end
|
31
36
|
|
32
37
|
# rubocop: disable Lint/MissingCopEnableDirective
|
@@ -42,6 +42,18 @@ module Money
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
def exist
|
46
|
+
cryptos = []
|
47
|
+
@data&.map do |item|
|
48
|
+
request = Money::Helpers::RequestApp.new.operation_exist(item)
|
49
|
+
next if request[:response]['exist'] == true
|
50
|
+
|
51
|
+
cryptos << item
|
52
|
+
end&.compact
|
53
|
+
|
54
|
+
cryptos
|
55
|
+
end
|
56
|
+
|
45
57
|
def pairs
|
46
58
|
@data&.map do |item|
|
47
59
|
filtered = item[:exchanges].select { |cmc_item| EXCHANGES.include?(cmc_item[:exchange]) }
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require 'json'
|
5
|
+
require 'net/http'
|
6
|
+
|
7
|
+
module Money
|
8
|
+
module Helpers
|
9
|
+
class RequestApp
|
10
|
+
def operation_exist(payload)
|
11
|
+
url = build_url('operations/exist')
|
12
|
+
builder_request(url: url, payload: payload)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def build_url(path, params = {})
|
18
|
+
URI.parse("#{Money::Base.path_prefix}#{path}")
|
19
|
+
end
|
20
|
+
|
21
|
+
def builder_request(url:, payload:)
|
22
|
+
http = Net::HTTP.new(url.host, url.port)
|
23
|
+
request = Net::HTTP::Get.new(url)
|
24
|
+
request['Authorization'] = 'Bearer 5c16c565fbd9f128063019f2828be964'
|
25
|
+
request['Content-Type'] = 'application/json'
|
26
|
+
request.body = JSON.dump(payload)
|
27
|
+
|
28
|
+
response = http.request(request)
|
29
|
+
{ response: JSON.parse(response.body), status: response.code.to_i == 200 }
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/money/version.rb
CHANGED
data/lib/money.rb
CHANGED
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.
|
4
|
+
version: 0.0.4
|
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-
|
11
|
+
date: 2023-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|
@@ -237,6 +237,7 @@ files:
|
|
237
237
|
- lib/money/resources/helpers/controls/validator.rb
|
238
238
|
- lib/money/resources/helpers/format.rb
|
239
239
|
- lib/money/resources/helpers/http_request.rb
|
240
|
+
- lib/money/resources/helpers/request_app.rb
|
240
241
|
- lib/money/resources/new.rb
|
241
242
|
- lib/money/resources/top.rb
|
242
243
|
- lib/money/version.rb
|
@@ -262,5 +263,5 @@ requirements: []
|
|
262
263
|
rubygems_version: 3.3.24
|
263
264
|
signing_key:
|
264
265
|
specification_version: 4
|
265
|
-
summary: aga-money0.0.
|
266
|
+
summary: aga-money0.0.4
|
266
267
|
test_files: []
|