Skip to content

Commit

Permalink
Merge pull request #11 from arvicco/master
Browse files Browse the repository at this point in the history
Fixed all instances of calls silently dropping params
  • Loading branch information
prdn committed Mar 17, 2016
2 parents 3477c0e + 7412f6b commit 6fe217c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/bitfinex/deposit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def deposit method, wallet_name, renew=0
renew: renew
}

authenticated_post("deposit/new", params).body
authenticated_post("deposit/new", params: params).body
end
end
end
6 changes: 3 additions & 3 deletions lib/bitfinex/margin_funding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def new_offer(currency, amount, rate, period, direction)
# @example:
# client.cancel_offer(1000)
def cancel_offer(offer_id)
authenticated_post("offer/cancel", {offer_id: offer_id}).body
authenticated_post("offer/cancel", params: {offer_id: offer_id.to_i}).body
end

# Get the status of an offer. Is it active? Was it cancelled? To what extent has it been executed? etc.
Expand All @@ -39,7 +39,7 @@ def cancel_offer(offer_id)
# @example:
# client.offer_status(1000)
def offer_status(offer_id)
authenticated_post("offer/status", {offer_id: offer_id}).body
authenticated_post("offer/status", params: {offer_id: offer_id.to_i}).body
end

# View your funds currently taken (active credits)
Expand Down Expand Up @@ -94,7 +94,7 @@ def total_taken_funds
# @example:
# client.close_funding(1000)
def close_funding(swap_id)
authenticated_post("funding/close", {swap_id: swap_id}).body
authenticated_post("funding/close", params: {swap_id: swap_id.to_i}).body
end
end
end
13 changes: 8 additions & 5 deletions lib/bitfinex/orders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ module OrdersClient
def new_order(symbol, amount, type, side, price = nil, params = {})
check_params(params, %i{is_hidden is_postonly ocoorder buy_price_oco})

# for 'market' order, we need to pass a random positive price, not nil
price ||= 0.00001 if type == "market" || type == "exchange market"

params.merge!({
symbol: symbol,
amount: amount.to_s,
Expand Down Expand Up @@ -58,9 +61,9 @@ def multiple_orders(orders)
def cancel_orders(ids=nil)
case ids
when Array
authenticated_post("order/cancel/multi", {order_ids: ids}).body
when Numeric
authenticated_post("order/cancel", {order_id: ids}).body
authenticated_post("order/cancel/multi", params: {order_ids: ids.map(&:to_i)}).body
when Numeric, String
authenticated_post("order/cancel", params: {order_id: ids.to_i}).body
when NilClass
authenticated_post("order/cancel/all").body
else
Expand Down Expand Up @@ -91,7 +94,7 @@ def replace_order(id, symbol, amount, type, side, price, is_hidden=false)
is_hidden: is_hidden,
price: price.to_s
}
authenticated_post("order/cancel/replace", params).body
authenticated_post("order/cancel/replace", params: params).body
end

# Get the status of an order. Is it active? Was it cancelled? To what extent has it been executed? etc.
Expand All @@ -101,7 +104,7 @@ def replace_order(id, symbol, amount, type, side, price, is_hidden=false)
# @exmaple:
# client.order_status(100)
def order_status(id)
authenticated_post("order/status", order_id: id).body
authenticated_post("order/status", params: {order_id: id.to_i}).body
end


Expand Down
4 changes: 2 additions & 2 deletions lib/bitfinex/positions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ def positions
# It is a long position: The amount in the last unit of the position pair that you have in your trading wallet AND/OR the realized profit of the position is greater or equal to the purchase amount of the position (base price * position amount) and the funds which need to be returned. For example, for a long BTCUSD position, you can claim the position if the amount of USD you have in the trading wallet is greater than the base price * the position amount and the funds used.
#
# It is a short position: The amount in the first unit of the position pair that you have in your trading wallet is greater or equal to the amount of the position and the margin funding used.
# @param position_id [int] The position ID given by `/positions`
# @param position_id [int] The position ID given by `/positions`
# @param amount [decimal] The partial amount you wish to claim
# @return [Hash]
# @example:
# client.claim_position(100,10)
def claim_position(position_id, amount)
authenticated_post("position/claim", {position_id: position_id, amount: amount}).body
authenticated_post("position/claim", params: {position_id: position_id, amount: amount}).body
end
end
end
18 changes: 9 additions & 9 deletions lib/bitfinex/wallet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ module Bitfinex
module WalletClient

# See your balances.
#
#
# @param params :type [string] “trading”, “deposit” or “exchange”.
# @param params :currency [string] currency
# @param params :amount [decimal] How much balance of this currency in this wallet
# @param params :available [decimal] How much X there is in this wallet that is available to trade
# @return [Array]
# @example:
# @return [Array]
# @example:
# client.balances
def balances(params = {})
check_params(params, %i{type currency amount available})
authenticated_post("balances", params).body
authenticated_post("balances", params: params).body
end

# See your trading wallet information for margin trading.
#
#
# @return [Array]
# @example:
# @example:
# client.margin_infos
def margin_infos
authenticated_post("margin_infos").body
end

# Allow you to move available balances between your wallets.
#
#
# @param amount [decimal] Amount to transfer
# @param currency [string] Currency of funds to transfer
# @param wallet_from [string] Wallet to transfer from
Expand All @@ -40,7 +40,7 @@ def transfer(amount, currency, wallet_from, wallet_to)
wallet_from: wallet_from,
wallet_to: wallet_to
}
authenticated_post("transfer", params).body
authenticated_post("transfer", params: params).body
end

# Allow you to request a withdrawal from one of your wallet.
Expand Down Expand Up @@ -74,7 +74,7 @@ def withdraw(withdraw_type, walletselected, amount, params={})
walletselected: walletselected,
amount: amount})

authenticated_post("withdraw", params).body
authenticated_post("withdraw", params: params).body
end

# Check the permissions of the key being used to generate this request
Expand Down

0 comments on commit 6fe217c

Please sign in to comment.