US stocks rallied, with the S&P 500 and Nasdaq closing higher as investors grew hopeful over potential Middle East de-escalation and Iran talks. Softer US producer inflation and a solid earnings season boosted risk appetite. Tech, software and semiconductor stocks led gains, with indices nearing record highs.