Skip to content

Commit d95a88f

Browse files
Merge pull request #18 from Visionary-Code-Works/dev
new version v1.2.0
2 parents c8e7fae + 26580ed commit d95a88f

42 files changed

Lines changed: 2587 additions & 534 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/old_python_publish_yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.github/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='stock-analysis-program',
5-
version='1.0.0',
5+
version='1.2.0',
66
packages=find_packages(),
77
include_package_data=True,
88
description='A Python-based toolkit for fetching and visualizing financial data and metrics for stocks.',

.github/workflows/ci.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
test:
15+
name: Test Python ${{ matrix.python-version }}
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
python-version: ["3.11", "3.12", "3.13"]
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
cache: "pip"
31+
32+
- name: Install Poetry
33+
run: |
34+
python -m pip install --upgrade pip
35+
python -m pip install poetry
36+
37+
- name: Validate package metadata
38+
run: poetry check
39+
40+
- name: Install dependencies
41+
run: poetry install --with dev
42+
43+
- name: Run tests
44+
run: poetry run pytest -q
45+
46+
build:
47+
name: Build package
48+
runs-on: ubuntu-latest
49+
needs: test
50+
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v6
54+
55+
- name: Set up Python
56+
uses: actions/setup-python@v5
57+
with:
58+
python-version: "latest"
59+
cache: "pip"
60+
61+
- name: Install build tooling
62+
run: |
63+
python -m pip install --upgrade pip
64+
python -m pip install poetry twine
65+
66+
- name: Build distributions
67+
run: poetry build
68+
69+
- name: Check distributions
70+
run: twine check dist/*

.github/workflows/jekyll-gh-pages.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,43 @@
1-
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
2-
name: Deploy Jekyll with GitHub Pages dependencies preinstalled
1+
name: Deploy Docs to GitHub Pages
32

43
on:
5-
# Runs on pushes targeting the default branch
64
push:
75
branches: ["main"]
6+
paths:
7+
- "README.md"
8+
- "docs/**"
9+
- ".github/workflows/jekyll-gh-pages.yml"
810

9-
# Allows you to run this workflow manually from the Actions tab
1011
workflow_dispatch:
1112

12-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1313
permissions:
1414
contents: read
1515
pages: write
1616
id-token: write
1717

18-
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19-
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2018
concurrency:
2119
group: "pages"
2220
cancel-in-progress: false
2321

2422
jobs:
25-
# Build job
2623
build:
2724
runs-on: ubuntu-latest
2825
steps:
2926
- name: Checkout
3027
uses: actions/checkout@v4
28+
3129
- name: Setup Pages
3230
uses: actions/configure-pages@v4
31+
3332
- name: Build with Jekyll
3433
uses: actions/jekyll-build-pages@v1
3534
with:
3635
source: ./
3736
destination: ./_site
37+
3838
- name: Upload artifact
3939
uses: actions/upload-pages-artifact@v3
4040

41-
# Deployment job
4241
deploy:
4342
environment:
4443
name: github-pages
Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,52 @@
1-
name: Upload Python Package
1+
name: Publish Python Package
22

33
on:
44
push:
55
tags:
6-
- 'v*'
6+
- "v*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
711

812
jobs:
9-
deploy:
13+
publish:
1014
runs-on: ubuntu-latest
15+
environment:
16+
name: pypi
17+
url: https://pypi.org/project/stock-analysis-program/
18+
1119
steps:
12-
- uses: actions/checkout@v4
13-
14-
- name: Set up Python
15-
uses: actions/setup-python@v5
16-
with:
17-
python-version: '3.x'
18-
19-
- name: Install Poetry
20-
run: |
21-
pip install --upgrade pip
22-
pip install poetry
23-
24-
- name: Build and publish to PyPI
25-
env:
26-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
27-
run: |
28-
poetry config virtualenvs.create false
29-
poetry build
30-
poetry publish
20+
- name: Checkout
21+
uses: actions/checkout@v6
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: "latest"
27+
cache: "pip"
28+
29+
- name: Install release tooling
30+
run: |
31+
python -m pip install --upgrade pip
32+
python -m pip install poetry twine
33+
34+
- name: Validate package metadata
35+
run: poetry check
36+
37+
- name: Install dependencies
38+
run: poetry install --with dev
39+
40+
- name: Run tests
41+
run: poetry run pytest -q
42+
43+
- name: Build distributions
44+
run: poetry build
45+
46+
- name: Check distributions
47+
run: twine check dist/*
48+
49+
- name: Publish to PyPI
50+
env:
51+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
52+
run: poetry publish

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,4 @@ $RECYCLE.BIN/
225225

226226
.vscode/
227227
archive/
228+
pytest-cache-files-*/

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ The Stock Analysis Program is a Python-based toolkit designed to fetch and visua
1515

