The United States and Taiwan ended two days of negotiations in Taipei yesterday in open disagreement on the basis for their future relations.

The unsuccessful conclusion of bilateral talks came just three days before the United States is scheduled to officially recognize Peking as the sole government of all of China and withdraw its diplomatic recognition from the Republic of China government on Taiwan.

President Chiang Ching-kuo, in a final meeting with Deputy Secretary of State Warren Christopher and a U.S. diplomatic team, insisted that "government to government level mechanisms" must be set up to continue relations between Taipei and Washington, and that the United States must provide security assurances "of a legal nature" to replace the Mutual Defense Treaty that is being terminated.

Saying that there is "no agreement" on government-level relations, a State Department official told reporters here that the issues in contention are "highly complex" and will have to be thrashed out over a period of time.

Harvey Feldman, director of the State Department's Office of Republic of China Affairs, said negotiations would continue both in Taipei and Washington trhough official channels after the United States withdraws its diplomatic recognition Jan. 1.

In preparation for the diplomatic shift, Taiwan's ambassador to Washington, James Shen, left Dulles Airport for home late yesterday to an emotional sendoff by friends and supporters. He received a final goodbye at the airport from Undersecretary of State David Newsom.

Earlier in the day, Shen said goodbye at his embassy to Sen. Barry Goldwater (R-Ariz.), who denounced the switch in U.S. diplomatic relations and charged President Carter with "lying, thumbing his nose at the Constitution and the U.S. Congress, and selling out Taiwan," Shen said, "All I want to say is that I'm very sad."

The departure from Taipei of the U.S. party headed by Christopher was hastier. For security reasons, the departure time of the group was not announced in advance, and what was described as the "abrupt" departure surprised some Taiwan officials.

The Christopher party was met on arrival in Taipei Wednesday night by 6,000 to 10,000 angry demonstrators who hurled eggs, tomatoes, mud and rocks at the U.S. officials and smashed their automobile windshields with bamboo sticks. During their stay, a Taiwanese set himself on fire to protest the U.S. action and the newspaper China News said another chopped off his left index finger and wrote "I love my country" in blood on apiece of white linen.

Chiang's presentation to Christopher in their final meeting, made public by Taiwan officials at a press conference, insisted that future ties with the United States must rest on "five underlying principles -- reality, continuity, security, legality and governmentality."

According to the official account, Chiang told Christopher that the government and people of Taiwan were "outraged" by Carter's decision to sever diplomatic relations with "a staunch ally."

U.S. officials said the Taiwan government appears to have stiffened its demand for government-to-government relations in the past four or five days. It had been anticipated that despite initial protests, Taiwan would settle for "unofficial" relations with Washington along the lines of those maintained with Japan and a large number of nations that do not recognize Taiwan diplomatically.

Peking insists that Taiwan is part of China, and has demanded that diplomatic relations with Taiwan be severed when formal ties are established with the mainland. The United States accepted this demand in agreeing to recognize Peking two weeks ago.

Chiang's presentation to Christopher seemed to suggest that the United States should recognize the Republic of China as the real and effective government of its small islands offshore from the vast mainland.

Calling it "an effective government, which has the wholehearted support of her people," Chiang said that "the legal status and international personality of the Republic of China is a simple reality which the United States must recognize and respect."

State Department officials noted yesterday that in the past, the Taiwan government has continued to insist that it is the sole legal government of all or China.

Feldman, calling the new position "a nuance of change," said it is not yet clear whether Taiwan is moving toward assertion of a "two China policy."