国内的程序化交易系统必须通过券商或期货公司的柜台间接介入交易所,并且需要进行看穿式监管认证,所以实盘系统一般很少使用云主机或docker虚拟环境。这里使用docker-ubuntu主要是为了设置一个相对纯净的开发环境。服务器版本可以通过vscode-web方式直接开发,本机则一般通过ssh使用pycharm、clion等ide开发。
开发环境
启动容器
1 2 3 docker pull ubuntu docker run --name iubuntu -t -i -d -p 4100:22 ubuntu docker exec -t -i iubuntu /bin/bash
SSH
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 apt-get update apt-get dist-upgrade -y apt-get install -y sudo vim git net-tools rsync sudo iputils-ping apt-get install -y openssh-client openssh-server # 启动SSH /etc/init.d/ssh start ps -e|grep ssh # 在表头添加 vim /etc/ssh/sshd_config PermitRootLogin yes service ssh restart passwd root
VSCode-Web
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 apt-get install -y curl curl -fsSL https://code-server.dev/install.sh | sh # 首次运行生成配置文件 code-server # 修改配置文件 vim ~/.config/code-server/config.yaml bind-addr: 0.0.0.0:7101 auth: password password: 1234567890 cert: false # 或命令行启动 code-server --port 7101 --host 0.0.0.0 --auth password 1234567890
Docker-Ubunut设置时区
1 2 apt-get install tzdata tzselect
Run 'dpkg-reconfigure tzdata' if you wish to change it.
配置Docker-Ubuntu的中文环境
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 locale -a apt-get update apt-get install -y locales apt-get install language-pack-zh-hans locale-gen zh_CN locale-gen zh_CN.utf8 locale-gen zh_CN.UTF-8 locale-gen zh_CN.GB18030 # 看看当前启用的本地支持 locale -a export LANG=zh_CN.UTF-8 export LC_ALL=zh_CN.UTF-8 export LANGUAGE=zh_CN.UTF-8 # 现在来看看当前的字符集 locale sudo update-locale LANG=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8 LANGUAGE=zh_CN.UTF-8 cat /etc/default/locale
C++
1 apt-get install -y build-essential cmake gdb gdbserver
Python
1 2 3 4 5 6 7 8 9 10 11 cd opt wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh bash Miniconda3-latest-Linux-x86_64.sh /opt/miniconda3 bash <!-- 默认启动 --> vim ~/.bashrc export PATH="/opt/miniconda3/bin:$PATH" export PATH="$PATH:/opt/miniconda3/bin"
Libstdc++.so.6:
version `GLIBCXX_3.4.22’ not found(conda)
1 2 3 4 5 strings /opt/miniconda3/lib/libstdc++.so.6 | grep GLIBCXX strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX cd /opt/miniconda3/lib rm libstdc++.so.6 cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 ./
Python库
todo:如何指定python库的版本 1 2 3 4 5 pip install pandas pip install notebook jupyter notebook --no-browser --port 7102 --ip=0.0.0.0 jupyter notebook --no-browser --port 7102 --allow-root --ip='*' --NotebookApp.token='' --NotebookApp.password=''
Projector
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 sudo apt install less libxext6 libxrender1 libxtst6 libfreetype6 libxi6 -y pip install projector-installer # not need vim ~/.bashrc export PATH="$PATH:~/.local/bin" cd ~/.projector cd /root/.projector/configs/CLion vim config.ini # 修改端口 [PROJECTOR] port = 7102 host = 0.0.0.0 projector config rebuild CLion projector run clion
生成镜像
1 2 3 4 5 6 docker commit iubuntu ubuntu-simnow docker save ubuntu-simnow > ubuntu-simnow.tar docker run --name ubuntu-simnow -t -i -d -p 7100:22 -p 7101:7101 -p 7102:7102 -p 7103:7103 -p 7104:7104 -p 7105:7105 -p 7106:7106 -p 7107:7107 -p 7108:7108 ubuntu-simnow /usr/sbin/sshd -D docker exec -t -i ubuntu-simnow /bin/bash code-server --port 7101 --host 0.0.0.0 --auth password 1234567890
启动SSH
1 2 3 docker start ubuntu-simnow docker exec -t -i ubuntu-simnow /bin/bash code-server
Clickhouse
Docker Network
实现docker互联 1 2 3 4 docker network create otpnet docker network connect --alias ubuntu-simnow otpnet ubuntu-simnow docker network connect --alias single-clickhouse-server otpnet single-clickhouse-server docker network inspect otpnet