Javascript bot programming using Gemini API, NodeJS and CryptoCompare - DISCUSSION

hello,

i get this when trying the buy order.

Windows PowerShell
Copyright © Microsoft Corporation. All rights reserved.

PS C:\Users\GamerX> cd “C:\Users\GamerX\Desktop\Ivan on tech academy\code”
PS C:\Users\GamerX\Desktop\Ivan on tech academy\code> node index.js
(node:4892) UnhandledPromiseRejectionWarning: #
(Use node --trace-warnings ... to show where the warning was created)
(node:4892) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:4892) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
PS C:\Users\GamerX\Desktop\Ivan on tech academy\code>

best regards,

Glenn

1 Like

hello @Glenn, hope you are ok.

Try to run your commands with windows console instead of PowerShell. To open windows console just use cmd to open it. Let me know if that works for you :nerd_face:

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

Hello everyone !

I built my strategy and my javascript trading bot.

Now, I would like to run it on a cloud server, like Google Cloud Platform. (24/24 running, stability, etc…)

Has anyone tried to do this ? Could anyone help me, give me some advises or links to learn that ?

I know almost nothing about web development but I’m very motivated for this project. (in fact I think this next step could be a very interesting following to the course)

1 Like

I could suggest: https://vpsdime.com/

You will need to learn about VPS, which is a virtual private server, how to deploy your own website or script on a vps that will be 24/7 executing your code.

There are tons of videos on youtube to learn how to deploy VPS, is a little bit complex but not impossible, also is like programming a personal worker for you 24/7.

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

1 Like

I am having major issues when trying to setup and use yarn and gemini sandbox.

I keep getting this error.

PS C:\Users\jaber\Documents> node index.js
(node:11996) UnhandledPromiseRejectionWarning: #
(Use node --trace-warnings ... to show where the warning was created)
(node:11996) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:11996) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I have checked online, tried using Command Prompt instead of PowerShell, I have tried creating new API keys, tried using master API key, tried using the examples in READme, tried the CLI flag mentioned in the error message and nodejs.org, I have authorized my PC and my IP address for use with Gemini…

PLZ help.

1 Like

I am getting a new error now after adding a .catch to my script -

{
result: ‘error’,
reason: ‘InvalidSignature’,
message: ‘InvalidSignature’
}

I thought it might have to do with the API key(s), so I generated both Master and Primary keys multiple times in order to make sure I wasn’t making a mistake when entering the key information into my code. That is however, not the case. Here is my script

const GeminiAPI = require("gemini-api").default;
const secret = "FHxiEv1iEX3nQ42kvoyvXAcY4Jz";
const key = "ewqSCGmJbAlr9nTHYKSN";
const restClient = new GeminiAPI({key, secret, sandbox:true});


restClient.newOrder({amount:10,price:20000,side:"buy",symbol:"BTCUSD"})
.then(response => console.log(response))
.catch(error => console.log(error));

Thanks in advance!

1 Like

Hi @Vote3rdParty, hope you are ok.

Now it looks for me that you are setting wrong the secret and key, my secret start with “account-xxxxxx”).

Here are mine just to give you an example on the length and structure of each, try to verify that your secret and key are the same has mine in structure or length.

image

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

1 Like

I am having big problems to install yarn gemini-api on my computer. It is a mac and on the terminal allways says:

-bash: yarn: command not found

1 Like

Hey @Fino, hope you are great.

You might need to install yarn in your system before you can run it.

Here is a quick tutorial for it:
https://tecadmin.net/install-yarn-macos/

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

const GeminiAPI = require(“gemini-api”).default;
const secret = “mScnN”;
const key = “account-k5sE”;
const restClient = new GeminiAPI({key, secret, sandbox:true});
// Create API with primary
// Set permissions to Fund Manager, Trading, Require Heartbeat (all checkboxes)

restClient.newOrder({amount:3,price:24000,side:“buy”,symbol:“btcusd”})
.then(response => console.log(response))
.catch(console.error);

The video is old. Apparently you can’t create a video for years and not think something would change on the network lol

1 Like

Yes a little bit of true, technologies advance at a so fast speed that a 1 to 3 years old video is not accurate enough by now, still most of the fundamentals are there.

We are working hard to upgrade all our courses that needs to get an update on their lessons, but this is a slow process for our Senseis (filip and ivan), we have been upgraded for example Ethereum Programming Solidity 101 this month, and we are planning to do the same for other courses :nerd_face:, just stay tuned.

Carlos Z.

Hi @ivan or @thecil , I got stuck again!

when I try to run my index.js file (i have replaced the last 4 & 5 characters of the key and secret for safety reasons):

const GeminiAPI = require("gemini-api").default;

