I am struggling creating an indicator file:
TypeError: indicators.hourlyMovingAverage is not a function
Could some one please help me to find where did I did wrong??
This is the index.js:
global.fetch = require("node-fetch");
const GeminiAPI = require("gemini-api").default;
const secret = "ya9WSHtMj1QdsK3ktxSQhNuPKAG";
const key = "account-XOaIsk30KogZtaR8aXfc";
const restClient = new GeminiAPI({key, secret, sandbox:true});
const indicators = require("./indicators.js");
indicators.hourlyMovingAverage('BTC','USD',50,function(result){
console.log("MA =",result);
})
and this is indicators.js:
const CCAPIKey = "0773176134ab71e4b6bcb484570c487a784d47340eb620a0684500f0f8941e0a";
const CryptoCompareAPI = require("cryptocompare");
CryptoCompareAPI.setApiKey(CCAPIKey);
module.export = {
hourlyMovingAverage: function(cryptoAsset,fiatCurrency,hours,callback){
if (hours>169){
console.error("Only upto 169 hours allowed");
return
}
CryptoCompareAPI.histoHour(cryptoAsset, fiatCurrency)
.then(data => {
data = data.reverse();
var sum = 0;
for(var i = 0;i<hours;i++){
sum += data[i].close;
}
var movingAverage = sum/hours;
callback(movingAverage);
})
.catch(console.error);
}
}