Skip to content

This Python script uses the OpenAI API to interact with ChatGPT and analyzes stock headlines. This is NOT INVESTMENT ADVICE. This is meant as an educational tool.

Notifications You must be signed in to change notification settings

JeremiahPetersen/Stock-Sentiment-Analysis-ChatGPT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

This Python script uses the OpenAI API to interact with ChatGPT and analyzes stock headlines. The script reads stock headlines data from a CSV file, sends each headline to ChatGPT for sentiment analysis, and evaluates the success rate of the resulting predictions. The script assumes the availability of a CSV file with headlines, stock symbols, and dates, as well as a function to fetch the next day's return for a given stock. You will need to replace "your_api_key_here" with your actual API key for the OpenAI API.

The CSV file should contain three columns: stock, date, and headline. Here's a sample format for the CSV file:

stock,date,headline
AAPL,2022-10-01,Apple announces new iPhone with groundbreaking features
AAPL,2022-10-02,Apple faces production delays due to supply chain issues
GOOGL,2022-10-01,Google unveils next-generation Pixel smartphone
GOOGL,2022-10-03,Google acquires AI startup for $500 million

Each row in the CSV file represents a stock headline, with the stock symbol (e.g., "AAPL" for Apple Inc.), the date of the headline (in the format YYYY-MM-DD), and the text of the headline itself. Make sure that the header in the CSV file matches the column names used in the analyze_headlines function in the Python script:

for index, row in headlines_data.iterrows():
headline = row["headline"]
stock = row["stock"]
date = row["date"]

About

This Python script uses the OpenAI API to interact with ChatGPT and analyzes stock headlines. This is NOT INVESTMENT ADVICE. This is meant as an educational tool.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages