HOW FAR does the stock market have to fall, and for how long, to force the White House and Congress into a compromise on the budget? Last week's air of desperate urgency evaporated with remarkable speed once the market began to rise again. Yesterday's yo-yo ought to be sufficient evidence that the market is still dangerously off balance. The budget impasse here in Washington is feeding the anxieties that the market is reflecting.

The basic difference between Congress and Mr. Reagan lies deeper than the stale quarrel over spending priorities. Most of the congressional negotiators, of both parties, think that the budget deficit makes a real difference. Mr. Reagan continues to believe that it really doesn't. He seems to believe that it affects public psychology, like a rainy weekend, but that the antidote is a little sunshine. The possibility that the deficit might have a direct arithmetical effect on stock prices remains foreign to him. How could that be, when stocks rose dramatically through five years of huge deficits?

The answer is that other circumstances favored the United States and its financial markets for the first four of those five years. But then, as it always does, luck ran out.

When a government runs a deficit, lenders have to put up the money that it borrows. A country with a high savings rate, like Japan, can run big deficits with plenty of savings left over for industrial development and expansion. A country with a low savings rate -- and Americans save notoriously little -- can afford a big deficit temporarily, as long as foreigners are willing to lend it their savings. That's how the United States got along until early this year. But then the foreign investors began to think they were holding too many dollars, and last winter the voluntary flow of private foreign investment fell sharply. That made the dollar drop.

To prop it up, foreign governments bought billions of dollars. But that sharpened the political differences between this country and the others over economic policy. As long as the United States keeps running those big budget deficits, any solution means either higher interest rates or higher inflation -- and probably both. Both are bad for stock prices. The open quarrel with the Germans last month over interest rates seems to have been the trigger of the market's crash.

That's why the United States has to get its deficit down. And that's why it has to be done both quickly and firmly.