# 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:
```bash
pip install stocklerain1001
```
## Usage
### Loading historical data:
```python
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):
```python
# 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):
```python
# 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:
```python
# 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:
```python
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:
```python
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
Raw data
{
"_id": null,
"home_page": "",
"name": "stocklerain1001",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "python,stock,finance,SMA,RSI",
"author": "Abdurrahman Al-boti",
"author_email": "<abdurrahman.alboti@bahcesehir.edu.tr>",
"download_url": "https://files.pythonhosted.org/packages/6f/5d/1c2abddb862381e2c88a0195a15a2606293ff01a4e9e7f0d10a8cf805fe4/stocklerain1001-0.0.1.tar.gz",
"platform": null,
"description": "\n# StockInfo\n\nStockInfo 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.\n\n## Installation\n\nYou can install StockInfo using pip:\n\n```bash\npip install stocklerain1001\n```\n## Usage\n### Loading historical data:\n```python\nfrom stocklerain1001 import StockInfo\n\n# Create an instance of the StockInfo class\nstock_info = StockInfo()\n\n# Load historical data from a CSV file (default: \"orcl.csv\" in the 'data' directory)\nstock_info.load_data()\n\n# Access the loaded data\ndata = stock_info.Data\n```\n### Calculating Simple Moving Averages (SMA):\n```python\n# Calculate SMA with a specified window size (default: 5)\nsma_values = stock_info.calculate_sma(window_size=10)\n\n# Access the calculated SMA values\nprint(sma_values)\n```\n### Calculating Relative Strength Index (RSI):\n```python\n# Calculate RSI with a specified window size (default: 14)\nrsi_values = stock_info.calculate_rsi(window_size=14)\n\n# Access the calculated RSI values\nprint(rsi_values)\n```\n### Writing Results to CSV:\n```python\n# Write SMA results to a CSV file\nsma_header = ['Date', 'Close', 'SMA']\nsma_data = [(stock_info.Data[i][\"Date\"], stock_info.Data[i]['Close'], sma) for i, sma in enumerate(sma_values)]\nstock_info.write_file(\"sma_results.csv\", sma_header, sma_data)\n\n# Write RSI results to a CSV file\nrsi_header = ['Date', 'Close', 'RSI']\nrsi_data = [(stock_info.Data[i][\"Date\"], stock_info.Data[i]['Close'], rsi) for i, rsi in enumerate(rsi_values)]\nstock_info.write_file(\"rsi_results.csv\", rsi_header, rsi_data)\n```\n## Examples\n### Basic Usage:\n```python\nfrom stocklerain1001 import StockInfo\n\n# Load historical data\nstock_info = StockInfo()\nstock_info.load_data()\n\n# Calculate SMA and write results to CSV\nsma_values = stock_info.calculate_sma(window_size=5)\nsma_header = ['Date', 'Close', 'SMA']\nsma_data = [(stock_info.Data[i][\"Date\"], stock_info.Data[i]['Close'], sma) for i, sma in enumerate(sma_values)]\nstock_info.write_file(\"sma_results.csv\", sma_header, sma_data)\n\n# Calculate RSI and write results to CSV\nrsi_values = stock_info.calculate_rsi(window_size=14)\nrsi_header = ['Date', 'Close', 'RSI']\nrsi_data = [(stock_info.Data[i][\"Date\"], stock_info.Data[i]['Close'], rsi) for i, rsi in enumerate(rsi_values)]\nstock_info.write_file(\"rsi_results.csv\", rsi_header, rsi_data)\n```\n### Custom Data File and Output Directory:\n```python\nfrom stocklerain1001 import StockInfo\n\n# Load historical data\nstock_info = StockInfo()\nstock_info.load_data()\n\n# Calculate SMA and write results to CSV\nsma_values = stock_info.calculate_sma(window_size=5)\nsma_header = ['Date', 'Close', 'SMA']\nsma_data = [(stock_info.Data[i][\"Date\"], stock_info.Data[i]['Close'], sma) for i, sma in enumerate(sma_values)]\nstock_info.write_file(\"sma_results.csv\", sma_header, sma_data)\n\n# Calculate RSI and write results to CSV\nrsi_values = stock_info.calculate_rsi(window_size=14)\nrsi_header = ['Date', 'Close', 'RSI']\nrsi_data = [(stock_info.Data[i][\"Date\"], stock_info.Data[i]['Close'], rsi) for i, rsi in enumerate(rsi_values)]\nstock_info.write_file(\"rsi_results.csv\", rsi_header, rsi_data)\n```\n## Contributing\nContributions are welcome! If you encounter any issues or have suggestions for improvements, please create an issue or submit a pull request.\n\n## Licence\nThis project is licensed under the MIT License\n",
"bugtrack_url": null,
"license": "",
"summary": "Stock information analysis package",
"version": "0.0.1",
"project_urls": null,
"split_keywords": [
"python",
"stock",
"finance",
"sma",
"rsi"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "abf036fc75a3278da3ebc2ea7d570354ee3da805f883e74313173496343d17f6",
"md5": "b64fe64eea4a80996f29eb81bd84db2e",
"sha256": "f3568988e7c3cfeabc3e3b7b83847f5323224621f50492ce69f6b5355de49627"
},
"downloads": -1,
"filename": "stocklerain1001-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b64fe64eea4a80996f29eb81bd84db2e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4259,
"upload_time": "2024-01-07T19:54:14",
"upload_time_iso_8601": "2024-01-07T19:54:14.589322Z",
"url": "https://files.pythonhosted.org/packages/ab/f0/36fc75a3278da3ebc2ea7d570354ee3da805f883e74313173496343d17f6/stocklerain1001-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6f5d1c2abddb862381e2c88a0195a15a2606293ff01a4e9e7f0d10a8cf805fe4",
"md5": "c73bbecb4b3b929517a630560f7d128e",
"sha256": "7730f8b4d91310d5ff6042e35138eea7a3a3f0510fa81bb8654a4b7fed592202"
},
"downloads": -1,
"filename": "stocklerain1001-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "c73bbecb4b3b929517a630560f7d128e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3701,
"upload_time": "2024-01-07T19:54:18",
"upload_time_iso_8601": "2024-01-07T19:54:18.141062Z",
"url": "https://files.pythonhosted.org/packages/6f/5d/1c2abddb862381e2c88a0195a15a2606293ff01a4e9e7f0d10a8cf805fe4/stocklerain1001-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-07 19:54:18",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "stocklerain1001"
}