Skip to main content

Stock information analysis package

Project description

StockInfo

StockInfo is a Python package for loading historical stock data, calculating Simple Moving Averages (SMA) and Relative Strength Index (RSI), and writing the results to CSV files.

Installation

You can install StockInfo using pip:

pip install stockinfoain1001

Usage

Loading historical data:

from stockinfoain1001 import StockInfo

# Create an instance of the StockInfo class
stock_info = StockInfo()

# Load historical data from a CSV file (default: "orcl.csv" in the 'data' directory)
stock_info.load_data()

# Access the loaded data
data = stock_info.Data

Calculating Simple Moving Averages (SMA):

# Calculate SMA with a specified window size (default: 5)
sma_values = stock_info.calculate_sma(window_size=10)

# Access the calculated SMA values
print(sma_values)

Calculating Relative Strength Index (RSI):

# Calculate RSI with a specified window size (default: 14)
rsi_values = stock_info.calculate_rsi(window_size=14)

# Access the calculated RSI values
print(rsi_values)

Writing Results to CSV:

# Write SMA results to a CSV file
sma_header = ['Date', 'Close', 'SMA']
sma_data = [(stock_info.Data[i]["Date"], stock_info.Data[i]['Close'], sma) for i, sma in enumerate(sma_values)]
stock_info.write_file("sma_results.csv", sma_header, sma_data)

# Write RSI results to a CSV file
rsi_header = ['Date', 'Close', 'RSI']
rsi_data = [(stock_info.Data[i]["Date"], stock_info.Data[i]['Close'], rsi) for i, rsi in enumerate(rsi_values)]
stock_info.write_file("rsi_results.csv", rsi_header, rsi_data)

Examples

Basic Usage:

from stockinfoain1001 import StockInfo

# Load historical data
stock_info = StockInfo()
stock_info.load_data()

# Calculate SMA and write results to CSV
sma_values = stock_info.calculate_sma(window_size=5)
sma_header = ['Date', 'Close', 'SMA']
sma_data = [(stock_info.Data[i]["Date"], stock_info.Data[i]['Close'], sma) for i, sma in enumerate(sma_values)]
stock_info.write_file("sma_results.csv", sma_header, sma_data)

# Calculate RSI and write results to CSV
rsi_values = stock_info.calculate_rsi(window_size=14)
rsi_header = ['Date', 'Close', 'RSI']
rsi_data = [(stock_info.Data[i]["Date"], stock_info.Data[i]['Close'], rsi) for i, rsi in enumerate(rsi_values)]
stock_info.write_file("rsi_results.csv", rsi_header, rsi_data)

Custom Data File and Output Directory:

from stockinfoain1001 import StockInfo

# Load historical data
stock_info = StockInfo()
stock_info.load_data()

# Calculate SMA and write results to CSV
sma_values = stock_info.calculate_sma(window_size=5)
sma_header = ['Date', 'Close', 'SMA']
sma_data = [(stock_info.Data[i]["Date"], stock_info.Data[i]['Close'], sma) for i, sma in enumerate(sma_values)]
stock_info.write_file("sma_results.csv", sma_header, sma_data)

# Calculate RSI and write results to CSV
rsi_values = stock_info.calculate_rsi(window_size=14)
rsi_header = ['Date', 'Close', 'RSI']
rsi_data = [(stock_info.Data[i]["Date"], stock_info.Data[i]['Close'], rsi) for i, rsi in enumerate(rsi_values)]
stock_info.write_file("rsi_results.csv", rsi_header, rsi_data)

Contributing

Contributions are welcome! If you encounter any issues or have suggestions for improvements, please create an issue or submit a pull request.

Licence

This project is licensed under the MIT License

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

stockinfoain1001-1.0.2.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stockinfoain1001-1.0.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file stockinfoain1001-1.0.2.tar.gz.

File metadata

  • Download URL: stockinfoain1001-1.0.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for stockinfoain1001-1.0.2.tar.gz
Algorithm Hash digest
SHA256 6608ff19bb8862afa642528aff1319f06ac73dad228dd47bfe9dda000e5f5c22
MD5 88997b09f8bbc657c26e9fe5d14512e6
BLAKE2b-256 4315c5d4abd2c26959f1ce8761b9f7bf85eaeb0ecf91f0695a5f95abfedb36f9

See more details on using hashes here.

File details

Details for the file stockinfoain1001-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for stockinfoain1001-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a1e1820f7e1153305257c6ae7606a90db8d36864e8ae5211ec08e4e8a87e6e44
MD5 71f6e299782774b9886b3ed74b7219f1
BLAKE2b-256 d52b7b685edaa1b1020d03af1530df4488dd3474b39705a5455efed19f6e185c

See more details on using hashes here.

Supported by

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