YESTERDAY, we spoke of the accomplishments of President Reagan's last four years.

Today, we glance ahead at the term to come and perhaps its largest challenge. The greatest achievement of President Reagan's first administration has been the change in the country's atmosphere. It's been one of the periods in which Americans have got along pretty well with each other. What are the prospects for the next four years?

One very prominent contributor to this era of good feelings has been a wave of rising prosperity -- generated by a federal budget deficit beyond the imagination of Mr. Reagan's predecessors. The one piece of legislation about which he cared deeply, the tax cut, was enacted within seven months of his first inauguration. The signing of that bill, four years ago this August, was the high point of that administration. Since then the president has been content to let the economy run its course, first into a deep recession and then on to a booming recovery that, happily for himself, coincided with his reelection campaign.

The deficit now hangs over Mr. Reagan's administration like a shadow. It brings to mind the genie in the fairy tale who, having performed a great service for the king, wants to be paid. But the king does not wish to pay. The king tries to ignore the genie, whose assistance he no longer needs. But the genie refuses to go back into the bottle. Instead, he begins to make mischief for the king. Do you suppose that the events of Mr. Reagan's second term are going to follow the fairy story? Maybe not. But then again, whether in stories or in national politics, in the end genies usually insist on being paid in full.

Unrequited so far, Mr. Reagan's economic genie is now making difficulties for him by opening up a huge trade deficit that has to be financed from abroad. No one can tell the president how long this inflow of foreign money will continue. His seers and economists can only tell him that if the flow slows down, the result will be Trouble with a capital T.

Mr. Reagan has banished the seers and economists from the palace, and begun to pursue other interests. How about foreign affairs? There are great things to be done in the crucial areas of disarmament negoiation and peacemaking. It's an appealing idea. But the rest of the world does not always allow an American president to choose his own time and place of action. It's hard to think of a moment when the world has been less demanding of American leadership than the present. If serious international money trouble were to arise, that would change very quickly.

Mr. Reagan has not conveyed any strong sense of a new political direction for the second term. What he evidently has in mind is four years as much as possible like the last four. That, certainly, is what the voters asked for. But he may yet have to wrestle the genie of the deficit for control of the national agenda in the late 1980s. A lot of his friends in Congress are telling him that. It's beginning to look as though the test for him in the second term will be to avoid becoming wholly entangled in that one question -- whether the genie has to be paid, and by whom.