From 354d249d8f815e9c85506c58e5fb5493109e2892 Mon Sep 17 00:00:00 2001 From: "Gavin.Chan" Date: Fri, 16 Feb 2018 14:54:57 +0000 Subject: [PATCH] Ensure start time does not roll back in candles --- libcryptomarket/core/candle/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libcryptomarket/core/candle/__init__.py b/libcryptomarket/core/candle/__init__.py index dc59462..6708d8d 100644 --- a/libcryptomarket/core/candle/__init__.py +++ b/libcryptomarket/core/candle/__init__.py @@ -73,10 +73,13 @@ def candles(source, symbol, start_time, end_time, frequency, **kwargs): data["start_time"].iloc[0] >= last_start_time): break - start_time = data["end_time"].iloc[-1] - all_data.append(data) + if data["end_time"].iloc[-1] > start_time: + start_time = data["end_time"].iloc[-1] + else: + break + if len(all_data) == 0: raise ValueError("Start time cannot be after end time.") elif len(all_data) == 1: