bitfinex-rb 0.1.0 → 1.0.0
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.rb +28 -30
- data/lib/{bitfinex/errors.rb → errors.rb} +2 -2
- data/lib/models/alert.rb +27 -0
- data/lib/models/balance_info.rb +25 -0
- data/lib/models/candle.rb +29 -0
- data/lib/models/currency.rb +27 -0
- data/lib/models/funding_credit.rb +41 -0
- data/lib/models/funding_info.rb +40 -0
- data/lib/models/funding_loan.rb +40 -0
- data/lib/models/funding_offer.rb +38 -0
- data/lib/models/funding_ticker.rb +50 -0
- data/lib/models/funding_trade.rb +31 -0
- data/lib/models/ledger_entry.rb +33 -0
- data/lib/models/margin_info.rb +67 -0
- data/lib/models/model.rb +56 -0
- data/lib/models/movement.rb +33 -0
- data/lib/models/notification.rb +30 -0
- data/lib/models/order.rb +197 -0
- data/lib/models/order_book.rb +265 -0
- data/lib/models/position.rb +33 -0
- data/lib/models/public_trade.rb +27 -0
- data/lib/models/trade.rb +34 -0
- data/lib/models/trading_ticker.rb +33 -0
- data/lib/models/user_info.rb +27 -0
- data/lib/models/wallet.rb +28 -0
- data/lib/rest/rest_client.rb +103 -0
- data/lib/rest/v1.rb +63 -0
- data/lib/rest/v1/account_info.rb +23 -0
- data/lib/{bitfinex → rest}/v1/deposit.rb +2 -3
- data/lib/{bitfinex → rest}/v1/funding_book.rb +2 -4
- data/lib/{bitfinex → rest}/v1/historical_data.rb +2 -2
- data/lib/{bitfinex → rest}/v1/lends.rb +1 -2
- data/lib/{bitfinex → rest}/v1/margin_funding.rb +1 -2
- data/lib/rest/v1/order_book.rb +17 -0
- data/lib/{bitfinex → rest}/v1/orders.rb +6 -8
- data/lib/{bitfinex → rest}/v1/positions.rb +6 -2
- data/lib/{bitfinex → rest}/v1/stats.rb +1 -3
- data/lib/{bitfinex → rest}/v1/symbols.rb +1 -2
- data/lib/rest/v1/ticker.rb +13 -0
- data/lib/{bitfinex → rest}/v1/trades.rb +1 -16
- data/lib/{bitfinex → rest}/v1/wallet.rb +1 -2
- data/lib/rest/v2.rb +47 -0
- data/lib/{bitfinex → rest}/v2/margin.rb +1 -2
- data/lib/{bitfinex → rest}/v2/personal.rb +2 -18
- data/lib/{bitfinex → rest}/v2/stats.rb +1 -4
- data/lib/rest/v2/ticker.rb +20 -0
- data/lib/{bitfinex → rest}/v2/trading.rb +3 -49
- data/lib/{bitfinex → rest}/v2/utils.rb +1 -3
- data/lib/ws/ws2.rb +529 -0
- metadata +74 -56
- data/lib/bitfinex-api-rb.rb +0 -1
- data/lib/bitfinex-rb.rb +0 -1
- data/lib/bitfinex/api_versions.rb +0 -7
- data/lib/bitfinex/authenticated_rest.rb +0 -57
- data/lib/bitfinex/client.rb +0 -38
- data/lib/bitfinex/configurable.rb +0 -48
- data/lib/bitfinex/connection.rb +0 -52
- data/lib/bitfinex/v1/account_info.rb +0 -38
- data/lib/bitfinex/v1/orderbook.rb +0 -36
- data/lib/bitfinex/v1/ticker.rb +0 -27
- data/lib/bitfinex/v2/ticker.rb +0 -58
- data/lib/bitfinex/version.rb +0 -3
- data/lib/bitfinex/websocket_connection.rb +0 -231
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8606ee4dc2dfdab159222376cdd3819df830f8d1
|
4
|
+
data.tar.gz: 8ccf0f428e9f06143427ad4f1d3c3fd16be6ee57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28e9e659341d71b2e1592bbda88555ee800d6a16aac810e968567a7e1fef2724af81aa3b590e2e11f65f813ab202e9777fc2f716a191231758dbd67e744ead79
|
7
|
+
data.tar.gz: 1acf7d6bc3363c637d1ff6bbdd3ef25531f5ade7ced8acfc7a6ca75a88778681ae9d1900d8f0ce2d66b3cd56053217b131e13301e54fbf812d1244e63f152dae
|
data/lib/bitfinex.rb
CHANGED
@@ -4,35 +4,33 @@ require 'openssl'
|
|
4
4
|
require 'faraday'
|
5
5
|
require 'json'
|
6
6
|
require 'faraday_middleware'
|
7
|
-
require '
|
8
|
-
require 'bitfinex/errors'
|
9
|
-
require 'bitfinex/connection'
|
10
|
-
require 'bitfinex/websocket_connection'
|
11
|
-
require 'bitfinex/authenticated_rest'
|
12
|
-
require 'bitfinex/api_versions'
|
13
|
-
require 'bitfinex/client'
|
7
|
+
require 'dotenv/load'
|
14
8
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
require 'bitfinex/v1/orderbook'
|
20
|
-
require 'bitfinex/v1/lends'
|
21
|
-
require 'bitfinex/v1/symbols'
|
22
|
-
require 'bitfinex/v1/stats'
|
23
|
-
require 'bitfinex/v1/account_info'
|
24
|
-
require 'bitfinex/v1/deposit'
|
25
|
-
require 'bitfinex/v1/orders'
|
26
|
-
require 'bitfinex/v1/wallet'
|
27
|
-
require 'bitfinex/v1/positions'
|
28
|
-
require 'bitfinex/v1/historical_data'
|
29
|
-
require 'bitfinex/v1/margin_funding'
|
30
|
-
|
31
|
-
# API Version 2
|
32
|
-
require 'bitfinex/v2/stats'
|
33
|
-
require 'bitfinex/v2/ticker'
|
34
|
-
require 'bitfinex/v2/utils'
|
35
|
-
require 'bitfinex/v2/personal'
|
36
|
-
require 'bitfinex/v2/trading'
|
37
|
-
require 'bitfinex/v2/margin'
|
9
|
+
require_relative './errors'
|
10
|
+
require_relative './rest/v1'
|
11
|
+
require_relative './rest/v2'
|
12
|
+
require_relative './ws/ws2'
|
38
13
|
|
14
|
+
require_relative './models/alert'
|
15
|
+
require_relative './models/balance_info'
|
16
|
+
require_relative './models/candle'
|
17
|
+
require_relative './models/currency'
|
18
|
+
require_relative './models/funding_credit'
|
19
|
+
require_relative './models/funding_info'
|
20
|
+
require_relative './models/funding_loan'
|
21
|
+
require_relative './models/funding_offer'
|
22
|
+
require_relative './models/funding_ticker'
|
23
|
+
require_relative './models/funding_trade'
|
24
|
+
require_relative './models/ledger_entry'
|
25
|
+
require_relative './models/margin_info'
|
26
|
+
require_relative './models/model'
|
27
|
+
require_relative './models/movement'
|
28
|
+
require_relative './models/notification'
|
29
|
+
require_relative './models/order_book'
|
30
|
+
require_relative './models/order'
|
31
|
+
require_relative './models/position'
|
32
|
+
require_relative './models/public_trade'
|
33
|
+
require_relative './models/trade'
|
34
|
+
require_relative './models/trading_ticker'
|
35
|
+
require_relative './models/user_info'
|
36
|
+
require_relative './models/wallet'
|
@@ -24,9 +24,9 @@ module Bitfinex
|
|
24
24
|
when 403
|
25
25
|
raise ForbiddenError, env.body['message']
|
26
26
|
when 404
|
27
|
-
raise NotFoundError, env.
|
27
|
+
raise NotFoundError, env.url
|
28
28
|
when 500
|
29
|
-
raise InternalServerError, env.body
|
29
|
+
raise InternalServerError, env.body
|
30
30
|
else
|
31
31
|
super
|
32
32
|
end
|
data/lib/models/alert.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative './model'
|
2
|
+
|
3
|
+
module Bitfinex
|
4
|
+
module Models
|
5
|
+
class Alert < Model
|
6
|
+
BOOL_FIELDS = []
|
7
|
+
FIELDS = {
|
8
|
+
:key => 0,
|
9
|
+
:type => 1,
|
10
|
+
:symbol => 2,
|
11
|
+
:price => 3
|
12
|
+
}
|
13
|
+
|
14
|
+
FIELDS.each do |key, index|
|
15
|
+
attr_accessor key
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize (data)
|
19
|
+
super(data, FIELDS, BOOL_FIELDS)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.unserialize (data)
|
23
|
+
return Model.unserialize(data, FIELDS, BOOL_FIELDS)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative './model'
|
2
|
+
|
3
|
+
module Bitfinex
|
4
|
+
module Models
|
5
|
+
class BalanceInfo < Model
|
6
|
+
BOOL_FIELDS = []
|
7
|
+
FIELDS = {
|
8
|
+
:amount => 0,
|
9
|
+
:amount_net => 1
|
10
|
+
}
|
11
|
+
|
12
|
+
FIELDS.each do |key, index|
|
13
|
+
attr_accessor key
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize (data)
|
17
|
+
super(data, FIELDS, BOOL_FIELDS)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.unserialize (data)
|
21
|
+
return Model.unserialize(data, FIELDS, BOOL_FIELDS)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative './model'
|
2
|
+
|
3
|
+
module Bitfinex
|
4
|
+
module Models
|
5
|
+
class Candle < Model
|
6
|
+
BOOL_FIELDS = []
|
7
|
+
FIELDS = {
|
8
|
+
:mts => 0,
|
9
|
+
:open => 1,
|
10
|
+
:close => 2,
|
11
|
+
:high => 3,
|
12
|
+
:low => 4,
|
13
|
+
:volume => 5
|
14
|
+
}
|
15
|
+
|
16
|
+
FIELDS.each do |key, index|
|
17
|
+
attr_accessor key
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize (data)
|
21
|
+
super(data, FIELDS, BOOL_FIELDS)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.unserialize (data)
|
25
|
+
return Model.unserialize(data, FIELDS, BOOL_FIELDS)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative './model'
|
2
|
+
|
3
|
+
module Bitfinex
|
4
|
+
module Models
|
5
|
+
class Currency < Model
|
6
|
+
BOOL_FIELDS = []
|
7
|
+
FIELDS = {
|
8
|
+
:id => 0,
|
9
|
+
:name => 1,
|
10
|
+
:pool => 2,
|
11
|
+
:explorer => 3
|
12
|
+
}
|
13
|
+
|
14
|
+
FIELDS.each do |key, index|
|
15
|
+
attr_accessor key
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize (data)
|
19
|
+
super(data, FIELDS, BOOL_FIELDS)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.unserialize (data)
|
23
|
+
return Model.unserialize(data, FIELDS, BOOL_FIELDS)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative './model'
|
2
|
+
|
3
|
+
module Bitfinex
|
4
|
+
module Models
|
5
|
+
class FundingCredit < Model
|
6
|
+
BOOL_FIELDS = ['notify', 'hidden', 'renew', 'no_close']
|
7
|
+
FIELDS = {
|
8
|
+
:id => 0,
|
9
|
+
:symbol => 1,
|
10
|
+
:side => 2,
|
11
|
+
:mts_create => 3,
|
12
|
+
:mts_update => 4,
|
13
|
+
:amount => 5,
|
14
|
+
:flags => 6,
|
15
|
+
:status => 7,
|
16
|
+
:rate => 11,
|
17
|
+
:period => 12,
|
18
|
+
:mts_opening => 13,
|
19
|
+
:mts_last_payout => 14,
|
20
|
+
:notify => 15,
|
21
|
+
:hidden => 16,
|
22
|
+
:renew => 18,
|
23
|
+
:rate_real => 19,
|
24
|
+
:no_close => 20,
|
25
|
+
:position_pair => 21
|
26
|
+
}
|
27
|
+
|
28
|
+
FIELDS.each do |key, index|
|
29
|
+
attr_accessor key
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize (data)
|
33
|
+
super(data, FIELDS, BOOL_FIELDS)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.unserialize (data)
|
37
|
+
return Model.unserialize(data, FIELDS, BOOL_FIELDS)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative './model'
|
2
|
+
|
3
|
+
module Bitfinex
|
4
|
+
module Models
|
5
|
+
class FundingInfo < Model
|
6
|
+
attr_accessor :symbol, :yield_loan, :yield_lend
|
7
|
+
attr_accessor :duration_loan, :duration_lend
|
8
|
+
|
9
|
+
def initialize (data)
|
10
|
+
super(data, {}, [])
|
11
|
+
end
|
12
|
+
|
13
|
+
def serialize ()
|
14
|
+
[
|
15
|
+
'sym',
|
16
|
+
self.symbol,
|
17
|
+
[
|
18
|
+
self.yield_loan,
|
19
|
+
self.yield_lend,
|
20
|
+
self.duration_loan,
|
21
|
+
self.duration_lend
|
22
|
+
]
|
23
|
+
]
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.unserialize (arr)
|
27
|
+
symbol = arr[1]
|
28
|
+
data = arr[2]
|
29
|
+
|
30
|
+
{
|
31
|
+
:symbol => symbol,
|
32
|
+
:yield_loan => data[0],
|
33
|
+
:yield_lend => data[1],
|
34
|
+
:duration_loan => data[2],
|
35
|
+
:duration_lend => data[3]
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative './model'
|
2
|
+
|
3
|
+
module Bitfinex
|
4
|
+
module Models
|
5
|
+
class FundingLoan < Model
|
6
|
+
BOOL_FIELDS = ['notify', 'hidden', 'renew', 'no_close']
|
7
|
+
FIELDS = {
|
8
|
+
:id => 0,
|
9
|
+
:symbol => 1,
|
10
|
+
:side => 2,
|
11
|
+
:mts_create => 3,
|
12
|
+
:mts_update => 4,
|
13
|
+
:amount => 5,
|
14
|
+
:flags => 6,
|
15
|
+
:status => 7,
|
16
|
+
:rate => 11,
|
17
|
+
:period => 12,
|
18
|
+
:mts_opening => 13,
|
19
|
+
:mts_last_payout => 14,
|
20
|
+
:notify => 15,
|
21
|
+
:hidden => 16,
|
22
|
+
:renew => 18,
|
23
|
+
:rate_real => 19,
|
24
|
+
:no_close => 20
|
25
|
+
}
|
26
|
+
|
27
|
+
FIELDS.each do |key, index|
|
28
|
+
attr_accessor key
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize (data)
|
32
|
+
super(data, FIELDS, BOOL_FIELDS)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.unserialize (data)
|
36
|
+
return Model.unserialize(data, FIELDS, BOOL_FIELDS)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative './model'
|
2
|
+
|
3
|
+
module Bitfinex
|
4
|
+
module Models
|
5
|
+
class FundingOffer < Model
|
6
|
+
BOOL_FIELDS = ['notify', 'hidden', 'renew']
|
7
|
+
FIELDS = {
|
8
|
+
:id => 0,
|
9
|
+
:symbol => 1,
|
10
|
+
:mts_create => 2,
|
11
|
+
:mts_update => 3,
|
12
|
+
:amount => 4,
|
13
|
+
:amount_orig => 5,
|
14
|
+
:type => 6,
|
15
|
+
:flags => 9,
|
16
|
+
:status => 10,
|
17
|
+
:rate => 14,
|
18
|
+
:period => 15,
|
19
|
+
:notify => 16,
|
20
|
+
:hidden => 17,
|
21
|
+
:renew => 19,
|
22
|
+
:rate_real => 20
|
23
|
+
}
|
24
|
+
|
25
|
+
FIELDS.each do |key, index|
|
26
|
+
attr_accessor key
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize (data)
|
30
|
+
super(data, FIELDS, BOOL_FIELDS)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.unserialize (data)
|
34
|
+
return Model.unserialize(data, FIELDS, BOOL_FIELDS)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative './model'
|
2
|
+
|
3
|
+
module Bitfinex
|
4
|
+
module Models
|
5
|
+
class FundingTicker < Model
|
6
|
+
attr_accessor :symbol, :frr, :bid, :bid_period, :bid_size, :ask
|
7
|
+
attr_accessor :ask_period, :ask_size, :daily_change, :daily_change_perc
|
8
|
+
attr_accessor :last_price, :volume, :high, :low
|
9
|
+
|
10
|
+
def initialize (data)
|
11
|
+
super(data, {}, [])
|
12
|
+
end
|
13
|
+
|
14
|
+
def serialize ()
|
15
|
+
[
|
16
|
+
self.symbol,
|
17
|
+
[
|
18
|
+
self.frr, self.bid, self.bid_period, self.bid_size, self.ask,
|
19
|
+
self.ask_period, self.ask_size, self.daily_change,
|
20
|
+
self.daily_change_perc, self.last_price, self.volume, self.high,
|
21
|
+
self.low
|
22
|
+
]
|
23
|
+
]
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.unserialize (arr)
|
27
|
+
symbol = arr[0]
|
28
|
+
payload = arr[1]
|
29
|
+
data = payload.kind_of?(Array) ? payload : arr.dup[1..-1]
|
30
|
+
|
31
|
+
{
|
32
|
+
:symbol => symbol,
|
33
|
+
:frr => data[0],
|
34
|
+
:bid => data[1],
|
35
|
+
:bid_period => data[2],
|
36
|
+
:bid_size => data[3],
|
37
|
+
:ask => data[4],
|
38
|
+
:ask_period => data[5],
|
39
|
+
:ask_size => data[6],
|
40
|
+
:daily_change => data[7],
|
41
|
+
:daily_change_perc => data[8],
|
42
|
+
:last_price => data[9],
|
43
|
+
:volume => data[10],
|
44
|
+
:high => data[11],
|
45
|
+
:low => data[12]
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative './model'
|
2
|
+
|
3
|
+
module Bitfinex
|
4
|
+
module Models
|
5
|
+
class FundingTrade < Model
|
6
|
+
BOOL_FIELDS = []
|
7
|
+
FIELDS = {
|
8
|
+
:id => 0,
|
9
|
+
:symbol => 1,
|
10
|
+
:mts_create => 2,
|
11
|
+
:offer_id => 3,
|
12
|
+
:amount => 4,
|
13
|
+
:rate => 5,
|
14
|
+
:period => 6,
|
15
|
+
:maker => 7
|
16
|
+
}
|
17
|
+
|
18
|
+
FIELDS.each do |key, index|
|
19
|
+
attr_accessor key
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize (data)
|
23
|
+
super(data, FIELDS, BOOL_FIELDS)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.unserialize (data)
|
27
|
+
return Model.unserialize(data, FIELDS, BOOL_FIELDS)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|