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

@ivan
Anyone! I am completely stuck, cannot get pass this error:

node index.js
{ result: 'error',
  reason: 'InvalidSignature',
  message: 'InvalidSignature' }

My code:

global.fetch = require("node-fetch");
const GeminiAPI = require("gemini-api").default;
const secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const key = "account-xxxxxxxxxxxxxxxxxxxxxxx";
const restClient = new GeminiAPI({key, secret, sandbox:true});
const indicators = require("./indicators.js");

restClient.newOrder({amount:1,
                      price:12000,
                      side:"buy",
                      symbol:"BTCUSD",
                      options:["immediate-or-cancel"]})
.then(res => console.log(res))
.catch(error => console.error(error));

Indicators.js:

const CCAPIKey ="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const CryptoCompareAPI = require("cryptocompare");
CryptoCompareAPI.setApiKey(CCAPIKey);



module.exports = {



    hourlyMovingAverage:function(cryptoAsset,fiatCurrency,hours, callback) {

    if(hours>169){
      console.error("Only up to 169 hours allowed!")
      return
    }

    CryptoCompareAPI.histoHour(cryptoAsset, fiatCurrency)
.then(data => {
  data = data.reverse()
  //finding the MA for last 100 days

  var sum = 0;
  //get the last closing prices for past 100 hours
  for(var i = 0;i<100;i++){
    sum+=(data[i].close);
  }
  var movingAverage = sum/100;
  console.log(movingAverage);


  /*console.log(data[0])
  console.log(data.length)*/
  // go to unix timestamp to convert the time https://www.unixtimestamp.com/

    })
.catch(console.error)

  }

}

The semicolon indicates the end of the function call(s). So it must be after the final function in this case the catch()

Thanks! That worked for me, but there was a delay. Mine didn’t start working until the next day.

Hello this is my code

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

const secret = “2HwvuwRA2vBucAsyT6N82kFCceEH”;

const key = “master-3elxuDwCd54ek3vTQZjD”;

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

restClient.newOrder({amount:10,price:100,side:“buy”,symbol:“btcusd”,account:“primary”})

.then(response => console.log(response))

.catch(error => console.log(error));

This is the error I get

SyntaxError: Invalid or unexpected token
?[90m at wrapSafe (internal/modules/cjs/loader.js:1053:16)?[39m
?[90m at Module._compile (internal/modules/cjs/loader.js:1101:27)?[39m
?[90m at Object.Module._extensions…js (internal/modules/cjs/loader.js:1157:10)?[39m
?[90m at Module.load (internal/modules/cjs/loader.js:985:32)?[39m
?[90m at Function.Module._load (internal/modules/cjs/loader.js:878:14)?[39m
?[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)?[39m
?[90m at internal/main/run_main_module.js:17:47?[39m

They say it’s a syntax error, in the restClient.newOrder, commas and double quotes are considered invalid characters.
What should I do? Thanks

Hello @Yogalholic, hope you are great.

Check that your double quotes are not curvy, some times that little mistype could end on syntax error.

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

Carlos Z.

1 Like

Well that was specifically the problem! Thanks
Now that you mentioned it yes I have other questions but it may be not the appropriate place to ask. I am coding a bot a bitfinex and I need help, I have read the API documentation many times but there are still some unclear points to me. Where could I ask questions about it on the forum? Thanks again

Hi i wanted to ask how do we connect the pinescript from tradingview that we learned earlier with Philip to an exchange to trade? Is this similar to what we are trying to do now?
And why we use cryptocompare and not tradingview? Also what is the reason we use JS over Python for this course Thanx a lot :slight_smile:

Hello, I wonder about the function newOrder, do we really have to set a “price” parameter? If we want to schedule some trades whatever the price is, is it enough to just set the “amount” parameter?
Thanks

1 Like

I might need to check your newOrder function in order to help you check what should be changed.

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

Carlos Z.

Thanks but everything is fine now. I’ve made some research and learn that what I wanted to do is not a “Limit Order” but a “Market Order”

@Mauro hello… I think this was the post i mentioned Binance. There may be another one lost somewhere. I would love to get some step by step guides on how to Create a BOT and deploy it on the binance Exchange api…

Any one did this yet?

Best wishes everyone.

Rob.

1 Like

but who is going to buy or sell through the command window? this is useless
this was useful in an app for the phone or in php

1 Like

Having the same issue right now…don’t suppose anyone helped you with this when you asked last month @Tino?

1 Like

Hello @Cryptoshi007, hope you are great.

Could you please share an screenshot of your issue? If its the same, the error msg said that you are not allowed to run scripts, could be that you are not the Administrator, try to run PowerShell as Administrator.

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

Carlos Z.

no not yet. But I haven;t really followed up on it as I also am doing other courses in the academy. Thanks for reminding me. Will check again this week :slight_smile:

1 Like

how do you record something executable? the idea is not to use the command window right?

1 Like

I NEED HELPPPPP

but who is going to buy or sell through the command window?
HOW DO YOU RECORD TO A FILE EXECUTABLE ON PC OR ON MOBILE PHONE?

1 Like

Hey @R.C, here are some links that can give you a better understanding.

Hope you find this useful.
If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

I had the same problem and I solved thanks to your suggestion. Very glad to you, thanks for helping!

Guys I was enjoying the course a lot, but got stucked when I attempted to generate the Gemini Security Key. After creating the account, logging in, confirming email, getting the authentication SMS and all procedures I start to create the security key. The system asks a nickname and then the problem is that is asking to insert a USB key. I have no idea about what this USB key is. I tried to insert a generic USB key in a USB port, but does not works. I tried from two browsers (Brave and Mozilla) and I receive the same message (as per attached screenshots). Anyone can help me?