Class: Honeymaker::Exchanges::Kucoin

Inherits:
Honeymaker::Exchange show all
Defined in:
lib/honeymaker/exchanges/kucoin.rb

Constant Summary collapse

BASE_URL =
"https://api.kucoin.com"

Constants inherited from Honeymaker::Exchange

Honeymaker::Exchange::ERROR_PATTERNS, Honeymaker::Exchange::OPTIONS

Instance Method Summary collapse

Methods inherited from Honeymaker::Exchange

#cache_ttl, #classify_error, #find_ticker, #get_price, #symbols, #tickers_info

Instance Method Details

#get_bid_ask(symbol) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/honeymaker/exchanges/kucoin.rb', line 30

def get_bid_ask(symbol)
  with_rescue do
    response = connection.get("/api/v1/market/orderbook/level1") do |req|
      req.params = { symbol: symbol }
    end

    data = response.body["data"]
    {
      bid: BigDecimal(data["bestBid"]),
      ask: BigDecimal(data["bestAsk"])
    }
  end
end

#get_tickers_infoObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/honeymaker/exchanges/kucoin.rb', line 8

def get_tickers_info
  with_rescue do
    response = connection.get("/api/v2/symbols")

    response.body["data"].filter_map do |product|
      {
        ticker: product["symbol"],
        base: product["baseCurrency"],
        quote: product["quoteCurrency"],
        minimum_base_size: product["baseMinSize"],
        minimum_quote_size: product["quoteMinSize"],
        maximum_base_size: product["baseMaxSize"],
        maximum_quote_size: product["quoteMaxSize"],
        base_decimals: Utils.decimals(product["baseIncrement"]),
        quote_decimals: Utils.decimals(product["quoteIncrement"]),
        price_decimals: Utils.decimals(product["priceIncrement"]),
        available: product["enableTrading"]
      }
    end
  end
end