Class: Cryptoexchange::Exchanges::Bcoin::Services::Market

Inherits:
Services::Market show all
Defined in:
lib/cryptoexchange/exchanges/bcoin/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/bcoin/services/market.rb', line 6

def supports_individual_ticker_query?
  false
end

Instance Method Details

#adapt(market_pair, data) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cryptoexchange/exchanges/bcoin/services/market.rb', line 29

def adapt(market_pair, data)
  Cryptoexchange::Models::Ticker.new(
    base: market_pair.base,
    target: market_pair.target,
    market: market_pair.market,
    ask: NumericHelper.to_d(data['lowestAsk'].to_f),
    bid: NumericHelper.to_d(data['highestBid'].to_f),
    last: NumericHelper.to_d(data['last'].to_f),
    high: NumericHelper.to_d(data['high24hr'].to_f),
    low: NumericHelper.to_d(data['low24Hr'].to_f),
    volume: NumericHelper.to_d(data['baseVolume'].to_f),
    timestamp: nil,
    payload: data
  )
end

#adapt_all(output) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cryptoexchange/exchanges/bcoin/services/market.rb', line 16

def adapt_all(output)
  output['data'].map do |pair, data|
    base, target = pair.split('/')
    market_pair = Cryptoexchange::Models::MarketPair.new(
      base: base,
      target: target,
      market: Bcoin::Market::NAME
    )

    adapt(market_pair, data)
  end
end

#fetchObject



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

def fetch
  output = super(Bcoin::Market::API_URL)
  adapt_all(output)
end