Dollar stays firm on US optimism, but risks loom