Class: Honeymaker::Exchanges::Coinbase
- Inherits:
-
Honeymaker::Exchange
- Object
- Honeymaker::Exchange
- Honeymaker::Exchanges::Coinbase
- Defined in:
- lib/honeymaker/exchanges/coinbase.rb
Constant Summary collapse
- BASE_URL =
"https://api.coinbase.com"- ASSET_BLACKLIST =
[ "RENDER", # has the same external_id as RNDR "ZETACHAIN", # has the same external_id as ZETA "WAXL" # has the same external_id as AXL ].freeze
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
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/honeymaker/exchanges/coinbase.rb', line 40 def get_bid_ask(symbol) with_rescue do response = connection.get("/api/v3/brokerage/market/products/#{symbol}") { bid: BigDecimal(response.body["bid"]), ask: BigDecimal(response.body["ask"]) } end end |
#get_tickers_info ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/honeymaker/exchanges/coinbase.rb', line 14 def get_tickers_info with_rescue do response = connection.get("/api/v3/brokerage/market/products") response.body["products"].filter_map do |product| ticker = product["product_id"] base, quote = ticker.split("-") next if ASSET_BLACKLIST.include?(base) { ticker: ticker, base: base, quote: quote, minimum_base_size: product["base_min_size"], minimum_quote_size: product["quote_min_size"], maximum_base_size: product["base_max_size"], maximum_quote_size: product["quote_max_size"], base_decimals: Utils.decimals(product["base_increment"]), quote_decimals: Utils.decimals(product["quote_increment"]), price_decimals: Utils.decimals(product["price_increment"]), available: true } end end end |