Which timezone to use while converting timestamp to isoformat() for start and end in api.get_bars()?

**start_date = (dt.now().astimezone(timezone('America/New_York')) - timedelta(minutes= 25)).isoformat()**
**end_date = (dt.now().astimezone(timezone('America/New_York'))).isoformat()**

df = api.get_bars('MSFT', start = start_date, end = end_date, timeframe = '1Minute').df
df.reset_index(inplace = True)

df = df[['timestamp', 'open', 'high', 'low', 'close']]

timestamp_ = pd.Index(df['timestamp'])
timestamp_ny = timestamp_.tz_convert('US/Eastern')

df['timestamp'] = timestamp_ny
df

I’m using this code to get the minute-level data for the last 25 minutes. I’m not sure if the start and end specified here are correct.

(dt.now().astimezone(timezone(‘America/New_York’)) - timedelta(minutes= 25)).isoformat() → this finds the current local time (IST in my case) converts into ET time - 25 minutes and THEN converts into ISO format.

Is this correct?

OR

Would this be correct?
(dt.now().astimezone(timezone(‘UTC’)) - timedelta(minutes= 25)).isoformat()

Any help would be greatly appreciated. Thanks!

1 Like