This is a monte carlo simulation of stock prices and investment performance.
It has been created to help to determine optimal buy/sell investment strategies.
The change in the stock price will be determined as a function of its recent changes and pseudo-randomness (random numbers). A stock thats price recently dropped by a lot is more likely to drop further in price than a stock that has been stable or increasing. This allows the simulation to mimick the effect of the stock market where it goes through periods of rallies and corrections (ups and downs).
- Note that this will only run on a linux operating system. If you are using windows, you will need to run it through WSL.
- See the most recent version here
- Click on 'Assets' to reveal the available downloads.
- Download the programme by clicking on
runSim
.
- You will need to give the programme appropriate executable permissions for it to run. Once you have downloaded it, run the following command:
chmod +x runSim
- For usage information run the program without any command line arguments as such:
./runSim
This will display the necessary command line argument for the simulation to work. - The general format for running the programme is:
./runSim strategy numMonths initialStockPrice initialCashValue
strategy
must be an integer (whole number)- 0 = buy and hold. Buy as much as possible, as often as possible.
- 1 = dollar cost average. Buy once a week until you run out of cash.
numMonths
must be an integer (whole number). If you want the simulation to run over a period of two years, thennumMonths
will be 24 (12 months/year x 2 years)initialStockPrice
must be a number above 0 (can be a decimal/double number)initialCashValue
is the amount of cash that the account starts with (positive number). It helps regulate buy and sell strategies to simulate an individual investor following the strategy.
It is written in C. Runs the simulation concurrently with threading. Any contributions are much appreciated!