From e71206593772fc71d46f665c8afb44ccd6493010 Mon Sep 17 00:00:00 2001 From: Yury Kotlyarov Date: Mon, 21 Dec 2020 09:30:22 +0700 Subject: [PATCH 1/7] Add orders history --- lib/rest/v2/orders.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/rest/v2/orders.rb b/lib/rest/v2/orders.rb index 49595d1..9e34c00 100644 --- a/lib/rest/v2/orders.rb +++ b/lib/rest/v2/orders.rb @@ -8,6 +8,23 @@ def orders authenticated_post("auth/r/orders").body end + # Returns historic closed or cancelled orders + # + # @param symbol [string] symbol used for the order + # + # @example: + # client.orders_history + # client.orders_history('tBTCUSD') + def orders_history(symbol = nil) + if symbol + path = "v2/auth/r/orders/#{symbol}/hist" + else + path = "v2/auth/r/orders/#{symbol}/hist" + end + + authenticated_post(path).body + end + # Get Trades generated by an Order # # @param order_id [int32] Id of the order From 46e4f482ee9d3aca5e0f73da25a39024114e3f64 Mon Sep 17 00:00:00 2001 From: Yury Kotlyarov Date: Mon, 21 Dec 2020 09:33:01 +0700 Subject: [PATCH 2/7] fixing orders history paths --- lib/rest/v2/orders.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rest/v2/orders.rb b/lib/rest/v2/orders.rb index 9e34c00..bb1f8ab 100644 --- a/lib/rest/v2/orders.rb +++ b/lib/rest/v2/orders.rb @@ -17,9 +17,9 @@ def orders # client.orders_history('tBTCUSD') def orders_history(symbol = nil) if symbol - path = "v2/auth/r/orders/#{symbol}/hist" + path = "auth/r/orders/#{symbol}/hist" else - path = "v2/auth/r/orders/#{symbol}/hist" + path = "auth/r/orders/hist" end authenticated_post(path).body From f3e1f8676ef739baf6f1eef3966d925aefee2d96 Mon Sep 17 00:00:00 2001 From: Yury Kotlyarov Date: Sat, 26 Dec 2020 01:01:30 +0700 Subject: [PATCH 3/7] feat: Pass additional params --- lib/rest/v2/orders.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rest/v2/orders.rb b/lib/rest/v2/orders.rb index bb1f8ab..775e71e 100644 --- a/lib/rest/v2/orders.rb +++ b/lib/rest/v2/orders.rb @@ -15,14 +15,14 @@ def orders # @example: # client.orders_history # client.orders_history('tBTCUSD') - def orders_history(symbol = nil) + def orders_history(symbol=nil, params={}) if symbol path = "auth/r/orders/#{symbol}/hist" else path = "auth/r/orders/hist" end - authenticated_post(path).body + authenticated_post(path, params: params).body end # Get Trades generated by an Order From 26e7b7fb0535f606a594668a948a858b956c0846 Mon Sep 17 00:00:00 2001 From: Yury Kotlyarov Date: Sat, 26 Dec 2020 10:50:09 +0700 Subject: [PATCH 4/7] debug --- lib/rest/rest_client.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/rest/rest_client.rb b/lib/rest/rest_client.rb index b8e547a..199858a 100644 --- a/lib/rest/rest_client.rb +++ b/lib/rest/rest_client.rb @@ -61,6 +61,11 @@ def authenticated_post(url, options = {}) end response = rest_connection.post do |req| + puts "-----------" + puts "url: #{url}" + puts "body: #{body}" + puts "-----------" + req.url complete_url req.body = body.to_json req.options.timeout = config[:rest_timeout] From 61bf400ad86db5d40959872e01de032373cef63a Mon Sep 17 00:00:00 2001 From: Yury Kotlyarov Date: Sat, 26 Dec 2020 11:43:26 +0700 Subject: [PATCH 5/7] named params --- lib/rest/v2/orders.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest/v2/orders.rb b/lib/rest/v2/orders.rb index 775e71e..2e0eadc 100644 --- a/lib/rest/v2/orders.rb +++ b/lib/rest/v2/orders.rb @@ -15,7 +15,7 @@ def orders # @example: # client.orders_history # client.orders_history('tBTCUSD') - def orders_history(symbol=nil, params={}) + def orders_history(symbol: nil, params: {}) if symbol path = "auth/r/orders/#{symbol}/hist" else From 58744e9d64c69f2f38d5676f99e753d5f5c55287 Mon Sep 17 00:00:00 2001 From: Yury Kotlyarov Date: Sat, 26 Dec 2020 11:59:14 +0700 Subject: [PATCH 6/7] cleanup --- lib/rest/rest_client.rb | 5 ----- lib/rest/v2/orders.rb | 6 +++++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/rest/rest_client.rb b/lib/rest/rest_client.rb index 199858a..b8e547a 100644 --- a/lib/rest/rest_client.rb +++ b/lib/rest/rest_client.rb @@ -61,11 +61,6 @@ def authenticated_post(url, options = {}) end response = rest_connection.post do |req| - puts "-----------" - puts "url: #{url}" - puts "body: #{body}" - puts "-----------" - req.url complete_url req.body = body.to_json req.options.timeout = config[:rest_timeout] diff --git a/lib/rest/v2/orders.rb b/lib/rest/v2/orders.rb index 2e0eadc..c9b7ac3 100644 --- a/lib/rest/v2/orders.rb +++ b/lib/rest/v2/orders.rb @@ -11,10 +11,14 @@ def orders # Returns historic closed or cancelled orders # # @param symbol [string] symbol used for the order + # @param params [Hash] can contains id with array of order identifiers, start, end, limit + # + # More at: https://docs.bitfinex.com/reference#rest-auth-orders-history # # @example: # client.orders_history - # client.orders_history('tBTCUSD') + # client.orders_history(symbol: 'tBTCUSD') + # client.orders_history(symbol: 'tBTCUSD', params: { id: [123, 234] }) def orders_history(symbol: nil, params: {}) if symbol path = "auth/r/orders/#{symbol}/hist" From ddc9ef4d33c7d8509e72d8949e957fbe291ed937 Mon Sep 17 00:00:00 2001 From: Yury Kotlyarov Date: Sat, 26 Dec 2020 15:54:38 +0700 Subject: [PATCH 7/7] docs --- lib/rest/v2/orders.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/rest/v2/orders.rb b/lib/rest/v2/orders.rb index c9b7ac3..e00c7bc 100644 --- a/lib/rest/v2/orders.rb +++ b/lib/rest/v2/orders.rb @@ -11,15 +11,19 @@ def orders # Returns historic closed or cancelled orders # # @param symbol [string] symbol used for the order - # @param params [Hash] can contains id with array of order identifiers, start, end, limit - # - # More at: https://docs.bitfinex.com/reference#rest-auth-orders-history + # @param params :start [int32] Millisecond start time + # @param params :end [int32] Millisecond end time + # @param params :limit [int32] Number of records + # @param params :id [Array] Allows you to retrieve specific orders by order ID (id: [ID1, ID2, ID3]) + # + # @return [Array] # # @example: # client.orders_history # client.orders_history(symbol: 'tBTCUSD') # client.orders_history(symbol: 'tBTCUSD', params: { id: [123, 234] }) def orders_history(symbol: nil, params: {}) + check_params(params, %i{start end limit id}) if symbol path = "auth/r/orders/#{symbol}/hist" else