Module: Bitfinex::RESTv2Trading

Included in:
RESTv2
Defined in:
lib/rest/v2/trading.rb

Instance Method Summary collapse

Instance Method Details

#active_positionsObject

Get active positions

return [Array]

@example:

client.active_positions


74
75
76
# File 'lib/rest/v2/trading.rb', line 74

def active_positions
  authenticated_post("auth/r/positions").body
end

#books(symbol = "btcusd", precision = "P0", params = {}) ⇒ Hash

The Order Books channel allow you to keep track of the state of the Bitfinex order book. It is provided on a price aggregated basis, with customizable precision.

@example:

client.orderbook("btcusd")

Parameters:

  • symbol (string) (defaults to: "btcusd")

    The symbol you want information about. You can find the list of valid symbols by calling the /symbols endpoint.

  • precision (string) (defaults to: "P0")

    Level of price aggregation (P0, P1, P2, P3, R0)

  • params (defaults to: {})

    :len [int32] Number of price points (“25”, “100”)

Returns:

  • (Hash)

    :bids [Array], :asks [Array]



44
45
46
47
# File 'lib/rest/v2/trading.rb', line 44

def books(symbol="btcusd", precision="P0", params = {})
  check_params(params, %i{len})
  get("book/#{symbol}/#{precision}", params: params).body
end

#candles(symbol = 'tBTCUSD', timeframe = '1m', section = "hist", params = {}) ⇒ Array

Provides a way to access charting candle info

@example:

client.candles('tBTCUSD')

Parameters:

  • symbol (string) (defaults to: 'tBTCUSD')

    The symbol you want information about.

  • timeframe (string) (defaults to: '1m')

    Available values: ‘1m’, ‘5m’, ‘15m’, ‘30m’, ‘1h’, ‘3h’, ‘6h’, ‘12h’, ‘1D’, ‘7D’, ‘14D’, ‘1M’

  • section (string) (defaults to: "hist")

    Available values: “last”, “hist”

  • params (defaults to: {})

    :limit [int32] Number of candles requested

  • params (defaults to: {})

    :start [int32] Filter start (ms)

  • params (defaults to: {})

    :end [int32] Filter end (ms)

  • params (defaults to: {})

    :sort [int32] if = 1 it sorts results returned with old > new

Returns:

  • (Array)


20
21
22
23
# File 'lib/rest/v2/trading.rb', line 20

def candles(symbol = 'tBTCUSD', timeframe = '1m', section = "hist", params = {})
  check_params(params, %i{limit start end sort})
  get("candles/trade:#{timeframe}:#{symbol}/#{section}", params).body
end

#trades(symbol = "tBTCUSD", params = {}) ⇒ Array

Trades endpoint includes all the pertinent details of the trade, such as price, size and time.

@example:

client.trades("tETHUSD")

Parameters:

  • symbol (string) (defaults to: "tBTCUSD")

    the name of the symbol

  • params (defaults to: {})

    :limit [int32] Number of records

  • params (defaults to: {})

    :start [int32] Millisecond start time

  • params (defaults to: {})

    :end [int32] Millisecond end time

  • params (defaults to: {})

    :sort [int32] if = 1 it sorts results returned with old > new

Returns:

  • (Array)


63
64
65
66
# File 'lib/rest/v2/trading.rb', line 63

def trades(symbol="tBTCUSD", params={})
  check_params(params, %i{limit start end sort})
  get("trades/#{symbol}", params).body
end