UNPKG

bfx-api-node-util

Version:
146 lines (111 loc) 4.78 kB
## Functions <dl> <dt><a href="#genAuthSig">genAuthSig(apiSecret, payload)</a><code>Object</code></dt> <dd><p>Generates an auth signature, payload, and nonce for passing to the WS &amp; REST APIs</p> </dd> <dt><a href="#isClass">isClass(f)</a><code>boolean</code></dt> <dd></dd> <dt><a href="#isSnapshot">isSnapshot(msg)</a><code>boolean</code></dt> <dd></dd> <dt><a href="#nonce">nonce()</a><code>number</code></dt> <dd><p>Generates a new nonce for usage with the Bitfinex APIs</p> </dd> <dt><a href="#padCandles">padCandles(candles, candleWidth)</a><code>Array.&lt;Array&gt;</code></dt> <dd><p>Fills in missing (0 volume) candles on the provided dataset. The result is a new array (does not mutate)</p> </dd> <dt><a href="#setSigFig">setSigFig(n, maxSigs)</a><code>string</code></dt> <dd><p>Smartly set the precision (decimal) on a value based off of the significant digit maximum. For example, calling with 3.34 when the max sig figs allowed is 5 would return &#39;3.3400&#39;, the representation number of decimals IF they weren&#39;t zeros.</p> </dd> <dt><a href="#setPrecision">setPrecision(number, decimals)</a><code>string</code></dt> <dd><p>Casts the provided value to a number if required, and limits the number of decimals to the specified value. Returns a decimal string.</p> </dd> <dt><a href="#prepareAmount">prepareAmount(amount)</a><code>string</code></dt> <dd><p>Prepares a amount for submitting via the API</p> </dd> <dt><a href="#preparePrice">preparePrice(price)</a><code>string</code></dt> <dd><p>Prepares a price for submitting via the API</p> </dd> </dl> <a name="genAuthSig"></a> ## genAuthSig(apiSecret, payload) ⇒ <code>Object</code> Generates an auth signature, payload, and nonce for passing to the WS & REST APIs **Kind**: global function **Returns**: <code>Object</code> - authSignature | Param | Type | Description | | --- | --- | --- | | apiSecret | <code>string</code> | | | payload | <code>string</code> | optional signature payload, generated by default | <a name="isClass"></a> ## isClass(f) ⇒ <code>boolean</code> **Kind**: global function **Returns**: <code>boolean</code> - isClass | Param | Type | | --- | --- | | f | <code>Class</code> | <a name="isSnapshot"></a> ## isSnapshot(msg) ⇒ <code>boolean</code> **Kind**: global function **Returns**: <code>boolean</code> - isSnapshot | Param | Type | | --- | --- | | msg | <code>Array</code> \| <code>Array.&lt;Array&gt;</code> | <a name="nonce"></a> ## nonce() ⇒ <code>number</code> Generates a new nonce for usage with the Bitfinex APIs **Kind**: global function **Returns**: <code>number</code> - nonce <a name="padCandles"></a> ## padCandles(candles, candleWidth) ⇒ <code>Array.&lt;Array&gt;</code> Fills in missing (0 volume) candles on the provided dataset. The result is a new array (does not mutate) **Kind**: global function **Returns**: <code>Array.&lt;Array&gt;</code> - paddedCandles | Param | Type | Description | | --- | --- | --- | | candles | <code>Array.&lt;Array&gt;</code> | array-format candles | | candleWidth | <code>number</code> | in ms | <a name="setSigFig"></a> ## setSigFig(n, maxSigs) ⇒ <code>string</code> Smartly set the precision (decimal) on a value based off of the significant digit maximum. For example, calling with 3.34 when the max sig figs allowed is 5 would return '3.3400', the representation number of decimals IF they weren't zeros. **Kind**: global function **Returns**: <code>string</code> - str | Param | Type | Description | | --- | --- | --- | | n | <code>number</code> | | | maxSigs | <code>number</code> | default 5 | <a name="setPrecision"></a> ## setPrecision(number, decimals) ⇒ <code>string</code> Casts the provided value to a number if required, and limits the number of decimals to the specified value. Returns a decimal string. **Kind**: global function **Returns**: <code>string</code> - result | Param | Type | Default | | --- | --- | --- | | number | <code>number</code> \| <code>string</code> | <code>0</code> | | decimals | <code>number</code> | <code>0</code> | <a name="prepareAmount"></a> ## prepareAmount(amount) ⇒ <code>string</code> Prepares a amount for submitting via the API **Kind**: global function **Returns**: <code>string</code> - preparedAmount | Param | Type | Default | | --- | --- | --- | | amount | <code>number</code> \| <code>string</code> | <code>0</code> | <a name="preparePrice"></a> ## preparePrice(price) ⇒ <code>string</code> Prepares a price for submitting via the API **Kind**: global function **Returns**: <code>string</code> - preparedPrice | Param | Type | Default | | --- | --- | --- | | price | <code>number</code> \| <code>string</code> | <code>0</code> |