forked from QuantConnect/Lean
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DockerfileLeanFoundation
357 lines (327 loc) · 15.3 KB
/
DockerfileLeanFoundation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
#
# 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 <[email protected]>
# 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.0.9 \
pandas==2.1.4 \
scipy==1.11.4 \
numpy==1.26.4 \
wrapt==1.16.0 \
astropy==7.0.0 \
beautifulsoup4==4.12.3 \
dill==0.3.8 \
jsonschema==4.23.0 \
lxml==5.3.0 \
msgpack==1.1.0 \
numba==0.59.1 \
xarray==2024.11.0 \
plotly==5.24.1 \
jupyterlab==4.3.2 \
ipywidgets==8.1.5 \
jupyterlab-widgets==3.0.13 \
tensorflow==2.18.0 \
docutils==0.21.2 \
cvxopt==1.3.2 \
gensim==4.3.3 \
keras==3.7.0 \
lightgbm==4.5.0 \
nltk==3.9.1 \
graphviz==0.20.3 \
cmdstanpy==1.2.4 \
copulae==0.7.9 \
featuretools==1.31.0 \
PuLP==2.9.0 \
pymc==5.19.0 \
rauth==0.7.3 \
scikit-learn==1.4.2 \
scikit-optimize==0.10.2 \
aesara==2.9.4 \
tsfresh==0.20.2 \
tslearn==0.6.3 \
tweepy==4.14.0 \
PyWavelets==1.7.0 \
umap-learn==0.5.7 \
fastai==2.7.18 \
arch==7.2.0 \
copulas==0.12.0 \
creme==0.6.1 \
cufflinks==0.17.3 \
gym==0.26.2 \
deap==1.4.1 \
pykalman==0.9.7 \
cvxpy==1.6.0 \
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.36 \
xgboost==2.1.3 \
dtw-python==1.5.3 \
gluonts==0.16.0 \
gplearn==0.4.2 \
jax==0.4.35 \
jaxlib==0.4.35 \
keras-rl==0.4.2 \
pennylane==0.39.0 \
PennyLane-Lightning==0.39.0 \
pennylane-qiskit==0.36.0 \
qiskit==1.2.4 \
neural-tangents==0.6.5 \
mplfinance==0.12.10b0 \
hmmlearn==0.3.3 \
catboost==1.2.7 \
fastai2==0.0.30 \
scikit-tda==1.1.1 \
ta==0.11.0 \
seaborn==0.13.2 \
optuna==4.1.0 \
findiff==0.10.2 \
sktime==0.26.0 \
hyperopt==0.2.7 \
bayesian-optimization==2.0.0 \
pingouin==0.5.5 \
quantecon==0.7.2 \
matplotlib==3.7.5 \
sdeint==0.3.0 \
pandas_market_calendars==4.4.2 \
dgl==2.1.0 \
ruptures==1.1.9 \
simpy==4.1.1 \
scikit-learn-extra==0.3.0 \
ray==2.40.0 \
"ray[tune]"==2.40.0 \
"ray[rllib]"==2.40.0 \
"ray[data]"==2.40.0 \
"ray[train]"==2.40.0 \
fastText==0.9.3 \
h2o==3.46.0.6 \
prophet==1.1.6 \
torch==2.5.1 \
torchvision==0.20.1 \
ax-platform==0.4.3 \
alphalens-reloaded==0.4.5 \
pyfolio-reloaded==0.9.8 \
altair==5.5.0 \
modin==0.26.1 \
persim==0.3.7 \
ripser==0.6.10 \
pydmd==2024.12.1 \
spacy==3.7.5 \
pandas-ta==0.3.14b \
pytorch-ignite==0.5.1 \
tensorly==0.9.0 \
mlxtend==0.23.3 \
shap==0.46.0 \
lime==0.2.0.1 \
tensorflow-probability==0.25.0 \
mpmath==1.3.0 \
tensortrade==1.0.3 \
polars==1.16.0 \
stockstats==0.6.2 \
autokeras==2.0.0 \
QuantStats==0.0.64 \
hurst==0.0.5 \
numerapi==2.19.1 \
pymdptoolbox==4.0-b3 \
panel==1.5.4 \
hvplot==0.11.1 \
line-profiler==4.2.0 \
py-heat==0.0.6 \
py-heat-magic==0.0.2 \
bokeh==3.6.2 \
tensorflow-decision-forests==1.11.0 \
river==0.21.0 \
stumpy==1.13.0 \
pyvinecopulib==0.6.5 \
ijson==3.3.0 \
jupyter-resource-usage==1.1.0 \
injector==0.22.0 \
openpyxl==3.1.5 \
xlrd==2.0.1 \
mljar-supervised==1.1.9 \
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==1.0.0 \
interpret==0.6.7 \
DoubleML==0.9.0 \
jupyter-bokeh==4.0.5 \
imbalanced-learn==0.12.4 \
openai==1.57.0 \
lazypredict==0.2.14a1 \
darts==0.31.0 \
fastparquet==2024.11.0 \
tables==3.10.1 \
dimod==0.12.17 \
dwave-samplers==1.3.0 \
python-statemachine==2.5.0 \
pymannkendall==1.4.3 \
Pyomo==6.8.2 \
gpflow==2.9.2 \
pyarrow==15.0.1 \
dwave-ocean-sdk==8.0.1 \
chardet==5.2.0 \
stable-baselines3==2.4.0 \
Shimmy==2.0.0 \
pystan==3.10.0 \
FixedEffectModel==0.0.5 \
transformers==4.46.3 \
Rbeast==0.1.23 \
langchain==0.2.17 \
pomegranate==1.1.1 \
MAPIE==0.9.1 \
mlforecast==0.15.1 \
tensorrt==10.7.0 \
x-transformers==1.42.24 \
Werkzeug==3.1.3 \
TPOT==0.12.2 \
llama-index==0.12.2 \
mlflow==2.18.0 \
ngboost==0.5.1 \
pycaret==3.3.2 \
control==0.10.1 \
pgmpy==0.1.26 \
mgarch==0.3.0 \
jupyter-ai==2.28.2 \
keras-tcn==3.5.0 \
neuralprophet[live]==0.9.0 \
Riskfolio-Lib==6.1.1 \
fuzzy-c-means==1.7.2 \
EMD-signal==1.6.4 \
dask[complete]==2024.9.0 \
nolds==0.6.1 \
feature-engine==1.6.2 \
pytorch-tabnet==4.1.0 \
opencv-contrib-python-headless==4.10.0.84 \
POT==0.9.5 \
alibi-detect==0.12.0 \
datasets==2.21.0 \
scikeras==0.13.0 \
accelerate==0.34.2 \
peft==0.13.2 \
FlagEmbedding==1.2.11 \
contourpy==1.3.1 \
tensorboardX==2.6.2.2 \
scikit-image==0.22.0 \
scs==3.2.7 \
thinc==8.2.5 \
cesium==0.12.1 \
cvxportfolio==1.4.0 \
tsfel==0.1.9 \
ipympl==0.9.4 \
PyQt6==6.7.1 \
nixtla==0.6.4 \
tigramite==5.2.6.7 \
pytorch-forecasting==1.2.0 \
chronos-forecasting[training]==1.4.1 \
setuptools==73.0.1 \
tinygrad==0.10.0
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
RUN pip install --no-cache-dir iisignature==0.24 cupy-cuda12x==13.3.0 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.16 coincbc==2.10.12 openmpi=5.0.6 \
&& 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://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.5.1
# 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: 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
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/*
# label definitions
LABEL strict_python_version=3.11.11
LABEL python_version=3.11
LABEL target_framework=net6.0