Handle scenario where historical data is unavailable for the specified date(s)
This commit is contained in:
parent
ace4fe91ea
commit
07b3af1877
@ -95,6 +95,9 @@ def get_historical_data(symbol: str, interval: int, date: datetime = None,
|
|||||||
data = StringIO(data)
|
data = StringIO(data)
|
||||||
data = pd.read_csv(data, index_col = False,
|
data = pd.read_csv(data, index_col = False,
|
||||||
names=['Date', 'High', 'Low', 'Open', 'Close', 'Total Volume', 'Period Volume'])
|
names=['Date', 'High', 'Low', 'Open', 'Close', 'Total Volume', 'Period Volume'])
|
||||||
|
if data.empty:
|
||||||
|
return data
|
||||||
|
|
||||||
data['Date'] = pd.to_datetime(data['Date'])
|
data['Date'] = pd.to_datetime(data['Date'])
|
||||||
data['Date'] = data['Date'].dt.date
|
data['Date'] = data['Date'].dt.date
|
||||||
return data
|
return data
|
||||||
|
Loading…
Reference in New Issue
Block a user