Skip to content

kcenon/screener_system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

462 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Stock Screening Platform

CI Pipeline CD Pipeline Documentation PR Checks codecov License Docs Status Project Status Completion

A comprehensive stock analysis and screening platform for Korean markets (KOSPI/KOSDAQ) with 200+ financial and technical indicators.

πŸŽ‰ Project Status: MVP Complete! All 54 planned tickets completed (~358 hours). Production-ready with full documentation, testing, and CI/CD automation.

🎯 Features

βœ… Implemented (Production-Ready)

  • Advanced Stock Screening: Filter 2,400+ stocks using 200+ technical and financial indicators
    • Complex multi-criteria filtering with AND/OR logic
    • Filter presets (save/load/delete custom filters)
    • Export results to CSV/JSON
    • URL sharing for filter configurations
  • Real-time Market Data: WebSocket-based live updates
    • Real-time price streaming with JWT authentication
    • Order book visualization (10-level bid/ask)
    • Multi-instance support via Redis Pub/Sub
    • Auto-reconnection with exponential backoff
  • User Authentication & Authorization: JWT-based security
    • User registration and login
    • Role-based access control (RBAC)
    • Refresh token support
    • Rate limiting by user tier
  • Stock Detail Pages: Comprehensive stock information
    • Real-time price data and charts
    • Technical indicators visualization
    • Historical data analysis
    • Financial ratios and fundamentals
  • Data Pipeline: Automated data ingestion and processing
    • Apache Airflow orchestration
    • KIS API integration for real-time data
    • Daily price ingestion (2,400+ stocks)
    • 200+ indicator calculations
    • Error handling and retry logic
  • Monitoring & Observability: Production-grade monitoring
    • Prometheus metrics collection
    • Grafana dashboards
    • Performance baselines established
    • Alert configuration
  • Documentation: Comprehensive auto-generated docs
    • Docusaurus documentation platform
    • Python API docs (Sphinx)
    • TypeScript API docs (TypeDoc)
    • OpenAPI/Swagger UI
    • User guides and tutorials

🚧 Planned (Future Enhancements)

  • Portfolio Management: Track holdings and performance vs benchmarks
  • Price Alerts: Customizable notifications for price movements
  • Mobile App: React Native mobile application
  • Advanced Analytics: Backtesting and strategy builder
  • Social Features: Community discussions and shared analyses

πŸ“– Documentation

Comprehensive documentation is automatically built and deployed at kcenon.github.io/screener_system

The documentation site includes:

  • Getting Started Guide - Setup and installation
  • API Reference - Backend (Python) and Frontend (TypeScript) APIs
  • User Guides - Feature documentation
  • Architecture - System design and components
  • Contributing - Development guidelines

Building Documentation Locally

# Build all documentation
cd docs-site
npm install
npm start  # Opens http://localhost:3000

# Build Python API docs (Sphinx)
cd docs/api/python
sphinx-build -b html . _build/html

# Build Frontend API docs (TypeDoc)
cd frontend
npm run docs:generate

Documentation Pipeline

Documentation is automatically built and deployed on every push to main:

See CI/CD Setup Guide for details.

πŸ“Š Tech Stack

Frontend

  • Framework: React 18 + TypeScript
  • Build Tool: Vite
  • State Management: Zustand
  • Data Fetching: TanStack Query (React Query)
  • UI Components: Radix UI + Tailwind CSS
  • Charts: TradingView Lightweight Charts + Recharts

Backend

  • API Framework: FastAPI (Python)
  • Database: PostgreSQL 16 + TimescaleDB
  • Caching: Redis 7
  • Task Queue: Celery
  • Authentication: JWT (FastAPI-Users)

Infrastructure

  • Containerization: Docker + Docker Compose
  • Orchestration: Kubernetes
  • CI/CD: GitHub Actions
  • Monitoring: Grafana + Prometheus
  • Logging: ELK Stack

Data Pipeline

  • Workflow Orchestration: Apache Airflow
  • Data Processing: Pandas + NumPy
  • Data Sources: KRX API, F&Guide API

πŸš€ Quick Start

Prerequisites

  • Docker & Docker Compose
  • Node.js 18+
  • Python 3.9+
  • PostgreSQL 16+ (with TimescaleDB extension)
  • Redis 7+

Installation

Option 1: Docker Compose (Recommended)

# Clone repository
git clone https://github.com/kcenon/screener_system.git
cd screener_system

# Setup environment
cp .env.example .env
# Edit .env with your configuration

# Start all services with Docker Compose
docker-compose up -d

# Check service health
docker-compose ps

# View logs
docker-compose logs -f backend

Option 2: Local Development

# Clone repository
git clone https://github.com/kcenon/screener_system.git
cd screener_system

# Setup environment
cp .env.example .env

# Start database and cache only
docker-compose up -d postgres redis

# Backend setup
cd backend
pip install -r requirements.txt
uvicorn app.main:app --reload

# Frontend setup (in another terminal)
cd frontend
npm install
npm run dev

# Data pipeline setup (optional, in another terminal)
cd data_pipeline
# Follow data_pipeline/README.md for setup

