class Cryptoexchange::Exchanges::Upbit::Services::Trades

Public Instance Methods

adapt(output, market_pair) click to toggle source
# File lib/cryptoexchange/exchanges/upbit/services/trades.rb, line 15
def adapt(output, market_pair)
  output.collect do |trade|
    tr = Cryptoexchange::Models::Trade.new
    tr.trade_id  = trade['tid']
    tr.base      = market_pair.base
    tr.target    = market_pair.target
    tr.market    = Upbit::Market::NAME
    tr.type      = trade['ask_bid'] == 'BID' ? 'buy' : 'sell'
    tr.price     = trade['trade_price']
    tr.amount    = trade['trade_volume']
    tr.timestamp = trade['timestamp']
    tr.payload   = trade
    tr
  end
end
fetch(market_pair) click to toggle source
Calls superclass method Cryptoexchange::Services::Market#fetch
# File lib/cryptoexchange/exchanges/upbit/services/trades.rb, line 6
def fetch(market_pair)
  output = super(trades_url(market_pair))
  adapt(output, market_pair)
end
trades_url(market_pair) click to toggle source
# File lib/cryptoexchange/exchanges/upbit/services/trades.rb, line 11
def trades_url(market_pair)
  "#{Cryptoexchange::Exchanges::Upbit::Market::API_URL}/trades/ticks?market=#{market_pair.target}-#{market_pair.base}&count=200"
end