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

Hey @MosesCruz22, hope you are great.

Check your API settings for that key in gemini sandbox, are you sure you have activate the options to allo the key to create orders?

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

Carlos Z.

Hi,

I had the same issue and its working well on command console. So from now on dont use powershell due to its not working there just use command prompt?

1 Like

@thecil thank you! I made new API keys and it worked. I turned off “REQUIRES HEARTBEAT” and its been working well!

I was able to get through this portion of the course!

Yeah, powershell some times does not work completely well with some programs, so you can use both to verify any problem that you could face.

Carlos Z.

I’m having the same problem too

EDIT: Works for ETH but doesn’t work for BTC in my case.

If I put too low of a price then I get reason: 'ImmediateOrCancelWouldPost', if I put a high price then I get reason: 'ExceedsPriceLimits. In both cases is_cancelled: true.

If anyone else see’s this issue, the problem is for the following lesson:

Algorithmic Trading & Technical Analysis/Categories/Javascript bot programming using Gemini API, NodeJS and CryptoCompare/Creating Exchange Module

If someone has a solution for this please post, thanks!

2 Likes

Hi, I’m having a problem to connect gemini api, from windows power shell, when I write : “yarn add gemini-api” it gives me an error saying that execution of scripts is disabled from my system.
is there a way to resolve this? Now i’m using an old pc and old windows.

1 Like

Hey @jad, hope you are great.

I assume you are using powershell from windows, some times it goes buggy with some apps, i suggest you to use Windows Command Promt (cmd) which is the most oldest console of windows.

Carlos Z

You were right, thanks.
Now I have another problem

1 Like

“Unhandled Promise Rejection”

You might have a function that should wait for a return of a value with .then, or rebuilt it on a asycn function.

Carlos Z

duplicate ,sorry see below

i have no coding experience. I still tried not to have too high hopes! can anyone explain where one newb can improve these results.

in Atom; path: C:\Users\papaf\Documents\IOTAcad\JS trading Bot programming\index.js
const GeminiAPI = required(“gemini-api”).default;
const secret = “dVn6PiCyFCEMxnPAErwACaChsap”;
const key = “sZ8v0NzVGAO1Ap2v8vG8”;
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));

Results showing in Windows PowerShell window (please note: no apparent additional clarity gained from adding the additional catch of promise ending code, as in .catch(error…?) )

PS C:\Users\papaf\Documents\IOTAcad\JS trading Bot programming> node index.js
C:\Users\papaf\Documents\IOTAcad\JS trading Bot programming\index.js:5
restClient.newOrder({amount:10,price:100,side:“buy”,symbol:btcusd"})
^^^

SyntaxError: Invalid or unexpected token
←[90m at wrapSafe (internal/modules/cjs/loader.js:979:16)←[39m
←[90m at Module._compile (internal/modules/cjs/loader.js:1027:27)←[39m
←[90m at Object.Module._extensions…js (internal/modules/cjs/loader.js:1092:10)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:928:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:769:14)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)←[39m
←[90m at internal/main/run_main_module.js:17:47←[39m

a few other point of clarity:

i have found a duplicate index.js being created inside my folder …JS trading Bot programming\ node_modules\index.js form where i was referncing it originally and you can see from my edits, i attempted to follow ivan on screen to ensure the files are outside the \node_modules folder.

(I re-ran the installer for node-v14.15.5-x64.msi and installed all of the following:

Chocolatey upgraded 17/17 packages.

See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

  • Upgraded:
    • chocolatey-dotnetfx.extension v1.0.1
    • kb3033929 v1.0.5
    • python3 v3.9.1
    • visualstudio2017buildtools v15.9.33.0
    • chocolatey-windowsupdate.extension v1.0.4
    • vcredist140 v14.28.29325.2
    • kb2999226 v1.0.20181019
    • visualstudio-installer v2.0.1
    • kb2919355 v1.0.20160915
    • chocolatey-core.extension v1.3.5.1
    • kb2919442 v1.0.20160915
    • visualstudio2017-workload-vctools v1.3.2
    • chocolatey-visualstudio.extension v1.8.1
    • vcredist2015 v14.0.24215.20170201
    • dotnetfx v4.8.0.20190930
    • kb3035131 v1.0.3
    • python v3.9.1
  • Type ENTER to exit:

i attempted the add missing modules and even tried the homework of the following “holy task”: exercise to no avail. starting to think i must i retry/renew my keys for website login verification? (is about all I can think of, as side of some syntax error in plain sight!!?)

i have been moving on and removed the order commands and went to Getting Market Data from CryptoCompare module #19 and the new code/ new error now looks like this:

Code looks like:
global.fetch = require(“node-fetch”);

const GeminiAPI = required(“gemini-api”).default;
const secret = “dVn6PiCyFCEMxnPAErwACaChsap”;
const key = “sZ8v0NzVGAO1Ap2v8vG8”;
const CCAPIKey = “fefef09fff45aca3afec947d5bafbd32d585714b093cc2d6da2bdd63c4ee334b”;
const restClient = new GeminiAPI({key, secret, sandbox:true});

const CryptoCompareAPI = require(“cryptocompare”);
CryptoCompareAPI.setApikey(CCAPIKey);

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

CryptoCompareAPI.coinList()
.then(coinlist => {
console.log(coinlist)
})

the resultant error message, when i run the file path:

PS C:\Users\papaf\Documents\IOTAcad\JS trading Bot programming> node index.js
C:\Users\papaf\Documents\IOTAcad\JS trading Bot programming\index.js:3
const GeminiAPI = required(“gemini-api”).default;
^

ReferenceError: required is not defined
at Object. (C:\Users\papaf\Documents\IOTAcad\JS trading Bot programming\index.js:3:19)
←[90m at Module._compile (internal/modules/cjs/loader.js:1063:30)←[39m
←[90m at Object.Module._extensions…js (internal/modules/cjs/loader.js:1092:10)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:928:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:769:14)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)←[39m
←[90m at internal/main/run_main_module.js:17:47←[39m

Also maybe made matters worst in my attempt to self-troubleshoot! In a failed attempt to trouble shoot my Sandbox Key, i may have made matters worst after I attempted to re-assigned at Gemini.Sandbox 's Secret and Security Key and now that I removed Security Key, the website is asking me to add a USB this looks bad lol …do i go into the User Management to make a new profile as Admin???

1 Like

I got that error in the previous message after this code from lecture using gemini buy order:

const GeminiAPI = require(“gemini-api”).default;
const secret = “4MHxD…1ZgTJo5Hw”;
const key = “Jvk3L9…wEZipRB”;
const restClient = new GeminiAPI({key, secret, sandbox:true});
restClient.newOrder({amount:10,price:100,side:“buy”,symbol:“btcusd”})
.then(response => console.log(response));

what I need to do to solve it?

1 Like

Hi @jad, hope you are great.

@StaknSats .
Please check the structure of your API keys, here is a example to follow for this subject:

Carlos Z.

2 Likes


I have a problem, i installed yarn, and was installing gemini-api, but i keep getting an error message! please help @ivan

1 Like

Ok, here’s an update. I figured out that it was restricted in the system, so i used this tutorial and fixed it: https://windowsloop.com/enable-powershell-scripts-execution-windows-10/#:~:text=%20Steps%20to%20Enable%20PowerShell%20Scripts%20Execution%20on,“.%20This%20means%20the%20scripts%20are...%20More

NOW IT WORKS!!! (i think, i havn’t tested it yet)

3 Likes

Hey @cryptoforyou , hope you are great.

I assume you are using powershell from windows, some times it goes buggy with some apps, i suggest you to use Windows Command Promt (cmd) which is the most oldest console of windows.

Carlos Z

Nope, it works great now!!! i just had one thing locked

1 Like

does anyone know why he gemini exchange is acting weird??? it sais at bitcoin is at 50k but its at 58.

Guys!! since bitcoin is at 60k, (about,) that means that im supposed to put the price to buy at like 200,000$. so if i buy, i buy 200,000$, and i sell at 1 dollar… soooooooooooo…

1 Like

Hello, im having trouble installing yarn, this is the message that it appears to me…can some one help me please?

iMac-de-victor:AT victormanuelleosmartinez$ node index.js

Welcome to index.js file baaaam

iMac-de-victor:AT victormanuelleosmartinez$ npm install yarn–global

npm ERR! code E404

npm ERR! 404 Not Found - GET https://registry.npmjs.org/yarn--global - Not found

npm ERR! 404

npm ERR! 404 ‘yarn–global@latest’ is not in the npm registry.

npm ERR! 404 You should bug the author to publish it (or use the name yourself!)

npm ERR! 404

npm ERR! 404 Note that you can also install from a

npm ERR! 404 tarball, folder, http url, or git url.

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

npm ERR! /Users/victormanuelleosmartinez/.npm/_logs/2021-03-04T16_57_57_491Z-debug.log

iMac-de-victor:AT victormanuelleosmartinez$

iMac-de-victor:AT victormanuelleosmartinez$ npm install yarn–global

npm ERR! code E404

npm ERR! 404 Not Found - GET https://registry.npmjs.org/yarn--global - Not found

npm ERR! 404

npm ERR! 404 ‘yarn–global@latest’ is not in the npm registry.

npm ERR! 404 You should bug the author to publish it (or use the name yourself!)

npm ERR! 404

npm ERR! 404 Note that you can also install from a

npm ERR! 404 tarball, folder, http url, or git url.

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

npm ERR! /Users/victormanuelleosmartinez/.npm/_logs/2021-03-04T17_00_03_302Z-debug.log

1 Like