Family of functions with two horizontal asymptotes

I think what you're looking for is a form of logistic function, such as $$f(x)=\frac{2}{1+e^x}-1.$$

graph

edit: For your specific criteria with $y_1$ and $y_2$: $$f(x)=\frac{y_1-y_2}{1+e^x}+y_2.$$

edit 2: For comparison of my answer to the other two answers:

comparison graph

dashed/black: $\frac{2}{1+e^x}-1$; blue: $-\frac{2}{\pi}\arctan x$; red: $-\frac{x}{\sqrt{x^2+1}}$


Just take $- tan^{-1} x$. Vary it appropriately for additional constraints.


Another famous family of functions that behave as you describe is those of form $y=\dfrac{x}{\sqrt{x^2+1}}$. (This function is actually the sine of the arctan function George suggested)

Graph of $y=-\dfrac{x}{\sqrt{x^2+1}}$:

graph

For a general y1 and y2, the formula would be $y=-\dfrac{y_1-y_2}{2}*\dfrac{x}{\sqrt{x^2+1}}+\dfrac{y_1+y_2}{2}$