Start with this formula in your code: http://en.wikipedia.org/wiki/Black–Scholes#Instruments_paying_continuous_yield_dividends For example SPY has q=2.03% - http://uk.finance.yahoo.com/q?s=SPY You can also test using the put-call parity equation.
Maybe you are looking at it wrong. Firstly, I'd just use a fixed rate. Just use LIBOR or treasuries. Next, you don't know what the volatility is until you calc it. With B-S you have to iterate, changing the Vol input until you get the option price being quoted. Then that Vol value is the current IV for that option. Then use that IV value to calc the option value on the day you are concerned about, and at the underlying price. I graph daily and weekly option values at every percent, + and -, of different underlying price ranges and with + and - changes in IV. That way it is easy to see what happens if the stock goes up and down, or IV changes, etc. These kinds of calcs should be plenty good enough for "what if" speculation. At least they have been for me, for a long time.
why don't you just take the top of the book quotes and then figure out the rate from that to get an idea of what rate is being used??
Yeah, looks like OP is confounding a few things here... The right rate to use is the funding rate, whatever it might be, in your particular case (not that it matters that much, but anyways).