You're taxed on your net realized gain, if any. For example, if you sold stocks for a $10k gain and you sold stocks for a $7k loss, you'd be taxed on $3k.

And yes, wash sales can throw a monkey wrench in that equation if you're not careful.