Sha256: 1e7f50f20e7c0fd983ad9f016dbc67bdbb8048859b66142e0ff5df7232995298

Contents?: true

Size: 783 Bytes

Versions: 2

Compression:

Stored size: 783 Bytes

Contents

# frozen_string_literal: true

module Mcoin
  module Market
    # :nodoc:
    class Huobi < Base
      ENDPOINT = 'https://api.huobi.pro/market/detail/merged?symbol=%<type>s%<currency>s'

      def watch(type, currency)
        @pairs.add({ type: type.to_s.downcase, currency: currency.to_s.downcase })
      end

      private

      def build_ticker(pair, response)
        response = response['tick']
        Data::Ticker.new(
          :Huobi, pair[:type].upcase, pair[:currency].upcase,
          last: response['close'].to_s,
          ask:  response['ask'][0].to_s, bid:  response['bid'][0].to_s,
          low:  response['low'].to_s, high: response['high'].to_s,
          volume: response['vol'],
          timestamp: Time.now.utc.to_i
        )
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mcoin-0.6.1 lib/mcoin/market/huobi.rb
mcoin-0.6.0 lib/mcoin/market/huobi.rb