Skip to content

Gyanaa-Vaibhav/Stock-Predictor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stock Price Predictor

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.


Features

  • 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.

Technologies Used

Frontend

  • React: For building the UI components.
  • CSS: For styling the application.
  • TypeScript: For type safety.

Backend

  • 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.

Setup Instructions

Prerequisites

  • Node.js and npm installed
  • A valid OpenAI API Key and Polygon.io API Key

Clone the Repository

git clone https://github.com/Gyanaa-Vaibhav/stock-price-predictor.git
cd stock-price-predictor

Backend Setup

  1. Navigate to the backend folder.
  2. Install dependencies:
    npm install
  3. Create a .env file in the backend directory with the following content:
    OPENAI_KEY=your-openai-api-key
    POLYGON_KEY=your-polygon-api-key
  4. Start the Typescript Complier:
    npm run compile
  5. Start the server:
    npm run dev
    The server will run on http://localhost:5172.

Frontend Setup

  1. Navigate to the frontend folder.
  2. Install dependencies:
    npm install
  3. Create a .env file in the backend directory with the following content:
    VITE_SERVER_IP=http://localhost:5172
  4. Start the development server:
    npm run dev
    The application will run on http://localhost:5173.
  5. comment out these lines in vite.config.ts
    build: {
        outDir: '/var/www/html/StockPredictor',
        emptyOutDir: true,
      },
    

How to Use

  1. Open the application in your browser.
  2. Add up to 3 stock tickers (e.g., MSFT, AAPL).
  3. Click Generate Report.
  4. View the stock prediction report generated by the AI.

File Structure

Frontend

  • Main.tsx: Main React component.
  • styles/Main.css: Styles for the application.
  • loader.svg, add.svg, delete_icon.svg: Icons used in the UI.

Backend

  • server.js: Main server file.
  • dates.js: Utility for generating date ranges.
  • .env: Environment variables (API keys).

API Endpoints

POST /stock-data

Fetches historical stock price data for the given tickers.

Request

{
  "data": ["MSFT", "AAPL"]
}

Response

{
  "success": true,
  "data": ["stock-data-here"]
}

POST /prediction

Generates a stock prediction report using OpenAI.

Request

{
  "data": "stock-data-here"
}

Response

{
  "success": true,
  "message": "Stock prediction report"
}

Future Enhancements

  • 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.

License

This project is licensed under the MIT License.


Author

Gyanaa Vaibhav
GitHub

Enjoy predicting stock prices! 🚀

About

📈 Stock Predictor: Your AI-powered financial fortune-teller, accurate 15% of the time! Add tickers, get predictions, and maybe strike gold—or just enjoy the fun. 🚀

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors