date_range 1min ranges from 9:31am to 4pm instead of 9:30am to 3:59pm
ab-qf opened this issue · 3 comments
ab-qf commented
rsheftel commented
That is the intended behavior. The timestamp on the bar represents the time at the end of the bar. So the first 1min bar of the trading day goes from 9:30am to 9:31am, so the timestamp is 9:31am.
ab-qf commented
I would disagree and say the first bar usually goes from 9:30:00 until
9:30:59 and the second one starts at 9:31:00am. But OK, if this is
intended, I will just subtract a timedelta of 1 minute.
Thanks
…On Tue, Nov 14, 2023 at 13:10:19, rsheftel ***@***.***> wrote:
That is the intended behavior. The timestamp on the bar represents the
time at the end of the bar. So the first 1min bar of the trading day goes
from 9:30am to 9:31am, so the timestamp is 9:31am.
—
Reply to this email directly, view it on GitHub
<#304 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ARWB2FJLFOIWS2KYTJUX4LDYENNSXAVCNFSM6AAAAAA7KQMFZOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJQGA4DOMZUHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
maread99 commented
FWIW, you can get the index you're after from the exchange_calendars calendar which is (I believe) the source of the data for the 'XNYS' schedule...
import exchange_calendars as xcals
cal = xcals.get_calendar("XNYS")
index = cal.trading_index(
"2010-01-04",
"2023-10-31",
"1T",
intervals=False,
closed="left"
).tz_convert("US/Eastern")
Here the 'close' parameter effectively lets you choose which side of the bar you want to represent. Takes from:
- 'left' (default) gives you what you're after
- 'right' would give you what you were getting
- 'both' will include both the 09:00 and 16:00 minutes
- 'neither' will exclude both the 09:00 and 16:00 minutes