SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Evangelist N9ne's Avatar
    Join Date
    Aug 2002
    Location
    UK
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Stock Exchange Emulation

    This is a difficult one IMO. I want to emulate a stock exchange in PHP (and MySQL).

    There are several issues though, things that I'm not sure how to implement.

    Users will register and register a business to be on the stock exchange. These same users can buy and sell shares in other companies on the exchange. They have money allocated to them upon registration, say for arguments sake, $1000.

    The problem is the share prices. Share prices are determined by the selling and buying. What would be the best way to go about this? Maybe I can set it so that when a user buys say $100 worth of shares in Company X, where share prices are $1.00 each, and no one sells shares that day, that the share price will increase. However, how much does the share price increase by? Do I say 0.5% of the value invested in the company?

    Also, there's the human aspect of it. Naturally, in real life, any changes in the environment and economy may affect the share price. However, not directly, again, through sellers and buyers. I intend, randomly to make news items geared towards individual sectors or industries, or sometimes individual companies. I will put it as paramount importance that all users are aware and do read the "news articles". Therefore, can I rely on users selling shares (and selling exceeding buying due to a negative article inducing a fall in share price)?

    Also, what is the best way to implement this using PHP and MySQL? I am thinking a MySQL table just as a table displaying the companies, their share volumes and prices would suffice; however, the PHP handling of the share price itself is what is going to need your inputs!

    Any advice welcome on any aspect of this.

  2. #2
    SitePoint Guru defiance's Avatar
    Join Date
    Oct 2004
    Location
    United states
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    complicated...

    but there are ways to do that....

    you need to give your time to that...

  3. #3
    SitePoint Evangelist N9ne's Avatar
    Join Date
    Aug 2002
    Location
    UK
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by defiance
    complicated...

    but there are ways to do that....

    you need to give your time to that...
    I certainly do .

    The main issue is the share price determination by means of demand and supply. I need to develop some sort of bid/ask system maybe; I'm really looking for the best solution to handle supply/demand of shares. There won't be much trading going on in my system as I don't have the population of a country playing it, so I can't just rely on that.

    As far as my ideas go, I will have news items posted and these will affect industries/sectors and individual companies. I'm most likely going to have any reduction in an industry's value or a firm's market share result in a fall in the share price.

    Maybe I don't generally need to have the share prices change as a result of supply and demand? Even though it's a fundamental determinant of share price fluctuations, in my case it might be able to become an exception due to the nature of the game being played.

  4. #4
    Non-Member DaveMichaels's Avatar
    Join Date
    Nov 2004
    Location
    US
    Posts
    535
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might investigate NASDAQ - that's all computerized.

  5. #5
    SitePoint Evangelist N9ne's Avatar
    Join Date
    Aug 2002
    Location
    UK
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DaveMichaels
    You might investigate NASDAQ - that's all computerized.
    But doesn't the NASDAQ involve market makers for each firm?

  6. #6
    Non-Member DaveMichaels's Avatar
    Join Date
    Nov 2004
    Location
    US
    Posts
    535
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by N9ne
    But doesn't the NASDAQ involve market makers for each firm?
    Yes, but I don't know whether that is computerized too. I've never heard of human market makers (presumably sitting behind a computer) in NASDAQ.

  7. #7
    SitePoint Evangelist N9ne's Avatar
    Join Date
    Aug 2002
    Location
    UK
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DaveMichaels
    Yes, but I don't know whether that is computerized too. I've never heard of human market makers (presumably sitting behind a computer) in NASDAQ.
    I'm fairly sure that market makers are humans as they make "profits" by making rapid decisions with trading shares.

    http://www.investopedia.com/universi...g/trading3.asp

  8. #8
    Non-Member DaveMichaels's Avatar
    Join Date
    Nov 2004
    Location
    US
    Posts
    535
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Market Maker:
    A broker-dealer firm that accepts the risk of holding a particular number of shares of a particular security in order to facilitate trading in that security. Each market maker competes for customer order flow by displaying buy and sell quotations for a guaranteed number of shares. Once an order is received, the market maker immediately sells from its own inventory or seeks an offsetting order. This process takes place in mere seconds.
    http://www.investopedia.com/terms/m/marketmaker.asp

  9. #9
    SitePoint Evangelist N9ne's Avatar
    Join Date
    Aug 2002
    Location
    UK
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DaveMichaels
    I see, it is automated, however, implementing such a thing into my system might be quite difficult. Also, it may be overkill in terms of the time put into programming against its usage, as trading in shares will not occur too often. Maybe it might be better for me to only have the share price determined by sector/industry changes and the firm's profits, revenues and good and bad news.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •