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 stocklerain1001
Usage
Loading historical data:
from stocklerain1001 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 stocklerain1001 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 stocklerain1001 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
stocklerain1001-0.0.1.tar.gz
(3.7 kB
view details)
Built Distribution
File details
Details for the file stocklerain1001-0.0.1.tar.gz
.
File metadata
- Download URL: stocklerain1001-0.0.1.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7730f8b4d91310d5ff6042e35138eea7a3a3f0510fa81bb8654a4b7fed592202 |
|
MD5 | c73bbecb4b3b929517a630560f7d128e |
|
BLAKE2b-256 | 6f5d1c2abddb862381e2c88a0195a15a2606293ff01a4e9e7f0d10a8cf805fe4 |
File details
Details for the file stocklerain1001-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: stocklerain1001-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3568988e7c3cfeabc3e3b7b83847f5323224621f50492ce69f6b5355de49627 |
|
MD5 | b64fe64eea4a80996f29eb81bd84db2e |
|
BLAKE2b-256 | abf036fc75a3278da3ebc2ea7d570354ee3da805f883e74313173496343d17f6 |