Skip to main content

help you maintain your stock dashboard also predict future for a stock based upon past data and also use the news sentiments of stocks volatality

Project description

pystocktopus: Your Ultimate Stock Data Management and Analysis Toolkit

Actions Status Documentation Status GitHub issues

PyPI version PyPI platforms GitHub

GitHub Discussion

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 also use the news sentiments of stocks volatality.

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.

  • 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.

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

Upgrade your CSV dashboard with new data:

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'
column_ticker_name = "Tickers"
column_amount_name = "Amount"

# Print the user's CSV file path
print(user_csv_file)

# Read ticker values from the CSV file using the specified column name
ticker_values = CSVDataHandler.csv_data_reader(user_csv_file, column_ticker_name)

# Read amount values from the CSV file using the specified column name
amount_values = CSVDataHandler.csv_data_reader(user_csv_file, column_amount_name)

# Print the extracted ticker and amount values
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]}

# Combine the amount values with the closing data
result = CSVDataHandler.combine_data_csv(amount_values, closing_data)

# Update the user's CSV file with the combined data
CSVDataHandler.update_csv(user_csv_file, result)

# Close and clean up resources for the closing data
CSVDataHandler.close_list_csv(closing_data)

Do something with the extracted data

For example, plot the closing prices over time:

# Load the CSV dashboard
dashboard = pystocktopus.load_dashboard("my_dashboard.csv")

# Calculate a technical indicator, such as the moving average
moving_average = dashboard.calculate_moving_average(period=20)

# Perform statistical analysis on the data, such as calculating the correlation between two stocks
correlation = dashboard.calculate_correlation("AAPL", "GOOG")

# Generate a chart of the data, such as a candlestick chart
candlestick_chart = dashboard.plot_candlestick_chart()

Do something with the analysis results

For example, display the candlestick chart:

from pystocktopus.stock_forecasting import DataAnalysis

# Create an interactive bar chart of the stock price data with volume and 20-day moving average
DataAnalysis.interactive_bar(csv_file)

# Create an interactive candlestick chart of the stock price data
DataAnalysis.interactive_sticks(csv_file)

# Perform a basic analysis of the stock price data
DataAnalysis.stock_analysis(csv_file)

Do something with the sentiment predictions

For example, identify the most positive and negative news articles:

from pystocktopus.news_analysis import News

# Create a list of tickers to extract news articles for
ticker_values = ["GOOGL"]

# Specify the date range to extract news articles for
predict_date = "2023-08-05"

# Call the new_data_extract() method to extract news articles for the given tickers and date range
news_articles = News.new_data_extract(ticker_values, predict_date)

# Call the news_predict_analysis() method to predict the sentiment of the news articles for each ticker
analysis_results = News.news_predict_analysis(news_articles)

# Call the create_csv_with_predictions() method to create a CSV file with the predicted sentiment for each ticker
csv_filename = "news_predictions.csv"
News.create_csv_with_predictions(csv_filename, analysis_results)

Display the most positive and negative news articles:

import pystocktopus.news_analysis as news

result_strings = {
    "Ticker1": "Day1: i am excellent\nDay2: i am good\n",
    "Ticker2": "Day1: Title3\nDay2: Title4\n",
}
news_data = news.News.news_predict_analysis(result_strings)
print(news_data)
csv_filename = 'Test_result'
news.News.create_csv_with_predictions(csv_filename,news_data)

Get the current closing price for Amazon

# Import the StockExtractor class from the pystocktopus.core library.
from pystocktopus.core import StockExtractor

# Set the ticker values, timespan, multiplier, and user date.
ticker_values = ["AMZN", "SONY"]
timespan = "DAY"
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)

# Print the closing prices to the console.
print(Closing_price)

Do something with the current closing price

For example, print it to the console:

print("Current closing price for Amazon:", Closing_price)

Install pystocktopus

pystocktopus uses modern Python packaging and can be installed using pip -

python -m pip install pystocktopus

Setting-up API Key

To use the software properly setup these API keys to completely use the features of the project -

  1. Newsapi access from this.
  2. Polygon.io API access from this.

Use this to Setup API Globally

#Polyon API KEY
export api_key="YOUR-API-KEY"

#NewsApi KEY
export news_api="YOUR-API-KEY"

Contributing

If you want to contribute to pystocktopus (thanks!), please have a look at our Contributing Guide.

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

pystocktopus-0.1.tar.gz (40.8 kB view details)

Uploaded Source

Built Distribution

pystocktopus-0.1-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file pystocktopus-0.1.tar.gz.

File metadata

  • Download URL: pystocktopus-0.1.tar.gz
  • Upload date:
  • Size: 40.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for pystocktopus-0.1.tar.gz
Algorithm Hash digest
SHA256 ba24117d8be0427a7740c6c9e50543a5ebef90bec6dded6babb776c6db094a64
MD5 73f89f98d2905bc2569102bd68b503bb
BLAKE2b-256 597a95738f21e68cfe18501fa86c9bfae083e342edb741675cc729203e3f5bee

See more details on using hashes here.

File details

Details for the file pystocktopus-0.1-py3-none-any.whl.

File metadata

  • Download URL: pystocktopus-0.1-py3-none-any.whl
  • Upload date:
  • Size: 29.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for pystocktopus-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21fe23ea68e12dcfbaef1087f2fa5d4c8579deeb5167379d9482eee4f8ca7b12
MD5 7c87e3fc2769b81026b5407280e57f35
BLAKE2b-256 69b8f3f10da0b315c2d379929cd732b8f0843bb2471bc9e9fd443854992d1b60

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page