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,
|
result.result_rows,
|
||||||
columns=['date', 'open', 'high', 'low', 'close', 'volume']
|
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":
|
df = df.resample(rule).agg({
|
||||||
# Resample to desired interval
|
'open': 'first',
|
||||||
df.set_index('date', inplace=True)
|
'high': 'max',
|
||||||
minutes = minutes_map[interval]
|
'low': 'min',
|
||||||
rule = f'{minutes}T'
|
'close': 'last',
|
||||||
|
'volume': 'sum'
|
||||||
df = df.resample(rule).agg({
|
}).dropna()
|
||||||
'open': 'first',
|
|
||||||
'high': 'max',
|
df.reset_index(inplace=True)
|
||||||
'low': 'min',
|
|
||||||
'close': 'last',
|
return df
|
||||||
'volume': 'sum'
|
|
||||||
}).dropna()
|
|
||||||
|
|
||||||
df.reset_index(inplace=True)
|
|
||||||
|
|
||||||
return df
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error fetching data for {ticker}: {str(e)}")
|
print(f"Error fetching data for {ticker}: {str(e)}")
|
||||||
return pd.DataFrame()
|
return pd.DataFrame()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user