Stock Market algorythm

Posted on 2006-06-05
Last Modified: 2012-06-22
Does anyone know where I can find information about the kinds of algorythms used to determine current prices on the stock market?  

For example, the more people that want to buy a stock, the higher the price goes.  But how does the algorythm work that determines how high the prices goes?  Why does the stock rise to $1 instead of $1.10?

I'm working on a game that will have a market-like component.  As players buy weapons, the price of the weapons will increase for other players and likewise if lots of players sell off, then the price needs to drop.  I have a few ideas, but I'd really like to model it after a real market as much as possible?

Question by:spuerman
    LVL 9

    Accepted Solution

    Hi spuerman,
    There isn't a single algorithm to determine what price a company's stock goes for.  It's based upon what people are willing to pay.  If people want to get rid of their stock in a company, it's likely because the company is doing something wrong, and the people expect their stock value to fall for reasons unrelated to stock availability.  Also, ignoring economic influences (market share, etc.) and just treating the stock exchange as its own independent free-market system, you can simulate it using supply-and-demand.  The greater the available supply of the stock, the less bargaining power the owner of a set of shares has when he wants to sell.  Hence, the lower the price.  The opposite is true, as well.

    Of course, to get even a semi-realistic simulation, you need to simulate market influences external to the exchange.  In other words, stock prices need to frequently go up and down regardless of the sort of volume that company's stocks are seeing in the exchange.  And, even further, that fluctuation needs to spur action in the exchange.

    The fact that there's no set algorithm for determining stock prices is what makes it so problematic to play the stock market.  If there were a set algorithm, it'd be much easier to score big, because it would be much more deterministic.

    Nobody's ever come up with a foolproof method for simulating stocks.  Play around with it.  Even better, get on one of the stock exchange simulation games online (go to google and search for "stock market simulation".  The entire first page will be free stock market games that allow you to trade shares using the prices set in the real exchange), and run your simulation with real stocks and real trading volume, and tweak it until it starts working reasonably well.

    Then play the market with it and get rich.  (c:
    LVL 31

    Expert Comment

    The best information you can get is (I think they call it) Level 2 information - which is the details of (1) the Price that a Seller has posted that he is prepared to sell for (2) the price that a Buyer of the shares buys them for.  This is factual information because this is the value that the Shares changed hands for.  The price you often see advertised is what the Seller would *like* to sell the Shares for, which could be artificially high.

    Several companies offer this information, but you need a means to interpret it to produce an investment strategy.
    LVL 31

    Expert Comment


    gives details on Level 2 data
    LVL 31

    Expert Comment


    Author Comment

    so are you saying that there are literally people that just sit around & bid on what they are willing to pay for each stock out there & that the current price is based on that?  I had assumed there was some kind of algorythm so that everytime someone bought a stock, it would effectively raise the price while selling the stock would lower it.
    LVL 9

    Expert Comment

    Nope.  It's a free market system.  Prices are based on a compromise between what the owner wants to get and what the buyer wants to pay.  There are economic issues that make stocks more desirable to have (dividends paid by the company, annual growth percentage, stability, etc.), but ultimately, a share is only worth as much as you can get someone to pay for it.
    LVL 31

    Assisted Solution

    (This all relates to the UK market)

    There are "tipster" journals you can buy which give analysis on why you should buy a particular share.  Being a cynic I'm sure that Dealers subscribe to these journals themselves and artificially hike the prices on these shares and wait for the demand to roll in.  If it doesn't then they modify their prices downwards accordingly.  Similarly when there is *speculation* of a takeover, the price of the Target company may go sky-high to align with the price that the predator company will pay for the company, which will reflect in the new worth of the Target Company Shares.  There is quite often no basis at all to assume that something will happen.  

    ...and we haven't mentioned conventional Put and Get or Traded Options yet.  A good way to make money in a falling (bear) market.

    The barometer that a lot of people use to determine the outlook of the economy, prospects, optimism/pessimism is the price of Gilt Edged Securities.  Others use various Indicators - leading or laggard - to determine mood.  Read Investors Chronicle, which is a weekly publication.
    LVL 44

    Assisted Solution

    forget the stock market back to your original question

    >>I'm working on a game that will have a market-like component.  As players buy weapons, the price of the weapons will increase for other players and likewise if lots of players sell off, then the price needs to drop.  

    this will give you a go, its pure theory with a bit of real life mixed into it

    the stock market is a bad sample to take your cue from, you better start with some economic theory and add the complexity later

    stock market is not only people willing to pay prices but also able to pay them, so liquidity is the most important basic factor you need to take into account, since this is lagging central banking behaviour you still have to look at the real economy for cues about how much money will be around to play the stock market

    in real life you live in a village with no grocery store
    since you got a car you're willing to make the ride to town and buy surplus goods for people asking for them
    then you come and sell them in the village with a small profit because you calculate

    in the stock market you buy google at 380 and it goes to 410 because of gamblers around you
    one day the FED decides to turn off the liquidity tap, the initial reaction is not bad google closes at 390
    markets overnight react badly and the USD sells off
    google opens at 360

    stockmarkets have larger external unknowns then normal market behaviour outside of that so for your game i would dismiss the stock market because its a world on its own

    the best markets to watch for some relation to real life bid-ask behaviour are the commodities and then you should exclude precious metals those are the domain of the same forces as the stock market liquidity driven

    look at wheat, whool, sugar, coffee or cotton markets if you really want to base your game on financial markets, those markets incorporate pricing models that include weather, shortage and oversupply factors

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Title # Comments Views Activity
    fizzArray3  challenge 1 47
    zeroFront challenge 7 58
    Reading variable length EBCDIC in SAS 9 56
    python question 5 36
    I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now