This project implements a stock and options trading prediction system using the Black-Scholes model for options pricing and RANSAC & Linear Regression for stock predictions. It leverages the Polygon.io API for market data, integrates with a News API for sentiment analysis, and uses LLM for processing information.
- Stock Price Prediction: Uses RANSAC and Linear Regression models to predict future stock prices
- Options Pricing: Implements the Black-Scholes model for theoretical options pricing
- Options Analysis: Analyzes options contracts to identify potentially undervalued options
- Combined Analysis: Integrates stock predictions with options analysis for comprehensive trading insights
- News Analysis: Categorizes news articles by topic and analyzes their potential impact on stocks
- LLM Integration: Uses Large Language Models to process news and generate trading insights
- Real-Time Data: Provides real-time stock price updates via WebSocket connection
- Interactive Dashboard: Visualizes predictions and analysis through an intuitive web interface
- Python
- Flask
- pandas, numpy, scikit-learn
- Polygon.io API for market data
- News API for financial news
- OpenAI API for LLM processing
- WebSockets for real-time data streaming
- React.js
- Tailwind CSS
- Recharts for data visualization
- WebSocket client for real-time updates
- Python 3.8+
- Node.js 14+
- Polygon.io API key
- Clone the repository:
git clone <repository-url>
cd StockAndOption_Prediction
- Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
-
Set up your API keys:
- Create a
.env
file in the root directory - Add your API keys:
POLYGON_API_KEY=your_polygon_api_key_here NEWS_API_KEY=your_newsapi_key_here OPENAI_API_KEY=your_openai_api_key_here
- Create a
-
Start the Flask server:
cd backend
python app.py
- Install dependencies:
cd frontend
npm install
- Start the development server:
npm start
- Access the application at
http://localhost:3000
- Select a stock from the dropdown menu
- View stock price predictions using RANSAC and Linear Regression models
- Explore options analysis to identify potentially profitable options contracts
- Use the Black-Scholes calculator to price options with custom parameters
- Check the combined analysis for comprehensive trading insights
StockAndOption_Prediction/
├── backend/ # Backend Flask application
│ ├── blueprints/ # API route blueprints
│ ├── models/ # Machine learning models
│ ├── app.py # Main Flask application
│ ├── black_scholes.py # Black-Scholes model implementation
│ ├── data_fetcher.py # API integration with Polygon.io
│ ├── stock_predictior.py # Stock prediction models
│ └── README.md # Backend documentation
├── frontend/ # Frontend React application
│ ├── public/ # Static files
│ ├── src/ # Source code
│ │ ├── components/ # React components
│ │ │ ├── analysis/ # Analysis components
│ │ │ ├── common/ # Common UI components
│ │ │ └── tools/ # Tool components
│ │ ├── App.js # Main application component
│ │ └── index.js # Entry point
│ └── README.md # Frontend documentation
├── requirements.txt # Python dependencies
└── README.md # Project documentation
For more detailed information about the project structure, see the README files in the backend and frontend directories.
- Implement more advanced prediction models (LSTM, ARIMA)
- Add portfolio management features
- Integrate with trading platforms via APIs
- Implement backtesting functionality
- Add user authentication and personalized watchlists