Skip to content

Commit

Permalink
✨ implement secondbtc ticker
Browse files Browse the repository at this point in the history
  • Loading branch information
Swingcloud committed Nov 11, 2018
1 parent 6f1f181 commit dda35e6
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions lib/cryptoexchange/exchanges/secondbtc/services/market.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module Cryptoexchange::Exchanges
module Secondbtc
module Services
class Market < Cryptoexchange::Services::Market
class << self
def supports_individual_ticker_query?
false
end
end

def fetch
output = super ticker_url
adapt_all(output)
end

def ticker_url
"#{Cryptoexchange::Exchanges::Secondbtc::Market::API_URL}/ticker"
end

def adapt_all(output)
output.map do |pair, ticker|
next unless ticker['isFrozen'] == '0'
adapt(pair, ticker)
end.compact
end

def adapt(pair, output)
ticker = Cryptoexchange::Models::Ticker.new
target, base = pair.split('_')
ticker.base = base
ticker.target = target
ticker.market = Secondbtc::Market::NAME
ticker.last = NumericHelper.to_d(output['last'])
ticker.ask = NumericHelper.to_d(output['lowestAsk'])
ticker.bid = NumericHelper.to_d(output['highestBid'])
ticker.volume = NumericHelper.to_d(output['quoteVolume'])
ticker.high = NumericHelper.to_d(output['high24hr'])
ticker.low = NumericHelper.to_d(output['low24hr'])
ticker.change = NumericHelper.to_d(output['percentChange'])
ticker.payload = output
ticker
end
end
end
end
end

0 comments on commit dda35e6

Please sign in to comment.