CODEALPHA TASK- : Stock trading platforn
programming language : JAVA
TASK : Create a simulated stock trading platform with features like market data, buying/selling stocks, and tracking portfolio performance.
This stock trading platform program in Java simulates basic functionalities of a stock market environment. It consists of several key classes: Stock, Portfolio, MarketData, and StockTradingPlatform .
Stock Class : Represents a stock with attributes like symbol, name, price, and quantity. It provides methods to get and set these attributes, crucial for managing stock data.
Portfolio Class: Manages the user's stocks and cash balance. It allows buying and selling stocks, validates transactions based on available funds and stock quantities, and calculates the overall portfolio value dynamically.
MarketData Class: Simulates market behavior by providing current stock prices that fluctuate randomly within a range. It initializes with default stock prices and updates them periodically to reflect market changes.
StockTradingPlatform Class (Main): This serves as the interface for user interaction. It offers a command-line menu where users can:
- Buy Stocks: Users enter a stock symbol and quantity to purchase stocks, updating their portfolio and cash balance accordingly.
- Sell Stocks: Users sell owned stocks based on symbol and quantity, adjusting their portfolio and cash balance based on current stock prices.
- View Portfolio: Displays current cash balance, list of owned stocks with quantities, and overall portfolio value.
- Quit: Exits the program.
The program demonstrates core concepts of object-oriented programming, including encapsulation , inheritance , and polymorphism . It provides a simplified but effective simulation of stock trading, emphasizing real-time updates of stock prices and portfolio values based on user transactions. Extensions could include more sophisticated market data handling, user authentication, or graphical interfaces for enhanced user experience.

