0

Why does the first period aka 9:30 get cut off?

It returns the first period as 10:00. That is incorrect.

What am I doing wrong?

import pandas_market_calendars as mcal

nyse = mcal.get_calendar('NYSE')
early = nyse.schedule(start_date="2020-07-02", end_date="2020-10-14")  # .strftime(date_fmt)


dates = mcal.date_range(early, frequency="30min")
dates = dates.tz_convert('US/Eastern')
dates

DatetimeIndex(['2020-07-02 10:00:00-04:00', '2020-07-02 10:30:00-04:00',
               '2020-07-02 11:00:00-04:00', '2020-07-02 11:30:00-04:00',
               '2020-07-02 12:00:00-04:00', '2020-07-02 12:30:00-04:00',
               '2020-07-02 13:00:00-04:00', '2020-07-02 13:30:00-04:00',
               '2020-07-02 14:00:00-04:00', '2020-07-02 14:30:00-04:00',
               ...
               '2020-10-14 11:30:00-04:00', '2020-10-14 12:00:00-04:00',
               '2020-10-14 12:30:00-04:00', '2020-10-14 13:00:00-04:00',
               '2020-10-14 13:30:00-04:00', '2020-10-14 14:00:00-04:00',
               '2020-10-14 14:30:00-04:00', '2020-10-14 15:00:00-04:00',
               '2020-10-14 15:30:00-04:00', '2020-10-14 16:00:00-04:00'],
              dtype='datetime64[ns, US/Eastern]', length=949, freq=None)

1 Answers1

1

The addition of the parameter "closed", changed default from 'right'.

Relevant docstring

:param closed: same meaning as pandas date_range. 'right' will exclude the first value and should be used when the results should only include the close for each bar.

dates = mcal.date_range(early, frequency="30min", closed = "left")