Class: Honeymaker::Exchanges::BitMart

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

Constant Summary collapse

BASE_URL =
"https://api-cloud.bitmart.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/bitmart.rb', line 30

def get_bid_ask(symbol)
  with_rescue do
    response = connection.get("/spot/quotation/v3/ticker") do |req|
      req.params = { symbol: symbol }
    end

    data = response.body["data"]
    {
      bid: BigDecimal(data["best_bid"]),
      ask: BigDecimal(data["best_ask"])
    }
  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/bitmart.rb', line 8

def get_tickers_info
  with_rescue do
    response = connection.get("/spot/v1/symbols/details")

    response.body["data"]["symbols"].filter_map do |product|
      {
        ticker: product["symbol"],
        base: product["base_currency"],
        quote: product["quote_currency"],
        minimum_base_size: product["base_min_size"],
        minimum_quote_size: product["min_buy_amount"],
        maximum_base_size: nil,
        maximum_quote_size: nil,
        base_decimals: Utils.decimals(product["base_min_size"]),
        quote_decimals: Utils.decimals(product["quote_increment"]),
        price_decimals: product["price_max_precision"].to_i,
        available: product["trade_status"] == "trading"
      }
    end
  end
end