Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Working with Calendar Days vs Trading Days?

Just getting started and am looking for pointers to docs / guides on working with Calendar Days vs Trading Days.

Specifically, I want to say "give me the price from 1 year ago" or "give me the price from 30 days ago". Most of the examples seem focused on looking back based on trading days.

I am thinking the answer is to use pandas Time Series / Date functionality in conjunction with data.history and then doing lookups by date. However, wanted to ask the experts.

Thanks.

Michael

1 response

i don't have the code off-hand but it's something like,

date = get_datetime()
d = date.day
m = date.month

and then you can reconstruct the previous date of interest and use data.history for the price.