Calculation of Eccentricity of orbit from velocity and radius
If you have the relative position $\mathbf{r}$ and velocity $\mathbf{v}$ at the same point in time, compute the eccentricity vector:

$\mathbf{e} = \frac{\mathbf{v} \times \mathbf{h}}{\mu} - \frac{\mathbf{r}}{\|\mathbf{r}\|}$

Where $\mathbf{h} = \mathbf{r} \times \mathbf{v}$ is the specific relative angular momentum and $\mu = GM$ is the standard gravitational parameter.

The eccentricity is then given by the norm of the eccentricity vector $\left\| \mathbf{e} \right\|$.