With this cost function, buying and selling is a lot easier since it uses the same function. Also, shares are now always integers which is also easier to grasp. Reference: http://blog.oddhead.com/2006/10/30/implementing-hansons-market-maker/