bitfinex-rb 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bitfinex/connection.rb +1 -1
- data/lib/bitfinex/errors.rb +27 -0
- data/lib/bitfinex/funding_book.rb +1 -1
- data/lib/bitfinex/lends.rb +1 -1
- data/lib/bitfinex/orderbook.rb +2 -1
- data/lib/bitfinex/orders.rb +1 -2
- data/lib/bitfinex/version.rb +1 -1
- data/lib/bitfinex/wallet.rb +6 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20394641fe58898e7fa5501718f59ecec7e5a431
|
4
|
+
data.tar.gz: 49a23548584876b2b6d6970c1ce5336b9beb6648
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f5e35855f8157c774498ab745ed8742371ace95c55bbbbb72733c6a846128fca0837aaee8020bf2306f91d59948c0540d41ce39e6f47bcf2c8b4211e0e00611
|
7
|
+
data.tar.gz: 340a63e8b1b9140b5d209dcadff434bbfc9c2f4cb604f3923305951dd5c61563841c6a334e890fa4592273fb3b27603b18f9d476f747de2c4caf591f393b4427
|
data/lib/bitfinex/connection.rb
CHANGED
@@ -32,7 +32,7 @@ module Bitfinex
|
|
32
32
|
|
33
33
|
def new_rest_connection
|
34
34
|
Faraday.new(url: base_api_endpoint) do |conn|
|
35
|
-
conn.use
|
35
|
+
conn.use Bitfinex::CustomErrors
|
36
36
|
conn.response :logger, Logger.new(STDOUT) , bodies: true if config.debug_connection
|
37
37
|
conn.use FaradayMiddleware::ParseJson, :content_type => /\bjson$/
|
38
38
|
conn.adapter :net_http
|
data/lib/bitfinex/errors.rb
CHANGED
@@ -1,6 +1,33 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
|
1
3
|
module Bitfinex
|
2
4
|
class ClientError < Exception; end
|
3
5
|
class ParamsError < ClientError; end
|
4
6
|
class InvalidAuthKeyError < ClientError; end
|
5
7
|
class BlockMissingError < ParamsError; end
|
8
|
+
class ServerError < Exception; end # Error reported back by Binfinex server
|
9
|
+
class BadRequestError < ServerError; end
|
10
|
+
class NotFoundError < ServerError; end
|
11
|
+
class ForbiddenError < ServerError; end
|
12
|
+
class UnauthorizedError < ServerError; end
|
13
|
+
class InternalServerError < ServerError; end
|
14
|
+
|
15
|
+
class CustomErrors < Faraday::Response::Middleware
|
16
|
+
def on_complete(env)
|
17
|
+
case env[:status]
|
18
|
+
when 400
|
19
|
+
raise BadRequestError, env.body['message']
|
20
|
+
when 401
|
21
|
+
raise UnauthorizedError
|
22
|
+
when 403
|
23
|
+
raise ForbiddenError
|
24
|
+
when 404
|
25
|
+
raise NotFoundError
|
26
|
+
when 500
|
27
|
+
raise InternalServerError
|
28
|
+
else
|
29
|
+
super
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
6
33
|
end
|
data/lib/bitfinex/lends.rb
CHANGED
data/lib/bitfinex/orderbook.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
module Bitfinex
|
2
3
|
module OrderbookClient
|
3
4
|
|
@@ -12,7 +13,7 @@ module Bitfinex
|
|
12
13
|
# client.orderbook("btcusd")
|
13
14
|
def orderbook(symbol="btcusd", params = {})
|
14
15
|
check_params(params, %i{limit_bids limit_asks group})
|
15
|
-
get("book/#{symbol}",params).body
|
16
|
+
get("book/#{symbol}", params: params).body
|
16
17
|
end
|
17
18
|
|
18
19
|
|
data/lib/bitfinex/orders.rb
CHANGED
@@ -19,7 +19,7 @@ module Bitfinex
|
|
19
19
|
check_params(params, %i{is_hidden is_postonly ocoorder buy_price_oco})
|
20
20
|
|
21
21
|
# for 'market' order, we need to pass a random positive price, not nil
|
22
|
-
price ||= 0.
|
22
|
+
price ||= 0.001 if type == "market" || type == "exchange market"
|
23
23
|
|
24
24
|
params.merge!({
|
25
25
|
symbol: symbol,
|
@@ -29,7 +29,6 @@ module Bitfinex
|
|
29
29
|
exchange: 'bitfinex',
|
30
30
|
price: price.to_s
|
31
31
|
})
|
32
|
-
|
33
32
|
authenticated_post("order/new", params: params).body
|
34
33
|
end
|
35
34
|
|
data/lib/bitfinex/version.rb
CHANGED
data/lib/bitfinex/wallet.rb
CHANGED
@@ -35,10 +35,10 @@ module Bitfinex
|
|
35
35
|
# client.transfer(10, 'btc', "exchange", "deposit")
|
36
36
|
def transfer(amount, currency, wallet_from, wallet_to)
|
37
37
|
params = {
|
38
|
-
amount: amount,
|
39
|
-
currency: currency,
|
40
|
-
|
41
|
-
|
38
|
+
amount: amount.to_s,
|
39
|
+
currency: currency.upcase,
|
40
|
+
walletfrom: wallet_from.downcase,
|
41
|
+
walletto: wallet_to.downcase
|
42
42
|
}
|
43
43
|
authenticated_post("transfer", params: params).body
|
44
44
|
end
|
@@ -71,8 +71,8 @@ module Bitfinex
|
|
71
71
|
def withdraw(withdraw_type, walletselected, amount, params={})
|
72
72
|
params.merge!({
|
73
73
|
withdraw_type: withdraw_type,
|
74
|
-
walletselected: walletselected,
|
75
|
-
amount: amount})
|
74
|
+
walletselected: walletselected.downcase,
|
75
|
+
amount: amount.to_s})
|
76
76
|
|
77
77
|
authenticated_post("withdraw", params: params).body
|
78
78
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitfinex-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bitfinex
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|