US stocks gain to start the 2nd half of the year as traders wrap up early for Independence Day