The "Super Simple Stock Market" is a Python-based simulation designed to illustrate the basic principles of a stock market system. This project facilitates the simulation of trading activities, calculation of dividend yields, and tracking of stock price changes in a simplified environment.
This project supports development in a containerized environment using Docker and Visual Studio Code DevContainers. This ensures that you have a consistent, isolated, and reproducible environment.
- Install Docker
- Install Visual Studio Code
- Install the
Dev Containers
extension for Visual Studio Code
- Open Visual Studio Code and clone the repository within VS Code or open the project folder if already cloned.
- Press F1 to open the command palette and type
Dev Containers: Open Folder in Container...
. Select the project folder and it will start building the container. - Wait for the container to build. This may take a few minutes the first time as it downloads the necessary Docker image and sets up the environment.
- Once the build is complete, VS Code will automatically connect to the container. You can now run scripts and use the terminal inside Visual Studio Code to execute any project-related commands in a Docker environment.
- Run the project or tests by using the integrated terminal in VS Code.
If you prefer not to use Docker and Visual Studio Code Dev Containers, you can run the project directly on your local machine. Follow these steps to set up and run the project locally:
echo "Upgrading pip and installing required packages..."
pip install --upgrade pip
pip install -r requirements.txt
echo "Running unit tests..."
python -m unittest discover -s tests -v
echo "Analyzing code coverage..."
coverage run -m unittest discover -s tests -v
coverage html
This should produce the following report:
echo "Running the stock market simulation..."
python3 -m examples.simulation
This section provides direct links to the specific code implementations of major functionalities and requirements outlined in the project requirements file. Each link points to the relevant file and line in this GitHub repository where you can see how each feature is coded.
-
Functions to return the Dividend Yield for any given stock
- Dividend Yield for Common stock: app/stock.py
- Dividend Yield for Preferred stock: app/stock.py
- Calculatiuons of the divident yield for each stock: examples/simulation.py
-
Function to update multiple stock prices at once: app/market.py
-
Function to to record a trade: app/market.py
-
Function to return the Volume Weighted Stock Price on the trades in the past 15 minutes, for a given stock: app/market.py
-
Function to compute the Geometric Mean of prices for all stocks: app/market.py