Skip to content

Commit

Permalink
Merge pull request #10 from erubboli-bfx/master
Browse files Browse the repository at this point in the history
force types and remove trailing spaces
  • Loading branch information
prdn committed Mar 16, 2016
2 parents 39abbf2 + 68c52c1 commit 9f5c8c3
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion bitfinex-rb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']
spec.add_runtime_dependency 'faraday', '~> 0.9.2', '>= 0.9.2'
spec.add_runtime_dependency 'eventmachine', '~> 1.0.9.1'
spec.add_runtime_dependency 'eventmachine', '~> 1.0', '>= 1.0.9.1'
spec.add_runtime_dependency 'faraday-detailed_logger', '~> 1.0.0', '>= 1.0.0'
spec.add_runtime_dependency 'faye-websocket', '~> 0.10.3'
spec.add_runtime_dependency 'json', '~> 1.8.3','>= 1.8.3'
Expand Down
4 changes: 2 additions & 2 deletions lib/bitfinex/account_info.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Bitfinex

module AccountInfoClient
module AccountInfoClient

# Get account information
#
# @return [Hash] your account information
Expand Down
2 changes: 1 addition & 1 deletion lib/bitfinex/configurable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Configurable
def self.included(base)
base.extend(ClassMethods)
end

def config
self.class.config
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bitfinex/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
module Bitfinex
# Network Layer for API Rest client
module RestConnection
private
private
# Make an HTTP GET request
def get(url, options={})
rest_connection.get do |req|
Expand Down
6 changes: 3 additions & 3 deletions lib/bitfinex/deposit.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Bitfinex
module DepositClient
# Return your deposit address to make a new deposit.
#
#
# @param method [string] Method of deposit (methods accepted: “bitcoin”, “litecoin”, “darkcoin”, “mastercoin” (tethers)).
# @param wallet_name [string] Wallet to deposit in (accepted: “trading”, “exchange”, “deposit”). Your wallet needs to already exist
# @params renew [integer] (optional) Default is 0. If set to 1, will return a new unused deposit address
Expand All @@ -11,8 +11,8 @@ module DepositClient
# client.deposit("bitcoin", "exchange")
def deposit method, wallet_name, renew=0
params = {
method: method,
wallet_name: wallet_name,
method: method,
wallet_name: wallet_name,
renew: renew
}

Expand Down
4 changes: 2 additions & 2 deletions lib/bitfinex/funding_book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ module FundingBookClient
# @param currency [string] (optional) Speficy the currency, default "USD"
# @param params :limit_bids [int] (optional) Limit the number of funding bids returned. May be 0 in which case the array of bids is empty.
# @param params :limit_asks [int] (optional) Limit the number of funding offers returned. May be 0 in which case the array of asks is empty.
# @return [Hash] of :bids and :asks arrays
# @return [Hash] of :bids and :asks arrays
# @example:
# client.funding_book
# client.funding_book
def funding_book(currency="usd", params = {})
check_params(params, %i{limit_bids limit_asks})
get("lendbook/#{currency}", params).body
Expand Down
8 changes: 4 additions & 4 deletions lib/bitfinex/historical_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Bitfinex
module HistoricalDataClient

# View all of your balance ledger entries.
#
#
# @param currency [string] (optional) Specify the currency, default "USD"
# @param params :since [time] (optional) Return only the history after this timestamp.
# @param params :until [time] (optional) Return only the history before this timestamp.
Expand All @@ -12,13 +12,13 @@ module HistoricalDataClient
# @example:
# client.history
def history(currency="usd", params = {})
check_params(params, %i{since until limit wallet})
check_params(params, %i{since until limit wallet})
params.merge!({currency: currency})
authenticated_post("history", params).body
end

# View your past deposits/withdrawals.
#
#
# @param currency [string] (optional) Specify the currency, default "USD"
# @param params :method (optional) The method of the deposit/withdrawal (can be “bitcoin”, “litecoin”, “darkcoin”, “wire”)
# @param params :since (optional) Return only the history after this timestamp
Expand All @@ -34,7 +34,7 @@ def movements(currency="usd", params = {})
end

# View your past trades.
#
#
# @param symbol The pair traded (BTCUSD, LTCUSD, LTCBTC)
# @param params :until [time] (optional) Return only the history before this timestamp.
# @param params :timestamp [time] (optional) Trades made before this timestamp won’t be returned
Expand Down
4 changes: 2 additions & 2 deletions lib/bitfinex/lends.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module Bitfinex
module LendsClient
module LendsClient

