Investors in U.S.-based funds committed $3.45 billion to stock funds in the week ended Wednesday to capitalize on a final stretch of record gains in the U.S. stock market in 2013, data from Thomson Reuters' Lipper service showed on Thursday.

The inflows into stock funds in the week ended January 1 marked the second straight week of new money into the funds. The Standard & Poor's 500 ended the year at a record high in the holiday-shortened week.

Stock exchange-traded funds, which are thought to represent the institutional investor, attracted $3.05 billion in new cash, while stock mutual funds, which are commonly purchased by retail investors, attracted just $406 million.

"It was a last play by ETF investors," said Tom Roseen, head of research services at Lipper. The S&P 500, which rose 29.6 percent for the year, marked its best year since 1997.

Stock funds attracted a record $320 billion in new cash in 2013, trouncing the previous record of $201.5 billion in 2004 and marking the first inflows in three years, according to preliminary Lipper data. Lipper began tracking the funds in 1992.

Stock mutual funds attracted $183.7 billion of the net inflows into stock funds in 2013, while stock ETFs attracted $136.4 billion, the preliminary data show.

The Federal Reserve's $85 billion in monthly bond-buying stimulus, which the central bank has done in an attempt to spur hiring and lower long-term borrowing costs, kept bond yields low and led investors to seek higher income in stocks last year.

Funds that specialize in U.S. stocks attracted $163.9 billion of the net inflows into stock funds in 2013, while funds that mainly hold non-U.S. stocks attracted over $156 billion.

In the latest week, funds that hold Japanese stocks attracted $294 million after minor outflows over the previous week. Tokyo's Nikkei share average rose to a six-year high on December 26 and ended the year up 56.7 percent, buoyed by Japan's aggressive fiscal and monetary stimulus.

Taxable bond funds had outflows of $3.3 billion in the latest week, reversing the prior week's inflows. Investors sold bonds over the period on data showing improvement in U.S. jobs, while bracing for the Fed to begin cutting back its $85 billion in monthly bond-buying stimulus in January.

Investors pulled $1.1 billion out of funds that mainly hold safe-haven U.S. Treasuries, marking their biggest weekly outflows since early October. The yield on the benchmark 10-year U.S. Treasury topped 3 percent on December 27, marking a two-and-a-half year high.

Investors also shunned high-yield junk bond funds and withdrew $643.4 million from the funds, underscoring investors' aversion to bonds over the period.

Investors committed just $29 billion to taxable bond funds in 2013, marking the weakest turnout for the funds since 2000. Investors began pulling cash out of the funds in early June after Fed Chairman Ben Bernanke told Congress on May 22 that the central bank could begin reducing its monthly bond-buying later in the year.

Through the end of the year, the yield on the benchmark 10-year U.S. Treasury rose about 140 basis points from a yearly low of 1.62 percent on May 2. Investors feared that a pullback in the Fed's bond-buying would hurt bond prices by causing rates to spike higher.

High-yield bond funds sustained outflows of $5.3 billion in 2013, marking their first annual withdrawals since 2005. Analysts have said that investors awakened to the risk of losses in bonds last year, despite the view that they are safer than stocks.

Funds that hold floating-rate bank loans, which are protected from rising interest rates by being pegged to floating-rate benchmarks, attracted just $142.3 million in new cash over the weekly period, marking the weakest turnout for the funds since October 2012.

Those small inflows were an anomaly, since the funds attracted $62.6 billion in new cash in 2013, trouncing the previous record inflow of $18.2 billion in 2010. The funds, which Lipper began tracking in 2003, gained demand on the concerns of rising interest rates.

Thin trading volume over the reporting period resulted in inflows of $14 billion into money market funds, which are low-risk vehicles that invest in short-term securities. The funds are viewed as a place to park cash.

Investors pulled $28.4 billion out of commodities and precious metals funds last year, marking the first yearly outflows since Lipper began tracking the funds in 2011, the preliminary data showed.

Gold sank by 28 percent in 2013, marking its biggest annual loss in 32 years, as the Fed announced plans to unwind its easy money policies.

The weekly Lipper fund flow data is compiled from reports issued by U.S.-domiciled mutual funds and exchange-traded funds.