Class: Cryptoexchange::Exchanges::Crxzone::Services::Trades

Inherits:
Services::Market show all
Defined in:
lib/cryptoexchange/exchanges/crxzone/services/trades.rb

Instance Method Summary collapse

Methods inherited from Services::Market

#fetch_using_post, supports_individual_ticker_query?

Instance Method Details

#adapt(output, market_pair) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cryptoexchange/exchanges/crxzone/services/trades.rb', line 20

def adapt(output, market_pair)

  output.collect do |trade|
    tr = Cryptoexchange::Models::Trade.new
    tr.trade_id  = trade["ID"]
    tr.base      = market_pair.base
    tr.target    = market_pair.target
    tr.market    = Crxzone::Market::NAME
    tr.type      = (trade["Type"].to_f > 0 ? "sell" : "buy")
    tr.price     = trade["Price"]
    tr.amount    = trade["Amount"]
    tr.timestamp = trade["TimeStamp"]
    tr.payload   = trade
    tr
  end
end

#fetch(market_pair) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/cryptoexchange/exchanges/crxzone/services/trades.rb', line 6

def fetch(market_pair)
  result = IdFetcher.get_id(market_pair.base.upcase, market_pair.target.upcase)
  if result.length > 0
    pair = result.first
    pair_id = pair["ID"]
    output = super(trades_url(pair_id))
    adapt(output["Result"], market_pair)
  end
end

#trades_url(pair_id) ⇒ Object



16
17
18
# File 'lib/cryptoexchange/exchanges/crxzone/services/trades.rb', line 16

def trades_url(pair_id)
  "#{Cryptoexchange::Exchanges::Crxzone::Market::API_URL}/Trades?currencyPairID=#{pair_id}"
end