Cook potatoes in simmering water until soft and put them through a potato ricer. Saute onion in margarine until very soft. Add 1/2 of the onions to the potatoes and season with salt and pepper.
For the pirogi sift flour and salt into a bowl. Add vegetable oil and enough water to make a soft dough and mix until the dough no longer sticks to the hands. Cover dough and let rest for about 5 minutes. Roll out dough on a floured board to a 1/4-inch thickness. Cut dough into small squares and place a dollop of potato mixture in the center of each square. Fold dough, pinching ends to form a triangle. When all are made, put into boiling water and boil for about 10 minutes.
For bobalki, roll out leftover dough into 3-inch long pieces and cook with pirogi.
When all are cooked, drain and serve with the remaining Sauteed onions on top.