module Gemini::V1::MarginFundingClient

Public Instance Methods

cancel_offer(offer_id) click to toggle source

Cancel an offer

@param offer_id [int] The offer ID given by ‘#new_offer` @return [Hash] @example:

client.cancel_offer(1000)
# File lib/gemini/v1/margin_funding.rb, line 34
def cancel_offer(offer_id)
  authenticated_post("offer/cancel", params: {offer_id: offer_id.to_i}).body
end
close_funding(swap_id) click to toggle source

Allow you to close an unused or used taken fund

@param swap_id [int] The ID given by ‘#taken_funds` or `#unused_taken_funds @return [Hash] @example:

client.close_funding(1000)
# File lib/gemini/v1/margin_funding.rb, line 99
def close_funding(swap_id)
  authenticated_post("funding/close", params: {swap_id: swap_id.to_i}).body
end
credits() click to toggle source

View your funds currently taken (active credits)

@return [Array] @example:

client.credits
# File lib/gemini/v1/margin_funding.rb, line 53
def credits
  authenticated_post("credits").body
end
new_offer(currency, amount, rate, period, direction, frrdelta=false) click to toggle source

Submit a new offer

@param currency [string] The name of the currency, es: ‘USD’ @param amount [decimal] Offer size: how much to lend or borrow @param rate [decimal] Rate to lend or borrow at. In percentage per 365 days.

Set to 0 for FRR, ±delta for FRR±delta.

@param period [integer] Number of days of the funding contract (in days) @param direction [string] Either “lend” or “loan” @param frrdelta [bool] If true, the rate represents ±delta to FRR. @return [Hash] @example:

client.new_offer("btc", 10.0, 20, 365, "lend")
# File lib/gemini/v1/margin_funding.rb, line 16
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) click to toggle source

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

@param offer_id [int] The offer ID give by ‘#new_offer` @return [Hash] @example:

client.offer_status(1000)
# File lib/gemini/v1/margin_funding.rb, line 44
def offer_status(offer_id)
  authenticated_post("offer/status", params: {offer_id: offer_id.to_i}).body
end
offers() click to toggle source

View your active offers

@return [Array] An array of the results of /offer/status for all your live offers (lending or borrowing @example:

client.offers
# File lib/gemini/v1/margin_funding.rb, line 62
def offers
  authenticated_post("offers").body
end
taken_funds() click to toggle source

View your funding currently borrowed and used in a margin position

@return [Array] An array of your active margin funds @example:

client.taken_funds
# File lib/gemini/v1/margin_funding.rb, line 71
def taken_funds
  authenticated_post("taken_funds").body
end
total_taken_funds() click to toggle source

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

@return [Array] An array of your active funding @example:

client.total_taken_funds
# File lib/gemini/v1/margin_funding.rb, line 89
def total_taken_funds
  authenticated_post("total_taken_funds").body
end
unused_taken_funds() click to toggle source

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

@return [Array] An array of your active unused margin funds @example:

client.unused_taken_funds
# File lib/gemini/v1/margin_funding.rb, line 80
def unused_taken_funds
  authenticated_post("unused_taken_funds").body
end