A Python-based terminal application that combines stock market investment simulation with powerful file management capabilities. This project serves as both a learning tool for Python programming and provides practical file management utilities.
This project was created with the following learning objectives in mind:
-
Programming Concepts
- File I/O operations with JSON
- Command-line interface design
- User authentication system
- State management
- Error handling
- Data persistence
- Multi-language file execution
- Text file manipulation
-
Stock Market Concepts
- Basic investment mechanics
- Stock performance tracking
- Risk management with virtual money
- Portfolio management
-
User Authentication System
- Create new user accounts
- Secure login with username/password
- Persistent user data storage
-
Virtual Stock Market
- 6 different stocks (A through F)
- Random performance fluctuations (-100% to +100%)
- Real-time investment simulation
-
File Operations
- Read text files
- Create and edit files
- Save files to custom locations
- Execute code files in multiple languages
-
Command System
- Interactive terminal interface
- Comprehensive command set
- Built-in help and syntax guide
-
get- Retrieve informationget username- Display current usernameget password- Display current passwordget money- Check current balanceget stin- Get current stock informationget all- Display all user information
-
set- Modify user informationset username <new_username>- Change usernameset password <new_password>- Change password
-
invest- Make stock investments- Syntax:
invest <amount> <stock> - Example:
invest 100 a
- Syntax:
-
read- Read text files- Syntax:
read <filepath> - Example:
read document.txt - Supported extensions: .txt, .py, .js, .html, .css, .json, .md, .csv, .log, .xml, .yml, .yaml, .ini, .cfg
- Syntax:
-
write- Create new text files- Syntax:
write <filename> <extension> - Example:
write myfile txt - Type 'END' on a new line to finish writing
- Supports same extensions as read command
- Syntax:
-
save- Save written files- Syntax:
save <folder_path> - Example:
save C:\Documents\MyFiles - Creates folders if they don't exist
- Syntax:
-
execute- Run code files- Syntax:
execute <filepath> - Example:
execute script.py - Supported languages and required tools:
- Python (.py) - Python interpreter
- JavaScript (.js) - Node.js
- Java (.java) - JDK
- C++ (.cpp) - G++ compiler
- C (.c) - GCC compiler
- Ruby (.rb) - Ruby interpreter
- PHP (.php) - PHP interpreter
- Perl (.pl) - Perl interpreter
- Shell Scripts (.sh) - Bash
- PowerShell Scripts (.ps1) - PowerShell
- Syntax:
-
syntax- Get help with commands- Syntax:
syntax <command_name> - Example:
syntax execute
- Syntax:
-
list- Show all available commands
-
Starting the Game
python gameTerminal.py
-
First-time Setup
- Enter a username and password when prompted
- You'll start with $1000 in virtual money
-
Basic Gameplay Loop
- Use
get stinto check current stock performances - Analyze which stocks are performing well
- Use
investcommand to buy stocks - Monitor your money using
get money
- Use
-
Investment Strategy
- Stocks perform randomly between -100% and +100%
- Positive performance means profit
- Negative performance means loss
- Start with small investments to learn the system
-
Start Small
- Begin with small investments
- Try investing $100 in different stocks
- Compare results to understand the random nature of returns
-
Track Your Progress
- Keep notes of which stocks perform well
- Record your starting and ending amounts
- Try to develop investment strategies
-
Experiment Safely
- Try different investment amounts
- Test various combinations of stocks
- Learn from losses without real financial risk
The game uses:
- Python's built-in
jsonmodule for data persistence - Random number generation for stock performance
- File I/O for saving user data
- Command pattern for handling user input
- Dictionary-based command documentation
-
Base Requirements
- Python 3.x
- JSON module (built-in)
-
For Code Execution Features
- Python interpreter
- Node.js for JavaScript
- JDK for Java
- G++ compiler for C++
- GCC compiler for C
- Ruby interpreter
- PHP interpreter
- Perl interpreter
- Bash shell
- PowerShell
gameTerminal.py- Main application file containing all logicuser.json- User data storage fileREADME.md- Documentation and guide (this file)- Created files - Stored in user-specified locations
-
Code Study
- Review the JSON file handling
- Understand the command processing system
- Study the error handling implementation
-
Possible Enhancements
- Add historical tracking of investments
- Implement more complex stock behavior
- Add market trends and sectors
- Create a graphical interface
This is an educational project, and suggestions for improvements are welcome! Some areas that could be enhanced:
- More realistic stock market simulation
- Additional commands and features
- Better error handling
- User interface improvements
This project is open-source and available for educational purposes. Feel free to use, modify, and learn from it!