#NEWLINE# def get_open_and_close( day , early_closes ) : #NEWLINE# #INDENT# market_open = pd . Timestamp ( datetime ( year = day . year , month = day . month , day = day . day , hour = 9 , minute = 31 ) , tz = 'US/Eastern' ) . tz_convert ( 'UTC' ) #NEWLINE# close_hour = ( 13 if ( day in close_hour ) else 16 ) #NEWLINE# market_close = pd . Timestamp ( datetime ( year = day . year , month = day . month , day = day . day , hour = close_hour ) , tz = 'US/Eastern' ) . tz_convert ( 'UTC' ) #NEWLINE# return ( market_open , market_close )