Class: Bybit::RestApi::MarketService

Inherits:
BaseService show all
Defined in:
lib/bybit/rest_api/market_service.rb

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from Bybit::RestApi::BaseService

Instance Method Details

#get_adl_alert(**kwargs) ⇒ Hash

Get ADL alert information for the specified symbol.

GET /v5/market/adlalert

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :symbol (String)

    Symbol name

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



13
14
15
16
17
# File 'lib/bybit/rest_api/market_service.rb', line 13

def get_adl_alert(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/adlAlert', params: params)
end

#get_delivery_price(category:, **kwargs) ⇒ Hash

Get the delivery price for delivery contracts.

GET /v5/market/delivery-price

Parameters:

  • category (String)

    Product type

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :symbol (String)

    Symbol name

  • :base_coin (String)

    Base coin

  • :settle_coin (String)

    Settle coin

  • :limit (Integer)

    Limit for data size per page

  • :cursor (String)

    Cursor for pagination

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



31
32
33
34
35
# File 'lib/bybit/rest_api/market_service.rb', line 31

def get_delivery_price(category:, **kwargs)
  params = kwargs.merge(category: category)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/delivery-price', params: params)
end

#get_fee_group_info(product_type:, **kwargs) ⇒ Hash

Get the fee group structure information.

GET /v5/market/fee-group-info

Parameters:

  • product_type (String)

    Product type

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :group_id (String)

    Fee group id

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



45
46
47
48
49
# File 'lib/bybit/rest_api/market_service.rb', line 45

def get_fee_group_info(product_type:, **kwargs)
  params = kwargs.merge(product_type: product_type)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/fee-group-info', params: params)
end

#get_funding_rate_history(category:, symbol:, **kwargs) ⇒ Hash

Get the historical funding rate for a symbol.

GET /v5/market/funding/history

Parameters:

  • category (String)

    Product type

  • symbol (String)

    Symbol name

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :start_time (Integer)

    Start timestamp (ms)

  • :end_time (Integer)

    End timestamp (ms)

  • :limit (Integer)

    Limit for data size per page

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



62
63
64
65
66
# File 'lib/bybit/rest_api/market_service.rb', line 62

def get_funding_rate_history(category:, symbol:, **kwargs)
  params = kwargs.merge(category: category, symbol: symbol)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/funding/history', params: params)
end

#get_historical_volatility(category:, **kwargs) ⇒ Hash

Get the historical volatility for options.

GET /v5/market/historical-volatility

Parameters:

  • category (String)

    Product type

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :base_coin (String)

    Base coin

  • :quote_coin (String)

    Quote coin

  • :period (Integer)

    Period

  • :start_time (Integer)

    Start timestamp (ms)

  • :end_time (Integer)

    End timestamp (ms)

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



80
81
82
83
84
# File 'lib/bybit/rest_api/market_service.rb', line 80

def get_historical_volatility(category:, **kwargs)
  params = kwargs.merge(category: category)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/historical-volatility', params: params)
end

#get_index_price_components(index_name:, **kwargs) ⇒ Hash

Get the components of the index price.

GET /v5/market/index-price-components

Parameters:

  • index_name (String)

    Index name

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



92
93
94
95
96
# File 'lib/bybit/rest_api/market_service.rb', line 92

def get_index_price_components(index_name:, **kwargs)
  params = kwargs.merge(index_name: index_name)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/index-price-components', params: params)
end

#get_index_price_kline(symbol:, interval:, **kwargs) ⇒ Hash

Get index price kline data for a symbol.

GET /v5/market/index-price-kline

Parameters:

  • symbol (String)

    Symbol name

  • interval (String)

    Kline interval

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :category (String)

    Product type

  • :start (Integer)

    Start timestamp (ms)

  • :end_ (Integer)

    End timestamp (ms)

  • :limit (Integer)

    Limit for data size per page

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



110
111
112
113
114
115
# File 'lib/bybit/rest_api/market_service.rb', line 110

def get_index_price_kline(symbol:, interval:, **kwargs)
  params = kwargs.merge(symbol: symbol, interval: interval)
  params[:end] = params.delete(:end_) if params.key?(:end_)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/index-price-kline', params: params)
end

#get_instruments_info(category:, **kwargs) ⇒ Hash

Get the specification of instruments.

GET /v5/market/instruments-info

Parameters:

  • category (String)

    Product type

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :symbol (String)

    Symbol name

  • :status (String)

    Symbol status filter

  • :base_coin (String)

    Base coin

  • :limit (Integer)

    Limit for data size per page

  • :cursor (String)

    Cursor for pagination

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



129
130
131
132
133
# File 'lib/bybit/rest_api/market_service.rb', line 129

def get_instruments_info(category:, **kwargs)
  params = kwargs.merge(category: category)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/instruments-info', params: params)
end

#get_insurance_pool(**kwargs) ⇒ Hash

Get the insurance pool balance data.

GET /v5/market/insurance

Parameters:

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :coin (String)

    Coin name

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



142
143
144
145
146
# File 'lib/bybit/rest_api/market_service.rb', line 142

def get_insurance_pool(**kwargs)
  params = kwargs.dup
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/insurance', params: params)
end

#get_kline(symbol:, interval:, **kwargs) ⇒ Hash

Get kline (candlestick) data for a symbol.

GET /v5/market/kline

Parameters:

  • symbol (String)

    Symbol name

  • interval (String)

    Kline interval

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :category (String)

    Product type

  • :start (Integer)

    Start timestamp (ms)

  • :end_ (Integer)

    End timestamp (ms)

  • :limit (Integer)

    Limit for data size per page

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



198
199
200
201
202
203
# File 'lib/bybit/rest_api/market_service.rb', line 198

def get_kline(symbol:, interval:, **kwargs)
  params = kwargs.merge(symbol: symbol, interval: interval)
  params[:end] = params.delete(:end_) if params.key?(:end_)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/kline', params: params)
end

#get_long_short_ratio(category:, symbol:, period:, **kwargs) ⇒ Hash

Get the long/short account ratio for a symbol.

GET /v5/market/account-ratio

Parameters:

  • category (String)

    Product type

  • symbol (String)

    Symbol name

  • period (String)

    Data recording period

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :start_time (String)

    Start timestamp (ms)

  • :end_time (String)

    End timestamp (ms)

  • :limit (Integer)

    Limit for data size per page

  • :cursor (String)

    Cursor for pagination

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



161
162
163
164
165
# File 'lib/bybit/rest_api/market_service.rb', line 161

def get_long_short_ratio(category:, symbol:, period:, **kwargs)
  params = kwargs.merge(category: category, symbol: symbol, period: period)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/account-ratio', params: params)
end

#get_mark_price_kline(symbol:, interval:, **kwargs) ⇒ Hash

Get mark price kline data for a symbol.

GET /v5/market/mark-price-kline

Parameters:

  • symbol (String)

    Symbol name

  • interval (String)

    Kline interval

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :category (String)

    Product type

  • :start (Integer)

    Start timestamp (ms)

  • :end_ (Integer)

    End timestamp (ms)

  • :limit (Integer)

    Limit for data size per page

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



179
180
181
182
183
184
# File 'lib/bybit/rest_api/market_service.rb', line 179

def get_mark_price_kline(symbol:, interval:, **kwargs)
  params = kwargs.merge(symbol: symbol, interval: interval)
  params[:end] = params.delete(:end_) if params.key?(:end_)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/mark-price-kline', params: params)
end

#get_new_delivery_price(category:, base_coin:, **kwargs) ⇒ Hash

Get the new delivery price for delivery contracts.

GET /v5/market/new-delivery-price

Parameters:

  • category (String)

    Product type

  • base_coin (String)

    Base coin

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :settle_coin (String)

    Settle coin

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



214
215
216
217
218
# File 'lib/bybit/rest_api/market_service.rb', line 214

def get_new_delivery_price(category:, base_coin:, **kwargs)
  params = kwargs.merge(category: category, base_coin: base_coin)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/new-delivery-price', params: params)
end

#get_open_interest(category:, symbol:, interval_time:, **kwargs) ⇒ Hash

Get the open interest data for a symbol.

GET /v5/market/open-interest

Parameters:

  • category (String)

    Product type

  • symbol (String)

    Symbol name

  • interval_time (String)

    Interval time

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :start_time (Integer)

    Start timestamp (ms)

  • :end_time (Integer)

    End timestamp (ms)

  • :limit (Integer)

    Limit for data size per page

  • :cursor (String)

    Cursor for pagination

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



233
234
235
236
237
# File 'lib/bybit/rest_api/market_service.rb', line 233

def get_open_interest(category:, symbol:, interval_time:, **kwargs)
  params = kwargs.merge(category: category, symbol: symbol, interval_time: interval_time)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/open-interest', params: params)
end

#get_order_price_limit(symbol:, **kwargs) ⇒ Hash

Get the order price limit for a symbol.

GET /v5/market/price-limit

Parameters:

  • symbol (String)

    Symbol name

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :category (String)

    Product type

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).



