title: how to properly add/subtract business days for NYSE trading/holidays
body: <p>I am trying to extract price data from yahoo finance for -beforeDays to +afterDays days around the lockup expiration date (180 days from the ipo). The problem is when I check to to see the number of dates retrieved from yahoo finance, it varies. I need to have the same number of observations for each ticker. I am guessing that I have not set the calendar/holidays right. </p>
  
  <p>The code is as follows. The variable tickerdata has the data from the request to yahoo.</p>
  
  <pre><code>cal  &lt;- create.calendar("UnitedStates/NYSE", weekdays=c("saturday", "sunday"))
  for(i in seq(1,numrows , 1)) {
  
      ticker=tickerdata[i,"Ticker"];
      IPO.dat &lt;- as.Date(tickerdata[i,"Date"],format="%yyyy-%m-%d");
      from.dat&lt;-bizdays::offset(IPO.dat, 180-beforeDays, cal);
      to.dat&lt;-bizdays::offset(IPO.dat, 180+afterDays, cal);
  
     if (to.dat&lt;TodayDate.dat) {
        possibleError &lt;- tryCatch(
          { 
          histData&lt;- getSymbols(ticker, src="yahoo", from = from.dat, to =     
                   to.dat,adjust=TRUE,auto.assign=FALSE);
          print(paste("num rows: ",nrow(histData),"for ticker:",ticker,sep="") )
          },
          error=function(cond) { 
               message(paste("Error for ticker:",ticker,sep=""));
          },
          warning=function(cond) {
          message(paste("Error for ticker:",ticker,sep=""));
        },
        finally={
        }
      ) # end of catch
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Sample output looks like:
  [1] "num rows: 57for ticker:DNKN"</p>
  
  <p>[1] "num rows: 57for ticker:AMID"</p>
  
  <p>[1] "num rows: 54for ticker:SAVE"</p>