U.S. stocks were on track to post monthly gains Wednesday, while oil prices surged on reports that major producers were close to reaching a deal to cut production.

Oil prices have whipsawed in recent sessions on questions about whether the Organization of the Petroleum Exporting Countries would come to an agreement to curb output amid a global glut of supply.

U.S. crude oil rocketed 7% to $48.41 barrel as people familiar with…