Stocks rose on Tuesday as large tech companies like Apple and Amazon outperformed while investors remained cautiously optimistic Washington and Beijing could move forward on a trade deal.

The Dow Jones Industrial Average gained 256.10 points to close at 23,787.45, posting its first three-day winning streak since late November. The rose 0.97 percent to 2,574.41 as the real estate and communications services sectors outperformed. The Nasdaq Composite climbed 1.1 percent to 6,897. For the year so far, the Dow and S&P 500 have risen 1.97 percent and 2.7 percent, respectively. The Nasdaq is up nearly 4 percent in that time period.

Apple shares rose 1.9 percent after CEO Tim Cook tried to assuage some of the concerns plaguing the tech giant. In an interview with CNBC's Jim Cramer, Cook said Apple's "ecosystem has never been stronger." Apple took a beating last week after slashing its quarterly revenue forecast, citing a slowdown in China. Cook also said he feels good about the "real-time" information he receives regarding the U.S.-China trade talks.

Amazon also gained 1.66 percent, while Facebook jumped 3.26 percent. Netflix and Alphabet also closed higher. These gains add to the so-called FAANG trade's sharp rise since Dec. 24. Through Tuesday's close, Facebook shares have surged 15.9 percent since then, while Amazon has rocketed 26.8 percent. Alphabet shares, meanwhile, are up 11 percent in that time period. Netflix's stock is up nearly 37 percent in that time.

"People are getting a bit more optimistic. I think investors noticed that the FAANG stocks are solid companies and their valuations came down a lot after the big sell-off," said Ryan Nauman, market strategist at Informa Financial Intelligence. There's also "some optimism in trade and the FAANGs have been pretty highly correlated to the developments of trade."