Virtual Stock is an educational simulation tool designed to help beginners understand how investments grow over time—without using real money. Inspired by the concept of "virtual gambling", users can create and manage virtual portfolios, try investment strategies, and observe how their choices affect the portfolio's value.
-
Two types of portfolios:
- Inflexible: Cannot be modified after creation.
- Flexible: Can be updated (buy/sell more stocks).
-
Portfolio Creation Options:
- Start with a blank portfolio.
- Load saved portfolios from a local file.
- Import portfolios from a CSV file:
- Inflexible format:
portfolio_name, ticker_symbol, quantity, false - Flexible format:
portfolio_name, ticker_symbol, quantity, true, date, commission, buy/sell
- Inflexible format:
-
Error Handling:
- Validates quantity, commission, and ticker symbol.
- Handles file I/O exceptions gracefully.
- Displays all saved portfolios (flexible/inflexible) for the current user.
- Shows stocks and their quantities as a percentage of the portfolio.
- Flexible portfolios can display composition as of a given date.
- Inflexible portfolios show static composition.
- Calculates total value of a portfolio on a specific date.
- Flexible portfolios consider transaction history up to the selected date.
- Inflexible portfolios are valued based on the latest known prices.
- Displays the total investment cost including commission fees up to a certain date.
-
Text-Based Chart:
- Graphical representation using ASCII asterisks.
- Scales based on value ranges.
-
GUI-Based Chart:
- Java Swing-based bar chart.
- Displays yearly value performance.
- Invest a fixed amount at regular intervals over a time range.
- Users specify:
- Start/End Dates
- Frequency (in days)
- Investment amount and commission
- Percentage distribution among stocks
- Supports fractional share buying.
- Portfolios are saved as CSV files:
- Inflexible:
portfolio_name, ticker, quantity, false - Flexible:
portfolio_name, ticker, quantity, true, date, commission, buy/sell
- Inflexible:
Run with:
java -jar virtual-stock.jar -textSupports:
- Creating/Viewing flexible and inflexible portfolios
- Portfolio composition and valuation
- Buying/selling shares
- Cost basis & performance visualization
Run with:
java -jar virtual-stock.jar -guiSupports:
- Creating flexible portfolios
- Portfolio composition and performance
- Investing by quantity or dollar amount
- Dollar-cost averaging strategy