The S&P 500 was hanging on to a modest gain Friday, as bolstered trade hopes and upbeat consumer data stoked optimism on Wall Street ahead of an expected rate cut by the Federal Reserve.