A wave of seeming panic gripped investors to day, and heavy selling triggered a huge decline in stock and commodities prices.

Bond prices also fell after the Federal Reserve took actions this afternoon that kept the key federal funds interest rate from falling below 18 3/4 percent.

But the decline in bond prices paled before the 23.80-point decline in the Dow Jones Industrial Average of 30 major stocks and the $26.30-anounce fall in gold prices. Optimistic investors had no time to savor the Dow average's close over the 1,000 barrier Tuesday. The Dow closed today at 980.89.

It was the heaviest trading day by far on both the New York And American stock exchanges. Nearly 96.7 million shares changed hands on the big New York exchange, far surpassing the previous record of 84.3 million shares set on Nov. 5 in the investor jubilation that followed Ronald Reagan's presidential victory.

Analysts said the selling wave was triggered when Joe Graville, a widely followed technical analyst of the stock market, wired clients overnight, telling them taht they should "sell everything."

Sell orders were so heavy that more than 100 stocks could not begin trading when the bell sounded at 10 a.m. because not enough buyers could be found. "It took four hours before International Business Machines could open," according to Hildegard Zagorski, an analyst with the major brokerage firm Bache Halsey Stuart Shields Inc. The stock exchange calls the situation an order imbalance. About 50 stocks had the same trouble on the Amex.

Only Tuesday the Dow Jones Industrial Average climbed over 1,000 in what seemed to be a major victory for investors who believe stock prices remain undervalued and are on the way up. Unlike the Dow's brief, last-gasp flop over 1,000 (to 1,000.17) on Nov. 20, stock prices were moving strongly upward in late Tuesday trading when the Dow closed at 1,004.69.

Neverthe less, Bache's Zagorski noted, the Dow average, perhaps the most closely watched barometer of stock prices, closed nearly 8 points higher than its lowest price of the day. At 2:30 p.m. the Dow average was off 31.14.

Even after today's precipitous decline, the Dow average still is 17 points higher than when the new year started.

"The market would have sold off anyway," Zagorski said, "probably by 10 or 15 points," as investors tested the 1,000-level to see if it would hold. But the Granville advisory gave an extra impetus to the downward momentum. Only Monday, Granville's popular weekly newsletter urged subscribers to continue stock buying.

"The trend is still strong for stocks. No one man, not even Joe Granville, can fight the market," Zagorski said.

Although the optimists may have fought back during the last hour, they lost the day's battle. The number of New York Stock Exchange securities closing lower in price outnumbered those closing up by 1554 to 218, although earlier in the day decliners outnumbered advancing issues by nearly 20 to 1. Selling was so heavy that the New York Stock Exchange tape at one point was 3i minutes behind. At the close the tape was 12 minutes behind.

The Granville rocket spilled over into the Canadian stock market and sent share prices tumbling in Toronto.

The Toronto Stock Exchange composite index of 300 stocks, the main indicator of price movements, sank 54.04 to 2265.35, chopping $3.3 billion from the quoted value of Canadian shares on the exchange.

During the first hour, the index was down a record 61.37 points, before a modest recovery. The wave of "sell" orders caused the opening of many issues to be delayed as much as an hour. The stock market quotation tape was as much as 30 minutes behind market activity. Market analysts said the selling was approaching panic levels.

William Byers, director of commodity research at the big brokerage firm Bear, Stearns, said the collapse in stock prices served as the catalyst for a decline in commodities prices. However, he said, most commodities prices have been "shaky" since the middle of las December after they mounted a hesitant recovery from what Byers characterized as the "most precipitous decline in history."

The price of gold fell $26.30 to $571.50 and ounce in New York. Silver fell 97 cents to $15.32 an ounce, while the price of copper fell $1.35 to $85.95 a pound. Grain and cattle prices succumbed as well.

After the sharp decline in commodities prices in early December, many investors were unsure of themselves, Byers said. Trading volume and the number of commodities contracts outstanding dropped. He said besides the stock market decline, a seeming softening in the Iranian position towards the hostages alos helped push down the price of gold and silver, two commodities whose prices usually climb during tense international situations and ease when the climate becomes more relaxed.

Analysts said that the performance of both stock and commodites prices over the next few days is unclear. "Lots of people, if they weren't uneasy Tuesday, will be Thursday," Byers said.

Andrew Morse of th brokerage firm Drexel Burnham Lambert Inc. said that bonds that mature in about 30 years lost $11.25 for every $1,000 of face value while intermediate-term bonds lost between $3.25 and $6.25.

The Federal Reserve triggered the decline in bond prices about noon when it took steps in the open market to drain funds from the banking system when the so-caled federal funds rate was about 18 3/4 percent. Federal funds are monies banks lend each other overnight and a major tool the Fed uses in attempting to hold down the growth of the money supply to fight inflation.

Other short-term interest rates rose in response to the Fed's action as well, including bank certificates of deposit and Treasury bills.

Overnight reports that indicated possible release of the hostages sparked a flurry of dollar buying in Tokyo, sending it up to 201.25 yen from 199.60, United Press International reported. The dollar was trading at 200.75 yen in New York.

The dollar's strength was maintained in Europe and the United States by firmer interest rates.

in London the pound fell to $2.4130 from $2.4255 and to $2.41 in New York.

UPI reported the following European closing rates, with late New York prices in parentheses:

[frankfurt, 1.942 marks, up from 1.936 (1.95); Zurich, 1.7560 Swiss francs, up from 1.74855 (1.7660); Paris, 4.49 French francs, up from 4.4725 (4.51); Milan, 923.30 lire against 919.05 (922.75); and Brussels, 31.375 Belgian francs, up from 31.305 (31.28).]