# # LEAN Foundation Docker Container # Cross platform deployment for multiple brokerages # Intended to be used in conjunction with Dockerfile. This is just the foundation common OS+Dependencies required. # # Use base system for cleaning up wayward processes FROM phusion/baseimage:jammy-1.0.1 MAINTAINER QuantConnect # Use baseimage-docker's init system. CMD ["/sbin/my_init"] # Install OS Packages: # Misc tools for running Python.NET and IB inside a headless container. RUN apt-get update && apt-get -y install wget curl unzip \ && apt-get install -y git bzip2 zlib1g-dev \ xvfb libxrender1 libxtst6 libxi6 libglib2.0-dev libopenmpi-dev libstdc++6 openmpi-bin \ pandoc libcurl4-openssl-dev libgtk2.0.0 build-essential \ && apt-get clean && apt-get autoclean && apt-get autoremove --purge -y \ && rm -rf /var/lib/apt/lists/* # Install dotnet sdk & runtime RUN add-apt-repository ppa:dotnet/backports && apt-get update && apt-get install -y dotnet-sdk-9.0 && \ apt-get clean && apt-get autoclean && apt-get autoremove --purge -y && rm -rf /var/lib/apt/lists/* # Set PythonDLL variable for PythonNet ENV PYTHONNET_PYDLL="/opt/miniconda3/lib/libpython3.11.so" # Install miniconda ENV CONDA="Miniconda3-py311_24.9.2-0-Linux-x86_64.sh" ENV PATH="/opt/miniconda3/bin:${PATH}" RUN wget -q https://cdn.quantconnect.com/miniconda/${CONDA} && \ bash ${CONDA} -b -p /opt/miniconda3 && rm -rf ${CONDA} && \ conda config --set solver classic && \ conda config --set auto_update_conda false # Install java runtime for h2o lib RUN wget https://download.oracle.com/java/17/archive/jdk-17.0.12_linux-x64_bin.deb \ && dpkg -i jdk-17.0.12_linux-x64_bin.deb \ && update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-17.0.12-oracle-x64/bin/java 1 \ && rm jdk-17.0.12_linux-x64_bin.deb # Avoid pip install read timeouts ENV PIP_DEFAULT_TIMEOUT=120 # Install all packages RUN pip install --no-cache-dir \ cython==3.1.2 \ pandas==2.2.3 \ scipy==1.11.4 \ numpy==1.26.4 \ wrapt==1.17.2 \ astropy==7.1.0 \ beautifulsoup4==4.13.4 \ dill==0.3.8 \ jsonschema==4.24.0 \ lxml==5.4.0 \ msgpack==1.1.0 \ numba==0.59.1 \ xarray==2025.6.0 \ plotly==5.24.1 \ jupyterlab==4.4.3 \ ipywidgets==8.1.7 \ jupyterlab-widgets==3.0.15 \ tensorflow==2.18.0 \ docutils==0.21.2 \ cvxopt==1.3.2 \ gensim==4.3.3 \ keras==3.10.0 \ lightgbm==4.6.0 \ nltk==3.9.1 \ graphviz==0.20.3 \ cmdstanpy==1.2.5 \ copulae==0.7.9 \ featuretools==1.31.0 \ PuLP==3.2.1 \ pymc==5.23.0 \ rauth==0.7.3 \ scikit-learn==1.6.1 \ scikit-optimize==0.10.2 \ aesara==2.9.4 \ tsfresh==0.20.2 \ tslearn==0.6.3 \ tweepy==4.15.0 \ PyWavelets==1.8.0 \ umap-learn==0.5.7 \ fastai==2.8.2 \ arch==7.2.0 \ copulas==0.12.2 \ creme==0.6.1 \ cufflinks==0.17.3 \ gym==0.26.2 \ deap==1.4.3 \ pykalman==0.10.1 \ cvxpy==1.6.6 \ pyportfolioopt==1.5.6 \ pmdarima==2.0.4 \ pyro-ppl==1.9.1 \ riskparityportfolio==0.6.0 \ sklearn-json==0.1.0 \ statsmodels==0.14.4 \ QuantLib==1.38 \ xgboost==3.0.2 \ dtw-python==1.5.3 \ gluonts==0.16.1 \ gplearn==0.4.2 \ jax==0.5.3 \ jaxlib==0.5.3 \ keras-rl==0.4.2 \ pennylane==0.41.1 \ PennyLane-Lightning==0.41.1 \ pennylane-qiskit==0.36.0 \ qiskit==2.0.2 \ neural-tangents==0.6.5 \ mplfinance==0.12.10b0 \ hmmlearn==0.3.3 \ catboost==1.2.8 \ fastai2==0.0.30 \ scikit-tda==1.1.1 \ ta==0.11.0 \ seaborn==0.13.2 \ optuna==4.3.0 \ findiff==0.12.1 \ sktime==0.37.0 \ hyperopt==0.2.7 \ bayesian-optimization==2.0.4 \ pingouin==0.5.5 \ quantecon==0.8.1 \ matplotlib==3.8.4 \ sdeint==0.3.0 \ pandas_market_calendars==5.1.0 \ dgl==2.1.0 \ ruptures==1.1.9 \ simpy==4.1.1 \ scikit-learn-extra==0.3.0 \ ray==2.46.0 \ "ray[tune]"==2.46.0 \ "ray[rllib]"==2.46.0 \ "ray[data]"==2.46.0 \ "ray[train]"==2.46.0 \ fastText==0.9.3 \ h2o==3.46.0.7 \ prophet==1.1.7 \ torch==2.5.1 \ torchvision==0.20.1 \ ax-platform==1.0.0 \ alphalens-reloaded==0.4.6 \ pyfolio-reloaded==0.9.9 \ altair==5.5.0 \ modin==0.33.1 \ persim==0.3.8 \ ripser==0.6.12 \ pydmd==2025.6.1 \ spacy==3.8.7 \ pandas-ta==0.3.14b \ pytorch-ignite==0.5.2 \ tensorly==0.9.0 \ mlxtend==0.23.4 \ shap==0.47.2 \ lime==0.2.0.1 \ tensorflow-probability==0.25.0 \ mpmath==1.3.0 \ tensortrade==1.0.3 \ polars==1.30.0 \ stockstats==0.6.5 \ autokeras==2.0.0 \ QuantStats==0.0.64 \ hurst==0.0.5 \ numerapi==2.20.6 \ pymdptoolbox==4.0-b3 \ panel==1.7.1 \ hvplot==0.11.3 \ line-profiler==4.2.0 \ py-heat==0.0.6 \ py-heat-magic==0.0.2 \ bokeh==3.6.3 \ tensorflow-decision-forests==1.11.0 \ river==0.21.0 \ stumpy==1.13.0 \ pyvinecopulib==0.6.5 \ ijson==3.4.0 \ jupyter-resource-usage==1.1.1 \ injector==0.22.0 \ openpyxl==3.1.5 \ xlrd==2.0.1 \ mljar-supervised==1.1.17 \ dm-tree==0.1.9 \ lz4==4.4.4 \ ortools==9.11.4210 \ py_vollib==1.0.1 \ thundergbm==0.3.17 \ yellowbrick==1.5 \ livelossplot==0.5.6 \ gymnasium==1.0.0 \ interpret==0.6.11 \ DoubleML==0.10.0 \ jupyter-bokeh==4.0.5 \ imbalanced-learn==0.13.0 \ openai==1.86.0 \ lazypredict==0.2.16 \ darts==0.35.0 \ fastparquet==2024.11.0 \ tables==3.10.2 \ dimod==0.12.20 \ dwave-samplers==1.5.0 \ python-statemachine==2.5.0 \ pymannkendall==1.4.3 \ Pyomo==6.9.2 \ gpflow==2.10.0 \ pyarrow==19.0.1 \ dwave-ocean-sdk==8.3.0 \ chardet==5.2.0 \ stable-baselines3==2.6.0 \ Shimmy==2.0.0 \ pystan==3.10.0 \ FixedEffectModel==0.0.5 \ transformers==4.52.4 \ Rbeast==0.1.23 \ langchain==0.3.25 \ pomegranate==1.1.2 \ MAPIE==1.0.1 \ mlforecast==1.0.2 \ tensorrt==10.11.0.33 \ x-transformers==2.3.12 \ Werkzeug==3.1.3 \ TPOT==0.12.2 \ llama-index==0.12.41 \ mlflow==3.1.0 \ ngboost==0.5.6 \ control==0.10.1 \ pgmpy==1.0.0 \ mgarch==0.3.0 \ jupyter-ai==2.31.5 \ keras-tcn==3.5.6 \ neuralprophet[live]==0.9.0 \ Riskfolio-Lib==7.0.1 \ fuzzy-c-means==1.7.2 \ EMD-signal==1.6.4 \ dask[complete]==2025.2.0 \ nolds==0.6.2 \ feature-engine==1.8.3 \ pytorch-tabnet==4.1.0 \ opencv-contrib-python-headless==4.11.0.86 \ POT==0.9.5 \ alibi-detect==0.12.0 \ datasets==2.21.0 \ scikeras==0.13.0 \ accelerate==1.7.0 \ peft==0.15.2 \ FlagEmbedding==1.3.5 \ contourpy==1.3.2 \ tensorboardX==2.6.4 \ scikit-image==0.22.0 \ scs==3.2.7.post2 \ thinc==8.3.4 \ cesium==0.12.1 \ cvxportfolio==1.5.0 \ tsfel==0.1.9 \ ipympl==0.9.7 \ PyQt6==6.9.1 \ nixtla==0.6.6 \ tigramite==5.2.7.0 \ pytorch-forecasting==1.3.0 \ chronos-forecasting[training]==1.5.2 \ setuptools==73.0.1 \ tinygrad==0.10.3 \ DESlib==0.3.7 \ torchrl==0.6.0 \ tensordict==0.6.2 \ onnxmltools==1.14.0 \ onnxruntime==1.22.0 \ skl2onnx==1.19.1 \ sweetviz==2.3.1 \ filterpy==1.4.5 \ skfolio==0.7.0 \ lightweight-charts==2.1 \ KDEpy==1.1.12 \ lightning==2.5.1.post0 \ google-genai==1.19.0 # they have older dependency versions that can be ignored # https://github.com/Nixtla/neuralforecast/issues/1336#issuecomment-2921558564 # https://github.com/onnx/tensorflow-onnx/issues/2328#issuecomment-2682046428 RUN pip install --no-cache-dir --no-dependencies tf2onnx==1.16.1 neuralforecast==3.0.1 RUN conda install -c nvidia -y cuda-compiler=12.3.2 && conda clean -y --all ENV CUDA_MODULE_LOADING=LAZY ENV XLA_FLAGS=--xla_gpu_cuda_data_dir=/opt/miniconda3/ ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/miniconda3/lib/python3.11/site-packages/nvidia/cublas/lib/:/opt/miniconda3/lib/python3.11/site-packages/nvidia/cuda_cupti/lib/:/opt/miniconda3/lib/python3.11/site-packages/nvidia/cuda_nvrtc/lib/:/opt/miniconda3/lib/python3.11/site-packages/nvidia/cuda_runtime/lib/:/opt/miniconda3/lib/python3.11/site-packages/nvidia/cudnn/lib/:/opt/miniconda3/lib/python3.11/site-packages/nvidia/cufft/lib/:/opt/miniconda3/lib/python3.11/site-packages/nvidia/curand/lib/:/opt/miniconda3/lib/python3.11/site-packages/nvidia/cusolver/lib/:/opt/miniconda3/lib/python3.11/site-packages/nvidia/cusparse/lib/:/opt/miniconda3/lib/python3.11/site-packages/nvidia/nccl/lib/:/opt/miniconda3/lib/python3.11/site-packages/nvidia/nvjitlink/lib/:/opt/miniconda3/lib/python3.11/site-packages/nvidia/nvtx/lib/ # reduces GPU memory usage ENV PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True # required for numba to work correctly RUN ln -s /opt/miniconda3/lib/python3.11/site-packages/nvidia/cuda_runtime/lib/libcudart.so.12 /opt/miniconda3/lib/python3.11/site-packages/nvidia/cuda_runtime/lib/libcudart.so # iisignature requires numpy to be already installed. cupy requires cuda installed # https://github.com/omadson/fuzzy-c-means/issues/109 requires older tabulate but pandas requires 0.9.0, forcing version RUN pip install --no-cache-dir tabulate==0.9.0 iisignature==0.24 cupy-cuda12x==13.4.1 https://github.com/state-spaces/mamba/releases/download/v2.2.4/mamba_ssm-2.2.4+cu11torch2.5cxx11abiTRUE-cp311-cp311-linux_x86_64.whl mamba-ssm[causal-conv1d]==2.2.4 # TF uses this version, pytorch a slightly older (9.1) but cuDNN is backwards compatible RUN pip install --no-cache-dir nvidia-cudnn-cu12==9.3.0.75 # Install dwave tool RUN dwave install --all -y # Install 'ipopt' solver for 'Pyomo' RUN conda install -c conda-forge -y ipopt==3.14.17 coincbc==2.10.12 openmpi=5.0.8 \ && conda clean -y --all # Install spacy models RUN python -m spacy download en_core_web_md && python -m spacy download en_core_web_sm # Install PyTorch Geometric RUN TORCH=$(python -c "import torch; print(torch.__version__)") && \ CUDA=$(python -c "import torch; print('cu' + torch.version.cuda.replace('.', ''))") && \ pip install --no-cache-dir -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html \ torch-scatter==2.1.2 torch-sparse==0.6.18 torch-cluster==1.6.3 torch-spline-conv==1.2.2 torch-geometric==2.6.1 # Install nltk data RUN python -m nltk.downloader -d /usr/share/nltk_data punkt && \ python -m nltk.downloader -d /usr/share/nltk_data punkt_tab && \ python -m nltk.downloader -d /usr/share/nltk_data vader_lexicon && \ python -m nltk.downloader -d /usr/share/nltk_data stopwords && \ python -m nltk.downloader -d /usr/share/nltk_data wordnet # Install Pyrb RUN wget -q https://cdn.quantconnect.com/pyrb/pyrb-master-250054e.zip && \ unzip -q pyrb-master-250054e.zip && cd pyrb-master && \ pip install . && cd .. && rm -rf pyrb-master && rm pyrb-master-250054e.zip # Install SSM RUN wget -q https://cdn.quantconnect.com/ssm/ssm-master-646e188.zip && \ unzip -q ssm-master-646e188.zip && cd ssm-master && \ pip install . && cd .. && rm -rf ssm-master && rm ssm-master-646e188.zip # Install TA-lib for python RUN wget -q https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib_0.6.4_amd64.deb && \ dpkg -i ta-lib_0.6.4_amd64.deb && rm ta-lib_0.6.4_amd64.deb && \ pip install --no-cache-dir TA-Lib==0.6.4 # chronos-forecasting we manually copy the 'scripts' folder which holds the fine tuning tools RUN wget -q https://cdn.quantconnect.com/chronos-forecasting/chronos-forecasting-main-133761a.zip && \ unzip -q chronos-forecasting-main-133761a.zip && cd chronos-forecasting-main && \ cp -r scripts /opt/miniconda3/lib/python3.11/site-packages/chronos/ && \ cd .. && rm -rf chronos-forecasting-main && rm chronos-forecasting-main-133761a.zip RUN echo "{\"argv\":[\"python\",\"-m\",\"ipykernel_launcher\",\"-f\",\"{connection_file}\"],\"display_name\":\"Foundation-Py-Default\",\"language\":\"python\",\"metadata\":{\"debugger\":true}}" > /opt/miniconda3/share/jupyter/kernels/python3/kernel.json # Install wkhtmltopdf and xvfb to support HTML to PDF conversion of reports RUN apt-get update && apt install -y xvfb wkhtmltopdf && \ apt-get clean && apt-get autoclean && apt-get autoremove --purge -y && rm -rf /var/lib/apt/lists/* # Install fonts for matplotlib RUN wget -q https://cdn.quantconnect.com/fonts/foundation.zip && unzip -q foundation.zip && rm foundation.zip \ && mv "lean fonts/"* /usr/share/fonts/truetype/ && rm -rf "lean fonts/" "__MACOSX/" # Install IB Gateway and it's dependencies: Installs to /root/ibgateway RUN apt-get update && apt-get -y install libasound2 libnss3 libnspr4 && apt-get clean && apt-get autoclean && apt-get autoremove --purge -y && rm -rf /var/lib/apt/lists/* && \ mkdir -p /root/ibgateway && \ wget -q https://cdn.quantconnect.com/interactive/ibgateway-latest-standalone-linux-x64.v10.34.1c.sh && \ chmod 777 ibgateway-latest-standalone-linux-x64.v10.34.1c.sh && \ ./ibgateway-latest-standalone-linux-x64.v10.34.1c.sh -q -dir /root/ibgateway && \ rm ibgateway-latest-standalone-linux-x64.v10.34.1c.sh # label definitions LABEL strict_python_version=3.11.11 LABEL python_version=3.11 LABEL target_framework=net9.0