Skip to content

Week 1: Infrastructure Setup & Docker Configuration

Date: January 2, 2026 Phase: AlphaTwin Phase 1 - Portal Infrastructure Status: ✅ Completed

English Practice: "Why I chose Docker for Trading?"

When building a quantitative trading system, consistency and reproducibility are paramount. Docker provides the perfect solution by containerizing our entire development environment. Here's why Docker is ideal for trading applications:

Environment Consistency: Every developer and deployment environment runs the exact same container, eliminating "works on my machine" issues.

Dependency Management: Complex Python packages, system libraries, and configurations are all packaged together, ensuring reliable execution across different systems.

Version Control: Not just code, but entire runtime environments can be versioned and shared.

Scalability: Easy to scale from local development to cloud deployment without environment conflicts.

Security: Containers provide isolation, protecting trading algorithms and sensitive market data.

Setup Process

1. Project Structure Creation

Created the complete directory structure following the AlphaTwin specification:

AlphaTwin/
├── .github/                 # GitHub Actions (future CI/CD)
├── data/                    # Local data storage
│   ├── raw/                 # Original market data
│   └── processed/           # Cleaned datasets
├── docker/                  # Container configurations
│   ├── Dockerfile.app       # Quant engine environment
│   └── Dockerfile.docs      # Documentation portal
├── docs/                    # MkDocs portal content
│   ├── index.md            # Project manifesto
│   ├── architecture/       # Technical documentation
│   ├── strategies/         # Trading strategies (future)
│   └── logs/               # Development logs
├── src/                     # Core Python modules
│   ├── data_loader.py      # Market data acquisition
│   ├── backtest_engine.py  # Performance evaluation
│   └── signals.py          # Trading signals
├── notebooks/               # Jupyter experiments
├── mkdocs.yml              # Portal configuration
├── docker-compose.yml      # Multi-service orchestration
├── requirements.txt         # Python dependencies
└── README.md               # Project overview

2. Docker Configuration

Dockerfile.app (Quantitative Engine)

FROM python:3.13-slim

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Install Jupyter
RUN pip install jupyterlab

# Create directories
RUN mkdir -p data/raw data/processed src notebooks

CMD ["python"]

Key Decisions: - Python 3.13 for latest features and performance - Slim base image to reduce container size - Volume mounts for data persistence - Jupyter Lab for interactive development

Dockerfile.docs (Documentation Portal)

FROM python:3.13-slim

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Create docs directory
RUN mkdir -p docs

EXPOSE 8000

CMD ["mkdocs", "serve", "--dev-addr=0.0.0.0:8000"]

Rationale: Dedicated container for documentation ensures clean separation and easier deployment.

docker-compose.yml (Service Orchestration)

version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: docker/Dockerfile.app
    volumes:
      - ./data:/app/data
      - ./src:/app/src
      - ./notebooks:/app/notebooks
    ports:
      - "8888:8888"  # Jupyter
    command: jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root

  docs:
    build:
      context: .
      dockerfile: docker/Dockerfile.docs
    volumes:
      - ./docs:/app/docs
      - ./mkdocs.yml:/app/mkdocs.yml
    ports:
      - "8000:8000"
    command: mkdocs serve --dev-addr=0.0.0.0:8000

Benefits: - Isolated services for different purposes - Persistent data through volumes - Easy local development with port mapping

3. MkDocs Portal Configuration

Theme Selection: Material Design with Dark Mode

site_name: AlphaTwin
theme:
  name: material
  palette:
    scheme: slate  # Dark mode, trading terminal aesthetic
    primary: teal

Why Dark Mode? - Professional appearance similar to trading platforms - Reduced eye strain during long development sessions - Modern, tech-forward aesthetic

Mermaid.js Integration

markdown_extensions:
  - pymdownx.superfences:
      custom_fences:
        - name: mermaid
          class: mermaid
          format: !!python/name:pymdownx.superfences.fence_code_format

Capabilities Added: - Flowcharts for architecture visualization - Gantt charts for project timelines - Sequence diagrams for data flows - State diagrams for strategy logic

4. Python Environment Setup

Pyenv Configuration

  • Project-specific Python version: 3.13
  • .python-version file for automatic environment activation
  • Compatible with system Python installation

Dependencies Management

mkdocs>=1.4.0
mkdocs-material>=9.0.0
pymdown-extensions>=10.0
mkdocs-mermaid2-plugin>=1.0.0
yfinance>=0.2.0
pandas>=1.5.0
numpy>=1.21.0
matplotlib>=3.5.0
plotly>=5.0.0

Dependency Strategy: - MkDocs ecosystem for documentation - Financial data libraries (yfinance, pandas) - Visualization libraries (matplotlib, plotly) - Future-proof version constraints

5. Core Module Development

Data Loader (src/data_loader.py)

  • Yahoo Finance API integration
  • Automated data cleaning and processing
  • CSV/Parquet storage with metadata
  • Error handling and retry logic

Signal Generator (src/signals.py)

  • Abstract base class for strategy patterns
  • Multiple built-in strategies (MA Crossover, RSI, Momentum)
  • Signal combination and weighting
  • Extensible architecture for custom strategies

Backtest Engine (src/backtest_engine.py)

  • Event-driven backtesting framework
  • Performance metrics calculation (Sharpe, Sortino, etc.)
  • Risk analysis (VaR, CVaR, drawdowns)
  • Visualization and reporting capabilities

Challenges Encountered & Solutions

Challenge 1: Python Version Compatibility

Problem: Pyenv installation of Python 3.11 failed Solution: Used system Python 3.13.3, updated all configurations accordingly

Challenge 2: Mermaid.js Plugin Configuration

Problem: Initial MkDocs configuration didn't render Mermaid diagrams Solution: Corrected YAML syntax for pymdownx.superfences extension

Challenge 3: Docker Volume Permissions

Problem: Permission issues with mounted volumes Solution: Ensured proper user permissions and directory creation in Dockerfiles

Testing & Verification

Docker Services

# Start documentation portal
docker-compose up docs

# Start development environment
docker-compose up app

# Both services simultaneously
docker-compose up

MkDocs Portal

  • ✅ Dark theme rendering correctly
  • ✅ Mermaid diagrams displaying properly
  • ✅ Navigation structure functional
  • ✅ Responsive design on mobile

Python Environment

  • ✅ All dependencies installed successfully
  • ✅ Core modules importable without errors
  • ✅ Basic functionality tests passing

Next Steps

  1. Content Development: Add more detailed strategy documentation
  2. Data Pipeline: Implement automated data collection scripts
  3. Strategy Testing: Develop and backtest initial trading strategies
  4. CI/CD Setup: Configure GitHub Actions for automated testing
  5. Video Production: Begin creating tutorial content

Key Takeaways

This week established the foundation for AlphaTwin with a focus on developer experience and automation. The Docker-based approach ensures that the development environment is consistent, reproducible, and scalable. The MkDocs portal provides a professional platform for documentation and knowledge sharing.

The combination of containerization, version control, and comprehensive documentation creates a robust foundation for quantitative trading development - applying software engineering best practices to financial technology.


"The best error message is the one that never occurs." - Thomas Fuchs

Week 1 complete: Infrastructure established, portal operational, development environment ready.