Nasdaq gains 4% in August as tech rebound offsets hawkish Fed