whenever you sell a stock, you realize either a gain or a loss
so for taxes its pretty straight forward (if you actually keep track of the stocks you've realized a gain or loss on)
gains minus losses and that is what you owe in taxes....if your realized gains turns out to be a negative number..then that obviously means you realized more losses for the year and owe nothing
but its still very important to file a 1099