1616
## Installation
1717

18-
To use this program, ensure you have Python installed on your system. Clone this repository and install the required dependencies:
18+
Install the package from PyPI:
1919

2020
```bash
21-
git clone https://github.com/visionary-code-works/stock-analysis-program.git
22-
cd stock-analysis-program
23-
pip install -r requirements.txt
21+
pip install stock-analysis-program
22+
```
23+
24+
The package also installs a small command-line menu:
25+
26+
```bash
27+
stock-analysis
2428
```
2529

2630
## Usage
@@ -46,13 +50,24 @@ The program consists of multiple Python classes categorized into Fetchers and Pl
4650
### Example
4751

4852
```python
49-
from plotter.stock_price_plotter import StockPricePlotter
53+
from stock_analysis_program import StockPricePlotter
5054

5155
# Plotting stock prices for Apple and Microsoft
5256
price_plotter = StockPricePlotter(['AAPL', 'MSFT'])
5357
price_plotter.plot_closing_prices('2021-01-01', '2021-12-31')
5458
```
5559

60+
Plotter methods return Matplotlib figure and axes objects for notebook,
61+
testing, or dashboard usage:
62+
63+
```python
64+
figures = price_plotter.plot_closing_prices(
65+
'2021-01-01',
66+
'2021-12-31',
67+
show=False,
68+
)
69+
```
70+
5671
## Documentation
5772

5873
For detailed documentation on each component, please refer to the `docs` directory.

docs/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## v1.2.0
2+
3+
- Added the `stock-analysis` console command through the package metadata.
4+
- Moved CLI behavior into `stock_analysis_program.cli` and kept root `main.py` as a compatibility wrapper.
5+
- Standardized public imports around `stock_analysis_program`.
6+
- Updated plotter methods to return Matplotlib figure/axes objects and support `show=False`.
7+
- Added ticker normalization and clearer empty-data validation for fetchers and plotters.
8+
- Replaced network-dependent tests with mocked provider tests.
9+
- Updated README and documentation examples for PyPI installation and package imports.
10+
111
To rewrite the provided code as a set of classes, we need to organize the functionalities into logical units that represent distinct aspects of the operations. The code you provided contains various functions for fetching and analyzing stock data using the `yfinance` library. Here's how we can organize these functionalities into classes:
212

313
1. **StockAveragesFetcher**: Handles the fetching and calculation of moving averages and average trading volume for a single stock ticker.

docs/documentation.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ flowchart LR
8080
Each fetcher class can be used independently to retrieve specific data. For example:
8181

8282
```python
83-
from fetcher.stock_summary_fetcher import StockSummaryFetcher
83+
from stock_analysis_program import StockSummaryFetcher
8484

8585
# Fetching stock summaries
8686
summary_fetcher = StockSummaryFetcher(['AAPL', 'MSFT'])
@@ -93,7 +93,7 @@ print(summaries)
9393
Plotters are used for visualizing data. They often depend on fetchers to get the necessary data. For example:
9494

9595
```python
96-
from plotter.stock_price_plotter import StockPricePlotter
96+
from stock_analysis_program import StockPricePlotter
9797

9898
# Plotting stock prices
9999
price_plotter = StockPricePlotter(['AAPL', 'MSFT'])
@@ -121,8 +121,7 @@ To extend the program:
121121
Here's an example of how to integrate multiple components in a larger program:
122122

123123
```python
124-
from fetcher.revenue_growth_fetcher import RevenueGrowthFetcher
125-
from plotter.revenue_growth_plotter import RevenueGrowthPlotter
124+
from stock_analysis_program import RevenueGrowthFetcher, RevenueGrowthPlotter
126125

127126
def plot_revenue_growth(tickers):
128127
# Fetching revenue growth

0 commit comments

Comments
 (0)