From fd5aac3c5e649221c29dc58f05a46f660d15ff68 Mon Sep 17 00:00:00 2001 From: ezeswci Date: Fri, 31 Aug 2018 11:42:35 -0300 Subject: [PATCH 1/3] Add logic for not sending symbol on founding offers, credits and loans --- lib/transports/rest2.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/transports/rest2.js b/lib/transports/rest2.js index 20f26127..194685a3 100644 --- a/lib/transports/rest2.js +++ b/lib/transports/rest2.js @@ -527,7 +527,7 @@ class RESTv2 { } /** - * @param {string} symbol + * @param {string} symbol - optional, omit/leave empty for all * @param {number} start * @param {number} end * @param {number} limit @@ -535,8 +535,11 @@ class RESTv2 { * @return {Promise} p * @see https://docs.bitfinex.com/v2/reference#rest-auth-funding-offers-hist */ - fundingOfferHistory (symbol = 'tBTCUSD', start = null, end = null, limit = null, cb) { - return this._makeAuthRequest(`/auth/r/funding/offers/${symbol}/hist`, { + fundingOfferHistory (symbol, start = null, end = null, limit = null, cb) { + const url = !_isEmpty(symbol) + ? `/auth/r/funding/offers/${symbol}/hist` + : '/auth/r/funding/offers/hist' + return this._makeAuthRequest(url, { start, end, limit }, cb, FundingOffer) } @@ -552,7 +555,7 @@ class RESTv2 { } /** - * @param {string} symbol + * @param {string} symbol - optional, omit/leave empty for all * @param {number} start * @param {number} end * @param {number} limit @@ -560,8 +563,11 @@ class RESTv2 { * @return {Promise} p * @see https://docs.bitfinex.com/v2/reference#rest-auth-funding-loans-hist */ - fundingLoanHistory (symbol = 'tBTCUSD', start = null, end = null, limit = null, cb) { - return this._makeAuthRequest(`/auth/r/funding/loans/${symbol}/hist`, { + fundingLoanHistory (symbol, start = null, end = null, limit = null, cb) { + const url = !_isEmpty(symbol) + ? `/auth/r/funding/loans/${symbol}/hist` + : '/auth/r/funding/loans/hist' + return this._makeAuthRequest(url, { start, end, limit }, cb, FundingLoan) } @@ -577,7 +583,7 @@ class RESTv2 { } /** - * @param {string} symbol + * @param {string} symbol - optional, omit/leave empty for all * @param {number} start * @param {number} end * @param {number} limit @@ -585,8 +591,11 @@ class RESTv2 { * @return {Promise} p * @see https://docs.bitfinex.com/v2/reference#rest-auth-funding-credits-hist */ - fundingCreditHistory (symbol = 'tBTCUSD', start = null, end = null, limit = null, cb) { - return this._makeAuthRequest(`/auth/r/funding/credits/${symbol}/hist`, { + fundingCreditHistory (symbol, start = null, end = null, limit = null, cb) { + const url = !_isEmpty(symbol) + ? `/auth/r/funding/credits/${symbol}/hist` + : '/auth/r/funding/credits/hist' + return this._makeAuthRequest(url, { start, end, limit }, cb, FundingCredit) } From ac551d653de6d80ec43eaecaf63aa0efc1d4fde0 Mon Sep 17 00:00:00 2001 From: ezeswci Date: Fri, 31 Aug 2018 11:43:52 -0300 Subject: [PATCH 2/3] Add tests for not sending symbols on founding offers, credits and loans --- test/lib/transports/rest-2-integration.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/lib/transports/rest-2-integration.js b/test/lib/transports/rest-2-integration.js index 2284829c..dac368d5 100644 --- a/test/lib/transports/rest-2-integration.js +++ b/test/lib/transports/rest-2-integration.js @@ -111,10 +111,13 @@ describe('RESTv2 integration (mock server) tests', () => { ['positions'], ['fundingOffers', 'f_offers.sym', ['sym']], ['fundingOfferHistory', 'f_offer_hist.sym.start.end.limit', ['sym', 'start', 'end', 'limit']], + ['fundingOfferHistory', 'f_offer_hist.start.end.limit', ['', 'start', 'end', 'limit']], ['fundingLoans', 'f_loans.sym', ['sym']], ['fundingLoanHistory', 'f_loan_hist.sym.start.end.limit', ['sym', 'start', 'end', 'limit']], + ['fundingLoanHistory', 'f_loan_hist.start.end.limit', ['', 'start', 'end', 'limit']], ['fundingCredits', 'f_credits.sym', ['sym']], ['fundingCreditHistory', 'f_credit_hist.sym.start.end.limit', ['sym', 'start', 'end', 'limit']], + ['fundingCreditHistory', 'f_credit_hist.start.end.limit', ['', 'start', 'end', 'limit']], ['fundingTrades', 'f_trade_hist.sym.start.end.limit', ['sym', 'start', 'end', 'limit']], ['marginInfo', 'margin_info.k', ['k']], ['fundingInfo', 'f_info.k', ['k']], From fd4899dab9e8f3a7a83eb3307405c599e6afa2a0 Mon Sep 17 00:00:00 2001 From: ezeswci Date: Fri, 31 Aug 2018 11:48:16 -0300 Subject: [PATCH 3/3] Add documentation --- doc/rest2.md | 161 +++++++++++++++++++++++++-------------------------- 1 file changed, 80 insertions(+), 81 deletions(-) diff --git a/doc/rest2.md b/doc/rest2.md index f5ac8e43..23a3ccc6 100644 --- a/doc/rest2.md +++ b/doc/rest2.md @@ -98,9 +98,9 @@ See _makePublicLegacyRequest | Param | Type | | --- | --- | -| method | string | -| params | Object | -| cb | Method | +| method | string | +| params | Object | +| cb | Method | @@ -111,7 +111,7 @@ See _makePublicLegacyRequest | Param | Type | | --- | --- | -| cb | Method | +| cb | Method | @@ -122,8 +122,8 @@ See _makePublicLegacyRequest | Param | Type | Default | | --- | --- | --- | -| symbol | string | "tBTCUSD" | -| cb | Method | | +| symbol | string | "tBTCUSD" | +| cb | Method | | @@ -134,8 +134,8 @@ See _makePublicLegacyRequest | Param | Type | | --- | --- | -| symbols | Array.<string> | -| cb | Method | +| symbols | Array.<string> | +| cb | Method | @@ -146,9 +146,9 @@ See _makePublicLegacyRequest | Param | Type | Default | | --- | --- | --- | -| key | string | "pos.size:1m:tBTCUSD:long" | -| context | string | "hist" | -| cb | Method | | +| key | string | "pos.size:1m:tBTCUSD:long" | +| context | string | "hist" | +| cb | Method | | @@ -174,8 +174,8 @@ See _makePublicLegacyRequest | Param | Type | Default | | --- | --- | --- | -| type | string | "price" | -| cb | Method | | +| type | string | "price" | +| cb | Method | | @@ -186,9 +186,9 @@ See _makePublicLegacyRequest | Param | Type | Default | | --- | --- | --- | -| type | string | "price" | -| symbol | string | "tBTCUSD" | -| price | number | 0 | +| type | string | "price" | +| symbol | string | "tBTCUSD" | +| price | number | 0 | @@ -199,8 +199,8 @@ See _makePublicLegacyRequest | Param | Type | Default | | --- | --- | --- | -| symbol | string | "tBTCUSD" | -| price | number | 0 | +| symbol | string | "tBTCUSD" | +| price | number | 0 | @@ -254,7 +254,7 @@ See _makePublicLegacyRequest | Param | Type | | --- | --- | -| cb | Method | +| cb | Method | @@ -265,7 +265,7 @@ See _makePublicLegacyRequest | Param | Type | | --- | --- | -| cb | Method | +| cb | Method | @@ -321,12 +321,12 @@ See _makePublicLegacyRequest | Param | Type | Default | | --- | --- | --- | -| symbol | string | "tBTCUSD" | -| start | number | | -| end | number | | -| limit | number | | -| orderID | number | | -| cb | Method | | +| symbol | string | "tBTCUSD" | +| start | number | | +| end | number | | +| limit | number | | +| orderID | number | | +| cb | Method | | @@ -337,7 +337,7 @@ See _makePublicLegacyRequest | Param | Type | | --- | --- | -| cb | Method | +| cb | Method | @@ -348,8 +348,8 @@ See _makePublicLegacyRequest | Param | Type | Default | | --- | --- | --- | -| symbol | string | "fUSD" | -| cb | Method | | +| symbol | string | "fUSD" | +| cb | Method | | @@ -360,11 +360,11 @@ See _makePublicLegacyRequest | Param | Type | Default | | --- | --- | --- | -| symbol | string | "tBTCUSD" | -| start | number | | -| end | number | | -| limit | number | | -| cb | Method | | +| symbol | string | optional, omit/leave empty for all | +| start | number | | +| end | number | | +| limit | number | | +| cb | Method | | @@ -375,8 +375,8 @@ See _makePublicLegacyRequest | Param | Type | Default | | --- | --- | --- | -| symbol | string | "fUSD" | -| cb | Method | | +| symbol | string | "fUSD" | +| cb | Method | | @@ -387,11 +387,11 @@ See _makePublicLegacyRequest | Param | Type | Default | | --- | --- | --- | -| symbol | string | "tBTCUSD" | -| start | number | | -| end | number | | -| limit | number | | -| cb | Method | | +| symbol | string | optional, omit/leave empty for all | +| start | number | | +| end | number | | +| limit | number | | +| cb | Method | | @@ -402,8 +402,8 @@ See _makePublicLegacyRequest | Param | Type | Default | | --- | --- | --- | -| symbol | string | "fUSD" | -| cb | Method | | +| symbol | string | "fUSD" | +| cb | Method | | @@ -414,11 +414,11 @@ See _makePublicLegacyRequest | Param | Type | Default | | --- | --- | --- | -| symbol | string | "tBTCUSD" | -| start | number | | -| end | number | | -| limit | number | | -| cb | Method | | +| symbol | string | optional, omit/leave empty for all | +| start | number | | +| end | number | | +| limit | number | | +| cb | Method | | @@ -429,11 +429,11 @@ See _makePublicLegacyRequest | Param | Type | Default | | --- | --- | --- | -| symbol | string | "tBTCUSD" | -| start | number | | -| end | number | | -| limit | number | | -| cb | Method | | +| symbol | string | "tBTCUSD" | +| start | number | | +| end | number | | +| limit | number | | +| cb | Method | | @@ -444,8 +444,8 @@ See _makePublicLegacyRequest | Param | Type | Default | | --- | --- | --- | -| key | string | "base" | -| cb | Method | | +| key | string | "base" | +| cb | Method | | @@ -456,8 +456,8 @@ See _makePublicLegacyRequest | Param | Type | Default | | --- | --- | --- | -| key | string | "fUSD" | -| cb | Method | | +| key | string | "fUSD" | +| cb | Method | | @@ -468,7 +468,7 @@ See _makePublicLegacyRequest | Param | Type | | --- | --- | -| cb | Method | +| cb | Method | @@ -479,11 +479,11 @@ See _makePublicLegacyRequest | Param | Type | Default | | --- | --- | --- | -| symbol | string | "tBTCUSD" | -| dir | string | | -| rate | number | | -| type | string | | -| cb | Method | | +| symbol | string | "tBTCUSD" | +| dir | string | | +| rate | number | | +| type | string | | +| cb | Method | | @@ -513,7 +513,7 @@ Get a list of valid symbol names and details | Param | Type | | --- | --- | -| cb | Method | +| cb | Method | @@ -528,7 +528,7 @@ Request information about your account | Param | Type | | --- | --- | -| cb | Method | +| cb | Method | @@ -543,7 +543,7 @@ Request account withdrawl fees | Param | Type | | --- | --- | -| cb | Method | +| cb | Method | @@ -559,7 +559,7 @@ funding. | Param | Type | | --- | --- | -| cb | Method | +| cb | Method | @@ -651,7 +651,7 @@ Fetch the permissions of the key being used to generate this request | Param | Type | | --- | --- | -| cb | Method | +| cb | Method | @@ -666,7 +666,7 @@ Request your wallet balances | Param | Type | | --- | --- | -| cb | Method | +| cb | Method | @@ -679,10 +679,10 @@ Request your wallet balances | Param | Type | | --- | --- | -| params | Object | -| params.position_id | number | -| params.amount | number | -| cb | Method | +| params | Object | +| params.position_id | number | +| params.amount | number | +| cb | Method | @@ -695,9 +695,9 @@ Request your wallet balances | Param | Type | | --- | --- | -| params | Object | -| params.position_id | number | -| cb | Method | +| params | Object | +| params.position_id | number | +| cb | Method | @@ -718,8 +718,8 @@ Request your wallet balances | Param | Type | | --- | --- | -| keys | Array.<string> | -| cb | Method | +| keys | Array.<string> | +| cb | Method | @@ -729,8 +729,8 @@ Request your wallet balances | Param | Type | | --- | --- | -| keys | Array.<string> | -| cb | Method | +| keys | Array.<string> | +| cb | Method | @@ -742,4 +742,3 @@ Request your wallet balances | --- | --- | --- | | ccy1 | string | i.e. BTC | | ccy2 | string | i.e. USD | -