Access the application:

Loading Sample Data

After starting the services, load sample stock data for testing:

# Load pre-generated seed data (150 stocks, 252 days of prices)
docker exec -i screener_postgres psql -U screener_user -d screener_db \
  < database/seeds/seed_data.sql

# Verify data loaded
docker exec screener_postgres psql -U screener_user -d screener_db \
  -c "SELECT COUNT(*) FROM stocks; SELECT COUNT(*) FROM daily_prices;"

Sample Data Includes:

  • 150 stocks (100 KOSPI + 50 KOSDAQ)
  • 27,000 daily prices (~252 trading days per stock)
  • 600 financial statements (4 quarters per stock)
  • 150 calculated indicators

Note: This is test data for development only. For production, use real KRX API data via Airflow DAGs.

See Data Loading Guide for detailed instructions and customization options.

πŸ“ Project Structure

screener_system/
β”œβ”€β”€ frontend/                 # React SPA
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/      # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ pages/           # Page components
β”‚   β”‚   β”œβ”€β”€ hooks/           # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ services/        # API client services
β”‚   β”‚   β”œβ”€β”€ store/           # Zustand state management
β”‚   β”‚   └── utils/           # Utility functions
β”‚   β”œβ”€β”€ public/              # Static assets
β”‚   └── package.json
β”‚
β”œβ”€β”€ backend/                  # FastAPI application
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/             # API endpoints
β”‚   β”‚   β”œβ”€β”€ core/            # Core functionality
β”‚   β”‚   β”œβ”€β”€ db/              # Database models
β”‚   β”‚   β”œβ”€β”€ schemas/         # Pydantic schemas
β”‚   β”‚   └── services/        # Business logic
β”‚   β”œβ”€β”€ tests/               # Unit & integration tests
β”‚   └── requirements.txt
β”‚
β”œβ”€β”€ database/                 # Database schema & migrations
β”‚   β”œβ”€β”€ migrations/          # SQL migration files
β”‚   β”œβ”€β”€ seeds/               # Seed data
β”‚   β”œβ”€β”€ scripts/             # Utility scripts
β”‚   └── README.md
β”‚
β”œβ”€β”€ data_pipeline/            # Apache Airflow DAGs
β”‚   β”œβ”€β”€ dags/                # DAG definitions
β”‚   β”œβ”€β”€ plugins/             # Custom Airflow plugins
β”‚   β”œβ”€β”€ config/              # Configuration files
β”‚   └── README.md
β”‚
β”œβ”€β”€ api/                      # API specification
β”‚   β”œβ”€β”€ openapi.yaml         # OpenAPI 3.0 spec
β”‚   └── README.md
β”‚
β”œβ”€β”€ infrastructure/           # Infrastructure as Code
β”‚   β”œβ”€β”€ docker/              # Dockerfiles
β”‚   β”œβ”€β”€ kubernetes/          # K8s manifests
β”‚   β”œβ”€β”€ terraform/           # Cloud infrastructure
β”‚   └── monitoring/          # Grafana dashboards
β”‚
β”œβ”€β”€ docs/                     # Documentation
β”‚   β”œβ”€β”€ PRD.md               # Product Requirements
β”‚   β”œβ”€β”€ architecture.md      # System architecture
β”‚   β”œβ”€β”€ api-guide.md         # API usage guide
β”‚   └── deployment.md        # Deployment guide
β”‚
β”œβ”€β”€ tests/                    # End-to-end tests
β”‚   β”œβ”€β”€ e2e/                 # Cypress tests
β”‚   └── load/                # k6 load tests
β”‚
β”œβ”€β”€ .github/                  # GitHub workflows
β”‚   └── workflows/
β”‚       β”œβ”€β”€ ci.yml           # Continuous Integration
β”‚       └── cd.yml           # Continuous Deployment
β”‚
β”œβ”€β”€ docker-compose.yml        # Local development stack
β”œβ”€β”€ .env.example              # Environment variables template
β”œβ”€β”€ .gitignore
└── README.md                 # This file

πŸ”§ Development

Running Tests

# Frontend tests
cd frontend
npm test

# Backend tests
cd backend
pytest

# End-to-end tests
cd tests/e2e
npx cypress run

Code Quality

# Frontend linting
cd frontend
npm run lint

# Backend linting
cd backend
ruff check .
mypy app/

# Format code
cd frontend && npm run format
cd backend && ruff format .

Database Migrations

# Create new migration
alembic revision --autogenerate -m "description"

# Apply migrations
alembic upgrade head

# Rollback
alembic downgrade -1

πŸ“ˆ Performance Benchmarks

Performance targets measured and validated during Sprint 4:

Metric Target Actual Status
Screening Query Time (p99) < 500ms ~220ms βœ… 56% better
API Response Time (p95) < 200ms ~150ms βœ… 25% better
Page Load Time (p95) < 1.5s ~1.2s βœ… 20% better
DAG Execution (Full) < 10 min ~8.5 min βœ… 15% better
Cache Hit Rate > 80% ~85% βœ…
Test Coverage (Backend) > 70% 80% βœ…

