Class: Honeymaker::Exchanges::Mexc
- Inherits:
-
Honeymaker::Exchange
- Object
- Honeymaker::Exchange
- Honeymaker::Exchanges::Mexc
- Defined in:
- lib/honeymaker/exchanges/mexc.rb
Constant Summary collapse
- BASE_URL =
"https://api.mexc.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
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/honeymaker/exchanges/mexc.rb', line 32 def get_bid_ask(symbol) with_rescue do response = connection.get("/api/v3/ticker/bookTicker") do |req| req.params = { symbol: symbol } end { bid: BigDecimal(response.body["bidPrice"]), ask: BigDecimal(response.body["askPrice"]) } end end |
#get_tickers_info ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/honeymaker/exchanges/mexc.rb', line 8 def get_tickers_info with_rescue do response = connection.get("/api/v3/exchangeInfo") response.body["symbols"].filter_map do |product| f = Utils.parse_filters(product["filters"]) { ticker: product["symbol"], base: product["baseAsset"], quote: product["quoteAsset"], minimum_base_size: f[:lot_size]&.[]("minQty"), minimum_quote_size: f[:notional]&.[]("minNotional"), maximum_base_size: f[:lot_size]&.[]("maxQty"), maximum_quote_size: f[:notional]&.[]("maxNotional"), base_decimals: f[:lot_size] ? Utils.decimals(f[:lot_size]["stepSize"]) : product["baseAssetPrecision"], quote_decimals: product["quoteAssetPrecision"], price_decimals: f[:price] ? Utils.decimals(f[:price]["tickSize"]) : product["quotePrecision"], available: product["status"] == "TRADING" } end end end |