Class: Honeymaker::Exchanges::Gemini

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

Constant Summary collapse

BASE_URL =
"https://api.gemini.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



36
37
38
39
40
41
42
43
44
45
# File 'lib/honeymaker/exchanges/gemini.rb', line 36

def get_bid_ask(symbol)
  with_rescue do
    response = connection.get("/v1/pubticker/#{symbol.downcase}")

    {
      bid: BigDecimal(response.body["bid"]),
      ask: BigDecimal(response.body["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
29
30
31
32
33
34
# File 'lib/honeymaker/exchanges/gemini.rb', line 8

def get_tickers_info
  with_rescue do
    symbols_response = connection.get("/v1/symbols")
    symbols = symbols_response.body

    symbols.filter_map do |symbol|
      detail = connection.get("/v1/symbols/details/#{symbol}").body

      tick_size = detail["tick_size"]&.to_s || "0.01"
      quote_increment = detail["quote_increment"]&.to_s || "0.01"

      {
        ticker: symbol.upcase,
        base: detail["base_currency"].upcase,
        quote: detail["quote_currency"].upcase,
        minimum_base_size: detail["min_order_size"],
        minimum_quote_size: "0",
        maximum_base_size: nil,
        maximum_quote_size: nil,
        base_decimals: Utils.decimals(tick_size),
        quote_decimals: Utils.decimals(quote_increment),
        price_decimals: Utils.decimals(quote_increment),
        available: detail["status"] == "open"
      }
    end
  end
end