Stocks, dollar gain as unclear U.S. election thwarts Democratic sweep