# 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 stockinfoain1001
```
## Usage
### Loading historical data:
```python
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):
```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 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:
```python
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
Raw data
{
"_id": null,
"home_page": "",
"name": "stockinfoain1001",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "python,stock,finance,SMA,RSI",
"author": "Abdurrahman Javat",
"author_email": "<abdurrahman.javat@bahcesehir.edu.tr>",
"download_url": "https://files.pythonhosted.org/packages/e3/08/89dd1871b78ff97461b6a23fd108d1bbdb215228e5b3c508a6b432ac4d30/stockinfoain1001-1.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 stockinfoain1001\n```\n## Usage\n### Loading historical data:\n```python\nfrom stockinfoain1001 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 stockinfoain1001 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 stockinfoain1001 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": "1.0.1",
"project_urls": null,
"split_keywords": [
"python",
"stock",
"finance",
"sma",
"rsi"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8a11b86dc4af65bacdc69a51e7e73d8b94bd4fb1aa18e2905d50e249ca973422",
"md5": "9ea0c3af794c0fe48ab00cf8fd6edad5",
"sha256": "92b5e066b830215e0c3e617295304d10b1a3de0c77ca531d6fc16c77b95073a1"
},
"downloads": -1,
"filename": "stockinfoain1001-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9ea0c3af794c0fe48ab00cf8fd6edad5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4279,
"upload_time": "2024-01-03T09:32:55",
"upload_time_iso_8601": "2024-01-03T09:32:55.625468Z",
"url": "https://files.pythonhosted.org/packages/8a/11/b86dc4af65bacdc69a51e7e73d8b94bd4fb1aa18e2905d50e249ca973422/stockinfoain1001-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e30889dd1871b78ff97461b6a23fd108d1bbdb215228e5b3c508a6b432ac4d30",
"md5": "61917f3a7952bd76d74378ba2a258094",
"sha256": "d9d2f695931f556dc4416718c3726d81ec5f23cf50bee4f7a20b6c03c1a587ef"
},
"downloads": -1,
"filename": "stockinfoain1001-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "61917f3a7952bd76d74378ba2a258094",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3707,
"upload_time": "2024-01-03T09:32:56",
"upload_time_iso_8601": "2024-01-03T09:32:56.795917Z",
"url": "https://files.pythonhosted.org/packages/e3/08/89dd1871b78ff97461b6a23fd108d1bbdb215228e5b3c508a6b432ac4d30/stockinfoain1001-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-03 09:32:56",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "stockinfoain1001"
}