Investors avoiding risks from the Iran war are selling stocks and bonds and rebuilding cash allocations, in an echo of strategies followed after Russia invaded Ukraine in 2022.