# Get a list of the most recent funding data for the given currency: total amount provided and Flash Return Rate (in % by 365 days) over time.
#
# @param currency [string] (optional) Specify the currency, default "USD"
# @param currency [string] (optional) Specify the currency, default "USD"
# @param params :timestamp [time] (optional) Only show data at or after this timestamp
# @param params :limit_lends [int] (optional) Limit the amount of funding data returned. Must be > 1, default 50
# @return [Array]
Expand Down
35 changes: 18 additions & 17 deletions lib/bitfinex/orders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,28 @@ module OrdersClient
# @param params :is_hidden [bool] (optional) true if the order should be hidden. Default is false
# @param params :is_postonly [bool] (optional) true if the order should be post only. Default is false. Only relevant for limit orders
# @param params :ocoorder [bool] Set an additional STOP OCO order that will be linked with the current order
# @param params :buy_price_oco [decimal] If ocoorder is true, this field represent the price of the OCO stop order to place
# @param params :buy_price_oco [decimal] If ocoorder is true, this field represent the price of the OCO stop order to place
# @return [Hash]
# @example:
# client.new_order("usdbtc", 100, "market", "sell", 0)
def new_order(symbol, amount, type, side, price = nil, params = {})
# client.new_order("usdbtc", 100, "market", "sell", 0)
def new_order(symbol, amount, type, side, price = nil, params = {})
check_params(params, %i{is_hidden is_postonly ocoorder buy_price_oco})

params.merge!({
symbol: symbol,
amount: amount,
symbol: symbol,
amount: amount.to_s,
type: type,
side: side,
exchange: 'bitfinex',
price: price})
price: price.to_s
})

authenticated_post("order/new", params: params).body
end

# Submit several new orders at once
#
# @param orders [Array] Array of Hash with the following elements
# @param orders [Array] Array of Hash with the following elements
# @param orders :symbol [string] The name of the symbol
# @param orders :amount [decimal] Order size: how much to buy or sell
# @param orders :price [decimal] Price to buy or sell at. May omit if a market order
Expand All @@ -47,7 +48,7 @@ def multiple_orders(orders)

# Cancel an order
#
# @param ids [Array] or [integer] or nil
# @param ids [Array] or [integer] or nil
# if it's Array it's supposed to specify a list of IDS
# if it's an integer it's supposed to be a single ID
# if it's not specified it deletes all the orders placed
Expand All @@ -56,7 +57,7 @@ def multiple_orders(orders)
# client.cancel_orders([100,231,400])
def cancel_orders(ids=nil)
case ids
when Array
when Array
authenticated_post("order/cancel/multi", {order_ids: ids}).body
when Numeric
authenticated_post("order/cancel", {order_id: ids}).body
Expand All @@ -68,27 +69,27 @@ def cancel_orders(ids=nil)
end

# Replace an orders with a new one
#
#
# @param id [int] the ID of the order to replace
# @param symbol [string] the name of the symbol
# @param amount [decimal] Order size: how much to buy or sell
# @param type [string] Either “market” / “limit” / “stop” / “trailing-stop” / “fill-or-kill” / “exchange market” / “exchange limit” / “exchange stop” / “exchange trailing-stop” / “exchange fill-or-kill”. (type starting by “exchange ” are exchange orders, others are margin trading orders)
# @param type [string] Either “market” / “limit” / “stop” / “trailing-stop” / “fill-or-kill” / “exchange market” / “exchange limit” / “exchange stop” / “exchange trailing-stop” / “exchange fill-or-kill”. (type starting by “exchange ” are exchange orders, others are margin trading orders)
# @param side [string] Either “buy” or “sell”
# @param price [decimal] Price to buy or sell at. May omit if a market order
# @param is_hidden [bool] (optional) true if the order should be hidden. Default is false
# @return [Hash] the order
# @example:
# @example:
# client.replace_order(100,"usdbtc", 10, "market", "buy", 0)
def replace_order(id, symbol, amount, type, side, price, is_hidden=false)
params = {
order_id: id,
symbol: symbol,
amount: amount,
order_id: id.to_i,
symbol: symbol,
amount: amount.to_s,
type: type,
side: side,
exchange: 'bitfinex',
is_hidden: is_hidden,
price: price
price: price.to_s