Skip to content

Commit

Permalink
style: pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Dec 9, 2024
1 parent 9ed98af commit c012a3e
Show file tree
Hide file tree
Showing 62 changed files with 512,656 additions and 210 deletions.
89 changes: 58 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,66 @@
![GitHub Discussions](https://img.shields.io/github/discussions/Akhil-Sharma30/pystocktopus)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pystocktopus)
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/Akhil-Sharma30/pystocktopus/CI) -->

[pypi-version]: https://img.shields.io/pypi/v/pystocktopus
[pypi-platforms]: https://img.shields.io/pypi/pyversions/pystocktopus
[pypi-link]: https://pypi.org/project/pystocktopus/
[actions-badge]: https://img.shields.io/github/actions/workflow/status/Akhil-Sharma30/pystocktopus/main.yml
[actions-badge]:
https://img.shields.io/github/actions/workflow/status/Akhil-Sharma30/pystocktopus/main.yml
[actions-link]: https://github.com/Akhil-Sharma30/pystocktopus/actions
[![Actions Status][actions-badge]][actions-link]
[![Documentation Status](https://readthedocs.org/projects/pystocktopus/badge/?version=latest)](https://pystocktopus.readthedocs.io/en/latest/?badge=latest)
![GitHub issues](https://img.shields.io/github/issues/Akhil-Sharma30/pystocktopus)

[![PyPI version][pypi-version]][pypi-link]
[![PyPI platforms][pypi-platforms]][pypi-link]
![GitHub](https://img.shields.io/github/license/Akhil-Sharma30/pystocktopus?color=green)
[![Actions Status][actions-badge]][actions-link]
[![Documentation Status](https://readthedocs.org/projects/pystocktopus/badge/?version=latest)](https://pystocktopus.readthedocs.io/en/latest/?badge=latest)
![GitHub issues](https://img.shields.io/github/issues/Akhil-Sharma30/pystocktopus)

[![PyPI version][pypi-version]][pypi-link]
[![PyPI platforms][pypi-platforms]][pypi-link]
![GitHub](https://img.shields.io/github/license/Akhil-Sharma30/pystocktopus?color=green)

[![GitHub Discussion][github-discussions-badge]][github-discussions-link]
[![GitHub Discussion][github-discussions-badge]][github-discussions-link]

**Managing and analyzing stock data can be a complex and time-consuming task for investors and traders. Keeping track of historical stock data, updating it with new information, and extracting valuable insights from the data are all crucial aspects of making informed investment decisions.**
**Managing and analyzing stock data can be a complex and time-consuming task for
investors and traders. Keeping track of historical stock data, updating it with
new information, and extracting valuable insights from the data are all crucial
aspects of making informed investment decisions.**

Introducing **pystocktopus**, a powerful Python package for **Python 3.7+** designed to simplify stock data management, analysis, prediction, and use the news sentiments of stock volatility.
Introducing **pystocktopus**, a powerful Python package for **Python 3.7+**
designed to simplify stock data management, analysis, prediction, and use the
news sentiments of stock volatility.

**pystocktopus** is an easy-to-use and versatile library that empowers users to maintain and analyze their stock data with ease. Whether you are an experienced trader or a novice investor, pystocktopus provides a comprehensive set of tools to streamline your stock-related tasks.
**pystocktopus** is an easy-to-use and versatile library that empowers users to
maintain and analyze their stock data with ease. Whether you are an experienced
trader or a novice investor, pystocktopus provides a comprehensive set of tools
to streamline your stock-related tasks.

## Key Features

- **CSV Data Maintenance:**
pystocktopus provides a seamless solution for maintaining your stock data in CSV format. Whether you need to update existing data or extract new data from a CSV file, this package streamlines the process, ensuring that your stock data is always up-to-date and readily accessible.
- **CSV Data Maintenance:** pystocktopus provides a seamless solution for
maintaining your stock data in CSV format. Whether you need to update existing
data or extract new data from a CSV file, this package streamlines the
process, ensuring that your stock data is always up-to-date and readily
accessible.

- **Real-time Stock Analysis:** Stay ahead of the curve with real-time stock
analysis. pystocktopus offers tools to analyze your stock's performance and
predict how news and events will impact its growth. It leverages advanced
algorithms to assess whether news sentiment for a specific stock over a
defined period is positive or negative, helping you make informed investment
decisions.

- **Real-time Stock Analysis:**
Stay ahead of the curve with real-time stock analysis. pystocktopus offers tools to analyze your stock's performance and predict how news and events will impact its growth. It leverages advanced algorithms to assess whether news sentiment for a specific stock over a defined period is positive or negative, helping you make informed investment decisions.
- **Current Closing Price Extraction:** pystocktopus simplifies the process of
extracting the current closing price for a specific stock. With just a few
lines of code, you can access up-to-the-minute price information, enabling you
to monitor your investments with precision.

- **Current Closing Price Extraction:**
pystocktopus simplifies the process of extracting the current closing price for a specific stock. With just a few lines of code, you can access up-to-the-minute price information, enabling you to monitor your investments with precision.
- **Main Entry Point:** The main entry point for the application is `GUI.py`.
You can run the module using the command:

- **Main Entry Point:**
The main entry point for the application is `GUI.py`. You can run the module using the command:
```bash
python -m pystocktopus
```

- **Usage Examples:**
Usage examples are available in `main.py`.
- **Usage Examples:** Usage examples are available in `main.py`.

## Here are some examples of how the package can be used:

Expand All @@ -57,7 +77,7 @@ Introducing **pystocktopus**, a powerful Python package for **Python 3.7+** desi
from pystocktopus.stock_csv import CSVDataHandler

# Define the path to the user's CSV file and the column names for tickers and amounts
user_csv_file = 'TestCSV.csv'
user_csv_file = "TestCSV.csv"
column_ticker_name = "Tickers"
column_amount_name = "Amount"

Expand All @@ -75,8 +95,10 @@ print(ticker_values)
print(amount_values)

# Sample closing data for SONY and AMZN stocks
closing_data = {'SONY': [93.6, 93.49, 91.07, 90.03, 90.19, 90.44, 89.82, 83.85],
'AMZN': [133.68, 131.69, 128.21, 128.91, 139.57, 142.22, 139.94, 137.85]}
closing_data = {
"SONY": [93.6, 93.49, 91.07, 90.03, 90.19, 90.44, 89.82, 83.85],
"AMZN": [133.68, 131.69, 128.21, 128.91, 139.57, 142.22, 139.94, 137.85],
}

# Combine the amount values with the closing data
result = CSVDataHandler.combine_data_csv(amount_values, closing_data)
Expand Down Expand Up @@ -161,7 +183,7 @@ result_strings = {
}
news_data = news.News.news_predict_analysis(result_strings)
print(news_data)
csv_filename = 'Test_result'
csv_filename = "Test_result"
news.News.create_csv_with_predictions(csv_filename, news_data)
```

Expand All @@ -178,7 +200,9 @@ multiplier = 1
user_date = "2023-09-20"

# Extract the closing prices for the specified tickers, timespan, multiplier, and user date.
Closing_price = StockExtractor.ticker_data_collection(ticker_values, timespan, multiplier, user_date)
Closing_price = StockExtractor.ticker_data_collection(
ticker_values, timespan, multiplier, user_date
)

# Print the closing prices to the console.
print(Closing_price)
Expand All @@ -202,18 +226,20 @@ python -m pip install pystocktopus

### Accessing the GUI

If you only want to access the GUI, you can refer to this repository: [pystocktopus-GUI](https://github.com/Akhil-Sharma30/pystocktopus-GUI).
If you only want to access the GUI, you can refer to this repository:
[pystocktopus-GUI](https://github.com/Akhil-Sharma30/pystocktopus-GUI).

You can clone this repository and run the following commands:

```bash
pip install pystocktopus
pip install pystocktopus
python app.py
```

### Setting up API Key

To use the software, properly set up these _API keys_ to use the features of the project:
To use the software, properly set up these _API keys_ to use the features of the
project:

1. `Newsapi` access from [this](https://newsapi.org/).
2. `Polygon.io` API access from [this](https://polygon.io/).
Expand All @@ -230,8 +256,9 @@ export news_api="YOUR-API-KEY"

## Contributing

If you want to contribute to `pystocktopus` (thanks!), please have a look at our [Contributing Guide](https://github.com/Akhil-Sharma30/pystocktopus/blob/main/CONTRIBUTING.md).
If you want to contribute to `pystocktopus` (thanks!), please have a look at our
[Contributing Guide](https://github.com/Akhil-Sharma30/pystocktopus/blob/main/CONTRIBUTING.md).

---

Feel free to adjust any part of the text as needed!
Feel free to adjust any part of the text as needed!
15 changes: 7 additions & 8 deletions pystocktopus/GUI.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import tkinter as tk
from tkinter import messagebox
from __future__ import annotations

import os
from dotenv import load_dotenv
from datetime import datetime
import csv
import threading
import tkinter as tk
from tkinter import filedialog, messagebox

from dotenv import load_dotenv
from tkcalendar import DateEntry

from .core import StockExtractor
from .news_analysis import News
from .stock_forecasting import ModelStockData
from .stock_csv import CSVDataHandler
from tkinter import filedialog, messagebox
import threading
from .stock_forecasting import ModelStockData


def main():
Expand Down
5 changes: 3 additions & 2 deletions pystocktopus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"""

from __future__ import annotations
from .core import StockExtractor

from .config import api_key, news_api
from .core import StockExtractor
from .news_analysis import News
from .stock_csv import CSVDataHandler
from .stock_forecasting import ModelStockData
from .news_analysis import News
2 changes: 2 additions & 0 deletions pystocktopus/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from .GUI import main

main()
2 changes: 1 addition & 1 deletion pystocktopus/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from __future__ import annotations

import os
import logging
import os

# Configure logging
logging.basicConfig(
Expand Down
7 changes: 3 additions & 4 deletions pystocktopus/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@

import datetime
import json
import os
import logging
from polygon import RESTClient
from dotenv import load_dotenv
import os

import pystocktopus.config as config
from dotenv import load_dotenv
from polygon import RESTClient

# Configure logging
logging.basicConfig(
Expand Down
21 changes: 12 additions & 9 deletions pystocktopus/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from __future__ import annotations

import logging

import config
import pandas as pd
from core import StockExtractor
from news_analysis import News
from stock_csv import CSVDataHandler
from stock_forecasting import ModelStockData
import pandas as pd
from news_analysis import News
import logging

# Set up logging configuration
logging.basicConfig(
Expand All @@ -25,7 +28,7 @@ def main():
)
logging.info(f"Stock data collected for tickers: {ticker_values}")
except Exception as e:
logging.error(f"Error collecting stock data: {str(e)}")
logging.error(f"Error collecting stock data: {e!s}")

try:
CSVDataHandler.close_list_csv(data)
Expand All @@ -36,7 +39,7 @@ def main():
)
logging.info(f"CSV data combined successfully: {result}")
except Exception as e:
logging.error(f"Error handling CSV data: {str(e)}")
logging.error(f"Error handling CSV data: {e!s}")

try:
df = pd.read_csv("Your-CSV-FilePath")
Expand All @@ -46,7 +49,7 @@ def main():
second_column_name = df.columns[1]
logging.info(f"Second column name: {second_column_name}")
except Exception as e:
logging.error(f"Error reading CSV file: {str(e)}")
logging.error(f"Error reading CSV file: {e!s}")

try:
prediction = ModelStockData.create_fit_train_rnn(
Expand All @@ -56,7 +59,7 @@ def main():
)
logging.info(f"Model training and prediction complete: {prediction}")
except Exception as e:
logging.error(f"Error in model training or prediction: {str(e)}")
logging.error(f"Error in model training or prediction: {e!s}")

try:
result = News.new_data_extract(ticker_values=Article, predict_date=predict)
Expand All @@ -65,15 +68,15 @@ def main():
ans = News.news_predict_analysis(result)
logging.info(f"News analysis result: {ans}")
except Exception as e:
logging.error(f"Error in news analysis: {str(e)}")
logging.error(f"Error in news analysis: {e!s}")

try:
News.create_csv_with_predictions(
csv_filename="stock_data.csv", analysis_results=ans
)
logging.info("CSV file created with predictions.")
except Exception as e:
logging.error(f"Error creating CSV with predictions: {str(e)}")
logging.error(f"Error creating CSV with predictions: {e!s}")


if __name__ == "__main__":
Expand Down
5 changes: 2 additions & 3 deletions pystocktopus/news_analysis.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Copyright (c) 2023 Akhil Sharma. All rights reserved.
from __future__ import annotations

from datetime import datetime, timedelta
import logging
import os
from datetime import datetime, timedelta
from typing import List
from dotenv import load_dotenv

import pandas as pd
from dotenv import load_dotenv
from newsapi import NewsApiClient
from pystocktopus.config import news_api
from transformers import pipeline

# Set up logging configuration
Expand Down
8 changes: 4 additions & 4 deletions pystocktopus/stock_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from __future__ import annotations

import csv
import os
import logging # Import logging module
import os

import pandas as pd

Expand Down Expand Up @@ -71,7 +71,7 @@ def csv_data_reader(csv_file, csv_stock_column_name: str) -> list[str]:
logging.error(f"File not found: {csv_file}")
raise FileNotFoundError(f"File not found: {csv_file}")
except Exception as e:
logging.error(f"Error reading CSV file: {str(e)}")
logging.error(f"Error reading CSV file: {e!s}")
raise e

return data_values
Expand Down Expand Up @@ -136,7 +136,7 @@ def update_csv(
logging.error(f"CSV file not found: {csv_path}")
raise FileNotFoundError(f"CSV file not found: {csv_path}")
except Exception as e:
logging.error(f"Error updating CSV file: {str(e)}")
logging.error(f"Error updating CSV file: {e!s}")
raise e

@staticmethod
Expand Down Expand Up @@ -179,5 +179,5 @@ def close_list_csv(
logging.info(f"CSV file saved at: {file_path}")

except Exception as e:
logging.error(f"Error writing closing list data to CSV: {str(e)}")
logging.error(f"Error writing closing list data to CSV: {e!s}")
raise e
Loading

0 comments on commit c012a3e

Please sign in to comment.