Class: Cryptoexchange::Exchanges::Coinut::Services::Market

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

def supports_individual_ticker_query?
  true
end

Instance Method Details

#adapt(output, market_pair) ⇒ Object



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

def adapt(output, market_pair)
  ticker           = Cryptoexchange::Models::Ticker.new
  ticker.base      = market_pair.base
  ticker.target    = market_pair.target
  ticker.market    = Coinut::Market::NAME
  ticker.last      = NumericHelper.to_d(output['last'])
  ticker.high      = NumericHelper.to_d(output['highest_buy'])
  ticker.low       = NumericHelper.to_d(output['lowest_sell'])
  ticker.volume    = NumericHelper.to_d(output['volume24'])
  ticker.timestamp = nil
  ticker.payload   = output
  ticker
end

#fetch(market_pair) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cryptoexchange/exchanges/coinut/services/market.rb', line 11

def fetch(market_pair)
  authentication = Cryptoexchange::Exchanges::Coinut::Authentication.new(
    :market,
    Cryptoexchange::Exchanges::Coinut::Market::NAME
  )
  authentication.validate_credentials!

  payload_ = payload(market_pair)
  headers = authentication.headers(payload_)
  output = fetch_using_post(ticker_url, payload_, headers)
  adapt(output, market_pair)
end

#payload(market_pair) ⇒ Object



24
25
26
# File 'lib/cryptoexchange/exchanges/coinut/services/market.rb', line 24

def payload(market_pair)
  '{"nonce":' + SecureRandom.random_number(99999).to_s + ',"request":"inst_tick", "inst_id":' + market_pair.inst_id + ' }'
end

#ticker_urlObject



28
29
30
# File 'lib/cryptoexchange/exchanges/coinut/services/market.rb', line 28

def ticker_url
  Cryptoexchange::Exchanges::Coinut::Market::API_URL
end