Key Optimizations Applied:

  • Window function optimization (45% query speedup)
  • Redis caching with 5-minute TTL
  • Database connection pooling
  • Materialized views for complex queries
  • Atomic Redis operations for rate limiting

🚒 Deployment

Docker Production Build

# Build images
docker-compose -f docker-compose.prod.yml build

# Deploy
docker-compose -f docker-compose.prod.yml up -d

Kubernetes Deployment

# Apply manifests
kubectl apply -f infrastructure/kubernetes/

# Check status
kubectl get pods -n screener

# View logs
kubectl logs -f deployment/backend -n screener

πŸ“Š Monitoring

Note: Production URLs will be configured during deployment phase.

πŸ” Security

  • JWT-based authentication (15-minute access tokens)
  • HTTPS only (TLS 1.3)
  • Rate limiting (100-2000 req/min based on tier)
  • SQL injection prevention (parameterized queries)
  • XSS protection (Content Security Policy)
  • CSRF protection (SameSite cookies)
  • Regular dependency scans (Dependabot)

πŸ“ API Documentation

Comprehensive API documentation is available in multiple formats:

Documentation Portal (https://kcenon.github.io/screener_system):

Interactive API Docs (Backend Server):

Note: Interactive API docs (Swagger/ReDoc) are served by the FastAPI backend. Production URLs will be configured during deployment.

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

πŸ“„ License

This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.

πŸ“ž Support

πŸ“Š Project Statistics

Category Metrics
Development 54 tickets completed (100%)
Total Effort ~358 hours across 4 sprints
Test Coverage Backend: 80%, Frontend: 100% pass rate
Code Quality All linting/type checks passing
Documentation 100% API coverage, auto-generated
CI/CD Fully automated with GitHub Actions
Infrastructure Docker, Airflow, Monitoring ready
Security JWT auth, rate limiting, SQL injection prevention

πŸ—ΊοΈ Development Timeline

βœ… Sprint 1-2: Foundation & Core Features (Complete)

Tickets: 23 tickets, ~137 hours

  • βœ… Infrastructure (3 tickets)
    • Docker Compose development environment
    • CI/CD pipeline with GitHub Actions
    • Production monitoring and logging
  • βœ… Backend (6 tickets)
    • FastAPI project setup
    • User authentication API
    • Stock data API
    • Stock screening API (96 tests)
    • API rate limiting and throttling
    • WebSocket real-time streaming
  • βœ… Database (5 tickets)
    • PostgreSQL + TimescaleDB setup
    • Schema migrations
    • Indexes and materialized views
    • Functions and triggers
    • Order book schema
  • βœ… Data Pipeline (4 tickets)
    • Apache Airflow environment
    • Daily price ingestion DAG
    • Indicator calculation DAG (200+ indicators)
    • KIS API integration
  • βœ… Frontend (5 tickets)
    • React + Vite project setup
    • User authentication UI
    • Stock screener page (139 tests)
    • Stock detail page
    • Order book visualization

βœ… Sprint 3: Polish & Advanced Features (Complete)

Tickets: 12 tickets, ~114 hours

  • βœ… Technical debt resolution (5 tickets)
  • βœ… Security hardening (SQL injection fixes)
  • βœ… Performance optimization (45% query improvement)
  • βœ… Rate limiting documentation
  • βœ… Test coverage increase (59% β†’ 80%)

βœ… Sprint 4: Quality Assurance & Documentation (Complete)

Tickets: 19 tickets, ~107 hours

  • βœ… Bug Fixes & Validation (7 tickets)
    • Docker environment runtime testing
    • Airflow DAG runtime testing
    • Performance baseline measurement
    • CI/CD validation
    • Acceptance criteria validation
  • βœ… Documentation Sprint (9 tickets)
    • Docusaurus platform setup
    • Python API documentation (Sphinx)
    • TypeScript API documentation (TypeDoc)
    • Documentation guidelines and templates
    • CI/CD deployment pipeline
  • βœ… Security & Data Quality (3 tickets)
    • Dependency vulnerability resolution (29 CVEs)
    • Data quality validation
    • Sample data generation

πŸš€ Future Roadmap (Post-MVP)

Phase 1: Beta Launch (Next 2 months)

  • User acceptance testing
  • Performance tuning under load
  • Security audit and penetration testing
  • Production deployment and monitoring

Phase 2: Feature Expansion (Months 3-6)

  • Portfolio management and tracking
  • Price alerts and notifications
  • Advanced charting features
  • User watchlists and favorites
  • News integration

Phase 3: Advanced Features (Months 7-12)

  • Mobile app (React Native)
  • Backtesting engine
  • Strategy builder
  • API access for developers
  • Premium subscription tiers

Phase 4: Scale & Innovation (Year 2+)

  • AI-powered stock recommendations
  • Social features and community
  • International markets support
  • Institutional features
  • White-label solutions

πŸ“š Documentation


Made with ❀️ by πŸ€β˜€πŸŒ•πŸŒ₯ 🌊

About

Advanced stock screening platform for Korean markets (KOSPI/KOSDAQ) with 200+ financial indicators

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors