Refactor empty data check so that there is only one return statement

This commit is contained in:
moshferatu 2024-11-12 06:35:52 -08:00
parent 07b3af1877
commit 575e106f32

View File

@ -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__':