Files
quantconnect--lean/DockerfileLeanFoundation
T
Martin-Molinero 1a3fedb36d Foundation library update (#8069)
* Foundation update

* Minor fixes
2024-06-04 11:57:04 -03:00

337 lines
15 KiB
Plaintext

#
# 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 <contact@quantconnect.com>
# 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 6 sdk & runtime
RUN apt-get update && apt-get install -y dotnet-sdk-6.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.1.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
# Install java runtime for h2o lib
RUN wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.deb \
&& dpkg -i jdk-17_linux-x64_bin.deb \
&& update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-17-oracle-x64/bin/java 1 \
&& rm jdk-17_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.0.9 \
pandas==2.1.4 \
scipy==1.11.4 \
numpy==1.26.4 \
wrapt==1.16.0 \
astropy==6.0.0 \
beautifulsoup4==4.12.3 \
dill==0.3.8 \
jsonschema==4.21.1 \
lxml==5.1.0 \
msgpack==1.0.8 \
numba==0.59.0 \
xarray==2024.2.0 \
plotly==5.20.0 \
jupyterlab==4.1.5 \
tensorflow==2.16.1 \
docutils==0.20.1 \
cvxopt==1.3.2 \
gensim==4.3.2 \
keras==3.3.3 \
lightgbm==4.3.0 \
nltk==3.8.1 \
graphviz==0.20.1 \
cmdstanpy==1.2.1 \
copulae==0.7.9 \
featuretools==1.30.0 \
PuLP==2.8.0 \
pymc==5.10.4 \
rauth==0.7.3 \
scikit-learn==1.4.2 \
scikit-optimize==0.10.0 \
aesara==2.9.3 \
tsfresh==0.20.2 \
tslearn==0.6.3 \
tweepy==4.14.0 \
PyWavelets==1.5.0 \
umap-learn==0.5.5 \
fastai==2.7.14 \
arch==6.3.0 \
copulas==0.10.1 \
creme==0.6.1 \
cufflinks==0.17.3 \
gym==0.26.2 \
ipywidgets==8.1.2 \
deap==1.4.1 \
pykalman==0.9.7 \
cvxpy==1.4.2 \
pyportfolioopt==1.5.5 \
pmdarima==2.0.4 \
pyro-ppl==1.9.0 \
riskparityportfolio==0.5.1 \
sklearn-json==0.1.0 \
statsmodels==0.14.1 \
QuantLib==1.33 \
xgboost==2.0.3 \
dtw-python==1.3.1 \
gluonts==0.14.4 \
gplearn==0.4.2 \
jax==0.4.25 \
jaxlib==0.4.25 \
keras-rl==0.4.2 \
pennylane==0.35.1 \
PennyLane-Lightning==0.35.1 \
pennylane-qiskit==0.35.1 \
qiskit==1.0.2 \
neural-tangents==0.6.5 \
mplfinance==0.12.10b0 \
hmmlearn==0.3.2 \
catboost==1.2.3 \
fastai2==0.0.30 \
scikit-tda==1.0.0 \
ta==0.11.0 \
seaborn==0.13.2 \
optuna==3.5.0 \
findiff==0.10.0 \
sktime==0.26.0 \
hyperopt==0.2.7 \
bayesian-optimization==1.4.3 \
pingouin==0.5.4 \
quantecon==0.7.2 \
matplotlib==3.7.5 \
sdeint==0.3.0 \
pandas_market_calendars==4.4.0 \
dgl==2.1.0 \
ruptures==1.1.9 \
simpy==4.1.1 \
scikit-learn-extra==0.3.0 \
ray==2.9.3 \
"ray[tune]"==2.9.3 \
"ray[rllib]"==2.9.3 \
fastText==0.9.2 \
h2o==3.46.0.1 \
prophet==1.1.5 \
torch==2.2.1 \
torchvision==0.17.1 \
ax-platform==0.3.7 \
alphalens-reloaded==0.4.3 \
pyfolio-reloaded==0.9.5 \
altair==5.2.0 \
modin==0.26.1 \
persim==0.3.5 \
ripser==0.6.8 \
pydmd==1.0.0 \
spacy==3.7.4 \
pandas-ta==0.3.14b \
pytorch-ignite==0.4.13 \
tensorly==0.8.1 \
mlxtend==0.23.1 \
shap==0.45.0 \
lime==0.2.0.1 \
tensorflow-probability==0.24.0 \
mpmath==1.3.0 \
tensortrade==1.0.3 \
polars==0.20.15 \
stockstats==0.6.2 \
autokeras==2.0.0 \
QuantStats==0.0.62 \
hurst==0.0.5 \
numerapi==2.18.0 \
pymdptoolbox==4.0-b3 \
panel==1.3.8 \
hvplot==0.9.2 \
line-profiler==4.1.2 \
py-heat==0.0.6 \
py-heat-magic==0.0.2 \
bokeh==3.3.4 \
tensorflow-decision-forests==1.9.0 \
river==0.21.0 \
stumpy==1.12.0 \
pyvinecopulib==0.6.5 \
ijson==3.2.3 \
jupyter-resource-usage==1.0.2 \
injector==0.21.0 \
openpyxl==3.1.2 \
xlrd==2.0.1 \
mljar-supervised==1.1.6 \
dm-tree==0.1.8 \
lz4==4.3.3 \
ortools==9.9.3963 \
py_vollib==1.0.1 \
thundergbm==0.3.17 \
yellowbrick==1.5 \
livelossplot==0.5.5 \
gymnasium==0.28.1 \
interpret==0.5.1 \
DoubleML==0.7.1 \
jupyter-bokeh==4.0.0 \
imbalanced-learn==0.12.0 \
openai==1.30.4 \
lazypredict-nightly==0.3.0 \
darts==0.28.0 \
fastparquet==2024.2.0 \
tables==3.9.2 \
dimod==0.12.14 \
dwave-samplers==1.2.0 \
python-statemachine==2.1.2 \
pymannkendall==1.4.3 \
Pyomo==6.7.1 \
gpflow==2.9.1 \
pyarrow==15.0.1 \
dwave-ocean-sdk==6.9.0 \
chardet==5.2.0 \
stable-baselines3==2.3.2 \
Shimmy==1.3.0 \
pystan==3.9.0 \
FixedEffectModel==0.0.5 \
transformers==4.41.2 \
Rbeast==0.1.19 \
langchain==0.1.12 \
pomegranate==1.0.4 \
MAPIE==0.8.3 \
mlforecast==0.12.0 \
functime==0.9.5 \
tensorrt==8.6.1.post1 \
x-transformers==1.30.4 \
Werkzeug==3.0.1 \
TPOT==0.12.2 \
llama-index==0.10.19 \
mlflow==2.11.1 \
ngboost==0.5.1 \
pycaret==3.3.2 \
control==0.9.4 \
pgmpy==0.1.25 \
mgarch==0.3.0 \
jupyter-ai==2.12.0 \
keras-tcn==3.5.0 \
neuralprophet[live]==0.8.0 \
Riskfolio-Lib==6.0.0 \
fuzzy-c-means==1.7.2 \
EMD-signal==1.6.0 \
dask[complete]==2024.3.1 \
nolds==0.5.2 \
feature-engine==1.6.2 \
pytorch-tabnet==4.1.0 \
opencv-contrib-python-headless==4.9.0.80 \
POT==0.9.3 \
alibi-detect==0.12.0 \
datasets==2.17.1 \
scikeras==0.13.0 \
accelerate==0.30.1 \
peft==0.11.1 \
FlagEmbedding==1.2.10 \
contourpy==1.2.0
RUN conda install -c conda-forge -y cudatoolkit=11.8.0 cupy=13.1.0 && conda install -c nvidia -y cuda-compiler=12.2.2 && conda clean -y --all
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/:/opt/miniconda3/pkgs/cudatoolkit-11.8.0-h6a678d5_0/lib/
ENV CUDA_MODULE_LOADING=LAZY
# reduces GPU memory usage
ENV PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
# mamba-ssm & causal requires nvidia capabilities to be installed. iisignature requires numpy to be already installed
RUN pip install --no-cache-dir mamba-ssm==1.2.0.post1 causal-conv1d==1.2.0.post2 iisignature==0.24
# Install dwave tool
RUN dwave install --all -y
# Install 'ipopt' solver for 'Pyomo'
RUN conda install -c conda-forge ipopt==3.14.14 \
&& conda clean -y --all
# Install spacy models
RUN python -m spacy download en_core_web_md && python -m spacy download en_core_web_sm
RUN conda install -y -c conda-forge \
openmpi=5.0.2 \
&& conda clean -y --all
# 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.5.1
# Install nltk data
RUN python -m nltk.downloader -d /usr/share/nltk_data punkt && \
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://cdn.quantconnect.com/ta-lib/ta-lib-0.4.0-src.tar.gz && \
tar -zxvf ta-lib-0.4.0-src.tar.gz && cd ta-lib && \
./configure --prefix=/usr && make && make install && \
cd .. && rm -rf ta-lib && rm ta-lib-0.4.0-src.tar.gz && \
pip install --no-cache-dir TA-Lib==0.4.28
# Install uni2ts. We manually copy the 'cli' folder which holds the fine tuning tools
RUN wget -q https://cdn.quantconnect.com/uni2ts/uni2ts-main-ffe78db.zip && \
unzip -q uni2ts-main-ffe78db.zip && cd uni2ts-main && \
pip install . && cp -r cli /opt/miniconda3/lib/python3.11/site-packages/uni2ts/ && \
cd .. && rm -rf uni2ts-main && rm uni2ts-main-ffe78db.zip
# Install 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-b0bdbd9.zip && \
unzip -q chronos-forecasting-main-b0bdbd9.zip && cd chronos-forecasting-main && \
pip install ".[training]" && cp -r scripts /opt/miniconda3/lib/python3.11/site-packages/chronos/ && \
cd .. && rm -rf chronos-forecasting-main && rm chronos-forecasting-main-b0bdbd9.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: Installs to /root/ibgateway
RUN mkdir -p /root/ibgateway && \
wget -q https://cdn.quantconnect.com/interactive/ibgateway-stable-standalone-linux-x64.v10.19.2a.sh && \
chmod 777 ibgateway-stable-standalone-linux-x64.v10.19.2a.sh && \
./ibgateway-stable-standalone-linux-x64.v10.19.2a.sh -q -dir /root/ibgateway && \
rm ibgateway-stable-standalone-linux-x64.v10.19.2a.sh
# label definitions
LABEL strict_python_version=3.11.7
LABEL python_version=3.11
LABEL target_framework=net6.0