From 359f357c0002e1ce07d53498828780e433d59bf5 Mon Sep 17 00:00:00 2001 From: Onur Cetinkol Date: Sat, 28 Oct 2023 16:08:09 +0300 Subject: [PATCH] pandas deprecation warning --- setup.py | 2 +- tradingfeatures/api_base.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 0b5d289..4524852 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name="tradingfeatures", - version="0.6.4", + version="0.6.5", author="Onur Cetinkol", author_email="realiti44@gmail.com", description="A useful tool to download market history from popular exchanges.", diff --git a/tradingfeatures/api_base.py b/tradingfeatures/api_base.py index 03cf18c..1b5669f 100644 --- a/tradingfeatures/api_base.py +++ b/tradingfeatures/api_base.py @@ -115,16 +115,18 @@ def get_hist(self, try: df_temp = self.get(symbol=symbol, interval=interval_str, start=str(start_batch), end=str(end_batch)) if df_temp is None: # Try this fix for other apis - print(' Debug: df_temp is empty') - assert len(df) == 0, 'Debug: empty df_temp in middle of download' - df_temp = df + print(' Warning: Got empty window from exchange at start') + assert len(df) == 0, 'Warning: Got empty window from exchange in middle of download' + df_temp = pd.DataFrame() except Exception as e: # raise e print(e, '\nDebug: error between timestamps: ', start_batch, end_batch) if steps <= 1: return None - df_temp = pd.concat([df, df_temp]) - df = df_temp + if not (df.empty or df_temp.empty): + df = pd.concat([df, df_temp]) + elif not df_temp.empty: + df = df_temp.copy() if steps > verbose_after: print('\r' + f' {i} of {steps}', end='')