bitex 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 151ad0a112110c7ce40e5ce09c5f753a10253bcb
4
- data.tar.gz: aecf7f5c80fe3afba0da32ddb4f820f8d4fb7bc4
3
+ metadata.gz: '03555559d3d82a4f379a04f62d31c8ffaf2ab223'
4
+ data.tar.gz: 067a8204a071250238538d2b027bc98acc7a8174
5
5
  SHA512:
6
- metadata.gz: d9785a0c2b14f157e6cdef69079c12c4be59c9463bdff76bf865aa1931f98d46eff6d6b376c1392cf2bd0452870296c58e8e76475b0994ca3e0ce8dfaf6b1b26
7
- data.tar.gz: cb426c0e8d50ddd8982e8505d3696374ab637b0822693cfc98d53145dacd02de0fc220389db4195f38d2b0a9f9327b5072148d4505a2f65a2695f30d0f2f4193
6
+ metadata.gz: 8ff84068e327879b35f21bdb4eebc3ad1a2b23234f482b4705527b748e2184558b6f44c40e4ce0922daefdcd9e2f2b8be63765068b551167d9b1953555bfc56b
7
+ data.tar.gz: be63b22da048ff45b8048ceb613150d8f0e731ee0182d700038c9fd6fb73ba5e7e4fe6762c9c48011073801924595fff9bfcecdb0eaf68280035a7b37fd13d29
@@ -13,9 +13,6 @@ Metrics/LineLength:
13
13
  Metrics/MethodLength:
14
14
  Max: 20
15
15
 
16
- Metrics/MethodLength:
17
- Max: 20
18
-
19
16
  Metrics/ParameterLists:
20
17
  Max: 7
21
18
 
@@ -20,6 +20,7 @@ module Bitex
20
20
  @curl
21
21
  end
22
22
 
23
+ # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength
23
24
  def self.curl(verb, path, options = {}, files = {})
24
25
  verb = verb.upcase.to_sym
25
26
  query = verb == :GET ? "?#{options.to_query}" : ''
@@ -51,6 +52,7 @@ module Bitex
51
52
 
52
53
  curl
53
54
  end
55
+ # rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength
54
56
 
55
57
  def self.public(path, _options = {})
56
58
  response = curl(:GET, path)
@@ -1,5 +1,5 @@
1
1
  module Bitex
2
- # An Ask is an order to sell a given orderbook.
2
+ # An Ask is an order to sell a given order book.
3
3
  # @see BaseOrder
4
4
  class Ask < BaseOrder
5
5
  # @!attribute id
@@ -8,7 +8,7 @@ module Bitex
8
8
  # @!attribute created_at
9
9
  # @return [Time] Time when this Ask was created.
10
10
 
11
- # @!attribute orderbook
11
+ # @!attribute order_book
12
12
  # @return [Symbol] :btc_usd or :btc_ars
13
13
 
14
14
  # @!attribute quantity
@@ -53,12 +53,12 @@ module Bitex
53
53
 
54
54
  # TODO: rever esta documentacion
55
55
  # Create a new Ask for selling a Quantity of specie charging no less than Price per each.
56
- # @param orderbook [Symbol] :btc_usd or :btc_ars, whatever you're selling.
56
+ # @param order_book [Symbol] :btc_usd or :btc_ars, whatever you're selling.
57
57
  # @param quantity [BigDecimal] Quantity to sell.
58
58
  # @param price [BigDecimal] Minimum price to charge when selling.
59
59
  # @param wait [Boolean] Block the process and wait until this ask moves out of the :received state, defaults to false.
60
60
  # @see https://bitex.la/developers#create-ask
61
- def self.create!(orderbook, quantity, price, wait = false)
61
+ def self.create!(order_book, quantity, price, wait = false)
62
62
  super
63
63
  end
64
64
 
@@ -9,9 +9,9 @@ module Bitex
9
9
  # @return [Time] Time when this Bid was created.
10
10
  attr_accessor :created_at
11
11
 
12
- # @!attribute orderbook
12
+ # @!attribute order_book
13
13
  # @return [Symbol] :btc_usd or :btc_ars
14
- attr_accessor :orderbook
14
+ attr_accessor :order_book
15
15
 
16
16
  # @!attribute price
17
17
  # @return [BigDecimal] Maximum price to pay per unit.
@@ -52,8 +52,8 @@ module Bitex
52
52
  end
53
53
 
54
54
  # @visibility private
55
- def self.create!(orderbook, amount, price, wait = false)
56
- params = { amount: amount, price: price, orderbook: { btc_usd: 1, btc_ars: 5 }[orderbook] }
55
+ def self.create!(order_book, amount, price, wait = false)
56
+ params = { amount: amount, price: price, orderbook: { btc_usd: 1, btc_ars: 5 }[order_book] }
57
57
 
58
58
  order = from_json(Api.private(:post, "/private#{base_path}", params))
59
59
  retries = 0
@@ -75,7 +75,7 @@ module Bitex
75
75
  # @visibility private
76
76
  def self.from_json(json, order = nil)
77
77
  Api.from_json(order || new, json) do |thing|
78
- thing.orderbook = orderbooks[json[3]]
78
+ thing.order_book = order_books[json[3]]
79
79
  thing.price = json[6].to_s.to_d
80
80
  thing.status = statuses[json[7]]
81
81
  thing.reason = reasons[json[8]]
@@ -91,7 +91,7 @@ module Bitex
91
91
  order
92
92
  end
93
93
 
94
- def self.orderbooks
94
+ def self.order_books
95
95
  { 1 => :btc_usd, 5 => :btc_ars }
96
96
  end
97
97
 
@@ -1,5 +1,5 @@
1
1
  module Bitex
2
- # A Bid is an order to buy a given orderbook.
2
+ # A Bid is an order to buy a given order book.
3
3
  # @see BaseOrder
4
4
  class Bid < BaseOrder
5
5
  # @!attribute id
@@ -8,7 +8,7 @@ module Bitex
8
8
  # @!attribute created_at
9
9
  # @return [Time] Time when this Bid was created.
10
10
 
11
- # @!attribute orderbook
11
+ # @!attribute order_book
12
12
  # @return [Symbol] :btc_usd or :btc_ars
13
13
 
14
14
  # @!attribute amount
@@ -51,12 +51,12 @@ module Bitex
51
51
  end
52
52
 
53
53
  # Create a new Bid for spending Amount USD paying no more than price per unit.
54
- # @param orderbook [Symbol] :btc_usd or :btc_ars, whatever you're buying.
54
+ # @param order_book [Symbol] :btc_usd or :btc_ars, whatever you're buying.
55
55
  # @param amount [BigDecimal] Amount to spend buying.
56
56
  # @param price [BigDecimal] Maximum price to pay per unit.
57
57
  # @param wait [Boolean] Block the process and wait until this bid moves out of the :received state, defaults to false.
58
58
  # @see https://bitex.la/developers#create-bid
59
- def self.create!(orderbook, amount, price, wait = false)
59
+ def self.create!(order_book, amount, price, wait = false)
60
60
  super
61
61
  end
62
62
 
@@ -8,7 +8,7 @@ module Bitex
8
8
  # @!attribute created_at
9
9
  # @return [Time] Time when this Buy happened.
10
10
 
11
- # @!attribute orderbook
11
+ # @!attribute order_book
12
12
  # @return [Symbol] :btc_usd or :btc_ars
13
13
 
14
14
  # @!attribute quantity
@@ -12,7 +12,6 @@ module Bitex
12
12
  # The species order book as a Hash with two keys: bids and asks.
13
13
  # Each of them is a list of list consisting of [price, quantity]
14
14
  # @see https://bitex.la/developers#orderbook
