diff --git a/doc/rest2.md b/doc/rest2.md index 9bc09628..5ecbda1b 100644 --- a/doc/rest2.md +++ b/doc/rest2.md @@ -43,6 +43,7 @@ Communicates with v2 of the Bitfinex HTTP API * [.calcAvailableBalance(symbol, dir, rate, type, cb)](#RESTv2+calcAvailableBalance) ⇒ Promise * [.symbols(cb)](#RESTv2+symbols) ⇒ Promise * [.futures(cb)](#RESTv2+futures) ⇒ Promise + * [.derivsPositionCollateralSet(symbol, collateral, cb)](#RESTv2+derivsPositionCollateralSet) ⇒ Promise * ~~[.symbolDetails(cb)](#RESTv2+symbolDetails) ⇒ Promise~~ * ~~[.accountInfo(cb)](#RESTv2+accountInfo) ⇒ Promise~~ * ~~[.accountFees(cb)](#RESTv2+accountFees) ⇒ Promise~~ @@ -562,6 +563,21 @@ Get a list of valid symbol names | --- | --- | --- | | cb | Method | legacy callback | + +### resTv2.derivsPositionCollateralSet(symbol, collateral, cb) ⇒ Promise + +Changes the collateral value of an active derivatives position for a certain pair. + +**Kind**: instance method of [RESTv2](#RESTv2) +**Returns**: Promise - p +**See**: https://docs.bitfinex.com/v2/reference#rest-auth-deriv-pos-collateral-set + +| Param | Type | Description | +| --- | --- | --- | +| symbol | string | "tBTCF0:USDF0" | +| collateral | number | | +| cb | Method | | + ### ~~resTv2.symbolDetails(cb) ⇒ Promise~~ diff --git a/lib/rest2.js b/lib/rest2.js index af165d0e..0362fad8 100644 --- a/lib/rest2.js +++ b/lib/rest2.js @@ -886,6 +886,24 @@ class RESTv2 { }) } + /** + * Changes the collateral value of an active derivatives position for a certain pair. + * + * @param {string} symbol + * @param {number} collateral + * @param {Method?} cb - legacy callback + * @return {Promise} p + * @see https://docs.bitfinex.com/v2/reference#rest-auth-deriv-pos-collateral-set + */ + + derivsPositionCollateralSet (symbol, collateral, cb) { + const url = '/auth/w/deriv/collateral/set' + const isRequestValid = (res) => !!(res && res[0] && res[0][0]) + return this._makeAuthRequest(url, { + symbol, collateral + }, cb, isRequestValid) + } + /** * Get a list of valid symbol names and details * diff --git a/package.json b/package.json index b2f963ff..fd8971b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bfx-api-node-rest", - "version": "1.1.1", + "version": "1.1.2", "description": "Official Bitfinex REST v1 & v2 API interfaces", "engines": { "node": ">=7" @@ -37,15 +37,15 @@ "url": "https://github.com/bitfinexcom/bfx-api-node-rest/issues" }, "devDependencies": { - "bfx-api-mock-srv": "git+https://github.com/bitfinexcom/bfx-api-mock-srv.git", "babel-cli": "^6.26.0", "babel-plugin-transform-object-rest-spread": "^6.26.0", "babel-plugin-transform-regenerator": "^6.26.0", "babel-preset-env": "^1.7.0", + "bfx-api-mock-srv": "git+https://github.com/bitfinexcom/bfx-api-mock-srv.git", "chai": "^3.4.1", - "mocha": "^3.4.2", - "standard": "^10.0.2", - "jsdoc-to-markdown": "^1.3.1" + "jsdoc-to-markdown": "^5.0.0", + "mocha": "^6.1.4", + "standard": "^10.0.2" }, "dependencies": { "bfx-api-node-models": "^1.0.0", @@ -53,7 +53,7 @@ "bluebird": "^3.5.1", "copy": "^0.3.2", "debug": "^2.2.0", - "lodash": "^4.17.4", + "lodash": "^4.17.14", "request": "^2.67.0", "request-promise": "^4.2.0" } diff --git a/test/lib/rest-2-integration.js b/test/lib/rest-2-integration.js index 9c0242c7..5f3db45c 100644 --- a/test/lib/rest-2-integration.js +++ b/test/lib/rest-2-integration.js @@ -119,6 +119,7 @@ describe('RESTv2 integration (mock server) tests', () => { ['fundingTrades', 'f_trade_hist.sym.start.end.limit', ['sym', 'start', 'end', 'limit']], ['marginInfo', 'margin_info.k', ['k']], ['fundingInfo', 'f_info.k', ['k']], + ['derivsPositionCollateralSet', 'derivs_pos_col_set.symbol.collateral', ['symbol', 'collateral']], ['performance'], ['calcAvailableBalance', 'calc.sym.dir.rate.type', ['sym', 'dir', 'rate', 'type']] ]