UNPKG

nefertiti-node

Version:

ES module to work with Nefertiti crypto trade bot.

2,001 lines 25.1 kB
<!DOCTYPE html>
<html lang="en">
<head>
    
    <meta charset="utf-8">
    <title>Global - Documentation</title>
    
    
    <script src="scripts/prettify/prettify.js"></script>
    <script src="scripts/prettify/lang-css.js"></script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
    <script src="scripts/nav.js" defer></script>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
  <div class="navicon"></div>
</label>

<label for="nav-trigger" class="overlay"></label>

<nav >
    
    <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#deleteBot">deleteBot</a></li><li><a href="global.html#downloadNefertiti">downloadNefertiti</a></li><li><a href="global.html#filterMarketsByCurrency">filterMarketsByCurrency</a></li><li><a href="global.html#getAvailableMarkets">getAvailableMarkets</a></li><li><a href="global.html#getCurrentNefVersion">getCurrentNefVersion</a></li><li><a href="global.html#getSupportedExchanges">getSupportedExchanges</a></li><li><a href="global.html#pingBot">pingBot</a></li><li><a href="global.html#pingHub">pingHub</a></li><li><a href="global.html#postBot">postBot</a></li><li><a href="global.html#sendNotificationsTest">sendNotificationsTest</a></li><li><a href="global.html#updateBot">updateBot</a></li><li><a href="global.html#updateNef">updateNef</a></li></ul>
</nav>

<div id="main">
    
    <h1 class="page-title">Global</h1>
    

    




<section>

<header>
    
        <h2>
        
        </h2>
        
    
</header>

<article>
    
        <div class="container-overview">
        
            

<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>




            

            
        
        </div>
    

    

    

    
    
    

     

    

    

    
        <h3 class="subsection-title">Methods</h3>

        
            

    

    <h4 class="name" id="deleteBot"><span class="type-signature"></span>deleteBot<span class="signature">(port)</span><span class="type-signature"> &rarr; {Error}</span></h4>

    




<dl class="details">

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="api_delete.js.html">api/delete.js</a>, <a href="api_delete.js.html#line5">line 5</a>
    </li></ul></dd>
    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>





<div class="description usertext">
    <p>Function to stop and remove a bot.</p>
<ul>
<li>Does NOT consider cancelling orders</li>
</ul>
</div>









    <h5>Example</h5>
    
    <pre class="prettyprint"><code>// just issue the command directly, but expect no response:

deleteBot(38701)</code></pre>




    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>port</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>
|

<span class="param-type">number</span>


            
            </td>

            

            

            <td class="description last"><p>The port number of the bot to stop/remove</p></td>
        </tr>

    
    </tbody>
</table>
















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>return an error as of Nov 2021</p>
</div>



<dl class="param-type">
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Error</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id="downloadNefertiti"><span class="type-signature"></span>downloadNefertiti<span class="signature">()</span><span class="type-signature"></span></h4>

    




<dl class="details">

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="helpers_github-downloader.js.html">helpers/github-downloader.js</a>, <a href="helpers_github-downloader.js.html#line27">line 27</a>
    </li></ul></dd>
    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>





<div class="description usertext">
    <p>Downloads the latest release from GitHub for the client platform and architecture.</p>
</div>




























        
            

    

    <h4 class="name" id="filterMarketsByCurrency"><span class="type-signature"></span>filterMarketsByCurrency<span class="signature">(exchangeCode, filterCurrency)</span><span class="type-signature"></span></h4>

    




<dl class="details">

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="functions_filterMarketsByCurrency.js.html">functions/filterMarketsByCurrency.js</a>, <a href="functions_filterMarketsByCurrency.js.html#line3">line 3</a>
    </li></ul></dd>
    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>





<div class="description usertext">
    <p>Filter all of the markets that match a string</p>
</div>









    <h5>Example</h5>
    
    <pre class="prettyprint"><code>const gdaxEthMarkets = filtermarketsByCurrency('gdax', 'ETH-')
 console.log(gdaxEthMarkets)
[
{ name: 'ETH-USDT' },
{ name: 'ETH-GBP' },
{ name: 'ETH-EUR' },
{ name: 'ETH-DAI' },
{ name: 'ETH-BTC' },
{ name: 'ETH-USDC' },
{ name: 'ETH-USD' }
]</code></pre>




    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>exchangeCode</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>Can be exchange code (KUCN)or full name</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>filterCurrency</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>Case-sensitive market to search
