I believe the gains losses are aggregated to a total gain/loss at the end of the year, so in this case - yes, they would offset.
My understanding is that the loss you can take is limited, not to $3000, but to the amount of money you have at risk with the firm, so the limit you could deduct in...