Module: Bitfinex::RESTv1MarginFunding

Included in:
RESTv1
Defined in:
lib/rest/v1/margin_funding.rb

Instance Method Summary collapse

Instance Method Details

#cancel_offer(offer_id) ⇒ Hash

Cancel an offer

@example:

client.cancel_offer(1000)

Parameters:

  • offer_id (int)

    The offer ID given by ‘#new_offer`

Returns:

  • (Hash)


33
34
35
# File 'lib/rest/v1/margin_funding.rb', line 33

def cancel_offer(offer_id)
  authenticated_post("offer/cancel", params: {offer_id: offer_id.to_i}).body
end

#close_funding(swap_id) ⇒ Hash

Allow you to close an unused or used taken fund

@example:

client.close_funding(1000)

Parameters:

  • swap_id (int)

    The ID given by ‘#taken_funds` or `#unused_taken_funds

Returns:

  • (Hash)


98
99
100
# File 'lib/rest/v1/margin_funding.rb', line 98

def close_funding(swap_id)
  authenticated_post("funding/close", params: {swap_id: swap_id.to_i}).body
end

#creditsArray

View your funds currently taken (active credits)

@example:

client.credits

Returns:

  • (Array)


52
53
54
# File 'lib/rest/v1/margin_funding.rb', line 52

def credits
  authenticated_post("credits").body
end

#new_offer(currency, amount, rate, period, direction, frrdelta = false) ⇒ Hash

Submit a new offer

@example:

client.new_offer("btc", 10.0, 20, 365, "lend")

Parameters:

  • currency (string)

    The name of the currency, es: ‘USD’

  • amount (decimal)

    Offer size: how much to lend or borrow

  • rate (decimal)

    Rate to lend or borrow at. In percentage per 365 days. Set to 0 for FRR, ±delta for FRR±delta.

  • period (integer)

    Number of days of the funding contract (in days)

  • direction (string)

    Either “lend” or “loan”

  • frrdelta (bool) (defaults to: false)

    If true, the rate represents ±delta to FRR.

Returns:

  • (Hash)


15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rest/v1/margin_funding.rb', line 15

def new_offer(currency, amount, rate, period, direction, frrdelta=false)
  params = {
    currency: currency,
    amount: amount.to_s,
    rate: rate.to_s,
    period: period.to_i,
    direction: direction,
    frrdelta: !!frrdelta
  }
  authenticated_post("offer/new", params: params).body
end

#offer_status(offer_id) ⇒ Hash

Get the status of an offer. Is it active? Was it cancelled? To what extent has it been executed? etc.

@example:

client.offer_status(1000)

Parameters:

  • offer_id (int)

    The offer ID give by ‘#new_offer`

Returns:

  • (Hash)


43
44
45
# File 'lib/rest/v1/margin_funding.rb', line 43

def offer_status(offer_id)
  authenticated_post("offer/status", params: {offer_id: offer_id.to_i}).body
end

#offersArray

View your active offers

@example:

client.offers

Returns:

  • (Array)

    An array of the results of /offer/status for all your live offers (lending or borrowing



61
62
63
# File 'lib/rest/v1/margin_funding.rb', line 61

def offers
  authenticated_post("offers").body
end

#taken_fundsArray

View your funding currently borrowed and used in a margin position

@example:

client.taken_funds

Returns:

  • (Array)

    An array of your active margin funds



70
71
72
# File 'lib/rest/v1/margin_funding.rb', line 70

def taken_funds
  authenticated_post("taken_funds").body
end

#total_taken_fundsArray

View the total of your active funding used in your position(s).

@example:

client.total_taken_funds

Returns:

  • (Array)

    An array of your active funding



88
89
90
# File 'lib/rest/v1/margin_funding.rb', line 88

def total_taken_funds
  authenticated_post("total_taken_funds").body
end

#unused_taken_fundsArray

View your funding currently borrowed and not used (available for a new margin position).

@example:

client.unused_taken_funds

Returns:

  • (Array)

    An array of your active unused margin funds



79
80
81
# File 'lib/rest/v1/margin_funding.rb', line 79

def unused_taken_funds
  authenticated_post("unused_taken_funds").body
end