fix: Correct indentation error in get_stock_data function
This commit is contained in:
parent
b67586116c
commit
76075cd104
@ -96,24 +96,24 @@ def get_stock_data(ticker: str, start_date: datetime, end_date: datetime, interv
|
||||
result.result_rows,
|
||||
columns=['date', 'open', 'high', 'low', 'close', 'volume']
|
||||
)
|
||||
|
||||
if interval != "daily" and interval != "5min":
|
||||
# Resample to desired interval
|
||||
df.set_index('date', inplace=True)
|
||||
minutes = minutes_map[interval]
|
||||
rule = f'{minutes}T'
|
||||
|
||||
if interval != "daily" and interval != "5min":
|
||||
# Resample to desired interval
|
||||
df.set_index('date', inplace=True)
|
||||
minutes = minutes_map[interval]
|
||||
rule = f'{minutes}T'
|
||||
|
||||
df = df.resample(rule).agg({
|
||||
'open': 'first',
|
||||
'high': 'max',
|
||||
'low': 'min',
|
||||
'close': 'last',
|
||||
'volume': 'sum'
|
||||
}).dropna()
|
||||
|
||||
df.reset_index(inplace=True)
|
||||
|
||||
return df
|
||||
df = df.resample(rule).agg({
|
||||
'open': 'first',
|
||||
'high': 'max',
|
||||
'low': 'min',
|
||||
'close': 'last',
|
||||
'volume': 'sum'
|
||||
}).dropna()
|
||||
|
||||
df.reset_index(inplace=True)
|
||||
|
||||
return df
|
||||
except Exception as e:
|
||||
print(f"Error fetching data for {ticker}: {str(e)}")
|
||||
return pd.DataFrame()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user