15
- # TODO: standarize name for order-books: orderbook | order_book
16
15
  def self.order_book
17
16
  api_get('/market/order_book').symbolize_keys
18
17
  end
@@ -3,22 +3,24 @@ module Bitex
3
3
  # Both Buy and Sell are a kind of Match, they deserialize the same and have very similar fields, although their documentation
4
4
  # may differ.
5
5
  class Match
6
- attr_accessor :id, :orderbook, :quantity, :amount, :fee, :price, :created_at
6
+ attr_accessor :id, :order_book, :quantity, :amount, :fee, :price, :created_at
7
7
 
8
8
  # @visibility private
9
+ # rubocop:disable Metrics/AbcSize
9
10
  def self.from_json(json)
10
11
  Api.from_json(new, json) do |thing|
11
- thing.orderbook = orderbooks[json[3]]
12
+ thing.order_book = order_books[json[3]]
12
13
  thing.quantity = json[4].to_s.to_d
13
14
  thing.amount = json[5].to_s.to_d
14
15
  thing.fee = json[6].to_s.to_d
15
16
  thing.price = json[7].to_s.to_d
16
17
  end
17
18
  end
19
+ # rubocop:enable Metrics/AbcSize
18
20
 
19
21
  private_class_method
20
22
 
21
- def self.orderbooks
23
+ def self.order_books
22
24
  { 1 => :btc_usd, 5 => :btc_ars }
23
25
  end
24
26
 
@@ -33,7 +35,7 @@ module Bitex
33
35
  private
34
36
 
35
37
  def base_quote
36
- orderbook.upcase.to_s.split('_')
38
+ order_book.upcase.to_s.split('_')
37
39
  end
38
40
  end
39
41
  end
@@ -22,6 +22,7 @@ module Bitex
22
22
  @last_tree_fetch = nil
23
23
  end
24
24
 
25
+ # rubocop:disable Metrics/AbcSize
25
26
  def self.calculate_path(value, path)
26
27
  value = value.to_d
27
28
  path_to_calculator(path).each do |step|
@@ -57,12 +58,13 @@ module Bitex
57
58
  end
58
59
  value
59
60
  end
61
+ # rubocop:enable Metrics/AbcSize
60
62
 
61
63
  def self.path_to_calculator(path)
62
64
  steps = tree
63
65
  begin
64
66
  path.each { |step| steps = steps[step] }
65
- rescue StandardError => e
67
+ rescue StandardError
66
68
  raise "InvalidPath: #{path}"
67
69
  end
68
70
  steps
@@ -7,7 +7,7 @@ module Bitex
7
7
  # @!attribute created_at
8
8
  # @return [Time] Time when this Sell happened.
9
9
 
10
- # @!attribute orderbook
10
+ # @!attribute order_book
11
11
  # @return [Symbol] :btc_usd or :btc_ars
12
12
 
13
13
  # @!attribute quantity
@@ -50,6 +50,7 @@ module Bitex
50
50
  attr_accessor :transaction_id
51
51
 
52
52
  # @visibility private
53
+ # rubocop:disable Metrics/AbcSize
53
54
  def self.from_json(json)
54
55
  Api.from_json(new, json) do |thing|
55
56
  thing.specie = { 1 => :btc }[json[3]]
@@ -62,6 +63,7 @@ module Bitex
62
63
  thing.transaction_id = json[10]
63
64
  end
64
65
  end
66
+ # rubocop:enable Metrics/AbcSize
65
67
 
66
68
  def self.create!(specie, address, amount, label, kyc_profile_id = nil)
