This Python script is designed for algorithmic traders, particularly those involved in options and derivatives trading, to perform Natural Language Processing (NLP) analysis on textual data, such as PDF reports and text input. It offers insights into trading events, sentiment, risk assessment, named entity recognition, volatility, and mergers and acquisitions information.
-
Event Detection: Detect trading events such as earnings reports, interest rate changes, options activity, and more.
-
Sentiment Analysis: Analyze text sentiment and categorize it as Positive, Negative, or Neutral for market sentiment evaluation.
-
Risk Assessment: Evaluate the risk level of the text based on keywords related to trading risks.
-
Named Entity Recognition (NER): Recognize entities (e.g., organizations, cardinal numbers) and associate them with relevant sentences.
-
Volatility Analysis: Identify sentences mentioning "volatility" to monitor market volatility.
-
Mergers and Acquisitions (M&A) Detection: Detect sentences related to mergers and acquisitions for market insights.
- Clone this repository to your local machine.
- Install required dependencies using
pip install -r requirements.txt
. - Run the Flask app using
python nlp_analyzer.py
.
To use the NLP Analyzer, make a POST request to the /api/analyze
endpoint. You can provide text data directly or upload a PDF for analysis.
Example API Request:
import requests
url = 'http://localhost:5000/api/analyze'
data = {
'text': 'Insert your text here.'
}
files = {'file': ('report.pdf', open('report.pdf', 'rb'))}
response = requests.post(url, data=data, files=files)
print(response.json())
The script returns results for event detection, sentiment analysis, risk assessment, NER analysis, volatility mentions, and M&A information.
Configuration Customize event keywords and related terms by modifying the event_keywords_and_related dictionary in the script.
event_keywords_and_related = {
"earnings report": ["financial report", "earnings statement"],
"interest rate": ["rate change", "Fed policy"],
# Add more event keywords and related terms here
}
- Next.js
- Axios
- React
- Flask
- Vader
- Spacy
- PyPDF2
This project is licensed under the MIT License. See the LICENSE file for details.
This project relies on various Python libraries for NLP, PDF processing, and sentiment analysis.
If you have any questions or suggestions, feel free to contact me.
Happy trading