Skip to content

Commit

Permalink
Merge pull request #32 from ezewer/liquidations
Browse files Browse the repository at this point in the history
Liquidations
  • Loading branch information
prdn authored Aug 6, 2019
2 parents 6e20b2a + b77b20c commit 4df72bb
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
18 changes: 18 additions & 0 deletions doc/rest2.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Communicates with v2 of the Bitfinex HTTP API
* [.stats(key, context, cb)](#RESTv2+stats) ⇒ <code>Promise</code>
* [.candles(opts, cb)](#RESTv2+candles) ⇒ <code>Promise</code>
* [.currencies(cb)](#RESTv2+currencies) ⇒ <code>Promise</code>
* [.liquidations(cb)](#RESTv2+liquidations) ⇒ <code>Promise</code>
* [.alertList(type, cb)](#RESTv2+alertList) ⇒ <code>Promise</code>
* [.alertSet(type, symbol, price)](#RESTv2+alertSet) ⇒ <code>Promise</code>
* [.alertDelete(symbol, price)](#RESTv2+alertDelete) ⇒ <code>Promise</code>
Expand Down Expand Up @@ -184,6 +185,23 @@ Get a list of valid currencies ids and full names
| --- | --- | --- |
| cb | <code>Method</code> | legacy callback |

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

### resTv2.liquidations (start, end, limit, sort, cb) ⇒ <code>Promise</code>
Offers a feed of current and past liquidations

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

| Param | Type | Description |
| --- | --- | --- |
| start | <code>number</code> | <code></code> | |
| end | <code>number</code> | <code></code> | |
| limit | <code>number</code> | <code></code> | |
| sort | <code>number</code> | <code></code> | if 1, sorts results oldest first |
| cb | <code>Method</code> | | |

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

### resTv2.alertList(type, cb) ⇒ <code>Promise</code>
Expand Down
28 changes: 28 additions & 0 deletions lib/rest2.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const {
Candle,
Movement,
LedgerEntry,
Liquidations,
UserInfo,
Currency,
StatusMessagesDeriv
Expand Down Expand Up @@ -558,6 +559,33 @@ class RESTv2 {
return this._makePublicRequest(url, cb, PublicTrade)
}

/**
* @param {string} symbol
* @param {number?} start
* @param {number?} end
* @param {number?} limit
* @param {number?} sort - if 1, sorts results oldest first
* @param {Method} cb
* @return {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-public-liquidations
*/
liquidations (start = null, end = null, limit = null, sort = null, cb) {
const query = {}

if (start !== null) query.start = start
if (end !== null) query.end = end
if (limit !== null) query.limit = limit
if (sort !== null) query.sort = sort

let url = '/liquidations/hist'

if (Object.keys(query).length > 0) {
url += `?${new URLSearchParams(query).toString()}`
}

return this._makePublicRequest(url, cb, Liquidations)
}

/**
* @param {string?} symbol - optional, omit/leave empty for all
* @param {number} start
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bfx-api-node-rest",
"version": "1.1.2",
"version": "1.1.3",
"description": "Official Bitfinex REST v1 & v2 API interfaces",
"engines": {
"node": ">=7"
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 @@ -95,6 +95,7 @@ describe('RESTv2 integration (mock server) tests', () => {
['ticker', 'ticker.tBTCUSD', ['tBTCUSD']],
['tickers', 'tickers', [['tBTCUSD', 'tETHUSD']]],
['tickersHistory', 'tickers_hist', [['tBTCUSD', 'tETHUSD'], 'start', 'end', 'limit']],
['liquidations', 'liquidations.start.end.limit.sort', ['start', 'end', 'limit', 'sort']],
['stats', 'stats.key.context', ['key', 'context']],
['candles', 'candles.trade:30m:tBTCUSD.hist', [{ timeframe: '30m', symbol: 'tBTCUSD', section: 'hist' }]],
['statusMessages', 'status_messages.deriv.ALL', ['deriv', ['ALL']]],
Expand Down

0 comments on commit 4df72bb

Please sign in to comment.