Can be used as a quote currency with a hyphen in the correct place ('-BTC')</p></td>
        </tr>

    
    </tbody>
</table>
















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>an array of market objects that contain a string including @filterCurrency</p>
</div>



    



        
            

    

    <h4 class="name" id="getAvailableMarkets"><span class="type-signature"></span>getAvailableMarkets<span class="signature">(exchangeCode)</span><span class="type-signature"> &rarr; {array}</span></h4>

    




<dl class="details">

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="functions_getAvailableMarkets.js.html">functions/getAvailableMarkets.js</a>, <a href="functions_getAvailableMarkets.js.html#line4">line 4</a>
    </li></ul></dd>
    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>





<div class="description usertext">
    <p>Get all of the available markets for an exchange</p>
</div>









    <h5>Example</h5>
    
    <pre class="prettyprint"><code>const gdaxMarkets = getAvailableMarkets('gdax');</code></pre>




    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>exchangeCode</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>Exchange to use. can be code: 'kucn' or name: 'kucoin'</p></td>
        </tr>

    
    </tbody>
</table>
















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>returns an array of objects</p>
</div>



<dl class="param-type">
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">array</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id="getCurrentNefVersion"><span class="type-signature"></span>getCurrentNefVersion<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>

    




<dl class="details">

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="functions_getCurrentNefVersion.js.html">functions/getCurrentNefVersion.js</a>, <a href="functions_getCurrentNefVersion.js.html#line4">line 4</a>
    </li></ul></dd>
    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>





<div class="description usertext">
    <p>Check the current version of Nefertiti</p>
</div>









    <h5>Example</h5>
    
    <pre class="prettyprint"><code>const currentVersion = getCurrentNefVersion();
      console.log(currentVersion);</code></pre>


















<h5>Returns:</h5>

        
<div class="param-desc">
    <ul>
<li>current version of Nefertiti</li>
</ul>
</div>



<dl class="param-type">
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">string</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id="getSupportedExchanges"><span class="type-signature"></span>getSupportedExchanges<span class="signature">()</span><span class="type-signature"> &rarr; {array}</span></h4>

    




<dl class="details">

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="functions_getSupportedExchanges.js.html">functions/getSupportedExchanges.js</a>, <a href="functions_getSupportedExchanges.js.html#line4">line 4</a>
    </li></ul></dd>
    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>





<div class="description usertext">
    <p>Check which exchanges are currently supported by Nefertiti</p>
</div>









    <h5>Example</h5>
    
    <pre class="prettyprint"><code>const availableExchanges = getSupportedExchanges();
   console.log(availableExchanges)</code></pre>


















<h5>Returns:</h5>

        
<div class="param-desc">
    <ul>
<li>an array of objects of each supported exchange</li>
</ul>
</div>



<dl class="param-type">
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">array</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id="pingBot"><span class="type-signature"></span>pingBot<span class="signature">(port)</span><span class="type-signature"> &rarr; {JSON}</span></h4>

    




<dl class="details">

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="api_pingBot.js.html">api/pingBot.js</a>, <a href="api_pingBot.js.html#line4">line 4</a>
    </li></ul></dd>
    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>





<div class="description usertext">
    <p>Request information for a specific bot</p>
</div>









    <h5>Example</h5>
    
    <pre class="prettyprint"><code>// Call the function and chain it with .then():

pingBot(38701).then((results)=>{console.log(results)})

// or await it

const sellBot = await pingBot(38701)

// Return object example:
{
  port: 38701,
  command: 'sell',
  args: [ 'listen',...]
}</code></pre>




    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>port</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>
|

<span class="param-type">number</span>


            
            </td>

            

            

            <td class="description last"><p>The port that the bot is running on.</p></td>
        </tr>

    
    </tbody>
</table>
















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>Returns a JSON object</p>
</div>



<dl class="param-type">
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">JSON</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id="pingHub"><span class="type-signature"></span>pingHub<span class="signature">()</span><span class="type-signature"> &rarr; {JSON}</span></h4>

    




<dl class="details">

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="api_pingHub.js.html">api/pingHub.js</a>, <a href="api_pingHub.js.html#line4">line 4</a>
    </li></ul></dd>
    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>





<div class="description usertext">
    <p>Ping the listen server to get all running bots</p>
</div>









    <h5>Example</h5>
    
    <pre class="prettyprint"><code>// Call the function and chain it with .then():

pingHub().then((results) => {
    console.log(results, results.length);
  });

