Class: Cryptoexchange::Exchanges::Yunex::Services::Market

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

def supports_individual_ticker_query?
  true
end

Instance Method Details

#adapt(output, market_pair, depth) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/cryptoexchange/exchanges/yunex/services/market.rb', line 35

def adapt(output, market_pair, depth)

  market = output['data']
  ticker           = Cryptoexchange::Models::Ticker.new
  ticker.base      = market_pair.base
  ticker.target    = market_pair.target
  ticker.market    = Yunex::Market::NAME


  ticker.ask       = NumericHelper.to_d(depth["asks"][0][0])
  ticker.bid       = NumericHelper.to_d(depth["bids"][0][0])

  ticker.high      = NumericHelper.to_d(market['max_price'])
  ticker.low       = NumericHelper.to_d(market['min_price'])
  ticker.last      = NumericHelper.to_d(market['cur_price'])
  ticker.volume    = NumericHelper.to_d(market['volume'])
  ticker.timestamp = nil
  ticker.payload   = output

  ticker
end

#adapt_depth1(output, market_pair) ⇒ Object



31
32
33
# File 'lib/cryptoexchange/exchanges/yunex/services/market.rb', line 31

def adapt_depth1(output, market_pair)
    output["data"]
end

#depth_url(market_pair) ⇒ Object



25
26
27
28
29
# File 'lib/cryptoexchange/exchanges/yunex/services/market.rb', line 25

def depth_url(market_pair)
    base = market_pair.base.downcase
    target = market_pair.target.downcase
    "#{Cryptoexchange::Exchanges::Yunex::Market::API_URL}/api/market/depth?symbol=#{base}_#{target}&level=1"
end

#fetch(market_pair) ⇒ Object



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

def fetch(market_pair)
  depthOutput = super(depth_url(market_pair))
  depth = adapt_depth1(depthOutput, market_pair)

  output = super(ticker_url(market_pair))
  adapt(output, market_pair, depth)
end

#ticker_url(market_pair) ⇒ Object



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

def ticker_url(market_pair)
  base = market_pair.base.downcase
  target = market_pair.target.downcase
  "#{Cryptoexchange::Exchanges::Yunex::Market::API_URL}/api/market/trade/info?symbol=#{base}_#{target}"
end