246
247
248
249
250
# File 'lib/bybit/rest_api/market_service.rb', line 246

def get_order_price_limit(symbol:, **kwargs)
  params = kwargs.merge(symbol: symbol)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/price-limit', params: params)
end

#get_orderbook(category:, symbol:, **kwargs) ⇒ Hash

Get orderbook data for a specified symbol and category.

GET /v5/market/orderbook

Parameters:

  • category (String)

    Product type: spot, linear, inverse, option

  • symbol (String)

    Symbol name

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :limit (Integer)

    Limit size for each bid/ask

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



261
262
263
264
265
# File 'lib/bybit/rest_api/market_service.rb', line 261

def get_orderbook(category:, symbol:, **kwargs)
  params = kwargs.merge(category: category, symbol: symbol)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/orderbook', params: params)
end

#get_premium_index_price_kline(symbol:, interval:, **kwargs) ⇒ Hash

Get premium index price kline data.

GET /v5/market/premium-index-price-kline

Parameters:

  • symbol (String)

    Symbol name

  • interval (String)

    Kline interval

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :category (String)

    Product type: linear

  • :start (Integer)

    The start timestamp (ms)

  • :end_ (Integer)

    The end timestamp (ms)

  • :limit (Integer)

    Limit for data size per page. [1, 1000]. Default: 200

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



279
280
281
282
283
284
# File 'lib/bybit/rest_api/market_service.rb', line 279

def get_premium_index_price_kline(symbol:, interval:, **kwargs)
  params = kwargs.merge(symbol: symbol, interval: interval)
  params[:end] = params.delete(:end_) if params.key?(:end_)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/premium-index-price-kline', params: params)
end

#get_recent_public_trades(category:, **kwargs) ⇒ Hash

Get recent public trades.

GET /v5/market/recent-trade

Parameters:

  • category (String)

    Product type: spot, linear, inverse, option

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :symbol (String)

    Symbol name

  • :base_coin (String)

    Base coin, for option only

  • :option_type (String)

    Option type: Call or Put, for option only

  • :limit (Integer)

    Limit for data size per page

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



297
298
299
300
301
# File 'lib/bybit/rest_api/market_service.rb', line 297

def get_recent_public_trades(category:, **kwargs)
  params = kwargs.merge(category: category)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/recent-trade', params: params)
end

#get_risk_limit(category:, **kwargs) ⇒ Hash

Get risk limit information.

GET /v5/market/risk-limit

Parameters:

  • category (String)

    Product type: linear, inverse

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :symbol (String)

    Symbol name

  • :cursor (String)

    Cursor for pagination

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



312
313
314
315
316
# File 'lib/bybit/rest_api/market_service.rb', line 312

def get_risk_limit(category:, **kwargs)
  params = kwargs.merge(category: category)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/risk-limit', params: params)
end

#get_rpi_orderbook(symbol:, limit:, **kwargs) ⇒ Hash

Get RPI (Retail Price Improvement) orderbook data.

GET /v5/market/rpi_orderbook

Parameters:

  • symbol (String)

    Symbol name

  • limit (Integer)

    Limit size for each bid/ask

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :category (String)

    Product type: spot

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



327
328
329
330
331
# File 'lib/bybit/rest_api/market_service.rb', line 327

def get_rpi_orderbook(symbol:, limit:, **kwargs)
  params = kwargs.merge(symbol: symbol, limit: limit)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/rpi_orderbook', params: params)
end

#get_server_timeObject

Get Bybit server time.

GET /v5/market/time



338
339
340
# File 'lib/bybit/rest_api/market_service.rb', line 338

def get_server_time
  @session.public_request(path: '/v5/market/time')
end

#get_tickers(category:, **kwargs) ⇒ Hash

Get tickers information for a specified category.

GET /v5/market/tickers

Parameters:

  • category (String)

    Product type: spot, linear, inverse, option

  • kwargs (Hash)

    a customizable set of options

Options Hash (**kwargs):

  • :symbol (String)

    Symbol name

  • :base_coin (String)

    Base coin, for option only

  • :exp_date (String)

    Expiry date, for option only

Returns:

  • (Hash)

    Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).

See Also:



352
353
354
355
356
# File 'lib/bybit/rest_api/market_service.rb', line 352

def get_tickers(category:, **kwargs)
  params = kwargs.merge(category: category)
  params = Bybit::Utils::WireKeys.camelize(params)
  @session.public_request(path: '/v5/market/tickers', params: params)
end