marianogappa / crypto-candles

Universal crypto candlestick iterator library & CLI
MIT License
14 stars 2 forks source link

Research & improve patience setting #4

Closed marianogappa closed 2 years ago

marianogappa commented 2 years ago

Many exchanges will return results for the latest incomplete candlestick intervals. There's no way to tell if a received latest candlestick is gonna change or not (other than checking the current time and guessing). Experiments are required to see how much delay should be applied before allowing a given time's candlestick can be considered final.

marianogappa commented 2 years ago

I ended up running a script that uses crypto-candles to get the latest available candlesticks for BTC/USDT on all supported exchanges and for the smallest intervals, to see which ones change and how close to the current time they do.

Empirical evidence from the experiments show that, on the 1m interval, the last completed minute is unreliable on all exchanges. For the most part this is it, but e.g. for FTX, the 2nd most recent minute is also unreliable albeit is much less common. You'd have to test it for hours to see a change.

The race condition that causes past minutes to change is unavoidable without knowing more details about each platform's pipeline, so candlesticks can be cached but one cannot assume with 100% certainty that the caches are always correct.

The results of the experiments were encoded into the Patience setting of all exchanges.