Files
optimiz-rs/Dockerfile
T
Melvin Alvarez 9a8032e4ee feat(timeseries): add time-series integration helpers for financial analysis
- Implement 6 helper functions in src/timeseries_utils.rs:
  * prepare_for_hmm: Feature engineering for HMM regime detection
  * rolling_hurst_exponent: Mean-reversion detection (H < 0.5 = mean-reverting)
  * rolling_half_life: Mean-reversion speed for pairs trading
  * return_statistics: Risk metrics (mean, std, skew, kurt, sharpe)
  * create_lagged_features: ML feature matrix creation
  * rolling_correlation: Rolling correlation for pairs trading

- Add PyO3 bindings in src/timeseries_utils/python_bindings.rs:
  * All functions exposed with _py suffix
  * Proper signature decorators and error handling
  * Registered in lib.rs module system

- Update Python module exports:
  * python/optimizr/core.py: Import from _core
  * python/optimizr/__init__.py: Re-export all functions

- Create comprehensive example:
  * examples/timeseries_integration.py demonstrates all 6 functions
  * Includes integrated pairs trading workflow
  * Shows feature engineering for regime detection

- Technical details:
  * Fixed Array1<f64> type conversions for ndarray compatibility
  * Uses risk_metrics::hurst_exponent and estimate_half_life
  * Built successfully with maturin develop --release (40.93s)
  * All functions tested and working correctly

Part of Priority 3: Time-series integration helpers (Enhancement Strategy)
Addresses v0.3.0 roadmap: Bridge optimization with time-series analysis
2026-01-02 22:13:05 +01:00

58 lines
1.4 KiB
Docker

# OptimizR Development Container
# Multi-stage build for efficient image size
FROM rust:1.75-slim as rust-builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
python3-dev \
libssl-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy Rust source and build
COPY Cargo.toml Cargo.lock ./
COPY src ./src
RUN cargo build --release
# Final stage with Python
FROM python:3.11-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
git \
pkg-config \
libssl-dev \
libopenblas-dev \
gfortran \
patchelf \
&& rm -rf /var/lib/apt/lists/*
# Install Rust (needed for maturin)
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
WORKDIR /workspace
# Copy project files
COPY . .
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir maturin numpy scipy matplotlib pytest jupyter notebook ipykernel pandas seaborn
# Build the wheel and install it (without needing virtualenv)
RUN maturin build --release --out dist && \
pip install --no-cache-dir dist/*.whl
# Expose Jupyter port
EXPOSE 8888
# Default command: start Jupyter notebook
CMD ["jupyter", "notebook", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--allow-root", "--NotebookApp.token=''", "--NotebookApp.password=''"]