A tool for scraping and analyzing news and press releases from NASDAQ-listed companies.
Project description
Nasdaq news crawler
Nasdaq News Crawler is a Python library designed to facilitate the collection and sentiment analysis of financial news and press releases published on the Nasdaq website. This tool allows users to efficiently gather information about selected companies, perform sentiment analysis on the collected data using FinBERT model, and gain insights into how news might impact stock prices.
Instalation
pip install nasdaq-news-crawler
Requirements
The chromedriver.exe executable is only required if you want to use the collect_links() function to gather article links directly from the Nasdaq website. For other functionalities, such as scraping data from already collected links and performing sentiment analysis, ChromeDriver is not necessary.
Installing ChromeDriver
-
Download
chromedriver.exefrom the official site: https://developer.chrome.com/docs/chromedriver/downloads. -
Make sure to download the version that matches your installed version of Google Chrome.
-
Place
chromedriver.exein a folder included in your system's PATH or in your project directory.
When using the collect_links() function, make sure to provide the correct path to chromedriver.exe.
Supported Companies
The library currently supports the following NASDAQ-listed companies using their stock ticker symbols:
-
AMD
-
TSLA (Tesla)
-
AMZN (Amazon)
-
AAPL (Apple)
-
NFLX (Netflix)
-
NVDA (NVIDIA)
-
MSFT (Microsoft)
-
JD (JD.com)
-
CSCO (Cisco)
-
META (Meta Platforms, formerly Facebook)
Make sure to use these ticker symbols when specifying the company for data collection.
Available Data Sources
For the data_source_name parameter, you can choose only one of the following options:
-
press_releases– to collect press releases -
nasdaq_news– to collect general news headlines
Ensure you select the correct data source according to your needs.
Time Frame Format
The time_frame parameter accepts the following formats:
-
'YYYY-MM-DD'(e.g.,'2024-08-25') -
'1 day ago' -
'1 week ago' -
'1 month ago'
Ensure that the date provided is not in the future. The library will convert these formats to the appropriate date range internally.
Model Selection
When using the analyze_sentiment function, you can specify the model parameter:
-
0for the fine-tuned FinBERT model onpress_releases. When using this model, use dates intime_frameno earlier than "2024-07-18" to avoid data leakage. -
1for the fine-tuned FinBERT model onnasdaq_news. When using this model, use dates intime_frameno earlier than "2024-08-28" to avoid data leakage. -
Any other value will use the default FinBERT model.
This allows flexibility in selecting a model best suited for the type of data being analyzed.
Getting started
# Import the DataPipeline class from the nasdaq_news_crawler library
from nasdaq_news_crawler import DataPipeline
# Instantiate a DataPipeline object to manage the data collection and analysis process
pipeline = DataPipeline()
# Specify the company name using the stock ticker symbol (e.g., 'AMD')
company_name = 'AMD'
# Choose the data source (either 'press_releases' or 'nasdaq_news')
data_source_name = 'press_releases'
# Define the time frame for the news articles you want to collect (e.g., from '2024-08-25')
time_frame = '2024-08-25'
# Provide the path to the ChromeDriver executable (required only for the collect_links function)
chrome_driver_path = 'C:\\Users\\Norbix\\Desktop\\chromedriver.exe'
# Specify the folder path where the collected news will be saved
folder_path = 'C:\\Users\\Norbix\\Desktop\\amd'
# Choose the model (0, 1 or None)
model = 0
# Collect links from the specified source for the given company and time frame
# Note: This step requires ChromeDriver to be installed and the path provided
links = pipeline.collect_links(
company_name=company_name,
time_frame=time_frame,
source_name=data_source_name,
chrome_driver_path=chrome_driver_path
)
# Scrape the news content from the collected links and save it to a CSV file
file_path = pipeline.scrape_data(
links=links,
company_name=company_name,
source_name=data_source_name,
folder_path=folder_path
)
# Analyze the sentiment of the collected news articles using the FinBERT model
result = pipeline.analyze_sentiment(file_path=file_path, model=model, enable_cuda=True)
print(f"Sentiment analysis result: {result}")
Features
-
Collects news and press releases for specific companies listed on NASDAQ.
-
Performs sentiment analysis using the FinBERT model.
-
CUDA acceleration for faster analysis.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nasdaq_news_crawler-0.6.0.tar.gz.
File metadata
- Download URL: nasdaq_news_crawler-0.6.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58134257d2be995179290b354058f63a5527315c8bcbfd5c581bcc29899d6128
|
|
| MD5 |
96de154a565b11663b93a8066265281d
|
|
| BLAKE2b-256 |
49f4228bbdec49f65501cd4fa1ac40ee5b68c6a7f62aa0f16d491b3b4e62c9f3
|
File details
Details for the file nasdaq_news_crawler-0.6.0-py3-none-any.whl.
File metadata
- Download URL: nasdaq_news_crawler-0.6.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58173317b8c10ca6d1130503cf5683f0772c6aa550123281857ac8024f815db2
|
|
| MD5 |
0341f22be52e625319f7933eafbcc8de
|
|
| BLAKE2b-256 |
2b1b2de5f5ec86821d2c5cb6917648d43616ab71e604587b9428682de6a65ab2
|