Skip to content

Instantly share code, notes, and snippets.

@x-bart
Created October 3, 2018 10:22
Show Gist options
  • Save x-bart/7d488c9b80c2a9782496d3de71375f7b to your computer and use it in GitHub Desktop.
Save x-bart/7d488c9b80c2a9782496d3de71375f7b to your computer and use it in GitHub Desktop.
QuantConnect DockerfileLeanFoundation
#
# LEAN Foundation Docker Container 20180716
# 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:0.9.22
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 install -y wget bzip2 python3-pip python-opengl && \
apt-get install -y clang cmake curl git unzip xvfb libxrender1 libxtst6 libxi6 libglib2.0-dev
# Install miniconda and supported third party python packages
ENV PATH="/opt/miniconda3/bin:${PATH}"
RUN wget https://cdn.quantconnect.com/miniconda/Miniconda3-4.3.31-Linux-x86_64.sh && \
bash Miniconda3-4.3.31-Linux-x86_64.sh -b -p /opt/miniconda3 && \
rm -rf Miniconda3-latest-Linux-x86_64.sh && \
ln -s /opt/miniconda3/lib/libpython3.6m.so /usr/lib/libpython3.6.so && \
ln -s /opt/miniconda3/lib/libpython3.6m.so /usr/lib/libpython3.6m.so && \
conda update -y python conda pip && \
conda install -y cython pandas && \
conda install -y jsonschema lxml plotly quandl && \
conda install -y blaze cvxopt keras nltk tensorflow theano && \
conda install -y pytorch torchvision -c pytorch && \
pip install arch copulalib cvxpy deap gym pykalman pyro-ppl && \
pip install sklearn statistics tensorforce xgboost && \
pip install QuantLib-Python && \
conda clean -y --all
# Java for running IB inside container:
# https://github.com/dockerfile/java/blob/master/oracle-java8/Dockerfile
RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
add-apt-repository -y ppa:webupd8team/java && \
apt-get update && apt-get install -y oracle-java8-installer && \
rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/oracle-jdk8-installer
# Install IB Gateway: Installs to ~/Jts
RUN wget http://cdn.quantconnect.com/interactive/ibgateway-latest-standalone-linux-x64-v968.2d.sh && \
chmod 777 ibgateway-latest-standalone-linux-x64-v968.2d.sh && \
./ibgateway-latest-standalone-linux-x64-v968.2d.sh -q && \
wget -O ~/Jts/jts.ini http://cdn.quantconnect.com/interactive/ibgateway-latest-standalone-linux-x64-v968.2d.jts.ini && \
rm ibgateway-latest-standalone-linux-x64-v968.2d.sh
# Install IB Controller: Installs to ~/IBController
RUN wget http://cdn.quantconnect.com/interactive/IBController-QuantConnect-3.2.0.3.zip && \
unzip IBController-QuantConnect-3.2.0.3.zip -d ~/IBController && \
chmod -R 777 ~/IBController && \
rm IBController-QuantConnect-3.2.0.3.zip
# Mono C# for LEAN:
# From https://github.com/mono/docker/blob/master/
RUN apt-get update && rm -rf /var/lib/apt/lists/*
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
RUN echo "deb http://download.mono-project.com/repo/debian wheezy/snapshots/5.8.0.108 main" > /etc/apt/sources.list.d/mono-xamarin.list && \
apt-get update && apt-get install -y binutils mono-complete ca-certificates-mono mono-vbnc nuget referenceassemblies-pcl && \
apt-get install -y fsharp && rm -rf /var/lib/apt/lists/* /tmp/*
# Install Python.NET
# Have to add env TZ=UTC. See https://github.com/dotnet/coreclr/issues/602
RUN env TZ=UTC nuget install QuantConnect.pythonnet -Version 1.0.5.8 && \
cp QuantConnect.pythonnet.1.0.5.8/lib/Python.Runtime.dll /usr/lib
# Install TA-lib for python
RUN wget http://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 && \
pip install TA-lib
# Install DX Analytics
RUN git clone https://github.com/yhilpisch/dx.git && cd dx && \
python setup.py install && cd .. && rm -irf dx
# Install R
RUN apt-get update && \
apt-get install -y r-base && \
apt-get install -y pandoc && \
apt-get install -y libcurl4-openssl-dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment