@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)
}
}