I've been using vollib to calculate IV, but my answers have been different by tenths from other sources like NASDAQ and Yahoo. The answers range +- 0.5, sometimes even more.
The inputs are:
$S$ (float) – underlying asset price
$K$ (float) – strike price
$t$ (float) – time to expiration in years
$r$ (float) – risk-free interest rate
$q$ (float) – annualized continuous dividend rate
For $q$ I use $r=ln(1+\frac{D}{S})$, $D$ = annual dividend $S$ = spot price.
Any idea why this may happen?