All three major averages rose on Monday, despite Iran’s retaliatory attack on an American military base in Qatar.