The United States and Peru have signed a free trade agreement after 18 months of negotiations.