A professional, modular Python data-analysis pipeline for financial time-series data. The project ingests CSV data, computes moving averages, and produces high-quality visualizations. It demonstrates separation of concerns, reproducible environments, automated test coverage, and synthetic data generation for testing.
data/- raw input CSV files (example:raw_data.csv)assets/- tracked images / documentation assets (e.g.,trend_plot.png)output/- runtime artifacts (generated charts) — ignored by Gitscripts/- utility scripts (e.g.,generate_data.py)src/- core application codeanalyzer.py- data-processing logicvisualizer.py- plotting code
tests/- pytest unit testsmain.py- entry pointrequirements.txt- pinned dependencies.python-version(optional) - recommended Python version (e.g.,3.12).gitignore- ignore rules
- Python 3.12+ recommended
- Git
- pip
If you want to manage multiple Python versions locally, consider using pyenv. Place 3.12.x as the project version to ensure compatibility with the pinned dependencies.
- Clone the repository:
git clone https://github.com/yourusername/market_analyzer.git
cd market_analyzer- Create and activate a virtual environment:
# macOS / Linux
python -m venv venv
source venv/bin/activate
# Windows (PowerShell)
python -m venv venv
venv\Scripts\Activate.ps1- Install dependencies:
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements.txt- Generate synthetic test data:
python scripts/generate_data.py- Run the analysis and generate the visualization:
python main.py- View the result:
- A high-resolution plot
trend_plot.pngwill be created in theoutput/folder. - To show the image in the README, copy the desired image to
assets/trend_plot.pngand commit it.
Place your CSV in data/raw_data.csv. Required columns:
Date— inYYYY-MM-DDformatClose— numeric closing price
Example:
Date,Close
2024-01-01,150.00
2024-01-02,152.50
...- Change moving-average window in
main.py:
analyzer.calculate_moving_average(window=7)- Visualizer auto-detects any
SMA_<window>column and plots it.
If you prefer running scripts as modules, ensure package folders have __init__.py. Example:
python -m scripts.generate_dataor run files directly:
python scripts/generate_data.pyRun the test suite with:
pytestTests verify moving-average calculations and basic data validation. Add tests to tests/ to cover new features.
- Use
python -m pipto ensure installation into the active virtual environment:
python -m pip install -r requirements.txt- If you see Pandas warnings about
pyarrow, install it (it is included inrequirements.txt).
- pandas
- numpy
- pyarrow
- matplotlib
- pytest
All versions are pinned in requirements.txt for reproducibility.
Include a license file in the repo root (e.g., LICENSE with MIT License) to clarify usage terms.
