buying and selling stock function