Class: Cryptoexchange::Exchanges::Yunex::Services::Market
- Inherits:
-
Services::Market
- Object
- Services::Market
- Cryptoexchange::Exchanges::Yunex::Services::Market
- Defined in:
- lib/cryptoexchange/exchanges/yunex/services/market.rb
Class Method Summary collapse
Instance Method Summary collapse
- #adapt(output, market_pair, depth) ⇒ Object
- #adapt_depth1(output, market_pair) ⇒ Object
- #depth_url(market_pair) ⇒ Object
- #fetch(market_pair) ⇒ Object
- #ticker_url(market_pair) ⇒ Object
Methods inherited from Services::Market
Class Method Details
.supports_individual_ticker_query? ⇒ 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. = 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 |