Stock Price Predictor is a simple application that allows users to input stock tickers, fetch stock data, and generate predictions using OpenAI's API. This project demonstrates a combination of React-based frontend and Node.js-based backend with integration of external APIs.
- Add up to 3 stock tickers for analysis.
- Fetch historical stock price data from the Polygon.io API.
- Generate AI-based predictions and reports on stock performance using OpenAI's API.
- User-friendly interface with loading animations and interactive controls.
- Simple REST API for backend functionality.
- React: For building the UI components.
- CSS: For styling the application.
- TypeScript: For type safety.
- Node.js: For building the server.
- Express.js: For handling API routes.
- OpenAI API: For generating stock predictions.
- Polygon.io API: For fetching stock price data.
- dotenv: For managing environment variables.
- Node.js and npm installed
- A valid OpenAI API Key and Polygon.io API Key
git clone https://github.com/Gyanaa-Vaibhav/stock-price-predictor.git
cd stock-price-predictor- Navigate to the backend folder.
- Install dependencies:
npm install
- Create a
.envfile in the backend directory with the following content:OPENAI_KEY=your-openai-api-key POLYGON_KEY=your-polygon-api-key
- Start the Typescript Complier:
npm run compile
- Start the server:
The server will run on
npm run dev
http://localhost:5172.
- Navigate to the frontend folder.
- Install dependencies:
npm install
- Create a
.envfile in the backend directory with the following content:VITE_SERVER_IP=http://localhost:5172
- Start the development server:
The application will run on
npm run dev
http://localhost:5173. - comment out these lines in vite.config.ts
build: { outDir: '/var/www/html/StockPredictor', emptyOutDir: true, },
- Open the application in your browser.
- Add up to 3 stock tickers (e.g.,
MSFT,AAPL). - Click Generate Report.
- View the stock prediction report generated by the AI.
Main.tsx: Main React component.styles/Main.css: Styles for the application.loader.svg,add.svg,delete_icon.svg: Icons used in the UI.
server.js: Main server file.dates.js: Utility for generating date ranges..env: Environment variables (API keys).
Fetches historical stock price data for the given tickers.
{
"data": ["MSFT", "AAPL"]
}{
"success": true,
"data": ["stock-data-here"]
}Generates a stock prediction report using OpenAI.
{
"data": "stock-data-here"
}{
"success": true,
"message": "Stock prediction report"
}- Add user authentication for personalized experiences.
- Enable saving reports for future reference.
- Expand support for more stock tickers and larger datasets.
- Improve error handling and user feedback.
This project is licensed under the MIT License.
Gyanaa Vaibhav
GitHub
Enjoy predicting stock prices! 🚀