Class: Bitmex::Quote

Inherits:
Base
  • Object
show all
Defined in:
lib/bitmex/quote.rb

Overview

Best Bid/Offer Snapshots & Historical Bins Looks like all REST API methods return ‘403 Forbidden’ but Web socket API works just fine.

Author:

  • Iulian Costan

Instance Attribute Summary

Attributes inherited from Base

#rest, #websocket

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Bitmex::Base

Instance Method Details

#all(filters = {}) {|Hash| ... } ⇒ Array

Get all quotes

Parameters:

  • filters (Hash) (defaults to: {})

    the filters to apply to mostly REST API requests with a few exceptions

Options Hash (filters):

  • :symbol (String)

    the instrument symbol, this filter works in both REST and Websocket APIs

  • :filter (String)

    generic table filter, send key/value pairs Timestamp Filters

  • :columns (String)

    array of column names to fetch; if omitted, will return all columns.

  • :count (Double) — default: 100

    number of results to fetch.

  • :start (Double)

    Starting point for results.

  • :reverse (Boolean) — default: false

    if true, will sort results newest first.

  • :startTime (Datetime, String)

    Starting date filter for results.

  • :endTime (Datetime, String)

    Ending date filter for results

Yields:

  • (Hash)

    the quote data

Returns:

  • (Array)

    the quotes



10
11
12
13
14
15
16
# File 'lib/bitmex/quote.rb', line 10

def all(filters = {}, &ablock)
  if block_given?
    websocket.listen quote: filters[:symbol], &ablock
  else
    rest.get quotes_path, params: filters
  end
end

#bucketed(bin_size = '1h', filters = {}) {|Hash| ... } ⇒ Array

Get previous quotes in time buckets

Parameters:

  • bin_size ('1m', '5m', '1h', '1d') (defaults to: '1h')

    the interval to bucket by

  • filters (Hash) (defaults to: {})

    the filters to apply to mostly REST API requests with a few exceptions

Options Hash (filters):

  • :symbol (String)

    the instrument symbol, this filter works in both REST and Websocket APIs

  • :filter (String)

    generic table filter, send key/value pairs Timestamp Filters

  • :columns (String)

    array of column names to fetch; if omitted, will return all columns.

  • :count (Double) — default: 100

    number of results to fetch.

  • :start (Double)

    Starting point for results.

  • :reverse (Boolean) — default: false

    if true, will sort results newest first.

  • :startTime (Datetime, String)

    Starting date filter for results.

  • :endTime (Datetime, String)

    Ending date filter for results

Yields:

  • (Hash)

    the quote data

Returns:

  • (Array)

    the quotes by bucket



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bitmex/quote.rb', line 23

def bucketed(bin_size = '1h', filters = {}, &ablock)
  check_binsize bin_size

  if block_given?
    topic = { "quoteBin#{bin_size}": filters[:symbol] }
    websocket.listen topic, &ablock
  else
    params = filters.merge binSize: bin_size
    rest.get quotes_path(:bucketed), params: params
  end
end