Skip to content

Commit

Permalink
handle dates better in get_historical_prices and deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesir committed Dec 11, 2024
1 parent c029cad commit e494270
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lumibot/data_sources/tradier_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,12 @@ def get_historical_prices(
if "timestamp" in df.columns:
df = df.drop(columns=["timestamp"])

# if type of index is date, convert it to timestamp with timezone info of "America/New_York"
if isinstance(df.index[0], date):
df.index = pd.to_datetime(df.index).tz_localize("America/New_York")
# Check if the index contains dates and handle timezone
if isinstance(df.index[0], date): # Check if index contains date objects
if df.index.tz is None: # Check if the index is timezone-naive
df.index = pd.to_datetime(df.index).tz_localize("America/New_York")
else: # If the index is already timezone-aware
df.index = df.index.tz_convert("America/New_York")

# Convert the dataframe to a Bars object
bars = Bars(df, self.SOURCE, asset, raw=df, quote=quote)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="lumibot",
version="3.8.18",
version="3.8.19",
author="Robert Grzesik",
author_email="[email protected]",
description="Backtesting and Trading Library, Made by Lumiwealth",
Expand Down

0 comments on commit e494270

Please sign in to comment.