-1

I am looking for an algorithm that will calculate the intrinsic value of a stock based on the number of people buying /selling it and additionally consider the calls/puts to fluctuate the value of the stock.

Essentially:

Current Price = Function(Stock Price, Number of Sellers, Number of Buyers)

Essentially I want to know how the stock exchange server backends work and the algorithms involved in calculating the stock prices.

Any guides/help or documentation in this regard would be extremely helpful. I tried looking around using google but the information is very sparse, inaccurate and I don't even know what keywords to use for efficient search.

Also, are there any existing Java code that I can look at to get an idea?

Also, I found API close to what I was looking for at http://jessx.ec-lille.fr/index.php. Would still in interested to learn about the technology/algorithm behind it.

casperOne
  • 73,706
  • 19
  • 184
  • 253
Ganesh Krishnan
  • 7,155
  • 2
  • 44
  • 52

2 Answers2

2

Also, are there any existing java code that I can look at to get an idea?

I would be extremely surprised if you could get your hands on the source code of a real stock exchange system.

Having said that, I don't know if there is such a thing as an intrinsic value of a stock that is distinct from the price at which it is being bought and sold. Feel free to experiment, but you'd probably do better by researching the relevant Economics literature than looking for answers in code. You'd probably need a solid grounding in Economics just to understand the code.

(Bear in mind: if there is possibility of money to be made from an "intrinsic value" measure, the chances are that thousands of really smart people will have tried this already ...)

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
2

I think you are mixing two things here. In simple terms, an exchange provides a service that enables buyers and sellers to meet each other and realise transactions.

The price at which transactions happen is entirely determined by the orders received by the exchange (the clients buying and selling), not by the exchange, which merely reports the prices at which the transactions occur.

Where the exchange might have an impact is where it enables certain types of orders (say a stop order for example) and how it handles it - but it does not sound like you are interested in that part.

What you seem to be looking for could be as simple as:

  • define a price for an asset, say 100
  • have buyers and sellers randomly send orders at a limit +/- 10 cents of the current price
  • when a buy order meets a sell order (say a buyer wants to buy at 100.05 and a seller wants to sell at that price too), generate a transaction which gives a new price to the asset
  • loop

But from an implementation perspective, the (very) tricky part is in "buyers and sellers randomly send orders...".

You can also add exogeneous shocks (say an announcement) which modifies the balance of buyers vs. sellers, triggering a significant move in price (up or down).

assylias
  • 321,522
  • 82
  • 660
  • 783
  • The intrinsic value of a stock changes depending on the number of people who have bought the stock. For example a stock trading at $100 might increase in value to $115 when 10 people buy it and 3 sell it. Or it could change to $87 if 5 people sell it. I am interested to calculate the value ($115 or $87) for the buy/sale of the underlying stock. – Ganesh Krishnan Sep 16 '12 at 12:06
  • 1
    @GaneshKrishnan I'd say it depends on the number of people buying/selilng and their willingness to buy/sell. A typical example is a takeover situation: you will see many sellers who want to realise their gain and sell at a small discount to the takeover price, but it won't move the stock much below the takeover price because they are price sensitive and would rather wait than sell at too high a discount. – assylias Sep 16 '12 at 12:09
  • @GaneshKrishnan Now if you want to model the offer/demand properly, it can get fairly complicated. There are numerous papers on the subject, for example: http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1735338 – assylias Sep 16 '12 at 12:11
  • Thanks for the comments. I am looking for the buy/sell ratio vs price calculation algorithms. Edit: Thanks for the link to the paper. That's the kind of stuff I was looking for! – Ganesh Krishnan Sep 16 '12 at 12:12
  • 1
    There isn't a *"price calculation algorithm"*. You can try to model the arrival of buy/sell orders and deriver a price from that. – assylias Sep 16 '12 at 12:14