aga-money 0.0.2 → 0.0.3
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 +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 +4 -0
- 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: fb930bdcaebb946f5c5f841103ca4ce0ee1748872ba8ea89793cfe41099fdb17
         | 
| 4 | 
            +
              data.tar.gz: ff712f49838f5fd642c7e5d6148f1b0af121df9ab2bd22f3a2b2be2a95afd762
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 01606bcb91ba2f5f17fef8a33dbd0ac71e7a0e839504a440798f6579aed744f4dfba3ce3405b856678e82a031d90ae8fc6b12652943d9f861f01aadb7d8bba5a
         | 
| 7 | 
            +
              data.tar.gz: 0d1cd32b61a213d202198afeb721fd411a85dc516ceb77ba677b552bff22dbca02ffbb4ec7d339f5f1ad78d5ea04c5d0941e1b4bccb8ac1deb253abc746d3dc7
         | 
    
        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,6 +28,8 @@ module Money | |
| 26 28 | 
             
                      price = detection.dig(:payload, :price)
         | 
| 27 29 | 
             
                      return {} if price.nil?
         | 
| 28 30 |  | 
| 31 | 
            +
                      return {} if percentage(detection).round(3) < SET_PERC
         | 
| 32 | 
            +
             | 
| 29 33 | 
             
                      percentage(detection).round(3) >= computation_percentage(price).round(3)
         | 
| 30 34 | 
             
                    end
         | 
| 31 35 |  | 
| @@ -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.3
         | 
| 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.3
         | 
| 266 267 | 
             
            test_files: []
         |