Skip to content

Instantly share code, notes, and snippets.

View peterwj's full-sized avatar
🐙
Octopus

Peter Johnston peterwj

🐙
Octopus
  • Harvard
  • Cambridge / San Francisco
  • 23:38 (UTC -05:00)
View GitHub Profile
@jckantor
jckantor / NYSE_tradingdays.py
Last active February 9, 2023 13:22
Python dateutil rule sets for NYSE trading days and holiday observances.
from dateutil import rrule
import datetime
# Generate ruleset for holiday observances on the NYSE
def NYSE_holidays(a=datetime.date.today(), b=datetime.date.today()+datetime.timedelta(days=365)):
rs = rrule.rruleset()
# Include all potential holiday observances
rs.rrule(rrule.rrule(rrule.YEARLY, dtstart=a, until=b, bymonth=12, bymonthday=31, byweekday=rrule.FR)) # New Years Day