67
69
  from_json(
@@ -1,3 +1,3 @@
1
1
  module Bitex
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
@@ -6,7 +6,7 @@ describe Bitex::Ask do
6
6
  1, # 0 - API class reference
7
7
  12345678, # 1 - id
8
8
  946685400, # 2 - created_at
9
- 1, # 3 - orderbook
9
+ 1, # 3 - order_book
10
10
  100.0, # 4 - quantity
11
11
  100.0, # 5 - remaining_quantity
12
12
  1000.0, # 6 - price
@@ -18,7 +18,7 @@ describe Bitex::Ask do
18
18
  end
19
19
 
20
20
  it_behaves_like 'API class'
21
- it_behaves_like 'API class with a orderbook'
21
+ it_behaves_like 'API class with a order book'
22
22
  it_behaves_like 'JSON deserializable order'
23
23
 
24
24
  describe 'Api calls' do
@@ -6,7 +6,7 @@ describe Bitex::Bid do
6
6
  1, # 0 - API class reference
7
7
  12_345_678, # 1 - id
8
8
  946_685_400, # 2 - created_at
9
- 1, # 3 - orderbook
9
+ 1, # 3 - order_book
10
10
  100.0, # 4 - quantity
11
11
  100.0, # 5 - remaining_quantity
12
12
  1_000.0, # 6 - price
@@ -18,7 +18,7 @@ describe Bitex::Bid do
18
18
  end
19
19
 
20
20
  it_behaves_like 'API class'
21
- it_behaves_like 'API class with a orderbook'
21
+ it_behaves_like 'API class with a order book'
22
22
  it_behaves_like 'JSON deserializable order'
23
23
 
24
24
  describe 'Api calls' do
@@ -6,7 +6,7 @@ describe Bitex::Buy do
6
6
  4, # 0 - API class reference
7
7
  12_345_678, # 1 - id
8
8
  946_685_400, # 2 - created_at
9
- 1, # 3 - orderbook
9
+ 1, # 3 - order_book
10
10
  100.5, # 4 - quantity
11
11
  201, # 5 - amount
12
12
  0.05, # 6 - fee
@@ -16,7 +16,7 @@ describe Bitex::Buy do
16
16
  end
17
17
 
18
18
  it_behaves_like 'API class'
19
- it_behaves_like 'API class with a orderbook'
19
+ it_behaves_like 'API class with a order book'
20
20
  it_behaves_like 'JSON deserializable match'
21
21
 
22
22
  it 'sets the bid id' do
@@ -6,7 +6,7 @@ describe Bitex::Sell do
6
6
  3, # 0 - API class reference
7
7
  12_345_678, # 1 - id
8
8
  946685400, # 2 - created_at
9
- 1, # 3 - orderbook
9
+ 1, # 3 - order_book
10
10
  100.5, # 4 - quantity
11
11
  201, # 5 - amount
12
12
  0.05, # 6 - fee
@@ -16,7 +16,7 @@ describe Bitex::Sell do
16
16
  end
17
17
 
18
18
  it_behaves_like 'API class'
19
- it_behaves_like 'API class with a orderbook'
19
+ it_behaves_like 'API class with a order book'
20
20
  it_behaves_like 'JSON deserializable match'
21
21
 
22
22
  it 'sets the ask id' do
@@ -9,15 +9,15 @@ shared_examples_for 'API class' do
9
9
  end
10
10
  end
11
11
 
12
- shared_examples_for 'API class with a orderbook' do
13
- it 'makes orderbook 1 into btc_usd' do
12
+ shared_examples_for 'API class with a order book' do
13
+ it 'makes order book 1 into btc_usd' do
14
14
  as_json[3] = 1
15
- subject.class.from_json(as_json).orderbook.should == :btc_usd
15
+ subject.class.from_json(as_json).order_book.should == :btc_usd
16
16
  end
17
17
 
18
18
  it 'makes specie 5 into btc_ars' do
19
19
  as_json[3] = 5
20
- subject.class.from_json(as_json).orderbook.should == :btc_ars
20
+ subject.class.from_json(as_json).order_book.should == :btc_ars
21
21
  end
22
22
  end
23
23
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nubis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-05-09 00:00:00.000000000 Z
12
+ date: 2018-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport