The S&P 500 rose about 2% in December as the Trump rally rolled on, but that didn't stop a large number of individual investors from locking in gains.

"We've been seeing profit-taking in some sectors after the election, even when the S&P 500 was hitting new highs," says Steve Quirk, executive vice president of the trader group at TD Ameritrade (AMTD) .

The behavior-based TD Ameritrade Investor Movement Index, or IMX, which aggregates Main Street investor positions, fell 1% to 5.48 in December as retail investors slightly decreased their exposure to the U.S. equity markets for the second month in a row. The VIX, or so-called fear index, started and finished the month at 14.

Each month, TD Ameritrade pulls a sample from its client base of 6 million funded accounts that includes all accounts that completed a trade in the past month. The holdings and positions of this statistically significant sample are evaluated to calculate individual scores, and the median of those scores represents the monthly IMX.

As the holiday shopping season reached its peak in December, Amazon (AMZN) was a net buy. This is the third month in a row TD Ameritrade clients were buyers of Amazon as well as of Facebook (FB) .

Bank of America (BAC) , which appeared to stabilize following a dramatic increase after the presidential election in November, was also a net buy. Chipmaker Nvidia (NVDA) , one of the best performing stocks in the S&P 500, was also a popular buy.

On the flip side, Apple (AAPL) was net sold during the December IMX period as it traded up toward its year-to-date high. Energy sector issuers ConocoPhillips  (COP) and Chevron (CVX) were net sold as their share prices appeared to match gains in crude oil prices, which rose above $50 for the first time since October.

Looking back at 2016, Quirk said TD Ameritrade clients were net buyers overall in 2016, increasing their equity positions heading into 2017. The most popular buys of these investors over the past year were Amazon, followed by Facebook. Valeant Pharmaceuticals (VRX) , Gilead Sciences (GILD) and Alphabet (GOOG) rounded out the ranks of the top five stocks bought.

The five most popular stocks sold in 2016 by TD Ameritrade clients were Apple, Netflix (NFLX) , Alibaba (BABA) , Bank of America and Chevron.

Apple and Facebook are holdings in Jim Cramer's Action Alerts PLUS Charitable Trust Portfolio. Want to be alerted before Cramer buys or sells these stocks? Learn more now.

More from Markets

Stocks Gain Momentum Following Lull, Dow Back up Triple Digits, Nasdaq Negative

Stocks Gain Momentum Following Lull, Dow Back up Triple Digits, Nasdaq Negative

How to Be a Tactical Investor in the Current Market

How to Be a Tactical Investor in the Current Market

State Street Shares Fall as Earnings Fail to Meet Expectations

State Street Shares Fall as Earnings Fail to Meet Expectations

What Jim Cramer Would Do if He Was on the Fed

What Jim Cramer Would Do if He Was on the Fed

Skechers Flying High as Major Indexes Rebound

Skechers Flying High as Major Indexes Rebound