I have always wanted to be able to write my own software to run a stock exchange, but I have never been able to get a full grasp on how the whole stock exchange system worked. I always had been left with many questions.
- How exactly are the prices decided of the buying and selling of shares? Say I own 50,000 shares, and you own 25,000 shares, but you want to buy another 25,000 shares – how is that price determined?
- How would selling be done? Say I want to sell my 50,000 shares, what if no one wants to buy them straight away? Does the price rise or fall?
- Do I get to say how much I want to sell my shares for?
- Are you able to put down an order for 25,000 shares and wait until someone else sells shares? If so, are you able to set the price that you want to buy at?
The market determines arbitrarily the price that shares are sold to the buyer for. Say you’ve got a range of prices that different people are willing to buy shares for. The first guy selling shares will go to the guy paying the highest price. The one coming after will have to sell to someone who’s only willing to pay less.
Say you’ve got a range of prices that different people are willing to buy shares for. The first guy selling shares will go to the guy paying the highest price. The one coming after will have to sell to someone who’s only willing to pay less. Brokers only automate this process.
If you are buying shares, you’ll want to buy cheap first.
Say for example, you have two people. Person one has 1,000 shares for sale for $1.50 /each and person two has 1,000 shares for sale @ $1 /each. If I wanted to buy 1,500 shares, the price I would pay would be:
((500*1.5)+(1000*1))/1500
=1.16666666666666666667
=1.1667
So my buying price per share would not be $1 or $1.50, rather it would be $1.17 each.
How would I go about recording buy prices, so I can make funky graphs like Yahoo Finance / Google Finance does? Basically, I would record all transactions that occur, like the purchage above that I did for $1.17 a share, and then have the computer work out the average price of all transactions done in every say, 1 hour. Once I have all these averages, I just plot those numbers on the graph.
How would I go about automating buying shares if no one is selling anything? Well, there is margin buying, which is buying shares with money that you don’t have. Also, there is short selling, where you are selling for money shares that you don’t have, but there is not really an economic concept for buying shares that don’t exist. There is no real to implement on a small scale anything like margin buying or short selling.
special thanks goto Ari Rahikkala
Tim Groeneveld
says:No, it is still $1.17 for each share that is bought. Look at it this way, if 1,500 shares are bought at $1.17, that means $1755 was spent (the extra $5 was from the rounding) to by all the shares.
The figure of $1.17 that I show comes from this:
( (1000*$1) + (500*$1.50) ) / 1500
= $1.16666666666666666667
~ $1.17
But yes, the price paid in total would be $1750.
Lachlan
says:The price is determined by the selling price.
Person one has 1,000 shares for sale for $1.50 /each and person two has 1,000 shares for sale @ $1 /each. If I wanted to buy 1,500 shares, the price I would pay would be:
(1000*$1) + (500*$1.50)
= $1750
not $1.17 per share like you said.
Will
says:I presume it’ll all be worked into MyBanco? How will the money side of things work?