Class: Cryptoexchange::Exchanges::Cointiger::Services::Market

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

Constant Summary collapse

TARGETS =
['BTC', 'ETH', 'BITCNY', 'USDT']

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/cointiger/services/market.rb', line 6

def supports_individual_ticker_query?
  false
end

Instance Method Details

#adapt(output, market_pair) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cryptoexchange/exchanges/cointiger/services/market.rb', line 34

def adapt(output, market_pair)
  ticker           = Cryptoexchange::Models::Ticker.new
  ticker.base      = market_pair.base
  ticker.target    = market_pair.target
  ticker.market    = Cointiger::Market::NAME
  ticker.ask       = NumericHelper.to_d(output['lowestAsk'])
  ticker.bid       = NumericHelper.to_d(output['highestBid'])
  ticker.last      = NumericHelper.to_d(output['last'])
  ticker.high      = NumericHelper.to_d(output['high24hr'])
  ticker.low       = NumericHelper.to_d(output['low24hr'])
  ticker.volume    = NumericHelper.to_d(output['baseVolume'])
  ticker.timestamp = nil
  ticker.payload   = output
  ticker
end

#adapt_all(output) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cryptoexchange/exchanges/cointiger/services/market.rb', line 21

def adapt_all(output)
  output.map do |ticker|
    symbol = ticker[0]
    base, target = strip_pairs(symbol)
        market_pair = Cryptoexchange::Models::MarketPair.new(
                        base: base,
                        target: target,
                        market: Cointiger::Market::NAME
                      )
        adapt(ticker[1], market_pair)
  end
end

#fetchObject



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

def fetch
  output = super(ticker_url)
  adapt_all(output)
end

#strip_pairs(pair_symbol) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/cryptoexchange/exchanges/cointiger/services/market.rb', line 50

def strip_pairs(pair_symbol)
  #Match last 3 or 4 if it hits target
  last_6 = pair_symbol[-6..-1]
  last_4 = pair_symbol[-4..-1]
  last_3 = pair_symbol[-3..-1]

  if TARGETS.include? last_6
    base = pair_symbol[0..-7]
    target = last_6
  elsif
    TARGETS.include? last_4
    base = pair_symbol[0..-5]
    target = last_4
  elsif TARGETS.include? last_3
    base = pair_symbol[0..-4]
    target = last_3
  end

  [base, target]
end

#ticker_urlObject



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

def ticker_url
  "#{Cryptoexchange::Exchanges::Cointiger::Market::MARKET_URL}"
end