class Cryptoexchange::Exchanges::Cybex::Services::Trades

Constants

SECONDS

Public Instance Methods

adapt(output, market_pair) click to toggle source
# File lib/cryptoexchange/exchanges/cybex/services/trades.rb, line 20
def adapt(output, market_pair)
  output['result'].collect do |trade|
    tr           = Cryptoexchange::Models::Trade.new
    tr.trade_id  = nil
    tr.base      = market_pair.base
    tr.target    = market_pair.target
    tr.market    = Cybex::Market::NAME
    tr.price     = trade['price']
    tr.amount    = trade['amount']
    tr.timestamp = Time.parse(trade['date']).to_i
    tr.payload   = trade
    tr
  end
end
fetch(market_pair) click to toggle source
# File lib/cryptoexchange/exchanges/cybex/services/trades.rb, line 7
def fetch(market_pair)
  base, target = Cybex::Market.prepend_symbol_prefix(market_pair)
  now         = transform_time_string(Time.now.utc)
  one_day_ago = transform_time_string(Time.now.utc - SECONDS)
  output      = fetch_using_post(ticker_url,
                                 { "jsonrpc": "2.0", "method": "get_trade_history", "params": ["#{target}", "#{base}", now, one_day_ago, 100], "id": 1 })
  adapt(output, market_pair)
end
ticker_url() click to toggle source
# File lib/cryptoexchange/exchanges/cybex/services/trades.rb, line 16
def ticker_url
  "#{Cryptoexchange::Exchanges::Cybex::Market::API_URL}"
end
transform_time_string(time) click to toggle source
# File lib/cryptoexchange/exchanges/cybex/services/trades.rb, line 35
def transform_time_string(time)
  time.strftime("%FT%R")
end