No limit. You must use the loss to offset any gains (i.e. can't pick and choose when to use), but you can choose what gains (dicountable or non discountable) if gains are greater than losses