Module: Bitfinex::RESTv2Utils

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

Instance Method Summary collapse

Instance Method Details

#calc_avg_price(symbol = 'tBTCUSD', amount = 0, period = 0, rate_limit = nil) ⇒ Array

Calculate the average execution rate for Trading or Margin funding.

@example:

client.calc_avg_price('tBTCUSD', 1000, 1000)

Parameters:

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

    The symbol you want information about.

  • amount (string) (defaults to: 0)

    Amount. Positive for buy, negative for sell (ex. “1.123”)

  • period (string) (defaults to: 0)

    (optional) Maximum period for Margin Funding

  • rate_limit (string) (defaults to: nil)

    Limit rate/price (ex. “1000.5”)

Returns:

  • (Array)


15
16
17
18
19
20
21
22
23
# File 'lib/rest/v2/utils.rb', line 15

def calc_avg_price(symbol = 'tBTCUSD', amount = 0, period = 0, rate_limit = nil)
  params = {
    symbol: symbol,
    amount: amount.to_s,
    period: period.to_s
  }
  params[:rateLimit] = rate_limit.to_s unless rate_limit.nil?
  get("calc/trade/avg",params)
end