Class: Bitmex::Instrument

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

Overview

Tradeable Contracts, Indices, and History

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

#activeArray

Get all active instruments and instruments that have expired in <24hrs.

Returns:

  • (Array)

    active instruments



19
20
21
# File 'lib/bitmex/instrument.rb', line 19

def active
  rest.get instrument_path('active')
end

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

Get all instruments

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 instrument

Returns:

  • (Array)

    all instruments



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

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

#composite_index(filters = { symbol: '.XBT' }) ⇒ Array

Show constituent parts of an index.

Parameters:

  • filters (Hash) (defaults to: { symbol: '.XBT' })

    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

Returns:

  • (Array)

    the parts of an index



32
33
34
# File 'lib/bitmex/instrument.rb', line 32

def composite_index(filters = { symbol: '.XBT' })
  rest.get instrument_path('compositeIndex'), params: filters
end

#indicesArray

Get all price indices

Returns:

  • (Array)

    all indices



38
39
40
# File 'lib/bitmex/instrument.rb', line 38

def indices
  rest.get instrument_path('indices')
end

#intervalsBitmex::Mash

Return all active contract series and interval pairs

Returns:



25
26
27
# File 'lib/bitmex/instrument.rb', line 25

def intervals
  rest.get instrument_path('activeIntervals')
end