From 575e106f325ee1f1447cf7257fecb8fce90d9558 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Tue, 12 Nov 2024 06:35:52 -0800 Subject: [PATCH] Refactor empty data check so that there is only one return statement --- iqfeed/iqfeed.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/iqfeed/iqfeed.py b/iqfeed/iqfeed.py index 1caff0a..e39fe93 100644 --- a/iqfeed/iqfeed.py +++ b/iqfeed/iqfeed.py @@ -95,11 +95,9 @@ def get_historical_data(symbol: str, interval: int, date: datetime = None, data = StringIO(data) data = pd.read_csv(data, index_col = False, names=['Date', 'High', 'Low', 'Open', 'Close', 'Total Volume', 'Period Volume']) - if data.empty: - return data - - data['Date'] = pd.to_datetime(data['Date']) - data['Date'] = data['Date'].dt.date + if not data.empty: + data['Date'] = pd.to_datetime(data['Date']) + data['Date'] = data['Date'].dt.date return data if __name__ == '__main__':