bitfinex-rb 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bitfinex.rb +28 -30
  3. data/lib/{bitfinex/errors.rb → errors.rb} +2 -2
  4. data/lib/models/alert.rb +27 -0
  5. data/lib/models/balance_info.rb +25 -0
  6. data/lib/models/candle.rb +29 -0
  7. data/lib/models/currency.rb +27 -0
  8. data/lib/models/funding_credit.rb +41 -0
  9. data/lib/models/funding_info.rb +40 -0
  10. data/lib/models/funding_loan.rb +40 -0
  11. data/lib/models/funding_offer.rb +38 -0
  12. data/lib/models/funding_ticker.rb +50 -0
  13. data/lib/models/funding_trade.rb +31 -0
  14. data/lib/models/ledger_entry.rb +33 -0
  15. data/lib/models/margin_info.rb +67 -0
  16. data/lib/models/model.rb +56 -0
  17. data/lib/models/movement.rb +33 -0
  18. data/lib/models/notification.rb +30 -0
  19. data/lib/models/order.rb +197 -0
  20. data/lib/models/order_book.rb +265 -0
  21. data/lib/models/position.rb +33 -0
  22. data/lib/models/public_trade.rb +27 -0
  23. data/lib/models/trade.rb +34 -0
  24. data/lib/models/trading_ticker.rb +33 -0
  25. data/lib/models/user_info.rb +27 -0
  26. data/lib/models/wallet.rb +28 -0
  27. data/lib/rest/rest_client.rb +103 -0
  28. data/lib/rest/v1.rb +63 -0
  29. data/lib/rest/v1/account_info.rb +23 -0
  30. data/lib/{bitfinex → rest}/v1/deposit.rb +2 -3
  31. data/lib/{bitfinex → rest}/v1/funding_book.rb +2 -4
  32. data/lib/{bitfinex → rest}/v1/historical_data.rb +2 -2
  33. data/lib/{bitfinex → rest}/v1/lends.rb +1 -2
  34. data/lib/{bitfinex → rest}/v1/margin_funding.rb +1 -2
  35. data/lib/rest/v1/order_book.rb +17 -0
  36. data/lib/{bitfinex → rest}/v1/orders.rb +6 -8
  37. data/lib/{bitfinex → rest}/v1/positions.rb +6 -2
  38. data/lib/{bitfinex → rest}/v1/stats.rb +1 -3
  39. data/lib/{bitfinex → rest}/v1/symbols.rb +1 -2
  40. data/lib/rest/v1/ticker.rb +13 -0
  41. data/lib/{bitfinex → rest}/v1/trades.rb +1 -16
  42. data/lib/{bitfinex → rest}/v1/wallet.rb +1 -2
  43. data/lib/rest/v2.rb +47 -0
  44. data/lib/{bitfinex → rest}/v2/margin.rb +1 -2
  45. data/lib/{bitfinex → rest}/v2/personal.rb +2 -18
  46. data/lib/{bitfinex → rest}/v2/stats.rb +1 -4
  47. data/lib/rest/v2/ticker.rb +20 -0
  48. data/lib/{bitfinex → rest}/v2/trading.rb +3 -49
  49. data/lib/{bitfinex → rest}/v2/utils.rb +1 -3
  50. data/lib/ws/ws2.rb +529 -0
  51. metadata +74 -56
  52. data/lib/bitfinex-api-rb.rb +0 -1
  53. data/lib/bitfinex-rb.rb +0 -1
  54. data/lib/bitfinex/api_versions.rb +0 -7
  55. data/lib/bitfinex/authenticated_rest.rb +0 -57
  56. data/lib/bitfinex/client.rb +0 -38
  57. data/lib/bitfinex/configurable.rb +0 -48
  58. data/lib/bitfinex/connection.rb +0 -52
  59. data/lib/bitfinex/v1/account_info.rb +0 -38
  60. data/lib/bitfinex/v1/orderbook.rb +0 -36
  61. data/lib/bitfinex/v1/ticker.rb +0 -27
  62. data/lib/bitfinex/v2/ticker.rb +0 -58
  63. data/lib/bitfinex/version.rb +0 -3
  64. data/lib/bitfinex/websocket_connection.rb +0 -231
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1b2e7fdeb41e8d0de71ff3ab3a8c8f65b438f74
4
- data.tar.gz: 5ee463c95bed54185d0ad7b0bd99c75c2ad461ee
3
+ metadata.gz: 8606ee4dc2dfdab159222376cdd3819df830f8d1
4
+ data.tar.gz: 8ccf0f428e9f06143427ad4f1d3c3fd16be6ee57
5
5
  SHA512:
6
- metadata.gz: a393e8688103054bd93c9b73799c96a8ff6a921155ad1064f12de83332d82c32c7e244153b0ffea1390232b9454761c323aebc35523715f02fd6318ae5f28932
7
- data.tar.gz: d33751ff047447639cf5f2e7034e14e96b7dcf414984a1e72dde42a40e07c05aa2156ac0287653651f4b33c7452e8e27c485d30a8a5d5e2f590566fb17a75568
6
+ metadata.gz: 28e9e659341d71b2e1592bbda88555ee800d6a16aac810e968567a7e1fef2724af81aa3b590e2e11f65f813ab202e9777fc2f716a191231758dbd67e744ead79
7
+ data.tar.gz: 1acf7d6bc3363c637d1ff6bbdd3ef25531f5ade7ced8acfc7a6ca75a88778681ae9d1900d8f0ce2d66b3cd56053217b131e13301e54fbf812d1244e63f152dae
@@ -4,35 +4,33 @@ require 'openssl'
4
4
  require 'faraday'
5
5
  require 'json'
6
6
  require 'faraday_middleware'
7
- require 'bitfinex/configurable'
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
- # API Version 1
16
- require 'bitfinex/v1/ticker'
17
- require 'bitfinex/v1/trades'
18
- require 'bitfinex/v1/funding_book'
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.body['message']
27
+ raise NotFoundError, env.url
28
28
  when 500
29
- raise InternalServerError, env.body['message']
29
+ raise InternalServerError, env.body
30
30
  else
31
31
  super
32
32
  end
@@ -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