I am making an overly simplified version of a stock simulator game, because I:
- am fascinated with how the stock market works
- learn better & faster from a project like this, rather than text-books
Before writing any actual code, I started making an Excel spreadsheet to simulate the fluctuations of 1 company's stock based on how many people buy/sell the stock on any given day, so that when I have the code, I have something to compare it against to know that it works.
Variables I have access to:
- a) Total amount of stock issued - 10000
- b) Starting stock price when the company goes public - $10.00
- c) Stock available on any given day
- d) Stock bought/sold on that day - for example, 150 on day 1
- e) Stock bought/sold the previous day - when first starting the simulation, this number is 0
- f) Company profits on any given day - For simulation purposes, profits are calculated daily, not quarterly or yearly
- g) Stock price - This is what I need calculated
I tried using (d-e)/a which gives me a difference, like 0.015 which I use to get the stock price for the next day. But it just seems too simple, since buying 100% of the stock on day 1 and then selling 100% of it on day 2, brings down the price to $0.00. Perhaps this would work given enough random participants who all buy/sell the stock, but in this case, I need the simulation to work with just 1 person. And the simple function I wrote just gives too much power to that 1 person.
PS: For simulation purposes, I assume there is always a buyer and always a seller for the stocks.
PPS - Edited to provide the test numbers I'm starting with