Class: Cryptoexchange::Exchanges::Gopax::Services::Market

Inherits:
Services::Market show all
Defined in:
lib/cryptoexchange/exchanges/gopax/services/market.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Services::Market

#fetch_using_post

Class Method Details

.supports_individual_ticker_query?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/cryptoexchange/exchanges/gopax/services/market.rb', line 6

def supports_individual_ticker_query?
  true
end

Instance Method Details

#adapt(ticker1, ticker2, market_pair) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cryptoexchange/exchanges/gopax/services/market.rb', line 25

def adapt(ticker1, ticker2, market_pair)
  ticker           = Cryptoexchange::Models::Ticker.new
  ticker.base      = market_pair.base
  ticker.target    = market_pair.target
  ticker.market    = Gopax::Market::NAME
  ticker.ask       = NumericHelper.to_d(ticker1['ask'])
  ticker.bid       = NumericHelper.to_d(ticker1['bid'])
  ticker.last      = NumericHelper.to_d(ticker1['price'])
  ticker.high      = NumericHelper.to_d(ticker2['high'])
  ticker.low       = NumericHelper.to_d(ticker2['low'])
  ticker.volume    = NumericHelper.to_d(ticker1['volume'])
  ticker.timestamp = DateTime.parse(ticker2['time']).to_time.to_i
  ticker.payload   = [ticker1, ticker2]
  ticker
end

#fetch(market_pair) ⇒ Object



11
12
13
14
15
# File 'lib/cryptoexchange/exchanges/gopax/services/market.rb', line 11

def fetch(market_pair)
  ticker1 = super(ticker_url_one(market_pair))
  ticker2 = super(ticker_url_two(market_pair))
  adapt(ticker1, ticker2, market_pair)
end

#ticker_url_one(market_pair) ⇒ Object



17
18
19
# File 'lib/cryptoexchange/exchanges/gopax/services/market.rb', line 17

def ticker_url_one(market_pair)
  "#{Cryptoexchange::Exchanges::Gopax::Market::API_URL}/trading-pairs/#{market_pair.base}-#{market_pair.target}/ticker"
end

#ticker_url_two(market_pair) ⇒ Object



21
22
23
# File 'lib/cryptoexchange/exchanges/gopax/services/market.rb', line 21

def ticker_url_two(market_pair)
  "#{Cryptoexchange::Exchanges::Gopax::Market::API_URL}/trading-pairs/#{market_pair.base}-#{market_pair.target}/stats"
end