Skip to content

Commit

Permalink
Merge pull request #29 from ezewer/deriv-pos-col-set
Browse files Browse the repository at this point in the history
Deriv pos col set
  • Loading branch information
prdn authored Jul 18, 2019
2 parents e9607ff + 8c64437 commit 22355b9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
16 changes: 16 additions & 0 deletions doc/rest2.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Communicates with v2 of the Bitfinex HTTP API
* [.calcAvailableBalance(symbol, dir, rate, type, cb)](#RESTv2+calcAvailableBalance) ⇒ <code>Promise</code>
* [.symbols(cb)](#RESTv2+symbols) ⇒ <code>Promise</code>
* [.futures(cb)](#RESTv2+futures) ⇒ <code>Promise</code>
* [.derivsPositionCollateralSet(symbol, collateral, cb)](#RESTv2+derivsPositionCollateralSet) ⇒ <code>Promise</code>
* ~~[.symbolDetails(cb)](#RESTv2+symbolDetails) ⇒ <code>Promise</code>~~
* ~~[.accountInfo(cb)](#RESTv2+accountInfo) ⇒ <code>Promise</code>~~
* ~~[.accountFees(cb)](#RESTv2+accountFees) ⇒ <code>Promise</code>~~
Expand Down Expand Up @@ -562,6 +563,21 @@ Get a list of valid symbol names
| --- | --- | --- |
| cb | <code>Method</code> | legacy callback |

<a name="RESTv2+derivsPositionCollateralSet"></a>
### resTv2.derivsPositionCollateralSet(symbol, collateral, cb) ⇒ <code>Promise</code>

Changes the collateral value of an active derivatives position for a certain pair.

**Kind**: instance method of <code>[RESTv2](#RESTv2)</code>
**Returns**: <code>Promise</code> - p
**See**: https://docs.bitfinex.com/v2/reference#rest-auth-deriv-pos-collateral-set

| Param | Type | Description |
| --- | --- | --- |
| symbol | <code>string</code> | <code>&quot;tBTCF0:USDF0&quot;</code> |
| collateral | <code>number</code> | |
| cb | <code>Method</code> | |

<a name="RESTv2+symbolDetails"></a>

### ~~resTv2.symbolDetails(cb) ⇒ <code>Promise</code>~~
Expand Down
18 changes: 18 additions & 0 deletions lib/rest2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -37,23 +37,23 @@
"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",
"bfx-api-node-util": "^1.0.0",
"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"
}
Expand Down
1 change: 1 addition & 0 deletions test/lib/rest-2-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']]
]
Expand Down

0 comments on commit 22355b9

Please sign in to comment.