0

I'm using a public Kraken API to pull a small set of recent 1 minute bitcoin candles and put in an array.

I've defined the procedure as asynchronous, thinking that it'll be updated constantly (as it includes the working candle in the response). Or at least once a minute.

I've created a log file to output the candle data when received, and log when it's logged. The candle output is inconsistent and sometimes happens every minute, every 2 minutes, or sometimes every 5 minutes.

I'm hoping I've defined this wrong, rather than 'Kraken API data is inconsistently updated' I'm not a pro, so please take that into account in your response.

Below is a simplified version of the function definition;

strat.UpdateKrakenBitcoinTicker = async function () {
    let tickerData;
    const baseDomain = "https://api.kraken.com";
    const publicPath = "/0/public/";
    const endPointName = "OHLC";
    const inputSince = Math.floor(Date.now() / 1000) - Math.floor(25 * 60);  //now minus 25 minutes....
    
    const inputParameters = "pair=BTCUSD&interval=1&since=" + inputSince
    const apiEndpointFullURL = baseDomain + publicPath + endPointName + "?" + inputParameters;
    
    var keyArray = [];
    
    try {
    
        tickerData = await axios.get(apiEndpointFullURL);
        //Other parsing logic not shown
    }
        catch (error) {
    }
}

I've incorporated this into Gekko, trading bot, and it gets called during the check function (i.e. whenever a new candle is available.

this.UpdateKrakenBitcoinTicker();

However, Given it's asynchronous, it should pick up data whenever it's available right? Meaning ever 1 candle....

John Hedengren
  • 12,068
  • 1
  • 21
  • 25
TheDude
  • 3
  • 2

0 Answers0