Class: Cryptoexchange::Exchanges::Yunex::Services::Trades
Instance Method Summary
collapse
#fetch_using_post, supports_individual_ticker_query?
Instance Method Details
#adapt(output, market_pair) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/cryptoexchange/exchanges/yunex/services/trades.rb', line 16
def adapt(output, market_pair)
data = output["data"]["list"]
data.collect do |trade|
tr = Cryptoexchange::Models::Trade.new
tr.trade_id = trade['trade_id']
tr.base = market_pair.base
tr.target = market_pair.target
tr.price = trade['price']
tr.amount = trade['volume']
tr.type = tradeBy trade['trade_by']
tr.timestamp = timestamp trade['timestamp']
tr.payload = trade
tr.market = Yunex::Market::NAME
tr
end
end
|
#fetch(market_pair) ⇒ Object
5
6
7
8
|
# File 'lib/cryptoexchange/exchanges/yunex/services/trades.rb', line 5
def fetch(market_pair)
output = super(ticker_url(market_pair))
adapt(output, market_pair)
end
|
#ticker_url(market_pair) ⇒ Object
10
11
12
13
14
|
# File 'lib/cryptoexchange/exchanges/yunex/services/trades.rb', line 10
def ticker_url(market_pair)
base = market_pair.base.downcase
target = market_pair.target.downcase
"#{Cryptoexchange::Exchanges::Yunex::Market::API_URL}/api/order/trade/recent?symbol=#{base}_#{target}&count=10"
end
|
#timestamp(nanosecond) ⇒ Object
34
35
36
37
|
# File 'lib/cryptoexchange/exchanges/yunex/services/trades.rb', line 34
def timestamp(nanosecond)
sec = nanosecond / 1e9
sec.to_i
end
|
#tradeBy(type) ⇒ Object
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/cryptoexchange/exchanges/yunex/services/trades.rb', line 39
def tradeBy(type)
types = ""
case type
when 1
types = "sell"
when 2
types = "buy"
end
types
end
|