module Binance::Spot::Market
This module includes all spot public endpoints, including:
-
server time
-
kline
-
ticker
-
trades
-
orderbook
-
etc
@see binance-docs.github.io/apidocs/spot/en/#spot-account-trade
Public Instance Methods
Compressed/Aggregate Trades List
Get compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.
GET /api/v3/aggTrades
@param symbol [String] the symbol @option startTime [Integer] Timestamp in ms to get aggregate trades from INCLUSIVE. @option endTime [Integer] Timestamp in ms to get aggregate trades until INCLUSIVE. @option fromId [Integer] Trade
id to fetch from. Default gets most recent trades. @option limit [Integer] Default 500; max 1000. @see binance-docs.github.io/apidocs/spot/en/#compressed-aggregate-trades-list
# File lib/binance/spot/market.rb, line 104 def agg_trades(symbol:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) @session.public_request( path: '/api/v3/aggTrades', params: kwargs.merge(symbol: symbol) ) end
Current Average Price
Current average price for a symbol.
GET /api/v3/avgPrice
@param symbol [String] the symbol @see binance-docs.github.io/apidocs/spot/en/#kline-candlestick-data
# File lib/binance/spot/market.rb, line 147 def avg_price(symbol:) Binance::Utils::Validation.require_param('symbol', symbol) @session.public_request( path: '/api/v3/avgPrice', params: { symbol: symbol } ) end
Symbol Order Book Ticker
Best price/qty on the order book for a symbol or symbols.
GET /api/v3/ticker/bookTicker
@option symbol [String] the symbol @see binance-docs.github.io/apidocs/spot/en/#symbol-order-book-ticker
# File lib/binance/spot/market.rb, line 194 def book_ticker(symbol: nil) @session.public_request( path: '/api/v3/ticker/bookTicker', params: { symbol: symbol } ) end
Order Book
GET /api/v3/depth
@param symbol [String] the symbol @option limit [Integer] Default 100; max 1000. Valid limits:[5, 10, 20, 50, 100, 500, 1000, 5000] @see binance-docs.github.io/apidocs/spot/en/#order-book
# File lib/binance/spot/market.rb, line 48 def depth(symbol:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) @session.public_request( path: '/api/v3/depth', params: kwargs.merge(symbol: symbol) ) end
Exchange Information
GET /api/v3/exchangeInfo
@see binance-docs.github.io/apidocs/spot/en/#exchange-information
# File lib/binance/spot/market.rb, line 37 def exchange_info @session.public_request(path: '/api/v3/exchangeInfo') end
Old Trade
Lookup
X-MBX-APIKEY required
GET /api/v3/historicalTrades
@param symbol [String] the symbol @option limit [Integer] Default 500; max 1000. @option fromId [Integer] Trade
id to fetch from. Default gets most recent trades. @see binance-docs.github.io/apidocs/spot/en/#old-trade-lookup
# File lib/binance/spot/market.rb, line 83 def historical_trades(symbol:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) @session.public_request( path: '/api/v3/historicalTrades', params: kwargs.merge(symbol: symbol) ) end
Kline/Candlestick Data
Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.
GET /api/v3/klines
@param symbol [String] the symbol @param interval [String] interval @option startTime [Integer] Timestamp in ms to get aggregate trades from INCLUSIVE. @option endTime [Integer] Timestamp in ms to get aggregate trades until INCLUSIVE. @option limit [Integer] Default 500; max 1000. @see binance-docs.github.io/apidocs/spot/en/#kline-candlestick-data
# File lib/binance/spot/market.rb, line 126 def klines(symbol:, interval:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) Binance::Utils::Validation.require_param('interval', interval) @session.public_request( path: '/api/v3/klines', params: kwargs.merge( symbol: symbol, interval: interval ) ) end
Test Connectivity
GET /api/v3/ping
@see binance-docs.github.io/apidocs/spot/en/#test-connectivity
# File lib/binance/spot/market.rb, line 19 def ping @session.public_request(path: '/api/v3/ping') end
24hr Ticker Price Change Statistics
24 hour rolling window price change statistics. Careful when accessing this with no symbol.
GET /api/v3/ticker/24hr
@option symbol [String] the symbol @see binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics
# File lib/binance/spot/market.rb, line 164 def ticker_24hr(symbol: nil) @session.public_request( path: '/api/v3/ticker/24hr', params: { symbol: symbol } ) end
Symbol Price Ticker
Latest price for a symbol or symbols.
GET /api/v3/ticker/price
@option symbol [String] the symbol @see binance-docs.github.io/apidocs/spot/en/#symbol-price-ticker
# File lib/binance/spot/market.rb, line 179 def ticker_price(symbol: nil) @session.public_request( path: '/api/v3/ticker/price', params: { symbol: symbol } ) end
Check Server Time
GET /api/v3/time
@see binance-docs.github.io/apidocs/spot/en/#check-server-time
# File lib/binance/spot/market.rb, line 28 def time @session.public_request(path: '/api/v3/time') end
Recent Trades List
GET /api/v3/trades
@param symbol [String] the symbol @option limit [Integer] Default 500; max 1000. @see binance-docs.github.io/apidocs/spot/en/#recent-trades-list
# File lib/binance/spot/market.rb, line 64 def trades(symbol:, **kwargs) Binance::Utils::Validation.require_param('symbol', symbol) @session.public_request( path: '/api/v3/trades', params: kwargs.merge(symbol: symbol) ) end