I'm using python and Scrapy
What I am trying to do is calculate the growth rate of a stock (or rate of return) over a year, using monthly, weekly or daily data. Let's take this CAT data for example.
First on the list, is to calculate the rate of return at June 8, 2015. To do this, we use the formula (new - old)/old
, or (June 8 2015 - June 8 2014)/June 8 2014
. This would work fine, however there is no June 8, 2014 data! The closest is June 9th, or June 2nd.
Anyone have any ideas on how to tackle this accurately?
I did a long internship as a quant in a London IB and calculation of dates was not a trivial task and totally depending on the business application. You have all sorts of calendars, public holidays and other such things to take into account.
It really depends on what calendar you wish to reflect for example:
For your programming task:
pandas
for this