Im trying to use this binance api to back test some strategies. I have the async call but I want to extract the value from the call out so I can use it. I'm planning to use it for more than just a console log, I want to use it as a starting point to do some other logic later on. I feel lik Im close but I just can't quite get the syntax to do what I want. dataPoint has the value I want but I dont know how to get it to the parent function so I can use it in the future.
const ethCandlesticks = async function(time) {
let data = await binance.candlesticks("ETHUSDT", "1m", null , {limit: 1, endTime: time});
return data[0][4];
}
const test = () => {
let balance = 1000;
const oneMonthAgo = new Date(2022, 01, 01).getTime();
const data = ethCandlesticks(oneMonthAgo).then((dataPoint) => {
return dataPoint;
});
console.log("test" + data);
}
test();