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:
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