This repository is a stock predictions application demonstrating the integration between CloudFlare Workers, CloudFlare AI Gateway, CloudFlare Pages and OpenAI API for generating humorous stock predictions.
The application consists of three main components:
- A frontend web application built with vanilla JavaScript
- An OpenAI predictions worker for generating stock analysis
- A Polygon API worker for fetching historical stock data
- Real-time stock data fetching using Polygon.io API
- AI-powered stock predictions using OpenAI's GPT-4 model
- CORS-enabled API endpoints for cross-origin requests
- Smart placement optimization for CloudFlare Workers
- Configurable date ranges for historical data analysis
node.js
npm
- A CloudFlare account with Workers and Pages enabled
- A Polygon.io API key
- An OpenAI API key
-
Clone the repository:
git clone https://github.com/robinsalehjan/dodgy-stock-predictions.git cd dodgy-stock-predictions
-
Install dependencies and start the frontend:
cd web && npm install && npm run start
-
Deploy the OpenAI predictions worker:
cd workers/openai-stock-predictions-worker npm install npm run deploy
-
Deploy the Polygon API worker:
cd workers/polygon-api-worker npm install npm run deploy
The following environment variables need to be set in your CloudFlare Workers:
OPENAI_API_KEY
: Your OpenAI API keyAUTH_OPENAI_STOCK_PREDICTIONS_WORKER
: CloudFlare AI Gateway authorization token
POLYGON_API_KEY
: Your Polygon.io API key
This application is for entertainment purposes only. The stock predictions are intentionally humorous and should not be used for actual financial decisions.