const secret = "2bFz9ojXFE7beUEYyZvcYgSv****";
const key = "master-Vctx0N0MUQq4qni*****";

const restClient = new GeminiAPI({key, secret, sandbox:true});

restClient.newOrder({amount: 10, price: 27000, side:"buy", symbol:"btcusd"})
.then(response => console.log(response));

I get the following from the terminal (I am running all of this from an Ubuntu 20.04 Huawei notebook by the way, but I had no trouble installing yarn or the gemini package. I had node JS from beforehand).

(node:100099) UnhandledPromiseRejectionWarning: #<Object>
(Use `node --trace-warnings ...` to show where the warning was created)
(node:100099) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:100099) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Then I ran the following command: node --trace-warnings index.js, and I get the following:

(node:100146) UnhandledPromiseRejectionWarning: #<Object>
    at emitUnhandledRejectionWarning (internal/process/promises.js:170:15)
    at processPromiseRejections (internal/process/promises.js:247:11)
    at processTicksAndRejections (internal/process/task_queues.js:94:32)
(node:100146) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:100146) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    at emitDeprecationWarning (internal/process/promises.js:180:11)
    at processPromiseRejections (internal/process/promises.js:249:13)
    at processTicksAndRejections (internal/process/task_queues.js:94:32)

so, then I ran the following command: node --unhandled-rejections=strict index.js, and I get the following:

internal/process/promises.js:213
        triggerUncaughtException(err, true /* fromPromise */);
        ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<Object>".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

please a little help!

1 Like

I’m sure that error appears because you are using the Master Key of Gemini API instead of Private Key.

The Master Key use some kind of master-###... argument that I think gemini-api-node does not manage. Try to change/create a Private Key. (which start with accoutn-###...)

Carlos Z

1 Like

I did it … and replaced both the apikey and the secret, and I got the same errors :confounded:

@thecil … I already figured it out … I added a catch statement, and I realized I dont have enough USD :sweat_smile:

1 Like

Hey Carlos,

I got an error using the install command from GitHub in PowerShell so I installed from npmjs.com instead. I used the command npm install gemini-node-api. Is this the right one?

Let me know,

Tyler

PS C:\Users\TYLER-PC\desktop> yarn add gemini-api
yarn : File C:\Users\TYLER-PC\AppData\Roaming\npm\yarn.ps1 cannot be loaded because running scripts is
disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1

  • yarn add gemini-api
  •   + CategoryInfo          : SecurityError: (:) [], PSSecurityException
      + FullyQualifiedErrorId : UnauthorizedAccess
    

PS C:\Users\TYLER-PC\desktop> yarn add gemini-api
yarn : File C:\Users\TYLER-PC\AppData\Roaming\npm\yarn.ps1 cannot be loaded because running scripts is
disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1

  • yarn add gemini-api
  •   + CategoryInfo          : SecurityError: (:) [], PSSecurityException
      + FullyQualifiedErrorId : UnauthorizedAccess
    

PS C:\Users\TYLER-PC\desktop> npm install gemini-node-api
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No repository field.

  • [email protected]
    added 12 packages from 60 contributors and audited 12 packages in 3.613s

3 packages are looking for funding
run npm fund for details

found 0 vulnerabilities

PS C:\Users\TYLER-PC\desktop>

1 Like

Hey @Tyler11, hope you are ok.

First you are trying to install packages directly on the desktop folder, i could suggest to create a folder for all the Course content and code that will be need it.

Second you could try to use windows console (CMD) instead of powershell, some times i also have errors with powershell and then i try the same comand in cmd and it works.

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

1 Like

Will do tomorrow, thanks! Getting ready for Good Morning Crypto now…

1 Like

Carlos,

I got that problem solved, now I’m getting this signature error. I read and tried everything in this forum, spent a few hours trying different things in Gemini, cmd vs PowerShell, making changes to .js file. I’m stuck man! Here is my JavaScript and result:

const GeminiAPI = require(“gemini-api”).default;
const key = “account-fJpbLkl5XHJWEgGwXjVQ”;
const secret = “2ygqo83kmZTNBRQDkHnzVQmrvpC3”;
const restClient = new GeminiAPI({key, secret, sandox:true});

restClient.newOrder({amount:1,price:35000,side:“buy”,symbol:“btcusdt”})
.then(response => console.log(response))
.catch(console.error);

C:\Users\TYLER-PC\Documents\Crypto\Atom\tradingBot>node index.js
{
result: ‘error’,
reason: ‘InvalidSignature’,
message: ‘InvalidSignature’
}

Thanks in advance,

Tyler

1 Like

Are you sure your API keys comes from this website: https://exchange.sandbox.gemini.com/

If is true, you might wanna check the permissions on your API key, it is allowed to operate your funds or just read them??

Carlos Z