Oh yeah finally got through! Thank you very much.
I am on the indicator creation part now and I am getting this error:
code in indicator:
const CCAPIKey = "7070fb1cec78efbc4e88a389419001a97a0e232562f374c1321e3b03ebb7bc5f";
const CryptoCompareAPI = require("cryptocompare");
CryptoCompareAPI.setApiKey(CCAPIKey);
module.exports = {
movingAverage: function (cryptoAsset, fiatCurrency, hours){
if(hours>169){
console.error("Only up to 168 hours allowed!")
return
}
// 1 get data from CC
CryptoCompareAPI.histoHour(cryptoAsset, fiatCurrency)
.then(data => {
// 2 calculate MA from 100 past hours
data = data.reverse()
var sum = 0;
for(var i = 0; i<100; i++){
sum+=data[i].close
}
var movingAverage = sum/hours;
callback(movingAverage);
})
.catch(console.error)
}
}
code on the main index file:
global.fetch = require('node-fetch')
const GeminiAPI = require("gemini-api").default;
const secret = "uJVwHaon5Jrp9CB9LMYD8UFtucZ";
const key = "account-3mD9hql52ePPk7VuJFDR";
const restClient = new GeminiAPI({key, secret, sandbox:true});
const indicators = require("./indicators.js");
/*restClient.newOrder({amount:10, price:100,side:"buy",symbol:"ethusd"})
.then(response => restClient.cancelOrder({order_id:response.order_id}))
.then(response => console.log(response))
.catch(error => console.log(error));*/
//100 hour MA
indicators.movingAverage("ETH", "USD", 100, function(){
console.log("MA: ", result)
})
// 3 check continouslay if price is crossing 100 MA => BUY/SELL/uJVwHaon5Jrp9CB9LMYD8UFtucZ