// Return object example:
[{
  port: 38701,
  command: 'sell',
  args: ['listen',...]
},
{
  port: 38702,
  command: 'buy',
  args: ['listen',...]
}]</code></pre>


















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>Returns parsed JSON array of objects</p>
</div>



<dl class="param-type">
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">JSON</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id="postBot"><span class="type-signature"></span>postBot<span class="signature">(command, api, args)</span><span class="type-signature"> &rarr; {Promise.&lt;array>}</span></h4>

    




<dl class="details">

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="api_post.js.html">api/post.js</a>, <a href="api_post.js.html#line5">line 5</a>
    </li></ul></dd>
    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>





<div class="description usertext">
    <p>Issue a POST request to start a bot</p>
</div>









    <h5>Example</h5>
    
    <pre class="prettyprint"><code>apis.postBot('buy', ['gdax', 'apiKey123',...], {'mult': 1.05,...})
  .then((res) => {
     console.table(res);
});</code></pre>




    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>command</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>must be either 'sell' or 'buy'</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>api</code></td>
            

            <td class="type">
            
                
<span class="param-type">array</span>


            
            </td>

            

            

            <td class="description last"><p>An array of exchange API key information. Must be in this order: [<exchange>,<api key>, <api secret>,<api passphrase>]</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>args</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            

            

            <td class="description last"><p>Object keys are Nefertiti flags with appropriate values: {'mult': 1.05, 'market': 'BTC-USD'}</p></td>
        </tr>

    
    </tbody>
</table>
















<h5>Returns:</h5>

        
<div class="param-desc">
    <ul>
<li>Returns an array of objects with running bot information. Should be chained with '.then()'</li>
</ul>
</div>



<dl class="param-type">
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Promise.&lt;array></span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id="sendNotificationsTest"><span class="type-signature"></span>sendNotificationsTest<span class="signature">(service, appKey, chatKey)</span><span class="type-signature"></span></h4>

    




<dl class="details">

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="functions_sendNotificationsTest.js.html">functions/sendNotificationsTest.js</a>, <a href="functions_sendNotificationsTest.js.html#line5">line 5</a>
    </li></ul></dd>
    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>





<div class="description usertext">
    <p>Sends a message to the notifications service</p>
</div>











    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>service</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>the notification service. can be 'pushover' or 'telegram'</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>appKey</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>application key</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>chatKey</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>chat key (for telegram) or user key (for pushover)</p></td>
        </tr>

    
    </tbody>
</table>



















        
            

    

    <h4 class="name" id="updateBot"><span class="type-signature"></span>updateBot<span class="signature">(port, args)</span><span class="type-signature"> &rarr; {Promise.&lt;array>}</span></h4>

    




<dl class="details">

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="api_update.js.html">api/update.js</a>, <a href="api_update.js.html#line5">line 5</a>
    </li></ul></dd>
    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>





<div class="description usertext">
    <p>Issue a POST request to update a specific bot</p>
</div>









    <h5>Example</h5>
    
    <pre class="prettyprint"><code>updateBot(38702, { mult: '1.1' }).then((res) => {
   console.log(res)
 }</code></pre>




    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>port</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>
|

<span class="param-type">number</span>


            
            </td>

            

            

            <td class="description last"><p>Port of the bot to update</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>args</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            

            

            <td class="description last"><p>Object keys are Nefertiti flags with appropriate values {'mult': 1.05}</p></td>
        </tr>

    
    </tbody>
</table>
















<h5>Returns:</h5>

        
<div class="param-desc">
    <ul>
<li>Returns an array of objects with running bot information. Should be chained with '.then()'</li>
</ul>
</div>



<dl class="param-type">
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Promise.&lt;array></span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id="updateNef"><span class="type-signature"></span>updateNef<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>

    




<dl class="details">

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="functions_updateNef.js.html">functions/updateNef.js</a>, <a href="functions_updateNef.js.html#line4">line 4</a>
    </li></ul></dd>
    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>





<div class="description usertext">
    <p>Update the Nefertiti binary to the latest version</p>
</div>

























<h5>Returns:</h5>

        
<div class="param-desc">
    <ul>
<li>the results of the update, including version</li>
</ul>
</div>



<dl class="param-type">
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">string</span>


    </dd>
</dl>

    



        
    

    

    
</article>

</section>




    
    
</div>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.7</a> on Sat Dec 18 2021 15:50:34 GMT-0600 (Central Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>



</body>
</html>