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

try this out. @Tom1 also for you. And normally if you use only sandbox you shouldn’t have problems. Also @filip has mensionted that this course will be remade for those who can’t make it.

Hi guys, been following along on this exact video and got stuck when use the command “node index.js” in the PowerShell and below is the message I got.

“(node:64200) UnhandledPromiseRejectionWarning: #
(node:64200) 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:64200) [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.”

Please kindly advise what else I should be done.

Thanks

Also I took the next video explaining to use .catch(error => console.log(error)); to see the error but I couldn’t manage to solve the error either.

Please take these details to double check if there are anything wrong with my code,

My Gemini API Key #2
API KEY
account-o7lHoS2iVG2VpZA4qcCa

API SECRET (COPY TO A SAFE PLACE)
Wzg9zZjDjWbkUPjZBb9AVPDQ71n

----------------------MY JS code in Atom----------------------

const GeminiAPI = require(“gemini-api”).default;
const secret = “account-o7lHoS2iVG2VpZA4qcCa”;
const key = “Wzg9zZjDjWbkUPjZBb9AVPDQ71n”;
const restClient = new GeminiAPI({key, secret, sandbox:true});

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

------------------below is error i got from PowerShell-----------------------

PS C:\Users\kin_v\Desktop\Ivan on Tech\Trading Bot> node Index.js C:\Users\kin_v\Desktop\Ivan on Tech\Trading Bot\Index.js:7
.then(response => console.log(response));
^

SyntaxError: Unexpected token ‘.’
e[90m at wrapSafe (internal/modules/cjs/loader.js:1047:16)e[39m
e[90m at Module._compile (internal/modules/cjs/loader.js:1097:27)e[39m
e[90m at Object.Module._extensions…js (internal/modules/cjs/loader.js:1153:10)e[39m
e[90m at Module.load (internal/modules/cjs/loader.js:977:32)e[39m
e[90m at Function.Module._load (internal/modules/cjs/loader.js:877:14)e[39m
e[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)e[39m
e[90m at internal/main/run_main_module.js:18:47e[39m
PS C:\Users\kin_v\Desktop\Ivan on Tech\Trading Bot>


However, I manage to print out other API Rest such as getAllSymbol() etc.

Help is very appreciated.
Thx in advance.

You are making a mistake in defining the export modules. It has to look like this:

module.exports = {
    hourlyMovingAverage: function() {},
    dailyMovingAverage: function() {},
    minuteMovingAverage:function () {},
};

That being said it is only allowed to define module.exports one time and inside the {} you have to write the functions (DON´T FORGET the ,(!!!) after the function ends!

Hey,

in the following line:

restClient.newOrder({amount:10,price:100,side:“buy”,symbol:“btcusd”}); <------ (The ; has to be deleted)

You have to delete the ;(!!!) at the end of your code.

I am having difficulties to install Yarn (on a Mac). Here is the error message I get:
I tried to de-activate the firewall but it did not solve the issue.
I have installed the Macports (suggested by an other student) but now I have no idea of what to do.

Please help!

FP:~ federicopoetto$ cd “/Users/federicopoetto/Documents/Atom”;

FP:Atom federicopoetto$ npm install yarn --global

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules

npm ERR! code EACCES

npm ERR! syscall access

npm ERR! path /usr/local/lib/node_modules

npm ERR! errno -13

npm ERR! Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’

npm ERR! [Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’] {

npm ERR! errno: -13,

npm ERR! code: ‘EACCES’,

npm ERR! syscall: ‘access’,

npm ERR! path: ‘/usr/local/lib/node_modules’

npm ERR! }

npm ERR!

npm ERR! The operation was rejected by your operating system.

npm ERR! It is likely you do not have the permissions to access this file as the current user

npm ERR!

npm ERR! If you believe this might be a permissions issue, please double-check the

npm ERR! permissions of the file and its containing directories, or try running

npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:

npm ERR! /Users/federicopoetto/.npm/_logs/2020-05-10T14_15_19_238Z-debug.log

FP:Atom federicopoetto$

Hi @Federico

Can you do this command

ls -ld  /usr/local/lib/node_modules

then this command

id

And send us the result it seems that your user don’t have the required permission to install yarn in the /usr/local/lib/node_modules directory

You can install it using sudo but it’s not really recommended so if you send me this lines we could find an other way by setting the correct permission.

1 Like

Hi Gabba, thank you for your precious support. Here is the ouctome:

FP:~ federicopoetto$ ls -ld /usr/local/lib/node_modules
drwxr-xr-x 3 root wheel 102 10 mai 14:00 /usr/local/lib/node_modules
FP:~ federicopoetto$ id
uid=501(federicopoetto) gid=20(staff) groups=20(staff),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),398(com.apple.access_screensharing),33(_appstore),100(_lpoperator),204(_developer),395(com.apple.access_ftp),399(com.apple.access_ssh)
FP:~ federicopoetto$

you can fix the error with the following command

sudo chown -R $USER /usr/local/lib/node_modules

1 Like

Thank you Mick10, I really do appreciate.

Now it’s asking me a password, is it the log-in password?

Question: is this command going to compromise in any possible way the safety of my operating system? I mean, in terms of protection from external attacks? Or something similar…

I know, I know, you are probably going to laugh at me, but I am an absolute beginner and must take extra care to avoid making stupid mistakes :slight_smile:

Hi @Federico

This is a legit question, the command @Mick10 gave you will change the following:

Before

FP:~ federicopoetto$ ls -ld /usr/local/lib/node_modules
drwxr-xr-x 3 root wheel 102 10 mai 14:00 /usr/local/lib/node_modules

After

sudo chown -R $USER /usr/local/lib/node_modules

drwxr-xr-x 3 federicopoetto wheel 102 10 mai 14:00 /usr/local/lib/node_modules

As this folder was owned by root (see it as the super User on unix system) you need to modify this folder permission using the root user.

chown just allow you to change file system ownership
if you want to read more about permission look at this article:
https://kb.iu.edu/d/abdb

The important thing here is to not install external program with the root user because they ll be able to modify everything on your file system.

If you install a virus on your computer it’s better to install it with a regular user as with the super Admin user :wink:

Your default root password should be the same as your user if you never had set one, on Mac OSX High Sierra (10.13) there was a bug where you can enter an empty password. So if it doesn’t work send us your mac Os version.

sw_vers
1 Like

@Federico no risks. thats the command you are looking for. i did a quick google search of your issue and thats how the npm community solves it.

if you are afraid of messing up your computer. do a backup first. or do you developments in a virtual machine, thats best. you are doing developer stuff, you should prepare to fail and mess up and have a plan in case you do.

Thanks for your insight, Doc!

Dear Gabba and Mick10, I am not willing to compromise my computer. I do make regular back-ups but I fear violating the permissions might eventually lead to some potential vulnerabilities.

But I just noticed that I can install Yarn if I do not use the “-- global” command.
Here is the message I get:

FP:algotrading_code federicopoetto$ npm install yarn
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No repository field.

  • [email protected]
    added 1 package and audited 1 package in 1.931s
    found 0 vulnerabilities

Is this all right? Did it work?

Thanks,

Federico.

Hi @Federico

Yes it will work but if you install it without --global yarn will only be installed locally, so if you want to use it in an other project you will have to install it again.
Your node_modules in your local folder have the permission we recommended you to set in your /usr/local/lib , so this is exactly the same thing and this is why it’s working.

Installing modules in the “global” directory in your case “/usr/local/lib/” is useful when you are installing modules which are not specific to your current project. Using the local node_modules is used when the package you are installing will be used inside for this project.

For example during Ethereum course i m using ganache-cli which is an npm package, i need to launch this program from everywhere in my machine so i installed it globally because it s not used inside my project files.
But for example if i want to use “readline” in my project (at some point i ll do require(‘readline’) in my Javascript project) i need to install it locally.
By installing it locally yarn will be added to your package.json file, when someone will use your project usually you are not committing your node_modules so he will do an npm install to install locally all the modules needed, in your case he ll install yarn locally but he will not need it to use your project.

Long story short, if you need to install a module with npm to use it inside your project install it locally.
If you need to install a modules which will be use outside of your project install it globally .

If you don’t have the required permission in your global directory change it, it will not affect your computer because anyway if you install it locally the permission are the same. So the risk are the same

1 Like

Good Evening,

Hope everyone is doing well.

Mac User Problems :roll_eyes: - following instructions extremely carefully.
Powershell - Installed
Node Js - Installed
NPM - Installed
Atom - Installed

Spent hours on JS… Course.

Is there a video link ‘for Mac’ user to follow? In an effort to build this bot?

Many thanks

1 Like

@ivan Thank you so much for this amazing course! I was surprised that I was able to implement everything without needing any help in the forum!
That said in the last video, where you summarize everything you mention that we should work on our strategy, tweak our bots and then deploy it on a server to run 24/7. Could you please make a video showing how to deploy the bot and which servers can be used?

… You mean binance …?

hi,
I had the same problem and
“.catch(console.error);”
solved the problem.
Than you

is the academy website down again ???
i havent been able to log in in 2 days