Hopes for a deal to end the Iran war and revive the Strait of Hormuz drove oil lower while leaving stocks near record highs, with the market also supported by enthusiasm for artificial-intelligence trades.