Skip to content

Calendar

The date as a number, the same for every stock on a day.

day_of_week

day_of_week()

0 (Monday) to 6 (Sunday). The toy data runs Tuesday Jan 02 to Tuesday Jan 09, over a weekend.

day_of_week()
ABCD
Jan 021111
Jan 032222
Jan 043333
Jan 054444
Jan 080000
Jan 091111
where(day_of_week() == 4, rank(-returns(5)), None)         # trade on Fridays only

day_of_month

day_of_month()

1 to 31.

day_of_month() <= 5                                         # the first days of the month

month_of_year

month_of_year()

1 to 12.

where(month_of_year() == 1, 1, 0)                           # a January indicator
month_of_year() != delay(month_of_year(), 1)                # the first trading day of each month